From: David Lawrence Ramsey Date: Fri, 4 Jun 2004 18:18:17 +0000 (+0000) Subject: properly handle it when get_escape_seq_kbinput() returns ERR for an X-Git-Tag: v1.3.3~18 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e65e639465f54a2a92e2b47edcd2ff1ce96b97d8;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index 8d95220a..8b844f06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -311,6 +311,11 @@ CVS code - get_escape_seq_kbinput() - Add proper support for the keypad values and escape sequences 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() - Don't ungetch() anything if there's no control key and no meta key defined in the shortcut we clicked. (DLR) diff --git a/src/proto.h b/src/proto.h index 95109989..5f77dcb8 100644 --- a/src/proto.h +++ b/src/proto.h @@ -491,7 +491,8 @@ int get_ascii_kbinput(int kbinput, size_t ascii_digits #endif ); 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_verbatim_kbinput(WINDOW *win, int *verbatim_kbinput, size_t *verbatim_len, int allow_ascii); diff --git a/src/winio.c b/src/winio.c index a6f4430b..72cde515 100644 --- a/src/winio.c +++ b/src/winio.c @@ -152,14 +152,18 @@ int get_kbinput(WINDOW *win, int *meta_key) escape_seq = get_verbatim_kbinput(win, escape_seq, &es_len, 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) { - /* 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. */ + int ignore_seq; + *meta_key = FALSE; - if ((retval = get_escape_seq_kbinput(escape_seq, - es_len)) == ERR) { + retval = get_escape_seq_kbinput(escape_seq, es_len, + &ignore_seq); + + if (retval == ERR && !ignore_seq) { /* This escape sequence is unrecognized. Send it * back. */ 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_R: #endif - retval = ERR; break; default: switch (escapes) { @@ -293,7 +296,6 @@ int get_translated_kbinput(int kbinput, int *es break; case KEY_B2: /* Center (5) on numeric keypad * with NumLock off. */ - retval = ERR; break; case KEY_C1: /* End (1) on numeric keypad * with NumLock off. */ @@ -307,7 +309,6 @@ int get_translated_kbinput(int kbinput, int *es /* Slang doesn't support KEY_BEG. */ case KEY_BEG: /* Center (5) on numeric keypad * with NumLock off. */ - retval = ERR; break; #endif #ifdef KEY_END @@ -558,12 +559,18 @@ int get_control_kbinput(int kbinput) /* Translate escape sequences, most of which correspond to extended * keypad values, nto their corresponding key values. These sequences - * are generated when the keypad doesn't support the needed keys. - * Assume that Escape has already been read in. */ -int get_escape_seq_kbinput(int *escape_seq, size_t es_len) + * are generated when the keypad doesn't support the needed keys. If + * the escape sequence is recognized but we want to ignore it, return + * 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; + *ignore_seq = FALSE; + if (es_len > 1) { switch (escape_seq[0]) { case 'O': @@ -593,7 +600,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len) break; case 'E': /* Esc O E == Center (5) on numeric keypad * with NumLock off on xterm. */ - retval = ERR; + *ignore_seq = TRUE; break; case 'F': /* Esc O F == End on xterm. */ 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 * with NumLock off on * VT100/VT220/VT320/rxvt/Eterm. */ - retval = ERR; + *ignore_seq = TRUE; break; case 'v': /* Esc O v == Right (6) on numeric keypad * with NumLock off on @@ -910,7 +917,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len) break; case 'E': /* Esc [ E == Center (5) on numeric keypad * with NumLock off on FreeBSD console. */ - retval = ERR; + *ignore_seq = TRUE; break; case 'F': /* Esc [ F == End on FreeBSD * console/Eterm. */ @@ -1036,7 +1043,7 @@ int get_escape_seq_kbinput(int *escape_seq, size_t es_len) } #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 return retval;