aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-10-16 08:29:49 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-10-16 08:29:49 +0530
commit522626a88dffb820cc14be707ce0e6940df42e88 (patch)
treed8b3b313d03e24eb5c58af2fd043920e99cf01ba /src
parent3953639c5d8e44a2ff8140fd3067db866df11d08 (diff)
downloadnnn-522626a88dffb820cc14be707ce0e6940df42e88.tar.gz
Combine related cases together
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c94
1 files changed, 53 insertions, 41 deletions
diff --git a/src/nnn.c b/src/nnn.c
index d38d257..832269f 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3943,39 +3943,50 @@ nochange:
printwait("unsupported file", &presel);
goto nochange;
}
- case SEL_NEXT:
- if (ndents)
- move_cursor((cur + 1) % ndents, 0);
- break;
- case SEL_PREV:
- if (ndents)
- move_cursor((cur + ndents - 1) % ndents, 0);
- break;
- case SEL_PGDN: // fallthrough
- onscreen = xlines - 4;
- move_cursor(curscroll + (onscreen - 1), 1);
- curscroll += onscreen - 1;
- break;
- case SEL_CTRL_D:
- onscreen = xlines - 4;
- move_cursor(curscroll + (onscreen - 1), 1);
- curscroll += onscreen >> 1;
- break;
- case SEL_PGUP: // fallthrough
- onscreen = xlines - 4;
- move_cursor(curscroll, 1);
- curscroll -= onscreen - 1;
- break;
- case SEL_CTRL_U:
- onscreen = xlines - 4;
- move_cursor(curscroll, 1);
- curscroll -= onscreen >> 1;
- break;
- case SEL_HOME:
- move_cursor(0, 1);
- break;
+ case SEL_NEXT: // fallthorugh
+ case SEL_PREV: // fallthorugh
+ case SEL_PGDN: // fallthorugh
+ case SEL_CTRL_D: // fallthorugh
+ case SEL_PGUP: // fallthorugh
+ case SEL_CTRL_U: // fallthorugh
+ case SEL_HOME: // fallthorugh
case SEL_END:
- move_cursor(ndents - 1, 1);
+ switch (sel) {
+ case SEL_NEXT:
+ if (ndents)
+ move_cursor((cur + 1) % ndents, 0);
+ break;
+ case SEL_PREV:
+ if (ndents)
+ move_cursor((cur + ndents - 1) % ndents, 0);
+ break;
+ case SEL_PGDN:
+ onscreen = xlines - 4;
+ move_cursor(curscroll + (onscreen - 1), 1);
+ curscroll += onscreen - 1;
+ break;
+ case SEL_CTRL_D:
+ onscreen = xlines - 4;
+ move_cursor(curscroll + (onscreen - 1), 1);
+ curscroll += onscreen >> 1;
+ break;
+ case SEL_PGUP: // fallthrough
+ onscreen = xlines - 4;
+ move_cursor(curscroll, 1);
+ curscroll -= onscreen - 1;
+ break;
+ case SEL_CTRL_U:
+ onscreen = xlines - 4;
+ move_cursor(curscroll, 1);
+ curscroll -= onscreen >> 1;
+ break;
+ case SEL_HOME:
+ move_cursor(0, 1);
+ break;
+ default: /* case SEL_END: */
+ move_cursor(ndents - 1, 1);
+ break;
+ }
break;
case SEL_CDHOME: // fallthrough
case SEL_CDBEGIN: // fallthrough
@@ -4811,15 +4822,7 @@ nochange:
unmount(tmp, newpath, &presel, path);
goto nochange;
case SEL_QUITCD: // fallthrough
- case SEL_QUIT:
- for (r = 0; r < CTX_MAX; ++r)
- if (r != cfg.curctx && g_ctx[r].c_cfg.ctxactive) {
- r = get_input("Quit all contexts? [Enter]");
- break;
- }
-
- if (!(r == CTX_MAX || r == '\r'))
- break; // fallthrough
+ case SEL_QUIT: // fallthrough
case SEL_QUITCTX:
if (sel == SEL_QUITCTX) {
fd = cfg.curctx; /* fd used as tmp var */
@@ -4852,6 +4855,15 @@ nochange:
setdirwatch();
goto begin;
}
+ } else {
+ for (r = 0; r < CTX_MAX; ++r)
+ if (r != cfg.curctx && g_ctx[r].c_cfg.ctxactive) {
+ r = get_input("Quit all contexts? [Enter]");
+ break;
+ }
+
+ if (!(r == CTX_MAX || r == '\r'))
+ break; // fallthrough
}
if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) {