diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 1306cef5..ba2f7dd0 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import re import textwrap from datetime import datetime -from .util import split_title +from .util import split_title, bold, colorize_red class Entry: @@ -79,7 +79,10 @@ class Entry: else: indent = "" if not short and self.journal.config['linewrap']: - title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap']) + # Color date red and make sure first line of title is bolded + title = textwrap.fill(colorize_red(date_str) + " " + bold(self.title), self.journal.config['linewrap']) + # Make sure all lines after the first are bolded, too + title = "".join([bold(part) + "\n" for part in title.split("\n")]) body = "\n".join([ textwrap.fill( line, @@ -90,7 +93,7 @@ class Entry: for line in self.body.rstrip(" \n").splitlines() ]) else: - title = date_str + " " + self.title.rstrip("\n ") + title = colorize_red(date_str) + " " + bold(self.title.rstrip("\n ")) body = self.body.rstrip("\n ") # Suppress bodies that are just blanks and new lines. diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 72fe94b1..4bbc8e5f 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -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)), + lambda match: util.colorize_cyan(match.group(0)), pp, re.UNICODE) else: pp = re.sub( Entry.Entry.tag_regex(self.config['tagsymbols']), - lambda match: util.colorize(match.group(0)), + lambda match: util.colorize_cyan(match.group(0)), pp ) return pp diff --git a/jrnl/util.py b/jrnl/util.py index bc36ba9b..e284b857 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -180,11 +180,22 @@ def get_text_from_editor(config, template=""): return raw -def colorize(string): +def colorize_cyan(string): """Returns the string wrapped in cyan ANSI escape""" return u"\033[36m{}\033[39m".format(string) +def colorize_red(string): + """Returns the string wrapped in red ANSI escape""" + return u"\033[91m{}\033[0m".format(string) + + +def bold(string): + """Returns the string wrapped in bold ANSI escape. Bug / feature that it + also colors the text blue, for some unknown reason.""" + return u"\033[1m{}\033[0m".format(string) + + def slugify(string): """Slugifies a string. Based on public domain code from https://github.com/zacharyvoase/slugify