Skip to content

Commit

Permalink
Write keywords as colored @k1 @k2
Browse files Browse the repository at this point in the history
This is more readable and more compact than the existing `(k1, k2)`
format.
  • Loading branch information
agateau committed Oct 31, 2024
1 parent d913389 commit 06d74b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions yokadi/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ def getKeywordsAsString(self):

def getUserKeywordsNameAsString(self):
"""
Returns all keywords keys as a string like "key1, key2, key3...".
Returns all keywords keys as a string like "@key1 @key2 @key3...".
Internal keywords (starting with _) are ignored.
"""
keywords = [k for k in list(self.getKeywordDict().keys()) if not k.startswith("_")]
keywords.sort()
if keywords:
return ", ".join(keywords)
return " ".join(f"@{k}" for k in keywords)
else:
return ""

Expand Down
5 changes: 2 additions & 3 deletions yokadi/ycli/textlistrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ def __call__(self, task):
# Create title
title = task.title
if keywords and len(title) < maxWidth:
title += ' ('
colorizer.setColorAt(len(title), C.BOLD)
title += ' '
colorizer.setColorAt(len(title), C.ORANGE)
title += keywords
colorizer.setResetAt(len(title))
title += ')'

# Crop title to fit in self.width
titleWidth = len(title)
Expand Down

0 comments on commit 06d74b4

Please sign in to comment.