input: trim some oververbose comments

master
Benno Schulenberg 2016-05-04 09:54:22 +02:00
parent 7b3649abc9
commit 402cf718c4
1 changed files with 31 additions and 54 deletions

View File

@ -363,26 +363,20 @@ int parse_kbinput(WINDOW *win)
default: default:
switch (escapes) { switch (escapes) {
case 0: case 0:
/* One non-escape: normal input mode. Save the /* One non-escape: normal input mode. */
* non-escape character as the result. */
retval = *kbinput; retval = *kbinput;
break; break;
case 1: case 1:
/* Reset the escape counter. */ /* Reset the escape counter. */
escapes = 0; escapes = 0;
if (get_key_buffer_len() == 0 || key_buffer[0] == 0x1b) { if (get_key_buffer_len() == 0 || key_buffer[0] == 0x1b) {
/* One escape followed by a non-escape, and /* One escape followed by a single non-escape:
* there aren't any other keystrokes waiting: * meta key sequence mode. */
* meta key sequence mode. Set meta_key to
* TRUE, and save the lowercase version of the
* non-escape character as the result. */
meta_key = TRUE; meta_key = TRUE;
retval = tolower(*kbinput); retval = tolower(*kbinput);
} else } else
/* One escape followed by a non-escape, and /* One escape followed by a non-escape, and there
* there are other keystrokes waiting: escape * are more codes waiting: escape sequence mode. */
* sequence mode. Interpret the escape
* sequence. */
retval = parse_escape_sequence(win, *kbinput); retval = parse_escape_sequence(win, *kbinput);
break; break;
case 2: case 2:
@ -413,31 +407,25 @@ int parse_kbinput(WINDOW *win)
if (('0' <= *kbinput && *kbinput <= '2' && if (('0' <= *kbinput && *kbinput <= '2' &&
byte_digits == 0) || ('0' <= *kbinput && byte_digits == 0) || ('0' <= *kbinput &&
*kbinput <= '9' && byte_digits > 0)) { *kbinput <= '9' && byte_digits > 0)) {
/* Two escapes followed by one or more /* Two escapes followed by one or more decimal
* decimal digits, and there aren't any * digits, and there aren't any other codes
* other keystrokes waiting: byte sequence * waiting: byte sequence mode. If the range
* mode. If the byte sequence's range is * of the byte sequence is limited to 2XX (the
* limited to 2XX (the first digit is in the * first digit is between '0' and '2' and the
* '0' to '2' range and it's the first * others between '0' and '9', interpret it. */
* digit, or it's in the '0' to '9' range
* and it's not the first digit), increment
* the byte sequence counter and interpret
* the digit. If the byte sequence's range
* is not limited to 2XX, fall through. */
int byte; int byte;
byte_digits++; byte_digits++;
byte = get_byte_kbinput(*kbinput); byte = get_byte_kbinput(*kbinput);
/* If we've read in a complete byte sequence,
* reset the escape counter and the byte sequence
* counter, and put the obtained byte value back
* into the key buffer. */
if (byte != ERR) { if (byte != ERR) {
char *byte_mb; char *byte_mb;
int byte_mb_len, *seq, i; int byte_mb_len, *seq, i;
/* If we've read in a complete byte
* sequence, reset the escape counter
* and the byte sequence counter, and
* put back the corresponding byte
* value. */
escapes = 0; escapes = 0;
byte_digits = 0; byte_digits = 0;
@ -462,21 +450,15 @@ int parse_kbinput(WINDOW *win)
escapes = 0; escapes = 0;
if (byte_digits == 0) if (byte_digits == 0)
/* Two escapes followed by a non-decimal /* Two escapes followed by a non-decimal
* digit or a decimal digit that would * digit (or a decimal digit that would
* create a byte sequence greater than * create a byte sequence greater than 2XX)
* 2XX, we're not in the middle of a * and there aren't any other codes waiting:
* byte sequence, and there aren't any * control character sequence mode. */
* other keystrokes waiting: control
* character sequence mode. Interpret
* the control sequence and save the
* corresponding control character as
* the result. */
retval = get_control_kbinput(*kbinput); retval = get_control_kbinput(*kbinput);
else { else {
/* If we're in the middle of a byte /* An invalid digit in the middle of a byte
* sequence, reset the byte sequence * sequence: reset the byte sequence counter
* counter and save the character we got * and save the code we got as the result. */
* as the result. */
byte_digits = 0; byte_digits = 0;
retval = *kbinput; retval = *kbinput;
} }
@ -485,11 +467,9 @@ int parse_kbinput(WINDOW *win)
/* This is an iTerm2 sequence: ^[ ^[ [ X. */ /* This is an iTerm2 sequence: ^[ ^[ [ X. */
double_esc = TRUE; double_esc = TRUE;
} else { } else {
/* Two escapes followed by a non-escape, and /* Two escapes followed by a non-escape, and there
* there are other keystrokes waiting: combined * are more codes waiting: combined meta and escape
* meta and escape sequence mode. Reset the * sequence mode. */
* escape counter, set meta_key to TRUE, and
* interpret the escape sequence. */
escapes = 0; escapes = 0;
meta_key = TRUE; meta_key = TRUE;
retval = parse_escape_sequence(win, *kbinput); retval = parse_escape_sequence(win, *kbinput);
@ -499,17 +479,14 @@ int parse_kbinput(WINDOW *win)
/* Reset the escape counter. */ /* Reset the escape counter. */
escapes = 0; escapes = 0;
if (get_key_buffer_len() == 0) if (get_key_buffer_len() == 0)
/* Three escapes followed by a non-escape, and /* Three escapes followed by a non-escape, and no
* there aren't any other keystrokes waiting: * other codes are waiting: normal input mode. */
* normal input mode. Save the non-escape
* character as the result. */
retval = *kbinput; retval = *kbinput;
else else
/* Three escapes followed by a non-escape, and /* Three escapes followed by a non-escape, and more
* there are other keystrokes waiting: combined * codes are waiting: combined control character and
* control character and escape sequence mode. * escape sequence mode. First interpret the escape
* Interpret the escape sequence, and interpret * sequence, then the result as a control sequence. */
* the result as a control sequence. */
retval = get_control_kbinput( retval = get_control_kbinput(
parse_escape_sequence(win, *kbinput)); parse_escape_sequence(win, *kbinput));
break; break;