Add tag and body color customization options

This commit is contained in:
Aaron Lichtman 2019-11-06 19:29:55 +01:00
parent c63c999bc7
commit 4b934e36eb
No known key found for this signature in database
GPG key ID: 22368077DE9F9903
4 changed files with 8 additions and 8 deletions

View file

@ -106,7 +106,7 @@ class Entry:
return "{title}{sep}{body}\n".format(
title=title,
sep="\n" if has_body else "",
body=body if has_body else "",
body=colorize(body, self.journal.config['colors']['body']) if has_body else "",
)
def __repr__(self):

View file

@ -152,12 +152,12 @@ class Journal(object):
for tag in self.search_tags:
tagre = re.compile(re.escape(tag), re.IGNORECASE)
pp = re.sub(tagre,
lambda match: util.colorize(match.group(0), "CYAN"),
lambda match: util.colorize(match.group(0), self.config['colors']['tags']),
pp, re.UNICODE)
else:
pp = re.sub(
Entry.Entry.tag_regex(self.config['tagsymbols']),
lambda match: util.colorize(match.group(0), "CYAN"),
lambda match: util.colorize(match.group(0), self.config['colors']['tags']),
pp
)
return pp

View file

@ -59,8 +59,10 @@ default_config = {
'linewrap': 79,
'indent_character': '|',
'colors': {
'date': 'red',
'title': 'blue',
'date': 'none',
'title': 'none',
'body': 'none',
'tags': 'none',
},
}

View file

@ -173,9 +173,7 @@ def verify_config(config):
if upper_color == "NONE":
pass
if not getattr(colorama.Fore, upper_color, None):
# TODO: Not sure whether both of these should stay or not.
print("[{2}ERROR{3}: {0} set to invalid color: {1}]".format(key, color, ERROR_COLOR, RESET_COLOR))
log.error("Invalid color configuration value for '{0}'.".format(key))
print("[{2}ERROR{3}: {0} set to invalid color: {1}]".format(key, color, ERROR_COLOR, RESET_COLOR), file=sys.stderr)
all_valid_colors = False
return all_valid_colors