summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-22 01:16:29 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-22 01:27:05 -0400
commit81bf38584e43e5fc31e316246f11e210418548a9 (patch)
treef1a99e54d63737fcfd4ed4e48c6f9cd6b431bcc1 /src
parent7d005b8d98b5547e5847895140d52a2707545ed5 (diff)
downloadfork-ledger-81bf38584e43e5fc31e316246f11e210418548a9.tar.gz
fork-ledger-81bf38584e43e5fc31e316246f11e210418548a9.tar.bz2
fork-ledger-81bf38584e43e5fc31e316246f11e210418548a9.zip
Added new --bold-if option
Diffstat (limited to 'src')
-rw-r--r--src/report.cc11
-rw-r--r--src/report.h64
2 files changed, 59 insertions, 16 deletions
diff --git a/src/report.cc b/src/report.cc
index df37f9dc..77cfaffd 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -457,6 +457,14 @@ value_t report_t::fn_display_total(call_scope_t& scope)
return HANDLER(display_total_).expr.calc(scope);
}
+value_t report_t::fn_should_bold(call_scope_t& scope)
+{
+ if (HANDLED(bold_if_))
+ return HANDLER(bold_if_).expr.calc(scope);
+ else
+ return false;
+}
+
value_t report_t::fn_market(call_scope_t& args)
{
optional<datetime_t> moment = (args.has<datetime_t>(1) ?
@@ -905,6 +913,7 @@ option_t<report_t> * report_t::lookup_option(const char * p)
else OPT(base);
else OPT_ALT(basis, cost);
else OPT_(begin_);
+ else OPT(bold_if_);
else OPT(budget);
else OPT(by_payee);
break;
@@ -1226,6 +1235,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
return MAKE_FUNCTOR(report_t::fn_scrub);
else if (is_eq(p, "strip"))
return MAKE_FUNCTOR(report_t::fn_strip);
+ else if (is_eq(p, "should_bold"))
+ return MAKE_FUNCTOR(report_t::fn_should_bold);
break;
case 't':
diff --git a/src/report.h b/src/report.h
index e0073193..fc2fc1a2 100644
--- a/src/report.h
+++ b/src/report.h
@@ -140,6 +140,7 @@ public:
value_t fn_total_expr(call_scope_t& scope);
value_t fn_display_amount(call_scope_t& scope);
value_t fn_display_total(call_scope_t& scope);
+ value_t fn_should_bold(call_scope_t& scope);
value_t fn_market(call_scope_t& scope);
value_t fn_get_at(call_scope_t& scope);
value_t fn_is_seq(call_scope_t& scope);
@@ -379,9 +380,13 @@ public:
OPTION__(report_t, balance_format_, CTOR(report_t, balance_format_) {
on(none,
- "%(justify(scrub(display_total), 20, 20 + prepend_width, true, color))"
+ "%(ansify_if("
+ " justify(scrub(display_total), 20, 20 + prepend_width, true, color),"
+ " bold if should_bold))"
" %(!options.flat ? depth_spacer : \"\")"
- "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
+ "%-(ansify_if("
+ " ansify_if(partial_account(options.flat), blue if color),"
+ " bold if should_bold))\n%/"
"%$1\n%/"
"--------------------\n");
});
@@ -405,6 +410,18 @@ public:
parent->HANDLER(limit_).on(string("--begin"), predicate);
});
+ OPTION__
+ (report_t, bold_if_,
+ expr_t expr;
+ CTOR(report_t, bold_if_) {}
+ void set_expr(const optional<string>& whence, const string& str) {
+ expr = str;
+ on(whence, str);
+ }
+ DO_(args) {
+ set_expr(args.get<string>(0), args.get<string>(1));
+ });
+
OPTION_(report_t, budget, DO() {
parent->budget_flags |= BUDGET_BUDGETED;
});
@@ -808,21 +825,36 @@ public:
OPTION__(report_t, register_format_, CTOR(report_t, register_format_) {
on(none,
- "%(ansify_if(justify(format_date(date), date_width), green "
- " if color & date > today))"
- " %(ansify_if(justify(truncated(payee, payee_width), payee_width), "
- " bold if color & !cleared & actual))"
- " %(ansify_if(justify(truncated(display_account, account_width, "
- " abbrev_len), account_width), blue if color))"
- " %(justify(scrub(display_amount), amount_width, "
- " 3 + meta_width + date_width + payee_width + account_width"
- " + amount_width + prepend_width, true, color))"
- " %(justify(scrub(display_total), total_width, "
- " 4 + meta_width + date_width + payee_width + account_width"
- " + amount_width + total_width + prepend_width, true, color))\n%/"
+ "%(ansify_if("
+ " ansify_if(justify(format_date(date), date_width),"
+ " green if color and date > today),"
+ " bold if should_bold))"
+ " %(ansify_if("
+ " ansify_if(justify(truncated(payee, payee_width), payee_width), "
+ " bold if color and !cleared and actual),"
+ " bold if should_bold))"
+ " %(ansify_if("
+ " ansify_if(justify(truncated(display_account, account_width, "
+ " abbrev_len), account_width),"
+ " blue if color),"
+ " bold if should_bold))"
+ " %(ansify_if("
+ " justify(scrub(display_amount), amount_width, "
+ " 3 + meta_width + date_width + payee_width"
+ " + account_width + amount_width + prepend_width,"
+ " true, color),"
+ " bold if should_bold))"
+ " %(ansify_if("
+ " justify(scrub(display_total), total_width, "
+ " 4 + meta_width + date_width + payee_width"
+ " + account_width + amount_width + total_width"
+ " + prepend_width, true, color),"
+ " bold if should_bold))\n%/"
"%(justify(\" \", date_width))"
- " %(justify(truncated(has_tag(\"Payee\") ? payee : \" \", "
- " payee_width), payee_width))"
+ " %(ansify_if("
+ " justify(truncated(has_tag(\"Payee\") ? payee : \" \", "
+ " payee_width), payee_width),"
+ " bold if should_bold))"
" %$3 %$4 %$5\n");
});