diff --git a/CHANGELOG.md b/CHANGELOG.md index 50cc929b..98596850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ Changelog ========= +* [Improved] Supports a config option for setting word wrap. + ### 0.3.0 (May 24, 2012) * [Fixed] Dates such as "May 3" will now be interpreted as being in the past if the current day is at least 28 days in the future diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 35931bbf..c9e652e4 100644 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -2,6 +2,7 @@ # encoding: utf-8 import re +import textwrap class Entry: def __init__(self, journal, date=None, title="", body=""): @@ -19,7 +20,10 @@ class Entry: def __str__(self): date_str = self.date.strftime(self.journal.config['timeformat']) body_wrapper = "\n" if self.body else "" - body = body_wrapper + self.body.strip() + if self.journal.config['linewrap']: + body = body_wrapper + textwrap.fill(self.body, self.journal.config['linewrap']) + else: + body = body_wrapper + self.body.strip() space = "\n" return "%(date)s %(title)s %(body)s %(space)s" % { diff --git a/jrnl/install.py b/jrnl/install.py index debbaf7e..49f58e31 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -26,6 +26,7 @@ default_config = { 'timeformat': "%Y-%m-%d %H:%M", 'tagsymbols': '@', 'highlight': True, + 'linewrap': 80, }