mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Get rid of getch() ('Führer' works now)
This commit is contained in:
parent
76d582d5cd
commit
efc70f33e5
22
nnn.c
22
nnn.c
|
@ -930,7 +930,7 @@ filterentries(char *path)
|
||||||
curs_set(TRUE);
|
curs_set(TRUE);
|
||||||
printprompt(ln);
|
printprompt(ln);
|
||||||
|
|
||||||
while ((r = wget_wch(stdscr, ch)) != ERR)
|
while ((r = get_wch(ch)) != ERR)
|
||||||
if (r == OK)
|
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
|
||||||
|
@ -974,7 +974,7 @@ filterentries(char *path)
|
||||||
if (len == 1)
|
if (len == 1)
|
||||||
cur = 0;
|
cur = 0;
|
||||||
|
|
||||||
if (len == maxlen || !isprint(*ch))
|
if (len == maxlen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
wln[len] = (wchar_t)*ch;
|
wln[len] = (wchar_t)*ch;
|
||||||
|
@ -1027,7 +1027,8 @@ xreadline(char *fname)
|
||||||
{
|
{
|
||||||
int old_curs = curs_set(1);
|
int old_curs = curs_set(1);
|
||||||
size_t len, pos;
|
size_t len, pos;
|
||||||
int c, x, y;
|
int x, y, r;
|
||||||
|
wint_t ch[2] = {0};
|
||||||
wchar_t *buf = (wchar_t *)g_buf;
|
wchar_t *buf = (wchar_t *)g_buf;
|
||||||
size_t buflen = NAME_MAX - 1;
|
size_t buflen = NAME_MAX - 1;
|
||||||
|
|
||||||
|
@ -1048,19 +1049,20 @@ xreadline(char *fname)
|
||||||
mvaddnwstr(y, x, buf, len + 1);
|
mvaddnwstr(y, x, buf, len + 1);
|
||||||
move(y, x + pos);
|
move(y, x + pos);
|
||||||
|
|
||||||
c = getch();
|
if ((r = get_wch(ch)) != ERR) {
|
||||||
|
if (r == OK) {
|
||||||
if (c == KEY_ENTER || c == '\n' || c == '\r')
|
if (*ch == KEY_ENTER || *ch == '\n' || *ch == '\r')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (isprint(c) && pos < buflen) {
|
if (pos < buflen) {
|
||||||
memmove(buf + pos + 1, buf + pos, (len - pos) << 2);
|
memmove(buf + pos + 1, buf + pos, (len - pos) << 2);
|
||||||
buf[pos] = c;
|
buf[pos] = *ch;
|
||||||
++len, ++pos;
|
++len, ++pos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c) {
|
} else {
|
||||||
|
switch (*ch) {
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
if (pos > 0)
|
if (pos > 0)
|
||||||
--pos;
|
--pos;
|
||||||
|
@ -1085,6 +1087,8 @@ xreadline(char *fname)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
if (old_curs != ERR) curs_set(old_curs);
|
if (old_curs != ERR) curs_set(old_curs);
|
||||||
|
|
Loading…
Reference in a new issue