diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2020-05-03 16:16:14 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2020-05-03 16:25:59 +0530 |
commit | ebb6f153b51332ce2b64b3e717ea956484749d4c (patch) | |
tree | fb798e3b34d5120292b9aa53f3cd2f9c3e4d19c7 /src/nnn.c | |
parent | 3f60a1931f1e51c8e90516dd7e716244da7f42e7 (diff) | |
download | nnn-ebb6f153b51332ce2b64b3e717ea956484749d4c.tar.gz |
Context code '+' to create context smartly
Diffstat (limited to 'src/nnn.c')
-rw-r--r-- | src/nnn.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -4234,16 +4234,24 @@ static void rmlistpath() static void readpipe(int fd, char **path, char **lastname, char **lastdir) { - char *nextpath = NULL; + int r; + char ctx, *nextpath = NULL; ssize_t len = read(fd, g_buf, 1); if (len != 1) return; - char ctx = g_buf[0] - '0'; - - if (ctx > CTX_MAX) - return; + if (g_buf[0] == '+') { + r = cfg.curctx; + do + r = (r + 1) & ~CTX_MAX; + while (g_ctx[r].c_cfg.ctxactive && (r != cfg.curctx)); + ctx = r + 1; + } else { + ctx = g_buf[0] - '0'; + if (ctx > CTX_MAX) + return; + } len = read(fd, g_buf, 1); if (len != 1) @@ -4269,7 +4277,7 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir) xstrsncpy(*lastdir, *path, PATH_MAX); xstrsncpy(*path, nextpath, PATH_MAX); } else { - int r = ctx - 1; + r = ctx - 1; g_ctx[r].c_cfg.ctxactive = 0; savecurctx(&cfg, nextpath, dents[cur].name, r); |