aboutsummaryrefslogtreecommitdiff
path: root/dfm.c
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2026-03-08 17:16:36 +0200
committerDylan Araps <dylan.araps@gmail.com>2026-03-08 17:16:36 +0200
commite10a5a553f4733dcbbd1f1ed583e7dc083ad726a (patch)
treefc4e6545687f5555032c8cfd123519b9c7dd2ea7 /dfm.c
parent7ed6cd9440695bf115d07c9afe5729486e5f30e2 (diff)
dfm: keep track of nest level
Shows an indicator in the statusline if dfm is running inside of dfm and how deep the nesting is. Don't go too deep.
Diffstat (limited to 'dfm.c')
-rw-r--r--dfm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/dfm.c b/dfm.c
index 5582195..64e3cb0 100644
--- a/dfm.c
+++ b/dfm.c
@@ -194,6 +194,7 @@ struct fm {
fm_filter sf;
s64 tz;
+ u8 nl;
};
// Entry Virtual {{{
@@ -1400,6 +1401,15 @@ fm_draw_inf(struct fm *p)
p->f & FM_ROOT ? CUT(DFM_COL_NAV_ROOT) : CUT(DFM_COL_NAV);
s32 vw = p->col;
fm_draw_nav_begin(p, c);
+
+ if (unlikely(p->nl)) {
+ STR_PUSH(&p->io, " " VT_SGR(1));
+ str_push_c(&p->io, p->nl);
+ STR_PUSH(&p->io, VT_SGR0);
+ str_push(&p->io, c.d, c.l);
+ vw -= 2;
+ }
+
str_push_c(&p->io, ' ');
vw -= str_push_u32(&p->io, p->y + !!p->vl);
str_push_c(&p->io, '/');
@@ -3505,10 +3515,21 @@ fm_io_flush(str *s, void *ctx, usize n)
}
static inline int
+fm_nest(struct fm *p)
+{
+ char nl[2] = "0";
+ cut l = get_env("DFM_LEVEL", "");
+ if (l.l) p->nl = *nl = *l.d + 1;
+ return setenv("DFM_LEVEL", nl, 1);
+}
+
+static inline int
fm_init(struct fm *p)
{
if (fs_watch_init(&p->p) == -1)
return -1;
+ if (fm_nest(p) == -1)
+ return -1;
p->opener = get_env("DFM_OPENER", DFM_OPENER);
p->dfd = AT_FDCWD;
p->ds = DFM_DEFAULT_SORT;