diff options
author | John Wiegley <johnw@newartisans.com> | 2006-02-16 21:10:50 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:24 -0400 |
commit | 2df14a5b86371cd8008c72f9d16421c1a404a4a8 (patch) | |
tree | 247b3e1f9628fd62e19f0758d8f7265308b1d8e2 /format.cc | |
parent | 085420dd28802b8b5962c785dd31e0c28571147d (diff) | |
download | fork-ledger-2df14a5b86371cd8008c72f9d16421c1a404a4a8.tar.gz fork-ledger-2df14a5b86371cd8008c72f9d16421c1a404a4a8.tar.bz2 fork-ledger-2df14a5b86371cd8008c72f9d16421c1a404a4a8.zip |
Transactions now track their beginning and ending position, as do
entries. The new format strings %xB %xE %xb %xe can be used to
display those values relative to a transaction. The Emacs module now
relies on this support to exactly determine where a transaction is,
rather than the Elisp logic it relied on previously.
Diffstat (limited to 'format.cc')
-rw-r--r-- | format.cc | 48 |
1 files changed, 40 insertions, 8 deletions
@@ -191,6 +191,17 @@ element_t * format_t::parse_elements(const std::string& fmt) break; } + case 'x': + switch (*++p) { + case 'B': current->type = element_t::XACT_BEG_POS; break; + case 'b': current->type = element_t::XACT_BEG_LINE; break; + case 'E': current->type = element_t::XACT_END_POS; break; + case 'e': current->type = element_t::XACT_END_LINE; break; + case '\0': + goto END; + } + break; + case 'd': current->type = element_t::COMPLETE_DATE_STRING; current->chars = format_t::date_format; @@ -201,10 +212,10 @@ element_t * format_t::parse_elements(const std::string& fmt) break; case 'S': current->type = element_t::SOURCE; break; - case 'B': current->type = element_t::BEG_POS; break; - case 'b': current->type = element_t::BEG_LINE; break; - case 'E': current->type = element_t::END_POS; break; - case 'e': current->type = element_t::END_LINE; break; + case 'B': current->type = element_t::ENTRY_BEG_POS; break; + case 'b': current->type = element_t::ENTRY_BEG_LINE; break; + case 'E': current->type = element_t::ENTRY_END_POS; break; + case 'e': current->type = element_t::ENTRY_END_LINE; break; case 'X': current->type = element_t::CLEARED; break; case 'Y': current->type = element_t::ENTRY_CLEARED; break; case 'C': current->type = element_t::CODE; break; @@ -222,6 +233,7 @@ element_t * format_t::parse_elements(const std::string& fmt) } } + END: if (q != buf) { if (! result.get()) { result.reset(new element_t); @@ -389,26 +401,46 @@ void format_t::format(std::ostream& out_str, const details_t& details) const } break; - case element_t::BEG_POS: + case element_t::ENTRY_BEG_POS: if (details.entry) out << (unsigned long)details.entry->beg_pos; break; - case element_t::BEG_LINE: + case element_t::ENTRY_BEG_LINE: if (details.entry) out << details.entry->beg_line; break; - case element_t::END_POS: + case element_t::ENTRY_END_POS: if (details.entry) out << (unsigned long)details.entry->end_pos; break; - case element_t::END_LINE: + case element_t::ENTRY_END_LINE: if (details.entry) out << details.entry->end_line; break; + case element_t::XACT_BEG_POS: + if (details.xact) + out << (unsigned long)details.xact->beg_pos; + break; + + case element_t::XACT_BEG_LINE: + if (details.xact) + out << details.xact->beg_line; + break; + + case element_t::XACT_END_POS: + if (details.xact) + out << (unsigned long)details.xact->end_pos; + break; + + case element_t::XACT_END_LINE: + if (details.xact) + out << details.xact->end_line; + break; + case element_t::DATE_STRING: { std::time_t date = 0; if (details.xact) |