summaryrefslogtreecommitdiff
path: root/src/print.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-26 02:18:22 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-26 02:18:22 -0600
commit4cf95497f9afaead3d9d308dabe8e8b26949502f (patch)
tree99ea35c41def6930cfe4fe56711752e5366a175f /src/print.cc
parent40ab81308025e9655074da37671c444b4257f867 (diff)
downloadfork-ledger-4cf95497f9afaead3d9d308dabe8e8b26949502f.tar.gz
fork-ledger-4cf95497f9afaead3d9d308dabe8e8b26949502f.tar.bz2
fork-ledger-4cf95497f9afaead3d9d308dabe8e8b26949502f.zip
Keep notes on their own line if parsed that way
Diffstat (limited to 'src/print.cc')
-rw-r--r--src/print.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/print.cc b/src/print.cc
index 215ab30b..6725a336 100644
--- a/src/print.cc
+++ b/src/print.cc
@@ -43,12 +43,15 @@ namespace ledger {
namespace {
void print_note(std::ostream& out,
const string& note,
+ const bool note_on_next_line,
const std::size_t columns,
const std::size_t prior_width)
{
- // The 4 is for four leading spaces at the beginning of the posting, and
- // the 3 is for two spaces and a semi-colon before the note.
- if (columns > 0 && note.length() > columns - (prior_width + 3))
+ // The 3 is for two spaces and a semi-colon before the note.
+ if (note_on_next_line ||
+ (columns > 0 &&
+ (columns <= prior_width + 3 ||
+ note.length() > columns - (prior_width + 3))))
out << "\n ;";
else
out << " ;";
@@ -103,7 +106,8 @@ namespace {
static_cast<std::size_t>(report.HANDLER(columns_).value.to_long()) : 80);
if (xact.note)
- print_note(out, *xact.note, columns, unistring(leader).length());
+ print_note(out, *xact.note, xact.has_flags(ITEM_NOTE_ON_NEXT_LINE),
+ columns, unistring(leader).length());
out << '\n';
if (xact.metadata) {
@@ -226,7 +230,8 @@ namespace {
}
if (post->note)
- print_note(out, *post->note, columns, 4 + account_width);
+ print_note(out, *post->note, post->has_flags(ITEM_NOTE_ON_NEXT_LINE),
+ columns, 4 + account_width);
out << '\n';
}
}