tweaks: reshuffle the zeroing of a counter, to allow some direct returns
parent
8b2114a25f
commit
54238a5c46
21
src/winio.c
21
src/winio.c
|
@ -935,15 +935,16 @@ int parse_kbinput(WINDOW *win)
|
||||||
retval = keycode;
|
retval = keycode;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
escapes = 0;
|
||||||
if (keycode >= 0x80) {
|
if (keycode >= 0x80) {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (keycode == KEY_BACKSPACE)
|
if (keycode == KEY_BACKSPACE)
|
||||||
retval = CONTROL_SHIFT_DELETE;
|
return CONTROL_SHIFT_DELETE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
retval = keycode;
|
retval = keycode;
|
||||||
} else if (keycode == '\t')
|
} else if (keycode == '\t')
|
||||||
retval = SHIFT_TAB;
|
return SHIFT_TAB;
|
||||||
else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
|
else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
|
||||||
(keycode != 'O' && keycode != '[')) {
|
(keycode != 'O' && keycode != '[')) {
|
||||||
if (!solitary || (0x20 <= keycode && keycode <= 0x7E))
|
if (!solitary || (0x20 <= keycode && keycode <= 0x7E))
|
||||||
|
@ -953,9 +954,9 @@ int parse_kbinput(WINDOW *win)
|
||||||
/* One escape followed by a non-escape, and there
|
/* One escape followed by a non-escape, and there
|
||||||
* are more codes waiting: escape sequence mode. */
|
* are more codes waiting: escape sequence mode. */
|
||||||
retval = parse_escape_sequence(keycode);
|
retval = parse_escape_sequence(keycode);
|
||||||
escapes = 0;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
escapes = 0;
|
||||||
if (keycode == '[' && key_buffer_len > 0 &&
|
if (keycode == '[' && key_buffer_len > 0 &&
|
||||||
(('A' <= *key_buffer && *key_buffer <= 'D') ||
|
(('A' <= *key_buffer && *key_buffer <= 'D') ||
|
||||||
('a' <= *key_buffer && *key_buffer <= 'd'))) {
|
('a' <= *key_buffer && *key_buffer <= 'd'))) {
|
||||||
|
@ -964,7 +965,6 @@ int parse_kbinput(WINDOW *win)
|
||||||
kbinput = get_input(win, 1);
|
kbinput = get_input(win, 1);
|
||||||
keycode = *kbinput;
|
keycode = *kbinput;
|
||||||
free(kbinput);
|
free(kbinput);
|
||||||
escapes = 0;
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case 'A': return KEY_HOME;
|
case 'A': return KEY_HOME;
|
||||||
case 'B': return KEY_END;
|
case 'B': return KEY_END;
|
||||||
|
@ -991,22 +991,26 @@ int parse_kbinput(WINDOW *win)
|
||||||
/* If the decimal byte value is not yet complete,
|
/* If the decimal byte value is not yet complete,
|
||||||
* return nothing; otherwise convert it and put the
|
* return nothing; otherwise convert it and put the
|
||||||
* obtained byte(s) back into the input buffer. */
|
* obtained byte(s) back into the input buffer. */
|
||||||
if (byte == PROCEED)
|
if (byte == PROCEED) {
|
||||||
|
escapes = 2;
|
||||||
return ERR;
|
return ERR;
|
||||||
|
}
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
else if (byte > 0x7F && using_utf8()) {
|
else if (byte > 0x7F && using_utf8()) {
|
||||||
/* Convert the code to the corresponding Unicode. */
|
/* Convert the code to the corresponding Unicode. */
|
||||||
if (byte < 0xC0) {
|
if (byte < 0xC0) {
|
||||||
put_back((unsigned char)byte);
|
put_back((unsigned char)byte);
|
||||||
put_back(0xC2);
|
return 0xC2;
|
||||||
} else {
|
} else {
|
||||||
put_back((unsigned char)(byte - 0x40));
|
put_back((unsigned char)(byte - 0x40));
|
||||||
put_back(0xC3);
|
return 0xC3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else if (byte == '\t' || byte == DEL_CODE)
|
||||||
retval = byte;
|
retval = byte;
|
||||||
|
else
|
||||||
|
return byte;
|
||||||
} else if (digit_count > 0) {
|
} else if (digit_count > 0) {
|
||||||
/* A non-digit in the middle of a byte sequence... */
|
/* A non-digit in the middle of a byte sequence... */
|
||||||
retval = keycode;
|
retval = keycode;
|
||||||
|
@ -1015,7 +1019,6 @@ int parse_kbinput(WINDOW *win)
|
||||||
meta_key = TRUE;
|
meta_key = TRUE;
|
||||||
} else
|
} else
|
||||||
retval = convert_to_control(keycode);
|
retval = convert_to_control(keycode);
|
||||||
escapes = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue