Code refactor

This commit is contained in:
Arun Prakash Jana 2020-01-20 19:09:10 +05:30
parent d0f26e7c30
commit 9b45b05746
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -2150,41 +2150,31 @@ static int filterentries(char *path, char *lastname)
case KEY_DC: // fallthrough
case KEY_BACKSPACE: // fallthrough
case '\b': // fallthrough
case CONTROL('L'): // fallthrough
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');
goto end;
}
// fallthrough
case CONTROL('L'):
if (*ch == CONTROL('L')) {
if (wln[1]) {
ln[REGEX_MAX - 1] = ln[1];
wln[1] = '\0';
ln[1] = wln[1] = '\0';
len = 1;
ndents = total;
} else if (ln[REGEX_MAX - 1]) { /* Show the previous filter */
ln[1] = ln[REGEX_MAX - 1];
ln[REGEX_MAX - 1] = '\0';
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;
wcstombs(ln, wln, REGEX_MAX);
ndents = total;
if (matches(pln) != -1)
redraw(path);
@ -2195,7 +2185,9 @@ static int filterentries(char *path, char *lastname)
goto end;
}
if (r == OK) {
if (r != OK) /* Handle Fn keys in main loop */
break;
/* Handle all control chars in main loop */
if (*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^')
goto end;
@ -2266,8 +2258,6 @@ static int filterentries(char *path, char *lastname)
*/
redraw(path);
showfilter(ln);
} else
break;
}
end:
clearinfoln();