diff options
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | dfm.c | 21 |
2 files changed, 23 insertions, 1 deletions
@@ -217,8 +217,9 @@ at the actions each key is bound to. The statusline is as follows: ``` - 1/1 [RnHE] [1+] ~0B /path/to/current/directory/<query> +1 1/1 [RnHE] [1+] ~0B /path/to/current/directory/<query> + 1 - Shows nest level of dfm. Only shown if > 0. 1/1 - The entry number under the cursor and the total visible entries. [RnHE] - Indicators. @@ -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; |