Commit 4665531c authored by Bram Schoenmakers's avatar Bram Schoenmakers

Extract some color codes from the functions.

parent 98745c87
...@@ -10,19 +10,22 @@ PRIORITY_COLORS = { ...@@ -10,19 +10,22 @@ PRIORITY_COLORS = {
'C': '\033[34m' # blue 'C': '\033[34m' # blue
} }
PROJECT_COLOR = '\033[31m' # red
NEUTRAL_COLOR = '\033[0m'
def add_colors(p_todo_str, p_todo): def add_colors(p_todo_str, p_todo):
""" Adds colors to the todo string by inserting ANSI codes. """ """ Adds colors to the todo string by inserting ANSI codes. """
color = '\033[0m' color = NEUTRAL_COLOR
try: try:
color = PRIORITY_COLORS[p_todo.priority()] color = PRIORITY_COLORS[p_todo.priority()]
except KeyError: except KeyError:
pass pass
p_todo_str = '%s%s%s' % (color, p_todo_str, '\033[0m') p_todo_str = '%s%s%s' % (color, p_todo_str, NEUTRAL_COLOR)
if Config.HIGHLIGHT_PROJECTS_CONTEXTS: if Config.HIGHLIGHT_PROJECTS_CONTEXTS:
p_todo_str = re.sub(r'\B(\+|@)\S+', r'\033[31m\g<0>' + color, \ p_todo_str = re.sub(r'\B(\+|@)\S+', PROJECT_COLOR + r'\g<0>' + color, \
p_todo_str) p_todo_str)
return p_todo_str return p_todo_str
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment