From: David Lawrence Ramsey Date: Thu, 8 Jun 2006 02:01:49 +0000 (+0000) Subject: don't display "Unknown Command" on the statusbar if we get an unknown X-Git-Tag: v1.3.12~49 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=f102208c05af794ad0d97b2a828d5c6403767bb7;p=nano.git don't display "Unknown Command" on the statusbar if we get an unknown escape sequence at the statusbar prompt git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3631 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/src/proto.h b/src/proto.h index c6d5e29a..ed4ccaba 100644 --- a/src/proto.h +++ b/src/proto.h @@ -721,7 +721,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key); int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool *ignore_seq); int get_escape_seq_abcd(int kbinput); -int parse_escape_seq_kbinput(int kbinput); +int parse_escape_seq_kbinput(int kbinput, bool *ignore_seq); int get_byte_kbinput(int kbinput); #ifdef ENABLE_UTF8 long add_unicode_digit(int kbinput, long factor, long *uni); diff --git a/src/winio.c b/src/winio.c index 8c500635..f0e9eb27 100644 --- a/src/winio.c +++ b/src/winio.c @@ -517,8 +517,20 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) if (get_key_buffer_len() == 0) { *meta_key = TRUE; retval = tolower(*kbinput); - } else - retval = parse_escape_seq_kbinput(*kbinput); + } else { + bool ignore_seq; + + retval = parse_escape_seq_kbinput(*kbinput, + &ignore_seq); + + /* If the escape sequence is unrecognized and + * not ignored, throw it out. */ + if (retval == ERR && *ignore_seq == FALSE) { + if (win == edit) + statusbar(_("Unknown Command")); + beep(); + } + } break; case 2: /* Two escapes followed by one or more decimal @@ -1140,13 +1152,14 @@ int get_escape_seq_abcd(int kbinput) } /* Interpret the escape sequence in the keystroke buffer, the first - * character of which is kbinput. Assume that the keystroke buffer - * isn't empty, and that the initial escape has already been read in. */ -int parse_escape_seq_kbinput(int kbinput) + * character of which is kbinput. If we want to ignore the escape + * sequence, set retval to ERR and ignore_seq to TRUE. Assume that the + * keystroke buffer isn't empty, and that the initial escape has already + * been read in. */ +int parse_escape_seq_kbinput(int kbinput, bool *ignore_seq) { int retval, *seq; size_t seq_len; - bool ignore_seq; /* Put back the non-escape character, get the complete escape * sequence, translate the sequence into its corresponding key @@ -1154,19 +1167,12 @@ int parse_escape_seq_kbinput(int kbinput) unget_input(&kbinput, 1); seq_len = get_key_buffer_len(); seq = get_input(NULL, seq_len); - retval = get_escape_seq_kbinput(seq, seq_len, &ignore_seq); - - /* If the escape sequence is unrecognized and not ignored, throw it - * out, and indicate this on the statusbar. */ - if (retval == ERR && !ignore_seq) { - statusbar(_("Unknown Command")); - beep(); - } + retval = get_escape_seq_kbinput(seq, seq_len, ignore_seq); free(seq); #ifdef DEBUG - fprintf(stderr, "parse_escape_seq_kbinput(): kbinput = %d, seq_len = %lu, ignore_seq = %d, retval = %d\n", kbinput, (unsigned long)seq_len, (int)ignore_seq, retval); + fprintf(stderr, "parse_escape_seq_kbinput(): kbinput = %d, ignore_seq = %d, seq_len = %lu, retval = %d\n", kbinput, (int)ignore_seq, (unsigned long)seq_len, retval); #endif return retval;