mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Code refactor
This commit is contained in:
parent
d0f26e7c30
commit
9b45b05746
38
src/nnn.c
38
src/nnn.c
|
@ -2150,41 +2150,31 @@ static int filterentries(char *path, char *lastname)
|
||||||
case KEY_DC: // fallthrough
|
case KEY_DC: // fallthrough
|
||||||
case KEY_BACKSPACE: // fallthrough
|
case KEY_BACKSPACE: // fallthrough
|
||||||
case '\b': // fallthrough
|
case '\b': // fallthrough
|
||||||
case CONTROL('L'): // fallthrough
|
|
||||||
case 127: /* handle DEL */
|
case 127: /* handle DEL */
|
||||||
if (len == 1 && *ch != CONTROL('L')) {
|
if (len != 1) {
|
||||||
|
wln[--len] = '\0';
|
||||||
|
wcstombs(ln, wln, REGEX_MAX);
|
||||||
|
ndents = total;
|
||||||
|
} else
|
||||||
*ch = CONTROL('L');
|
*ch = CONTROL('L');
|
||||||
goto end;
|
// fallthrough
|
||||||
}
|
case CONTROL('L'):
|
||||||
|
|
||||||
if (*ch == CONTROL('L')) {
|
if (*ch == CONTROL('L')) {
|
||||||
if (wln[1]) {
|
if (wln[1]) {
|
||||||
ln[REGEX_MAX - 1] = ln[1];
|
ln[REGEX_MAX - 1] = ln[1];
|
||||||
wln[1] = '\0';
|
ln[1] = wln[1] = '\0';
|
||||||
len = 1;
|
len = 1;
|
||||||
|
ndents = total;
|
||||||
} else if (ln[REGEX_MAX - 1]) { /* Show the previous filter */
|
} else if (ln[REGEX_MAX - 1]) { /* Show the previous filter */
|
||||||
ln[1] = ln[REGEX_MAX - 1];
|
ln[1] = ln[REGEX_MAX - 1];
|
||||||
ln[REGEX_MAX - 1] = '\0';
|
ln[REGEX_MAX - 1] = '\0';
|
||||||
len = mbstowcs(wln, ln, REGEX_MAX);
|
len = mbstowcs(wln, ln, REGEX_MAX);
|
||||||
/*
|
|
||||||
* Go to the top, we don't know if the
|
|
||||||
* hovered file will match the filter
|
|
||||||
*/
|
|
||||||
cur = 0;
|
|
||||||
|
|
||||||
if (matches(pln) != -1)
|
|
||||||
redraw(path);
|
|
||||||
|
|
||||||
showfilter(ln);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
wln[--len] = '\0';
|
|
||||||
|
|
||||||
|
/* Go to the top, we don't know if the hovered file will match the filter */
|
||||||
cur = 0;
|
cur = 0;
|
||||||
|
|
||||||
wcstombs(ln, wln, REGEX_MAX);
|
|
||||||
ndents = total;
|
|
||||||
if (matches(pln) != -1)
|
if (matches(pln) != -1)
|
||||||
redraw(path);
|
redraw(path);
|
||||||
|
|
||||||
|
@ -2195,7 +2185,9 @@ static int filterentries(char *path, char *lastname)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r == OK) {
|
if (r != OK) /* Handle Fn keys in main loop */
|
||||||
|
break;
|
||||||
|
|
||||||
/* Handle all control chars in main loop */
|
/* Handle all control chars in main loop */
|
||||||
if (*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^')
|
if (*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^')
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -2266,8 +2258,6 @@ static int filterentries(char *path, char *lastname)
|
||||||
*/
|
*/
|
||||||
redraw(path);
|
redraw(path);
|
||||||
showfilter(ln);
|
showfilter(ln);
|
||||||
} else
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
clearinfoln();
|
clearinfoln();
|
||||||
|
|
Loading…
Reference in a new issue