Commit d6eb1751 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
parent e328ae94
No related merge requests found
Showing with 50 additions and 15 deletions
+50 -15
...@@ -97,14 +97,14 @@ CVS code - ...@@ -97,14 +97,14 @@ CVS code -
do_page_down(), do_up(), do_scroll_up(), do_down(), do_page_down(), do_up(), do_scroll_up(), do_down(),
do_scroll_down(), do_input(), do_search(), do_research(), and do_scroll_down(), do_input(), do_search(), do_research(), and
do_delete(). (DLR) do_delete(). (DLR)
- Ignore unhandled meta key sequences and escape sequences, and - Ignore unhandled meta key sequences, function keys, and escape
indicate it on the statusbar when we get an unhandled shortcut sequences, and indicate it on the statusbar when we get an
or toggle, as Pico does. To get this to work properly, add a unhandled shortcut or toggle, as Pico does. To get this to
shortcut for moving to the next search/replace string. New work properly, add a shortcut for moving to the next
function is_ascii_cntrl_char(); changes to shortcut_init(), search/replace string. New function is_ascii_cntrl_char();
do_input(), do_statusbar_input(), get_prompt_string(), and changes to shortcut_init(), do_input(), do_statusbar_input(),
parse_kbinput(). (DLR, suggested by Nick Warne and Benno get_prompt_string(), and parse_kbinput(). (DLR, suggested by
Schulenberg) Nick Warne and Benno Schulenberg)
- Explain the mouse support in more detail, and sync the text of - Explain the mouse support in more detail, and sync the text of
its description across all documentation. Changes to nano.1, its description across all documentation. Changes to nano.1,
nanorc.5, nanorc.sample, and nano.texi. (Benno Schulenberg and nanorc.5, nanorc.sample, and nano.texi. (Benno Schulenberg and
...@@ -283,6 +283,8 @@ CVS code - ...@@ -283,6 +283,8 @@ CVS code -
parse_kbinput() parse_kbinput()
- If we get NANO_CONTROL_8, properly handle it in all cases. - If we get NANO_CONTROL_8, properly handle it in all cases.
(DLR) (DLR)
- If we get Escape followed by an escape sequence, interpret the
escape sequence for consistency. (DLR)
get_control_kbinput() get_control_kbinput()
- Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno - Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno
Schulenberg) Schulenberg)
......
...@@ -1297,10 +1297,11 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool ...@@ -1297,10 +1297,11 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
#endif #endif
); );
/* If we got a non-high-bit control key or a meta key sequence, and /* If we got a non-high-bit control key, a meta key sequence, or a
* it's not a shortcut or toggle, throw it out. */ * function key, and it's not a shortcut or toggle, throw it out. */
if (*s_or_t == FALSE) { 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")); statusbar(_("Unknown Command"));
if (*meta_key == TRUE) if (*meta_key == TRUE)
*meta_key = FALSE; *meta_key = FALSE;
......
...@@ -100,10 +100,11 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, ...@@ -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. */ /* Set s_or_t to TRUE if we got a shortcut. */
*s_or_t = have_shortcut; *s_or_t = have_shortcut;
/* If we got a non-high-bit control key or a meta key sequence, and /* If we got a non-high-bit control key, a meta key sequence, or a
* it's not a shortcut or toggle, throw it out. */ * function key, and it's not a shortcut or toggle, throw it out. */
if (*s_or_t == FALSE) { 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) if (*meta_key == TRUE)
*meta_key = FALSE; *meta_key = FALSE;
input = ERR; input = ERR;
......
...@@ -589,7 +589,16 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) ...@@ -589,7 +589,16 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
free(byte_mb); free(byte_mb);
free(seq); 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. */ /* Reset the escape counter. */
escapes = 0; escapes = 0;
if (byte_digits == 0) if (byte_digits == 0)
...@@ -610,6 +619,28 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) ...@@ -610,6 +619,28 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
byte_digits = 0; byte_digits = 0;
retval = *kbinput; 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; break;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment