properly handle it when get_escape_seq_kbinput() returns ERR for an

escape sequence that is recognized but which should be ignored


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1801 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-06-04 18:18:17 +00:00
parent 16eb518dcd
commit e65e639465
3 changed files with 30 additions and 17 deletions

View File

@ -311,6 +311,11 @@ CVS code -
get_escape_seq_kbinput() get_escape_seq_kbinput()
- Add proper support for the keypad values and escape sequences - Add proper support for the keypad values and escape sequences
generated by the NumLock glitch. (DLR) generated by the NumLock glitch. (DLR)
- Add ignore_seq parameter. If a sequence is recognized but
ignored, we will now return ERR and set ignore_seq to TRUE, and
if a sequence is unrecognized, we will now return ERR and set
ignore_seq to FALSE. Also, here and elsewhere, don't bother
assigning ERR to retval when that's its initial value. (DLR)
get_mouseinput() get_mouseinput()
- Don't ungetch() anything if there's no control key and no meta - Don't ungetch() anything if there's no control key and no meta
key defined in the shortcut we clicked. (DLR) key defined in the shortcut we clicked. (DLR)

View File

@ -491,7 +491,8 @@ int get_ascii_kbinput(int kbinput, size_t ascii_digits
#endif #endif
); );
int get_control_kbinput(int kbinput); int get_control_kbinput(int kbinput);
int get_escape_seq_kbinput(int *escape_seq, size_t es_len); int get_escape_seq_kbinput(int *escape_seq, size_t es_len, int
*ignore_seq);
int get_escape_seq_abcd(int kbinput); int get_escape_seq_abcd(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, int *verbatim_kbinput, size_t int *get_verbatim_kbinput(WINDOW *win, int *verbatim_kbinput, size_t
*verbatim_len, int allow_ascii); *verbatim_len, int allow_ascii);

View File

@ -152,14 +152,18 @@ int get_kbinput(WINDOW *win, int *meta_key)
escape_seq = get_verbatim_kbinput(win, escape_seq, &es_len, escape_seq = get_verbatim_kbinput(win, escape_seq, &es_len,
FALSE); FALSE);
/* If the escape sequence is more than one character
* long, set meta_key to FALSE, translate the escape
* sequence into the corresponding key value, and save
* that as the result. */
if (es_len > 1) { if (es_len > 1) {
/* The escape sequence is more than one character int ignore_seq;
* long. Set meta_key to FALSE, translate the escape
* sequence into the corresponding key value, and save
* that as the result. */
*meta_key = FALSE; *meta_key = FALSE;
if ((retval = get_escape_seq_kbinput(escape_seq, retval = get_escape_seq_kbinput(escape_seq, es_len,
es_len)) == ERR) { &ignore_seq);
if (retval == ERR && !ignore_seq) {
/* This escape sequence is unrecognized. Send it /* This escape sequence is unrecognized. Send it
* back. */ * back. */
for (; es_len > 1; es_len--) for (; es_len > 1; es_len--)
@ -236,7 +240,6 @@ int get_translated_kbinput(int kbinput, int *es
case KEY_ALT_L: case KEY_ALT_L:
case KEY_ALT_R: case KEY_ALT_R:
#endif #endif
retval = ERR;
break; break;
default: default:
switch (escapes) { switch (escapes) {
@ -293,7 +296,6 @@ int get_translated_kbinput(int kbinput, int *es
break; break;
case KEY_B2: /* Center (5) on numeric keypad case KEY_B2: /* Center (5) on numeric keypad
* with NumLock off. */ * with NumLock off. */
retval = ERR;
break; break;
case KEY_C1: /* End (1) on numeric keypad case KEY_C1: /* End (1) on numeric keypad
* with NumLock off. */ * with NumLock off. */
@ -307,7 +309,6 @@ int get_translated_kbinput(int kbinput, int *es
/* Slang doesn't support KEY_BEG. */ /* Slang doesn't support KEY_BEG. */
case KEY_BEG: /* Center (5) on numeric keypad case KEY_BEG: /* Center (5) on numeric keypad
* with NumLock off. */ * with NumLock off. */
retval = ERR;
break; break;
#endif #endif
#ifdef KEY_END #ifdef KEY_END
@ -558,12 +559,18 @@ int get_control_kbinput(int kbinput)
/* Translate escape sequences, most of which correspond to extended /* Translate escape sequences, most of which correspond to extended
* keypad values, nto their corresponding key values. These sequences * keypad values, nto their corresponding key values. These sequences
* are generated when the keypad doesn't support the needed keys. * are generated when the keypad doesn't support the needed keys. If
* Assume that Escape has already been read in. */ * the escape sequence is recognized but we want to ignore it, return
int get_escape_seq_kbinput(int *escape_seq, size_t es_len) * ERR and set ignore_seq to TRUE; if it's unrecognized, return ERR and
* set ignore_seq to FALSE. Assume that Escape has already been read
* in. */
int get_escape_seq_kbinput(int *escape_seq, size_t es_len, int
*ignore_seq)
{ {
int retval = ERR; int retval = ERR;
*ignore_seq = FALSE;
if (es_len > 1) { if (es_len > 1) {
switch (escape_seq[0]) { switch (escape_seq[0]) {
case 'O': case 'O':
@ -593,7 +600,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len)
break; break;
case 'E': /* Esc O E == Center (5) on numeric keypad case 'E': /* Esc O E == Center (5) on numeric keypad
* with NumLock off on xterm. */ * with NumLock off on xterm. */
retval = ERR; *ignore_seq = TRUE;
break; break;
case 'F': /* Esc O F == End on xterm. */ case 'F': /* Esc O F == End on xterm. */
retval = NANO_END_KEY; retval = NANO_END_KEY;
@ -704,7 +711,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len)
case 'u': /* Esc O u == Center (5) on numeric keypad case 'u': /* Esc O u == Center (5) on numeric keypad
* with NumLock off on * with NumLock off on
* VT100/VT220/VT320/rxvt/Eterm. */ * VT100/VT220/VT320/rxvt/Eterm. */
retval = ERR; *ignore_seq = TRUE;
break; break;
case 'v': /* Esc O v == Right (6) on numeric keypad case 'v': /* Esc O v == Right (6) on numeric keypad
* with NumLock off on * with NumLock off on
@ -910,7 +917,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len)
break; break;
case 'E': /* Esc [ E == Center (5) on numeric keypad case 'E': /* Esc [ E == Center (5) on numeric keypad
* with NumLock off on FreeBSD console. */ * with NumLock off on FreeBSD console. */
retval = ERR; *ignore_seq = TRUE;
break; break;
case 'F': /* Esc [ F == End on FreeBSD case 'F': /* Esc [ F == End on FreeBSD
* console/Eterm. */ * console/Eterm. */
@ -1036,7 +1043,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len)
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "get_escape_seq_kbinput(): retval = %d\n", retval); fprintf(stderr, "get_escape_seq_kbinput(): retval = %d, ignore_seq = %d\n", retval, *ignore_seq);
#endif #endif
return retval; return retval;