Separator in "balance" now part of format string
This commit is contained in:
parent
d102641f2a
commit
56693fab9b
8 changed files with 46 additions and 23 deletions
|
|
@ -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();
|
||||
|
|
|
|||
19
src/output.h
19
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ o 2007/03/12 01:00:00
|
|||
$-3,200.00 Gains
|
||||
--------------------
|
||||
$8,000.00
|
||||
-273600s
|
||||
-273600s
|
||||
>>>2
|
||||
=== 0
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ bal --collapse
|
|||
$-0.35 Income
|
||||
--------------------
|
||||
$-0.35
|
||||
0.350 VMMXX
|
||||
0.350 VMMXX
|
||||
>>>2
|
||||
=== 0
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ bal --current
|
|||
$-0.35 Income:Dividends:Vanguard:VMMXX
|
||||
--------------------
|
||||
$-0.35
|
||||
0.350 VMMXX
|
||||
0.350 VMMXX
|
||||
>>>2
|
||||
=== 0
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ bal
|
|||
$-0.35 Income:Dividends:Vanguard:VMMXX
|
||||
--------------------
|
||||
$-0.35
|
||||
0.350 VMMXX
|
||||
0.350 VMMXX
|
||||
>>>2
|
||||
=== 0
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ o 2007/03/12 01:00:00
|
|||
2.0h A
|
||||
2.0h B
|
||||
--------------------
|
||||
4.0h
|
||||
4.0h
|
||||
>>>2
|
||||
=== 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue