summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-27 16:23:36 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-27 16:23:36 -0400
commit56693fab9b98b083308f628284e73ce2797f8a5f (patch)
tree2e61223f0ad79d64e1bdb09a075e60ecadcc8429 /src
parentd102641f2ac05931aad60b00c21e6ba87770907c (diff)
downloadfork-ledger-56693fab9b98b083308f628284e73ce2797f8a5f.tar.gz
fork-ledger-56693fab9b98b083308f628284e73ce2797f8a5f.tar.bz2
fork-ledger-56693fab9b98b083308f628284e73ce2797f8a5f.zip
Separator in "balance" now part of format string
Diffstat (limited to 'src')
-rw-r--r--src/output.cc35
-rw-r--r--src/output.h19
-rw-r--r--src/report.h5
3 files changed, 41 insertions, 18 deletions
diff --git a/src/output.cc b/src/output.cc
index 9c6b20ce..f7f18351 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -199,6 +199,35 @@ void gather_statistics::operator()(post_t& post)
}
}
+format_accounts::format_accounts(report_t& _report,
+ const string& format)
+ : report(_report), disp_pred()
+{
+ TRACE_CTOR(format_accounts, "report&, const string&");
+
+ if (report.HANDLED(display_)) {
+ DEBUG("account.display",
+ "Account display predicate: " << report.HANDLER(display_).str());
+ disp_pred.predicate.parse(report.HANDLER(display_).str());
+ }
+
+ const char * f = format.c_str();
+
+ if (const char * p = std::strstr(f, "%/")) {
+ account_line_format.parse(string(f, 0, p - f));
+ const char * n = p + 2;
+ if (const char * p = std::strstr(n, "%/")) {
+ total_line_format.parse(string(n, 0, p - n));
+ separator_format.parse(string(p + 2));
+ } else {
+ total_line_format.parse(n);
+ }
+ } else {
+ account_line_format.parse(format);
+ total_line_format.parse(format);
+ }
+}
+
void format_accounts::post_account(account_t& account)
{
bind_scope_t bound_scope(report, account);
@@ -233,7 +262,7 @@ void format_accounts::post_account(account_t& account)
if (format_account) {
account.xdata().add_flags(ACCOUNT_EXT_DISPLAYED);
- format.format(report.output_stream, bound_scope);
+ account_line_format.format(report.output_stream, bound_scope);
}
}
@@ -262,10 +291,10 @@ void format_accounts::flush()
account_t::xdata_t& xdata(report.session.master->xdata());
if (! report.HANDLED(no_total) && top_displayed > 1 && xdata.total) {
- out << "--------------------\n";
xdata.value = xdata.total;
bind_scope_t bound_scope(report, *report.session.master);
- format.format(out, bound_scope);
+ separator_format.format(out, bound_scope);
+ total_line_format.format(out, bound_scope);
}
out.flush();
diff --git a/src/output.h b/src/output.h
index 93fd1d53..c154bed1 100644
--- a/src/output.h
+++ b/src/output.h
@@ -63,7 +63,7 @@ protected:
format_t first_line_format;
format_t next_lines_format;
format_t between_format;
- xact_t * last_xact;
+ xact_t * last_xact;
post_t * last_post;
bool print_raw;
@@ -135,24 +135,15 @@ class format_accounts : public item_handler<account_t>
{
protected:
report_t& report;
- format_t format;
+ format_t account_line_format;
+ format_t total_line_format;
+ format_t separator_format;
item_predicate disp_pred;
std::list<account_t *> posted_accounts;
public:
- format_accounts(report_t& _report,
- const string& _format = "")
- : report(_report), format(_format), disp_pred()
- {
- TRACE_CTOR(format_accounts, "report&, const string&, bool");
-
- if (report.HANDLED(display_)) {
- DEBUG("account.display",
- "Account display predicate: " << report.HANDLER(display_).str());
- disp_pred.predicate.parse(report.HANDLER(display_).str());
- }
- }
+ format_accounts(report_t& _report, const string& _format);
virtual ~format_accounts() {
TRACE_DTOR(format_accounts);
}
diff --git a/src/report.h b/src/report.h
index 11af9644..0397e989 100644
--- a/src/report.h
+++ b/src/report.h
@@ -243,7 +243,10 @@ public:
on("%(ansify_if(justify(scrub(display_total), 20, -1, true), \"red\", "
" color & scrub(display_total) < 0))"
" %(!options.flat ? depth_spacer : \"\")"
- "%-(ansify_if(partial_account(options.flat), \"blue\", color))\n");
+ "%-(ansify_if(partial_account(options.flat), \"blue\", color))\n%/"
+ "%(ansify_if(justify(scrub(display_total), 20, -1, true), \"red\", "
+ " color & scrub(display_total) < 0))\n%/"
+ "--------------------\n");
});
OPTION(report_t, base);