tweaks: improve two comments, and reshuffle some lines for conciseness
parent
a08ca026f0
commit
88561506c9
52
src/winio.c
52
src/winio.c
|
@ -862,12 +862,12 @@ int convert_to_control(int kbinput)
|
||||||
return kbinput;
|
return kbinput;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract a single keystroke from the input stream. Translate escape
|
/* Extract one keystroke from the input stream. Translate escape sequences
|
||||||
* sequences and extended keypad codes into their corresponding values.
|
* and possibly keypad codes into their corresponding values. Set meta_key
|
||||||
* Set meta_key to TRUE when appropriate. Supported extended keypad values
|
* to TRUE when appropriate. Supported keypad keystrokes are: the arrow keys,
|
||||||
* are: [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
|
* Insert, Delete, Home, End, PageUp, PageDown, Enter, and Backspace (many of
|
||||||
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
|
* them also when modified with Shift, Ctrl, Alt, Shift+Ctrl, or Shift+Alt),
|
||||||
* the function keys (F1-F16), and the numeric keypad with NumLock off. */
|
* the function keys (F1-F12), and the numeric keypad with NumLock off. */
|
||||||
int parse_kbinput(WINDOW *win)
|
int parse_kbinput(WINDOW *win)
|
||||||
{
|
{
|
||||||
static int escapes = 0;
|
static int escapes = 0;
|
||||||
|
@ -892,10 +892,9 @@ int parse_kbinput(WINDOW *win)
|
||||||
if (keycode == ERR)
|
if (keycode == ERR)
|
||||||
return ERR;
|
return ERR;
|
||||||
|
|
||||||
|
/* If it is an ESC, increment the counter, but trim an overabundance. */
|
||||||
if (keycode == ESC_CODE) {
|
if (keycode == ESC_CODE) {
|
||||||
/* Increment the escape counter, but trim an overabundance. */
|
if (++escapes > 3 || digit_count > 0) {
|
||||||
escapes++;
|
|
||||||
if (escapes > 3 || digit_count > 0) {
|
|
||||||
digit_count = 0;
|
digit_count = 0;
|
||||||
escapes = 1;
|
escapes = 1;
|
||||||
}
|
}
|
||||||
|
@ -914,10 +913,8 @@ int parse_kbinput(WINDOW *win)
|
||||||
retval = keycode;
|
retval = keycode;
|
||||||
else if (keycode == '\t')
|
else if (keycode == '\t')
|
||||||
retval = SHIFT_TAB;
|
retval = SHIFT_TAB;
|
||||||
else if ((keycode != 'O' && keycode != '[') ||
|
else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
|
||||||
key_buffer_len == 0 || *key_buffer == ESC_CODE) {
|
(keycode != 'O' && keycode != '[')) {
|
||||||
/* One escape followed by a single non-escape:
|
|
||||||
* meta key sequence mode. */
|
|
||||||
if (!solitary || (0x20 <= keycode && keycode <= 0x7E))
|
if (!solitary || (0x20 <= keycode && keycode <= 0x7E))
|
||||||
meta_key = TRUE;
|
meta_key = TRUE;
|
||||||
retval = (shifted_metas) ? keycode : tolower(keycode);
|
retval = (shifted_metas) ? keycode : tolower(keycode);
|
||||||
|
@ -933,30 +930,22 @@ int parse_kbinput(WINDOW *win)
|
||||||
* an "ESC ESC [ x" sequence from Shift+Alt+arrow. */
|
* an "ESC ESC [ x" sequence from Shift+Alt+arrow. */
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case 'A':
|
case 'A':
|
||||||
retval = KEY_HOME;
|
retval = KEY_HOME; break;
|
||||||
break;
|
|
||||||
case 'B':
|
case 'B':
|
||||||
retval = KEY_END;
|
retval = KEY_END; break;
|
||||||
break;
|
|
||||||
case 'C':
|
case 'C':
|
||||||
retval = CONTROL_RIGHT;
|
retval = CONTROL_RIGHT; break;
|
||||||
break;
|
|
||||||
case 'D':
|
case 'D':
|
||||||
retval = CONTROL_LEFT;
|
retval = CONTROL_LEFT; break;
|
||||||
break;
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
case 'a':
|
case 'a':
|
||||||
retval = shiftaltup;
|
retval = shiftaltup; break;
|
||||||
break;
|
|
||||||
case 'b':
|
case 'b':
|
||||||
retval = shiftaltdown;
|
retval = shiftaltdown; break;
|
||||||
break;
|
|
||||||
case 'c':
|
case 'c':
|
||||||
retval = shiftaltright;
|
retval = shiftaltright; break;
|
||||||
break;
|
|
||||||
case 'd':
|
case 'd':
|
||||||
retval = shiftaltleft;
|
retval = shiftaltleft; break;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
double_esc = FALSE;
|
double_esc = FALSE;
|
||||||
|
@ -964,9 +953,8 @@ int parse_kbinput(WINDOW *win)
|
||||||
} else if (key_buffer_len == 0) {
|
} else if (key_buffer_len == 0) {
|
||||||
if ('0' <= keycode && ((keycode <= '2' && digit_count == 0) ||
|
if ('0' <= keycode && ((keycode <= '2' && digit_count == 0) ||
|
||||||
(keycode <= '9' && digit_count > 0))) {
|
(keycode <= '9' && digit_count > 0))) {
|
||||||
/* Two escapes followed by one or more decimal
|
/* Two escapes followed by one digit, and no other codes
|
||||||
* digits, and there aren't any other codes
|
* are waiting: byte sequence mode. If the range of the
|
||||||
* waiting: byte sequence mode. If the range of the
|
|
||||||
* byte sequence is limited to 2XX, interpret it. */
|
* byte sequence is limited to 2XX, interpret it. */
|
||||||
int byte = get_byte_kbinput(keycode);
|
int byte = get_byte_kbinput(keycode);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue