From d6eb17515da3099c4e3bb47ca022e963109850a0 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 25 May 2006 21:39:25 +0000 Subject: [PATCH] in parse_kbinput(), if we get Escape followed by an escape sequence, interpret the escape sequence for consistency; also ignore unhandled function keys for consistency git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3565 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 18 ++++++++++-------- src/nano.c | 7 ++++--- src/prompt.c | 7 ++++--- src/winio.c | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91d6bff3..3295fd04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -97,14 +97,14 @@ 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. To get this to work properly, add a - shortcut for moving to the next search/replace string. New - function is_ascii_cntrl_char(); changes to shortcut_init(), - do_input(), do_statusbar_input(), get_prompt_string(), and - parse_kbinput(). (DLR, suggested by Nick Warne and Benno - Schulenberg) + - Ignore unhandled meta key sequences, function keys, and escape + sequences, and indicate it on the statusbar when we get an + unhandled shortcut or toggle, as Pico does. To get this to + work properly, add a shortcut for moving to the next + search/replace string. New function is_ascii_cntrl_char(); + changes to shortcut_init(), do_input(), do_statusbar_input(), + get_prompt_string(), and parse_kbinput(). (DLR, suggested by + Nick Warne and Benno Schulenberg) - Explain the mouse support in more detail, and sync the text of its description across all documentation. Changes to nano.1, nanorc.5, nanorc.sample, and nano.texi. (Benno Schulenberg and @@ -283,6 +283,8 @@ CVS code - parse_kbinput() - If we get NANO_CONTROL_8, properly handle it in all cases. (DLR) + - If we get Escape followed by an escape sequence, interpret the + escape sequence for consistency. (DLR) get_control_kbinput() - Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno Schulenberg) diff --git a/src/nano.c b/src/nano.c index c4dd9377..afca8c67 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1297,10 +1297,11 @@ 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, throw it out. */ + /* If we got a non-high-bit control key, a meta key sequence, or a + * function key, and it's not a shortcut or toggle, throw it out. */ if (*s_or_t == FALSE) { - if (is_ascii_cntrl_char(input) || *meta_key == TRUE) { + if (is_ascii_cntrl_char(input) || *meta_key == TRUE || + *func_key == TRUE) { statusbar(_("Unknown Command")); if (*meta_key == TRUE) *meta_key = FALSE; diff --git a/src/prompt.c b/src/prompt.c index 7e60f2e1..6d4b5a83 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -100,10 +100,11 @@ 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, throw it out. */ + /* If we got a non-high-bit control key, a meta key sequence, or a + * function key, and it's not a shortcut or toggle, throw it out. */ if (*s_or_t == FALSE) { - if (is_ascii_cntrl_char(input) || *meta_key == TRUE) { + if (is_ascii_cntrl_char(input) || *meta_key == TRUE || + *func_key == TRUE) { if (*meta_key == TRUE) *meta_key = FALSE; input = ERR; diff --git a/src/winio.c b/src/winio.c index 36b96812..f31f823b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -589,7 +589,16 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) free(byte_mb); free(seq); } - } else { + /* Two escapes followed by one or more non-decimal + * digits: control character sequence mode, + * interrupted byte sequence mode, or escape + * sequence mode. If there aren't any other keys + * waiting, we have either a control character + * sequence or an interrupted byte sequence. If + * there are other keys waiting, we have a true + * escape sequence preceded by an extra escape, so + * interpret it. */ + } else if (get_key_buffer_len() == 0) { /* Reset the escape counter. */ escapes = 0; if (byte_digits == 0) @@ -610,6 +619,28 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) byte_digits = 0; retval = *kbinput; } + } else { + int *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 value, + * and save that as the result. */ + 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")); + + free(seq); } break; } -- 2.39.5