1
1

tweaks: adjust indentation after the previous changes

Этот коммит содержится в:
Benno Schulenberg 2016-07-13 18:26:45 +02:00
родитель 1af1f5c9f4
Коммит fe38b78486

Просмотреть файл

@ -382,252 +382,250 @@ int parse_kbinput(WINDOW *win)
return ERR; return ERR;
} }
switch (escapes) { switch (escapes) {
case 0: case 0:
/* One non-escape: normal input mode. */ /* One non-escape: normal input mode. */
retval = keycode; retval = keycode;
break; break;
case 1: case 1:
/* Reset the escape counter. */ /* Reset the escape counter. */
escapes = 0; escapes = 0;
if ((keycode != 'O' && keycode != 'o' && keycode != '[') || if ((keycode != 'O' && keycode != 'o' && keycode != '[') ||
get_key_buffer_len() == 0 || *key_buffer == 0x1B) { get_key_buffer_len() == 0 || *key_buffer == 0x1B) {
/* One escape followed by a single non-escape: /* One escape followed by a single non-escape:
* meta key sequence mode. */ * meta key sequence mode. */
if (!solitary || (keycode >= 0x20 && keycode < 0x7F)) if (!solitary || (keycode >= 0x20 && keycode < 0x7F))
meta_key = TRUE; meta_key = TRUE;
retval = tolower(keycode); retval = tolower(keycode);
} else } else
/* 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(win, keycode); retval = parse_escape_sequence(win, keycode);
break; break;
case 2: case 2:
if (double_esc) { if (double_esc) {
/* An "ESC ESC [ X" sequence from Option+arrow. */ /* An "ESC ESC [ X" sequence from Option+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;
#ifndef NANO_TINY #ifndef NANO_TINY
case 'C': case 'C':
retval = controlright; retval = controlright;
break; break;
case 'D': case 'D':
retval = controlleft; retval = controlleft;
break; break;
#endif #endif
} }
double_esc = FALSE; double_esc = FALSE;
escapes = 0;
} else if (get_key_buffer_len() == 0) {
if (('0' <= keycode && keycode <= '2' &&
byte_digits == 0) || ('0' <= keycode &&
keycode <= '9' && byte_digits > 0)) {
/* Two escapes followed by one or more decimal
* digits, and there aren't any other codes
* waiting: byte sequence mode. If the range
* of the byte sequence is limited to 2XX (the
* first digit is between '0' and '2' and the
* others between '0' and '9', interpret it. */
int byte;
byte_digits++;
byte = get_byte_kbinput(keycode);
/* 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) {
char *byte_mb;
int byte_mb_len, *seq, i;
escapes = 0; escapes = 0;
} else if (get_key_buffer_len() == 0) { byte_digits = 0;
if (('0' <= keycode && keycode <= '2' &&
byte_digits == 0) || ('0' <= keycode &&
keycode <= '9' && byte_digits > 0)) {
/* Two escapes followed by one or more decimal
* digits, and there aren't any other codes
* waiting: byte sequence mode. If the range
* of the byte sequence is limited to 2XX (the
* first digit is between '0' and '2' and the
* others between '0' and '9', interpret it. */
int byte;
byte_digits++; /* Put back the multibyte equivalent of
byte = get_byte_kbinput(keycode); * the byte value. */
byte_mb = make_mbchar((long)byte,
&byte_mb_len);
/* If we've read in a complete byte sequence, seq = (int *)nmalloc(byte_mb_len *
* reset the escape counter and the byte sequence sizeof(int));
* counter, and put the obtained byte value back
* into the key buffer. */
if (byte != ERR) {
char *byte_mb;
int byte_mb_len, *seq, i;
escapes = 0; for (i = 0; i < byte_mb_len; i++)
byte_digits = 0; seq[i] = (unsigned char)byte_mb[i];
/* Put back the multibyte equivalent of unget_input(seq, byte_mb_len);
* the byte value. */
byte_mb = make_mbchar((long)byte,
&byte_mb_len);
seq = (int *)nmalloc(byte_mb_len * free(byte_mb);
sizeof(int)); free(seq);
for (i = 0; i < byte_mb_len; i++)
seq[i] = (unsigned char)byte_mb[i];
unget_input(seq, byte_mb_len);
free(byte_mb);
free(seq);
}
} else {
/* Reset the escape counter. */
escapes = 0;
if (byte_digits == 0)
/* Two escapes followed by a non-decimal
* digit (or a decimal digit that would
* create a byte sequence greater than 2XX)
* and there aren't any other codes waiting:
* control character sequence mode. */
retval = get_control_kbinput(keycode);
else {
/* An invalid digit in the middle of a byte
* sequence: reset the byte sequence counter
* and save the code we got as the result. */
byte_digits = 0;
retval = keycode;
}
}
} else if (keycode == '[' && key_buffer_len > 0 &&
'A' <= *key_buffer && *key_buffer <= 'D') {
/* This is an iTerm2 sequence: ^[ ^[ [ X. */
double_esc = TRUE;
} else {
/* Two escapes followed by a non-escape, and there
* are more codes waiting: combined meta and escape
* sequence mode. */
escapes = 0;
meta_key = TRUE;
retval = parse_escape_sequence(win, keycode);
} }
break; } else {
case 3:
/* Reset the escape counter. */ /* Reset the escape counter. */
escapes = 0; escapes = 0;
if (get_key_buffer_len() == 0) if (byte_digits == 0)
/* Three escapes followed by a non-escape, and no /* Two escapes followed by a non-decimal
* other codes are waiting: normal input mode. */ * digit (or a decimal digit that would
* create a byte sequence greater than 2XX)
* and there aren't any other codes waiting:
* control character sequence mode. */
retval = get_control_kbinput(keycode);
else {
/* An invalid digit in the middle of a byte
* sequence: reset the byte sequence counter
* and save the code we got as the result. */
byte_digits = 0;
retval = keycode; retval = keycode;
else }
/* Three escapes followed by a non-escape, and more }
* codes are waiting: combined control character and } else if (keycode == '[' && key_buffer_len > 0 &&
* escape sequence mode. First interpret the escape 'A' <= *key_buffer && *key_buffer <= 'D') {
* sequence, then the result as a control sequence. */ /* This is an iTerm2 sequence: ^[ ^[ [ X. */
retval = get_control_kbinput( double_esc = TRUE;
parse_escape_sequence(win, keycode)); } else {
break; /* Two escapes followed by a non-escape, and there are more
* codes waiting: combined meta and escape sequence mode. */
escapes = 0;
meta_key = TRUE;
retval = parse_escape_sequence(win, keycode);
} }
break;
case 3:
/* Reset the escape counter. */
escapes = 0;
if (get_key_buffer_len() == 0)
/* Three escapes followed by a non-escape, and no
* other codes are waiting: normal input mode. */
retval = keycode;
else
/* Three escapes followed by a non-escape, and more
* codes are waiting: combined control character and
* escape sequence mode. First interpret the escape
* sequence, then the result as a control sequence. */
retval = get_control_kbinput(
parse_escape_sequence(win, keycode));
break;
}
if (retval == ERR) if (retval == ERR)
return ERR; return ERR;
switch (retval) { switch (retval) {
#ifdef KEY_SLEFT #ifdef KEY_SLEFT
/* Slang doesn't support KEY_SLEFT. */ /* Slang doesn't support KEY_SLEFT. */
case KEY_SLEFT: case KEY_SLEFT:
#endif #endif
case KEY_LEFT: case KEY_LEFT:
return sc_seq_or(do_left, keycode); return sc_seq_or(do_left, keycode);
#ifdef KEY_SRIGHT #ifdef KEY_SRIGHT
/* Slang doesn't support KEY_SRIGHT. */ /* Slang doesn't support KEY_SRIGHT. */
case KEY_SRIGHT: case KEY_SRIGHT:
#endif #endif
case KEY_RIGHT: case KEY_RIGHT:
return sc_seq_or(do_right, keycode); return sc_seq_or(do_right, keycode);
#ifdef KEY_SUP #ifdef KEY_SUP
/* ncurses and Slang don't support KEY_SUP. */ /* ncurses and Slang don't support KEY_SUP. */
case KEY_SUP: case KEY_SUP:
#endif #endif
case KEY_UP: case KEY_UP:
return sc_seq_or(do_up_void, keycode); return sc_seq_or(do_up_void, keycode);
#ifdef KEY_SDOWN #ifdef KEY_SDOWN
/* ncurses and Slang don't support KEY_SDOWN. */ /* ncurses and Slang don't support KEY_SDOWN. */
case KEY_SDOWN: case KEY_SDOWN:
#endif #endif
case KEY_DOWN: case KEY_DOWN:
return sc_seq_or(do_down_void, keycode); return sc_seq_or(do_down_void, keycode);
#ifdef KEY_SHOME #ifdef KEY_SHOME
/* HP-UX 10-11 and Slang don't support KEY_SHOME. */ /* HP-UX 10-11 and Slang don't support KEY_SHOME. */
case KEY_SHOME: case KEY_SHOME:
#endif #endif
#ifdef KEY_HOME #ifdef KEY_HOME
case KEY_HOME: case KEY_HOME:
#endif #endif
case KEY_A1: /* Home (7) on keypad with NumLock off. */ case KEY_A1: /* Home (7) on keypad with NumLock off. */
return sc_seq_or(do_home, keycode); return sc_seq_or(do_home, keycode);
#ifdef KEY_SEND #ifdef KEY_SEND
/* HP-UX 10-11 and Slang don't support KEY_SEND. */ /* HP-UX 10-11 and Slang don't support KEY_SEND. */
case KEY_SEND: case KEY_SEND:
#endif #endif
#ifdef KEY_END #ifdef KEY_END
case KEY_END: case KEY_END:
#endif #endif
case KEY_C1: /* End (1) on keypad with NumLock off. */ case KEY_C1: /* End (1) on keypad with NumLock off. */
return sc_seq_or(do_end, keycode); return sc_seq_or(do_end, keycode);
case KEY_PPAGE: case KEY_PPAGE:
case KEY_A3: /* PageUp (9) on keypad with NumLock off. */ case KEY_A3: /* PageUp (9) on keypad with NumLock off. */
return sc_seq_or(do_page_up, keycode); return sc_seq_or(do_page_up, keycode);
case KEY_NPAGE: case KEY_NPAGE:
case KEY_C3: /* PageDown (3) on keypad with NumLock off. */ case KEY_C3: /* PageDown (3) on keypad with NumLock off. */
return sc_seq_or(do_page_down, keycode); return sc_seq_or(do_page_down, keycode);
case KEY_ENTER: case KEY_ENTER:
return sc_seq_or(do_enter, keycode); return sc_seq_or(do_enter, keycode);
case KEY_BACKSPACE: case KEY_BACKSPACE:
return sc_seq_or(do_backspace, keycode); return sc_seq_or(do_backspace, keycode);
#ifdef KEY_SDC #ifdef KEY_SDC
/* Slang doesn't support KEY_SDC. */ /* Slang doesn't support KEY_SDC. */
case KEY_SDC: case KEY_SDC:
#endif #endif
case NANO_CONTROL_8: case NANO_CONTROL_8:
if (ISSET(REBIND_DELETE)) if (ISSET(REBIND_DELETE))
return sc_seq_or(do_delete, keycode); return sc_seq_or(do_delete, keycode);
else else
return sc_seq_or(do_backspace, keycode); return sc_seq_or(do_backspace, keycode);
#ifdef KEY_SIC #ifdef KEY_SIC
/* Slang doesn't support KEY_SIC. */ /* Slang doesn't support KEY_SIC. */
case KEY_SIC: case KEY_SIC:
return sc_seq_or(do_insertfile_void, keycode); return sc_seq_or(do_insertfile_void, keycode);
#endif #endif
#ifdef KEY_SBEG #ifdef KEY_SBEG
/* Slang doesn't support KEY_SBEG. */ /* Slang doesn't support KEY_SBEG. */
case KEY_SBEG: case KEY_SBEG:
#endif #endif
#ifdef KEY_BEG #ifdef KEY_BEG
/* Slang doesn't support KEY_BEG. */ /* Slang doesn't support KEY_BEG. */
case KEY_BEG: case KEY_BEG:
#endif #endif
case KEY_B2: /* Center (5) on keypad with NumLock off. */ case KEY_B2: /* Center (5) on keypad with NumLock off. */
return ERR; return ERR;
#ifdef KEY_CANCEL #ifdef KEY_CANCEL
#ifdef KEY_SCANCEL #ifdef KEY_SCANCEL
/* Slang doesn't support KEY_SCANCEL. */ /* Slang doesn't support KEY_SCANCEL. */
case KEY_SCANCEL: case KEY_SCANCEL:
#endif #endif
/* Slang doesn't support KEY_CANCEL. */ /* Slang doesn't support KEY_CANCEL. */
case KEY_CANCEL: case KEY_CANCEL:
return first_sc_for(currmenu, do_cancel)->keycode; return first_sc_for(currmenu, do_cancel)->keycode;
#endif #endif
#ifdef KEY_SUSPEND #ifdef KEY_SUSPEND
#ifdef KEY_SSUSPEND #ifdef KEY_SSUSPEND
/* Slang doesn't support KEY_SSUSPEND. */ /* Slang doesn't support KEY_SSUSPEND. */
case KEY_SSUSPEND: case KEY_SSUSPEND:
#endif #endif
/* Slang doesn't support KEY_SUSPEND. */ /* Slang doesn't support KEY_SUSPEND. */
case KEY_SUSPEND: case KEY_SUSPEND:
return sc_seq_or(do_suspend_void, 0); return sc_seq_or(do_suspend_void, 0);
#endif #endif
#ifdef PDCURSES #ifdef PDCURSES
case KEY_SHIFT_L: case KEY_SHIFT_L:
case KEY_SHIFT_R: case KEY_SHIFT_R:
case KEY_CONTROL_L: case KEY_CONTROL_L:
case KEY_CONTROL_R: case KEY_CONTROL_R:
case KEY_ALT_L: case KEY_ALT_L:
case KEY_ALT_R: case KEY_ALT_R:
return ERR; return ERR;
#endif #endif
#if !defined(NANO_TINY) && defined(KEY_RESIZE) #if !defined(NANO_TINY) && defined(KEY_RESIZE)
/* Since we don't change the default SIGWINCH handler when /* Since we don't change the default SIGWINCH handler when
* NANO_TINY is defined, KEY_RESIZE is never generated. * NANO_TINY is defined, KEY_RESIZE is never generated.
* Also, Slang and SunOS 5.7-5.9 don't support * Also, Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
* KEY_RESIZE. */ case KEY_RESIZE:
case KEY_RESIZE: return ERR;
return ERR;
#endif #endif
} }