curs_set(TRUE);
printprompt(ln);
- while ((r = wget_wch(stdscr, ch)) != ERR)
+ while ((r = get_wch(ch)) != ERR)
if (r == OK)
switch (*ch) {
case '\r': // with nonl(), this is ENTER key value
if (len == 1)
cur = 0;
- if (len == maxlen || !isprint(*ch))
+ if (len == maxlen)
break;
wln[len] = (wchar_t)*ch;
{
int old_curs = curs_set(1);
size_t len, pos;
- int c, x, y;
+ int x, y, r;
+ wint_t ch[2] = {0};
wchar_t *buf = (wchar_t *)g_buf;
size_t buflen = NAME_MAX - 1;
mvaddnwstr(y, x, buf, len + 1);
move(y, x + pos);
- c = getch();
-
- if (c == KEY_ENTER || c == '\n' || c == '\r')
- break;
+ if ((r = get_wch(ch)) != ERR) {
+ if (r == OK) {
+ if (*ch == KEY_ENTER || *ch == '\n' || *ch == '\r')
+ break;
- if (isprint(c) && pos < buflen) {
- memmove(buf + pos + 1, buf + pos, (len - pos) << 2);
- buf[pos] = c;
- ++len, ++pos;
- continue;
- }
+ if (pos < buflen) {
+ memmove(buf + pos + 1, buf + pos, (len - pos) << 2);
+ buf[pos] = *ch;
+ ++len, ++pos;
+ continue;
+ }
- switch (c) {
- case KEY_LEFT:
- if (pos > 0)
- --pos;
- break;
- case KEY_RIGHT:
- if (pos < len)
- ++pos;
- break;
- case KEY_BACKSPACE:
- if (pos > 0) {
- memmove(buf + pos - 1, buf + pos, (len - pos) << 2);
- --len, --pos;
- }
- break;
- case KEY_DC:
- if (pos < len) {
- memmove(buf + pos, buf + pos + 1, (len - pos - 1) << 2);
- --len;
+ } else {
+ switch (*ch) {
+ case KEY_LEFT:
+ if (pos > 0)
+ --pos;
+ break;
+ case KEY_RIGHT:
+ if (pos < len)
+ ++pos;
+ break;
+ case KEY_BACKSPACE:
+ if (pos > 0) {
+ memmove(buf + pos - 1, buf + pos, (len - pos) << 2);
+ --len, --pos;
+ }
+ break;
+ case KEY_DC:
+ if (pos < len) {
+ memmove(buf + pos, buf + pos + 1, (len - pos - 1) << 2);
+ --len;
+ }
+ break;
+ default:
+ break;
+ }
}
- break;
- default:
- break;
}
}