Commit 008ee60e authored by kidpixo's avatar kidpixo Committed by Bram Schoenmakers

Added color coding for

-  METADATA (key:value pairs)
-  LINK (foo://bar.bla)
parent cb24bc40
...@@ -32,12 +32,15 @@ class PrettyPrinterFilter(object): ...@@ -32,12 +32,15 @@ class PrettyPrinterFilter(object):
return p_todo_str return p_todo_str
PRIORITY_COLORS = { PRIORITY_COLORS = {
'A': '\033[36m', # cyan 'A': '\033[0;36m', # cyan
'B': '\033[33m', # yellow 'B': '\033[0;33m', # yellow
'C': '\033[34m' # blue 'C': '\033[0;34m' # blue
} }
PROJECT_COLOR = '\033[31m' # red PROJECT_COLOR = '\033[1;31m' # color for + keyword : red
CONTEXT_COLOR = '\033[1;35m' # color for @ keyword : magenta
METADATA_COLOR = '\033[1;32m' # color for @ metadata : green
LINK_COLOR = '\033[4;36m' # color for @ links : cyan/underline
NEUTRAL_COLOR = '\033[0m' NEUTRAL_COLOR = '\033[0m'
class PrettyPrinterColorFilter(PrettyPrinterFilter): class PrettyPrinterColorFilter(PrettyPrinterFilter):
...@@ -57,15 +60,21 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter): ...@@ -57,15 +60,21 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
except KeyError: except KeyError:
pass pass
p_todo_str = color + p_todo_str + NEUTRAL_COLOR 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( p_todo_str = re.sub(
r'\B(\+|@)(\S*\w)', r'\B(\+|@)(\S*\w)',
PROJECT_COLOR + r'\g<0>' + color, #PROJECT_COLOR + r'\g<0>' + color,
lambda m: (
CONTEXT_COLOR if m.group(0)[0] == "+"
else PROJECT_COLOR)+m.group(0)+color,
p_todo_str) p_todo_str)
p_todo_str = re.sub(r'\w(\S*:[^/\s]\S*)\w',METADATA_COLOR+r'\g<0>'+color,p_todo_str)
# add LINK_COLOR to anything like : (one group od charater and a :)(// and non whitespace chars)
p_todo_str = re.sub(r'\s(\w*:){1}(//\S*\w)',' '+LINK_COLOR+r'\1\2'+color,p_todo_str)
p_todo_str += NEUTRAL_COLOR p_todo_str += NEUTRAL_COLOR
# chnge any group of reduntant multiple NEUTRAL_GROUP occurrence to only one
p_todo_str = re.sub(r'('+re.escape(NEUTRAL_COLOR)+')+',NEUTRAL_COLOR,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