Restored the 'print' command.

This commit is contained in:
John Wiegley 2008-09-17 21:09:15 -04:00
parent 24e64c202e
commit 1b083919c0
4 changed files with 17 additions and 3 deletions

View file

@ -407,7 +407,10 @@ namespace ledger {
}
else if (verb == "print" || verb == "p") {
verb = "print";
command = reporter<>(new format_xacts(report, session.print_format));
command = reporter<>(new format_xacts(report,
report.format_string.empty() ?
session.print_format :
report.format_string));
}
else if (verb == "balance" || verb == "bal" || verb == "b") {
verb = "balance";

View file

@ -42,10 +42,18 @@ format_xacts::format_xacts(report_t& _report, const string& format)
if (const char * p = std::strstr(f, "%/")) {
first_line_format.parse(string(f, 0, p - f));
next_lines_format.parse(string(p + 2));
const char * n = p + 2;
if (const char * p = std::strstr(n, "%/")) {
next_lines_format.parse(string(n, 0, p - n));
between_format.parse(string(p + 2));
} else {
next_lines_format.parse(n);
between_format.parse("\n");
}
} else {
first_line_format.parse(format);
next_lines_format.parse(format);
between_format.parse("\n");
}
}
@ -56,6 +64,8 @@ void format_xacts::operator()(xact_t& xact)
if (! xact.has_xdata() ||
! xact.xdata().has_flags(XACT_EXT_DISPLAYED)) {
if (last_entry != xact.entry) {
if (last_entry)
between_format.format(out, *last_entry);
first_line_format.format(out, xact);
last_entry = xact.entry;
}

View file

@ -44,6 +44,7 @@ protected:
report_t& report;
format_t first_line_format;
format_t next_lines_format;
format_t between_format;
entry_t * last_entry;
xact_t * last_xact;

View file

@ -79,7 +79,7 @@ session_t::session_t()
("%-.9D %-.35P %-.39A %22.108t %!22.132T\n%/"
"%48|%-.38A %22.108t %!22.132T\n"),
print_format
("\n%d %Y%C%P\n %-34W %12o%n\n%/ %-34W %12o%n\n"),
("%(date)%(cleared ? \" *\" : (uncleared ? \"\" : \" !\"))%(code ? \" (\" + code + \")\" : \"\") %(payee)\n %-34(account) %12(amount)\n%/ %-34(account) %12(amount)%(note ? \" ; \" + note : \"\")\n"),
balance_format
("%20T %_%-a\n"),
equity_format