ignore unhandled meta key sequences and escape sequences, and indicate

it on the statusbar when we get an unhandled shortcut or toggle, as Pico
does


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3554 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2006-05-24 17:36:00 +00:00
parent 5538150e0a
commit 8e341e1b22
6 changed files with 37 additions and 3 deletions

View File

@ -96,6 +96,12 @@ CVS code -
do_page_down(), do_up(), do_scroll_up(), do_down(),
do_scroll_down(), do_input(), do_search(), do_research(), and
do_delete(). (DLR)
- Ignore unhandled meta key sequences and escape sequences, and
indicate it on the statusbar when we get an unhandled shortcut
or toggle, as Pico does. New function is_ascii_cntrl_char();
changes to do_input(), do_statusbar_input(), and
parse_kbinput(). (DLR, suggested by Nick Warne and Benno
Schulenberg)
- browser.c:
do_browser()
- Reference NANO_GOTODIR_(ALT|F)?KEY instead of

View File

@ -120,6 +120,13 @@ bool is_blank_mbchar(const char *c)
return isblank((unsigned char)*c);
}
/* This function is equivalent to iscntrl(), except in that it only
* handles non-high-bit control characters. */
bool is_ascii_cntrl_char(int c)
{
return (0 <= c && c < 32);
}
/* This function is equivalent to iscntrl(), except in that it also
* handles high-bit control characters. */
bool is_cntrl_char(int c)

View File

@ -1297,6 +1297,17 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
#endif
);
/* If we got a non-high-bit control key or a Meta key sequence, and
* it's not a shortcut or toggle, ignore it, and indicate this on
* the statusbar. */
if (*s_or_t == FALSE) {
if (is_ascii_cntrl_char(input) || *meta_key == TRUE) {
input = ERR;
*meta_key = FALSE;
statusbar(_("Unknown Command"));
}
}
if (allow_funcs) {
/* If we got a character, and it isn't a shortcut or toggle,
* it's a normal text character. Display the warning if we're

View File

@ -99,6 +99,15 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
/* Set s_or_t to TRUE if we got a shortcut. */
*s_or_t = have_shortcut;
/* If we got a non-high-bit control key or a Meta key sequence, and
* it's not a shortcut or toggle, ignore it. */
if (*s_or_t == FALSE) {
if (is_ascii_cntrl_char(input) || *meta_key == TRUE) {
input = ERR;
*meta_key = FALSE;
}
}
if (allow_funcs) {
/* If we got a character, and it isn't a shortcut or toggle,
* it's a normal text character. Display the warning if we're

View File

@ -174,6 +174,7 @@ bool niswblank(wchar_t wc);
bool is_byte(int c);
bool is_alnum_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c);
bool is_cntrl_char(int c);
#ifdef ENABLE_UTF8
bool is_cntrl_wchar(wchar_t wc);

View File

@ -536,10 +536,10 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
&ignore_seq);
/* If the escape sequence is unrecognized and
* not ignored, put back all of its characters
* except for the initial escape. */
* not ignored, indicate this on the
* statusbar. */
if (retval == ERR && !ignore_seq)
unget_input(seq, seq_len);
statusbar(_("Unknown Command"));
free(seq);
}