瀏覽代碼

Simplify filter handling

master
Arun Prakash Jana 7 年之前
父節點
當前提交
b854f396cf
共有 1 個檔案被更改,包括 25 行新增45 行删除
  1. +25
    -45
      nnn.c

+ 25
- 45
nnn.c 查看文件

@@ -930,21 +930,8 @@ filterentries(char *path)
curs_set(TRUE); curs_set(TRUE);
printprompt(ln); printprompt(ln);


while ((r = get_wch(ch)) != ERR) while ((r = get_wch(ch)) != ERR) {
if (r == OK) if (*ch == 127 /* handle DEL */ || *ch == KEY_DC || *ch == KEY_BACKSPACE) {
switch (*ch) {
case '\r': // with nonl(), this is ENTER key value
if (len == 1) {
cur = oldcur;
goto end;
}

if (matches(pln) == -1)
goto end;

redraw(path);
goto end;
case 127: // handle DEL
if (len == 1) { if (len == 1) {
cur = oldcur; cur = oldcur;
*ch = CONTROL('L'); *ch = CONTROL('L');
@@ -957,13 +944,26 @@ filterentries(char *path)


wcstombs(ln, wln, REGEX_MAX); wcstombs(ln, wln, REGEX_MAX);
ndents = total; ndents = total;
if (matches(pln) == -1) { if (matches(pln) == -1)
printprompt(ln);
continue; continue;
}
redraw(path); redraw(path);
printprompt(ln); printprompt(ln);
break; continue;
}

if (r == OK) {
switch (*ch) {
case '\r': // with nonl(), this is ENTER key value
if (len == 1) {
cur = oldcur;
goto end;
}

if (matches(pln) == -1)
goto end;

redraw(path);
goto end;
case CONTROL('L'): case CONTROL('L'):
if (len == 1) if (len == 1)
cur = oldcur; // fallthrough cur = oldcur; // fallthrough
@@ -986,32 +986,12 @@ filterentries(char *path)
redraw(path); redraw(path);
printprompt(ln); printprompt(ln);
} }
else } else {
switch (*ch) { if (len == 1)
case KEY_DC: // fallthrough cur = oldcur;
case KEY_BACKSPACE: goto end;
if (len == 1) { }
cur = oldcur; }
*ch = CONTROL('L');
goto end;
}

wln[--len] = '\0';
if (len == 1)
cur = oldcur;

wcstombs(ln, wln, REGEX_MAX);
ndents = total;
if (matches(pln) == -1)
continue;
redraw(path);
printprompt(ln);
break;
default:
if (len == 1)
cur = oldcur;
goto end;
}
end: end:
noecho(); noecho();
curs_set(FALSE); curs_set(FALSE);


||||||
x
 
000:0
Loading…
取消
儲存