Bläddra i källkod

Repeat search: reset current selection

master
Arun Prakash Jana 8 år sedan
förälder
incheckning
a7d88ad7f9
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: A75979F35C080412
1 ändrade filer med 12 tillägg och 11 borttagningar
  1. +12
    -11
      nnn.c

+ 12
- 11
nnn.c Visa fil

@@ -851,8 +851,8 @@ readln(char *path)
curs_set(TRUE); curs_set(TRUE);
printprompt(ln); printprompt(ln);


while ((r = wget_wch(stdscr, ch)) != ERR) {
if (r == OK) {
while ((r = wget_wch(stdscr, ch)) != ERR)
if (r == OK)
switch (*ch) { switch (*ch) {
case '\r': // with nonl(), this is ENTER key value case '\r': // with nonl(), this is ENTER key value
if (len == 1) { if (len == 1) {
@@ -872,10 +872,10 @@ readln(char *path)
goto end; goto end;
} }


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


wln[--len] = '\0';
wcstombs(ln, wln, LINE_MAX << 2); wcstombs(ln, wln, LINE_MAX << 2);
ndents = total; ndents = total;
if (matches(pln) == -1) { if (matches(pln) == -1) {
@@ -891,9 +891,12 @@ readln(char *path)
case CONTROL('Q'): case CONTROL('Q'):
goto end; goto end;
default: default:
/* Reset cur in case it's a repeat search */
if (len == 1)
cur = 0;

wln[len] = (wchar_t)*ch; wln[len] = (wchar_t)*ch;
++len;
wln[len] = '\0';
wln[++len] = '\0';
wcstombs(ln, wln, LINE_MAX << 2); wcstombs(ln, wln, LINE_MAX << 2);
ndents = total; ndents = total;
if (matches(pln) == -1) if (matches(pln) == -1)
@@ -901,7 +904,7 @@ readln(char *path)
redraw(path); redraw(path);
printprompt(ln); printprompt(ln);
} }
} else {
else
switch (*ch) { switch (*ch) {
case KEY_DC: // fallthrough case KEY_DC: // fallthrough
case KEY_BACKSPACE: case KEY_BACKSPACE:
@@ -911,10 +914,10 @@ readln(char *path)
goto end; goto end;
} }


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


wln[--len] = '\0';
wcstombs(ln, wln, LINE_MAX << 2); wcstombs(ln, wln, LINE_MAX << 2);
ndents = total; ndents = total;
if (matches(pln) == -1) if (matches(pln) == -1)
@@ -932,8 +935,6 @@ readln(char *path)
default: default:
goto end; goto end;
} }
}
}
end: end:
noecho(); noecho();
curs_set(FALSE); curs_set(FALSE);


Laddar…
Avbryt
Spara