Browse Source

Combine navigation case

master
Arun Prakash Jana 6 years ago
parent
commit
a8234f26e8
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 50 additions and 34 deletions
  1. +50
    -34
      src/nnn.c

+ 50
- 34
src/nnn.c View File

@@ -2797,45 +2797,61 @@ nochange:
printmsg("unsupported file"); printmsg("unsupported file");
goto nochange; goto nochange;
} }
case SEL_NEXT: case SEL_NEXT: // fallthrough
if (cur < ndents - 1) case SEL_PREV: // fallthrough
++cur; case SEL_PGDN: // fallthrough
else if (ndents) case SEL_PGUP: // fallthrough
/* Roll over, set cursor to first entry */ case SEL_HOME: // fallthrough
case SEL_END:
switch (sel) {
case SEL_NEXT:
if (cur < ndents - 1)
++cur;
else if (ndents)
/* Roll over, set cursor to first entry */
cur = 0;
break;
case SEL_PREV:
if (cur > 0)
--cur;
else if (ndents)
/* Roll over, set cursor to last entry */
cur = ndents - 1;
break;
case SEL_PGDN:
if (cur < ndents - 1)
cur += MIN((LINES - 4) / 2, ndents - 1 - cur);
break;
case SEL_PGUP:
if (cur > 0)
cur -= MIN((LINES - 4) / 2, cur);
break;
case SEL_HOME:
cur = 0; cur = 0;
break; break;
case SEL_PREV: default: /* case SEL_END */
if (cur > 0)
--cur;
else if (ndents)
/* Roll over, set cursor to last entry */
cur = ndents - 1; cur = ndents - 1;
break;
}
break; break;
case SEL_PGDN: case SEL_CDHOME: // fallthrough
if (cur < ndents - 1) case SEL_CDBEGIN: // fallthrough
cur += MIN((LINES - 4) / 2, ndents - 1 - cur); case SEL_CDLAST: // fallthrough
break;
case SEL_PGUP:
if (cur > 0)
cur -= MIN((LINES - 4) / 2, cur);
break;
case SEL_HOME:
cur = 0;
break;
case SEL_END:
cur = ndents - 1;
break;
case SEL_CDHOME:
dir = xgetenv("HOME", path); // fallthrough
case SEL_CDBEGIN:
if (sel == SEL_CDBEGIN)
dir = ipath; // fallthrough
case SEL_CDLAST:
if (sel == SEL_CDLAST)
dir = lastdir; // fallthrough
case SEL_VISIT: case SEL_VISIT:
if (sel == SEL_VISIT) switch (sel) {
case SEL_CDHOME:
dir = xgetenv("HOME", path);
break;
case SEL_CDBEGIN:
dir = ipath;
break;
case SEL_CDLAST:
dir = lastdir;
break;
default: /* case SEL_VISIT */
dir = mark; dir = mark;
break;
}


if (dir[0] == '\0') { if (dir[0] == '\0') {
printmsg("not set"); printmsg("not set");


||||||
x
 
000:0
Loading…
Cancel
Save