summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/account.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/account.cc b/src/account.cc
index da8b0b8e..114c4cc5 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -309,6 +309,20 @@ namespace {
return long(&account);
}
+ value_t get_depth_parent(account_t& account)
+ {
+ std::size_t depth = 0;
+ for (const account_t * acct = account.parent;
+ acct && acct->parent;
+ acct = acct->parent) {
+ std::size_t count = acct->children_with_flags(ACCOUNT_EXT_TO_DISPLAY);
+ assert(count > 0);
+ if (count > 1 || acct->has_xflags(ACCOUNT_EXT_TO_DISPLAY))
+ depth++;
+ }
+ return long(depth);
+ }
+
value_t get_depth_spacer(account_t& account)
{
std::size_t depth = 0;
@@ -425,6 +439,8 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
case 'd':
if (fn_name == "depth")
return WRAP_FUNCTOR(get_wrapper<&get_depth>);
+ else if (fn_name == "depth_parent")
+ return WRAP_FUNCTOR(get_wrapper<&get_depth_parent>);
else if (fn_name == "depth_spacer")
return WRAP_FUNCTOR(get_wrapper<&get_depth_spacer>);
break;