summaryrefslogtreecommitdiff
path: root/src/print.cc
diff options
context:
space:
mode:
authorChristophe Rhodes <csr21@cantab.net>2012-11-06 12:01:16 +0000
committerChristophe Rhodes <csr21@cantab.net>2012-11-06 12:31:01 +0000
commita6d40ada1f33ebce5ed55ddd2d54a187a1f70c59 (patch)
tree245130564aa228c57d6b135154cdca7b15c45ee2 /src/print.cc
parent8214a69e20aa6d5ef2dbb86ca670a02b013db0f1 (diff)
downloadfork-ledger-a6d40ada1f33ebce5ed55ddd2d54a187a1f70c59.tar.gz
fork-ledger-a6d40ada1f33ebce5ed55ddd2d54a187a1f70c59.tar.bz2
fork-ledger-a6d40ada1f33ebce5ed55ddd2d54a187a1f70c59.zip
right-justify amount_expr text in print report where possible
Diffstat (limited to 'src/print.cc')
-rw-r--r--src/print.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/print.cc b/src/print.cc
index 79d83161..a4a0bc6f 100644
--- a/src/print.cc
+++ b/src/print.cc
@@ -203,9 +203,15 @@ namespace {
(static_cast<std::string::size_type>(account_width) -
static_cast<std::string::size_type>(name.length()));
+ std::size_t amount_width =
+ (report.HANDLED(amount_width_) ?
+ lexical_cast<std::size_t>(report.HANDLER(amount_width_).str()) :
+ 12);
string amt;
if (post->amount_expr) {
- amt = post->amount_expr->text();
+ std::ostringstream amt_str;
+ justify(amt_str, post->amount_expr->text(), amount_width, true);
+ amt = amt_str.str();
}
else if (count == 2 && index == 2 &&
post_has_simple_amount(*post) &&
@@ -218,11 +224,6 @@ namespace {
// first.
}
else {
- std::size_t amount_width =
- (report.HANDLED(amount_width_) ?
- lexical_cast<std::size_t>(report.HANDLER(amount_width_).str()) :
- 12);
-
std::ostringstream amt_str;
value_t(post->amount).print(amt_str, static_cast<int>(amount_width),
-1, AMOUNT_PRINT_RIGHT_JUSTIFY |