README.md | 2 +- nnn.c | 20 ++++++++++++++++---- diff --git a/README.md b/README.md index 984fac945a93d99298835e19c787f2fa3d943291..33d0851822141336d3a32ea6108ddb6beff205d9 100644 --- a/README.md +++ b/README.md @@ -267,7 +267,7 @@ - the current context is in reverse - other used contexts are underlined - rest are unused -The bookmark prompt understands contexts. To switch contexts press ^B and enter the context number (1-4). +The bookmark prompt understands contexts. To switch contexts press ^B and enter the context number (1-4). >/. and at the bookmark prompt cycles between active contexts. The first time a context is entered, it copies the state of the last visited context. Each context remembers its start directory and last visited directory. diff --git a/nnn.c b/nnn.c index 8836ff580c89915ffa2c5fa54e61752a2afda9db..f7ff0772851a8ca8cf2a4b7449330dc90a30dabb 100644 --- a/nnn.c +++ b/nnn.c @@ -2485,6 +2485,7 @@ bool dir_changed = FALSE; /* setup first context */ xstrlcpy(g_ctx[0].c_init, ipath, PATH_MAX); + g_ctx[0].c_cfg = cfg; xstrlcpy(path, ipath, PATH_MAX); copyfilter(); @@ -2751,6 +2752,20 @@ case '-': //fallthrough case '&': presel = tmp[0]; goto begin; + case '>': + case '.': + case '<': + case ',': + r = cfg.curctx; + if (tmp[0] == '>' || tmp[0] == '.') + do + (r == MAX_CTX - 1) ? (r = 0) : ++r; + while (!g_ctx[r].c_cfg.ctxactive); + else + do + (r == 0) ? (r = MAX_CTX - 1) : --r; + while (!g_ctx[r].c_cfg.ctxactive); //fallthrough + tmp[0] = '1' + r; //fallthrough case '1': //fallthrough case '2': //fallthrough case '3': //fallthrough @@ -3298,10 +3313,7 @@ { uint iter = 1; r = cfg.curctx; while (iter < MAX_CTX) { - ++r; - r %= MAX_CTX; - DPRINTF_D(r); - DPRINTF_U(g_ctx[r].c_cfg.ctxactive); + (r == MAX_CTX - 1) ? (r = 0) : ++r; if (g_ctx[r].c_cfg.ctxactive) { g_ctx[cfg.curctx].c_cfg.ctxactive = 0;