From 91d48f85d0e907cc58eec98e9dce7f095273d7c0 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Sun, 24 Jan 2016 20:40:18 -0500 Subject: [PATCH] Make indent character configurable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks nice with │ (BOX DRAWINGS LIGHT VERTICAL) - Add indent_character to config settings - Use rpadded indent_character for textwrapping --- jrnl/Entry.py | 7 ++++--- jrnl/Journal.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 7ee53d07..338a271a 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -74,15 +74,16 @@ class Entry: """Returns a pretty-printed version of the entry. If short is true, only print the title.""" date_str = self.date.strftime(self.journal.config['timeformat']) + indent = self.journal.config['indent_character'].rstrip() + " " if not short and self.journal.config['linewrap']: title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap']) body = "\n".join([ textwrap.fill( line, self.journal.config['linewrap'], - initial_indent="| ", - subsequent_indent="| ", - drop_whitespace=True) or "| " + initial_indent=indent, + subsequent_indent=indent, + drop_whitespace=True) or indent for line in self.body.rstrip(" \n").splitlines() ]) else: diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 517076ba..f107e09e 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -26,6 +26,7 @@ class Journal(object): 'tagsymbols': '@', 'highlight': True, 'linewrap': 80, + 'indent_character': '|', } self.config.update(kwargs) # Set up date parser