nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 8e341e1b22023d6f172fb8ed908197c232545129
parent 5538150e0ac744126220373063a7dbfb624c8c7a
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Wed, 24 May 2006 17:36:00 +0000

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

Diffstat:
MChangeLog | 6++++++
Msrc/chars.c | 7+++++++
Msrc/nano.c | 11+++++++++++
Msrc/prompt.c | 9+++++++++
Msrc/proto.h | 1+
Msrc/winio.c | 6+++---
6 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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 diff --git a/src/chars.c b/src/chars.c @@ -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) diff --git a/src/nano.c b/src/nano.c @@ -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 diff --git a/src/prompt.c b/src/prompt.c @@ -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 diff --git a/src/proto.h b/src/proto.h @@ -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); diff --git a/src/winio.c b/src/winio.c @@ -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); }