diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-22 03:14:58 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-22 04:51:11 -0400 |
commit | 04fd1ae24c3be6f9d3400c55bce90c3fd743e96b (patch) | |
tree | 25d1ad1adfd755b41ee1f24b3177a2d11219e714 /src/value.cc | |
parent | 640279c65d638d777852a291d674c342a9b8115e (diff) | |
download | fork-ledger-04fd1ae24c3be6f9d3400c55bce90c3fd743e96b.tar.gz fork-ledger-04fd1ae24c3be6f9d3400c55bce90c3fd743e96b.tar.bz2 fork-ledger-04fd1ae24c3be6f9d3400c55bce90c3fd743e96b.zip |
Fixed the way values are justified for printing
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/value.cc b/src/value.cc index 7162a610..52760535 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1317,12 +1317,17 @@ value_t value_t::strip_annotations(const keep_details_t& what_to_keep) const void value_t::print(std::ostream& out, const int first_width, const int latter_width, + const bool right_justify, const optional<string>& date_format) const { if (first_width > 0 && ! is_amount() && ! is_balance() && ! is_string()) { out.width(first_width); - out << std::left; + + if (right_justify) + out << std::right; + else + out << std::left; } switch (type()) { @@ -1355,17 +1360,17 @@ void value_t::print(std::ostream& out, case AMOUNT: { if (as_amount().is_zero()) { out.width(first_width); - out << std::right << 0L; + out << (right_justify ? std::right : std::left) << 0; } else { std::ostringstream buf; buf << as_amount(); - justify(out, buf.str(), first_width, true); + justify(out, buf.str(), first_width, right_justify); } break; } case STRING: - justify(out, as_string(), first_width); + justify(out, as_string(), first_width, right_justify); break; case MASK: @@ -1381,14 +1386,15 @@ void value_t::print(std::ostream& out, else out << ", "; - value.print(out, first_width, latter_width, date_format); + value.print(out, first_width, latter_width, right_justify, + date_format); } out << ')'; break; } case BALANCE: - as_balance().print(out, first_width, latter_width); + as_balance().print(out, first_width, latter_width, right_justify); break; case POINTER: |