(parse_elements): Added %S, %B and %E elements, for printing the
source path, beginning and ending positions of an entry.
This commit is contained in:
parent
64461f0d95
commit
4fda551752
2 changed files with 31 additions and 1 deletions
29
format.cc
29
format.cc
|
|
@ -180,6 +180,9 @@ element_t * format_t::parse_elements(const std::string& fmt)
|
||||||
current->chars = format_t::date_format;
|
current->chars = format_t::date_format;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'S': current->type = element_t::SOURCE; break;
|
||||||
|
case 'B': current->type = element_t::BEG_POS; break;
|
||||||
|
case 'E': current->type = element_t::END_POS; break;
|
||||||
case 'X': current->type = element_t::CLEARED; break;
|
case 'X': current->type = element_t::CLEARED; break;
|
||||||
case 'C': current->type = element_t::CODE; break;
|
case 'C': current->type = element_t::CODE; break;
|
||||||
case 'P': current->type = element_t::PAYEE; break;
|
case 'P': current->type = element_t::PAYEE; break;
|
||||||
|
|
@ -296,7 +299,8 @@ void format_t::format(std::ostream& out_str, const details_t& details) const
|
||||||
|
|
||||||
if (! has_flag)
|
if (! has_flag)
|
||||||
unit_cost.commodity().flags &= ~COMMODITY_STYLE_VARIABLE;
|
unit_cost.commodity().flags &= ~COMMODITY_STYLE_VARIABLE;
|
||||||
} else {
|
}
|
||||||
|
else if (details.entry) {
|
||||||
unsigned int xacts_count = 0;
|
unsigned int xacts_count = 0;
|
||||||
transaction_t * first = NULL;
|
transaction_t * first = NULL;
|
||||||
transaction_t * last = NULL;
|
transaction_t * last = NULL;
|
||||||
|
|
@ -324,6 +328,29 @@ void format_t::format(std::ostream& out_str, const details_t& details) const
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case element_t::SOURCE:
|
||||||
|
if (details.entry) {
|
||||||
|
int idx = details.entry->src_idx;
|
||||||
|
for (strings_list::iterator i = details.entry->journal->sources.begin();
|
||||||
|
i != details.entry->journal->sources.end();
|
||||||
|
i++)
|
||||||
|
if (! idx--) {
|
||||||
|
out << *i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case element_t::BEG_POS:
|
||||||
|
if (details.entry)
|
||||||
|
out << (unsigned long)details.entry->beg_pos;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case element_t::END_POS:
|
||||||
|
if (details.entry)
|
||||||
|
out << (unsigned long)details.entry->end_pos;
|
||||||
|
break;
|
||||||
|
|
||||||
case element_t::DATE_STRING:
|
case element_t::DATE_STRING:
|
||||||
if (details.entry && details.entry->date) {
|
if (details.entry && details.entry->date) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
|
||||||
3
format.h
3
format.h
|
|
@ -17,6 +17,9 @@ struct element_t
|
||||||
enum kind_t {
|
enum kind_t {
|
||||||
STRING,
|
STRING,
|
||||||
VALUE_EXPR,
|
VALUE_EXPR,
|
||||||
|
SOURCE,
|
||||||
|
BEG_POS,
|
||||||
|
END_POS,
|
||||||
DATE_STRING,
|
DATE_STRING,
|
||||||
CLEARED,
|
CLEARED,
|
||||||
CODE,
|
CODE,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue