mirror of
https://github.com/jarun/nnn.git
synced 2025-02-26 03:01:32 +00:00
Remember detail/light mode of context
This commit is contained in:
parent
7ada9a0b6b
commit
f7dd38d90e
1 changed files with 40 additions and 29 deletions
69
src/nnn.c
69
src/nnn.c
|
@ -1869,35 +1869,6 @@ static int xlink(char *suffix, char *path, char *buf, int type)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void savecurctx(settings *curcfg, char *path, char *curname, int r /* next context num */)
|
|
||||||
{
|
|
||||||
settings cfg = *curcfg;
|
|
||||||
|
|
||||||
#ifdef DIR_LIMITED_COPY
|
|
||||||
g_crc = 0;
|
|
||||||
#endif
|
|
||||||
/* Save current context */
|
|
||||||
xstrlcpy(g_ctx[cfg.curctx].c_name, curname, NAME_MAX + 1);
|
|
||||||
g_ctx[cfg.curctx].c_cfg = cfg;
|
|
||||||
|
|
||||||
if (g_ctx[r].c_cfg.ctxactive) /* Switch to saved context */
|
|
||||||
cfg = g_ctx[r].c_cfg;
|
|
||||||
else { /* Setup a new context from current context */
|
|
||||||
g_ctx[r].c_cfg.ctxactive = 1;
|
|
||||||
xstrlcpy(g_ctx[r].c_path, path, PATH_MAX);
|
|
||||||
g_ctx[r].c_last[0] = '\0';
|
|
||||||
xstrlcpy(g_ctx[r].c_name, curname, NAME_MAX + 1);
|
|
||||||
g_ctx[r].c_fltr[0] = g_ctx[r].c_fltr[1] = '\0';
|
|
||||||
g_ctx[r].p_fltr = g_ctx[r].c_fltr + 1;
|
|
||||||
g_ctx[r].c_cfg = cfg;
|
|
||||||
g_ctx[r].c_cfg.runscript = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.curctx = r;
|
|
||||||
|
|
||||||
*curcfg = cfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool parsebmstr(void)
|
static bool parsebmstr(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -2204,6 +2175,40 @@ static void printent_long(const struct entry *ent, int sel, uint namecols)
|
||||||
|
|
||||||
static void (*printptr)(const struct entry *ent, int sel, uint namecols) = &printent_long;
|
static void (*printptr)(const struct entry *ent, int sel, uint namecols) = &printent_long;
|
||||||
|
|
||||||
|
static void savecurctx(settings *curcfg, char *path, char *curname, int r /* next context num */)
|
||||||
|
{
|
||||||
|
settings cfg = *curcfg;
|
||||||
|
|
||||||
|
#ifdef DIR_LIMITED_COPY
|
||||||
|
g_crc = 0;
|
||||||
|
#endif
|
||||||
|
/* Save current context */
|
||||||
|
xstrlcpy(g_ctx[cfg.curctx].c_name, curname, NAME_MAX + 1);
|
||||||
|
g_ctx[cfg.curctx].c_cfg = cfg;
|
||||||
|
|
||||||
|
if (g_ctx[r].c_cfg.ctxactive) { /* Switch to saved context */
|
||||||
|
/* Switch light/detail mode */
|
||||||
|
if (cfg.showdetail != g_ctx[r].c_cfg.showdetail)
|
||||||
|
/* set the reverse */
|
||||||
|
printptr = cfg.showdetail ? &printent : &printent_long;
|
||||||
|
|
||||||
|
cfg = g_ctx[r].c_cfg;
|
||||||
|
} else { /* Setup a new context from current context */
|
||||||
|
g_ctx[r].c_cfg.ctxactive = 1;
|
||||||
|
xstrlcpy(g_ctx[r].c_path, path, PATH_MAX);
|
||||||
|
g_ctx[r].c_last[0] = '\0';
|
||||||
|
xstrlcpy(g_ctx[r].c_name, curname, NAME_MAX + 1);
|
||||||
|
g_ctx[r].c_fltr[0] = g_ctx[r].c_fltr[1] = '\0';
|
||||||
|
g_ctx[r].p_fltr = g_ctx[r].c_fltr + 1;
|
||||||
|
g_ctx[r].c_cfg = cfg;
|
||||||
|
g_ctx[r].c_cfg.runscript = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.curctx = r;
|
||||||
|
|
||||||
|
*curcfg = cfg;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets only a single line (that's what we need
|
* Gets only a single line (that's what we need
|
||||||
* for now) or shows full command output in pager.
|
* for now) or shows full command output in pager.
|
||||||
|
@ -3929,6 +3934,12 @@ nochange:
|
||||||
path = g_ctx[r].c_path;
|
path = g_ctx[r].c_path;
|
||||||
lastdir = g_ctx[r].c_last;
|
lastdir = g_ctx[r].c_last;
|
||||||
lastname = g_ctx[r].c_name;
|
lastname = g_ctx[r].c_name;
|
||||||
|
|
||||||
|
/* Switch light/detail mode */
|
||||||
|
if (cfg.showdetail != g_ctx[r].c_cfg.showdetail)
|
||||||
|
/* Set the reverse */
|
||||||
|
printptr = cfg.showdetail ? &printent : &printent_long;
|
||||||
|
|
||||||
cfg = g_ctx[r].c_cfg;
|
cfg = g_ctx[r].c_cfg;
|
||||||
|
|
||||||
cfg.curctx = r;
|
cfg.curctx = r;
|
||||||
|
|
Loading…
Add table
Reference in a new issue