commit f28ff9dece93b488f34aca68834e7cbb965f330f
parent ec177be4168278b8ad5afdb300e0a2a91c42e848
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 24 Jul 2006 18:53:54 +0000
in parse_kbinput(), properly handle combined control character and
escape sequences, so that e.g. Esc Esc / will work properly when the /
is on the numeric keypad and NumLock is off
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3811 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -136,7 +136,10 @@ CVS code -
parse_kbinput()
- Properly handle combined meta and escape sequences, so that
e.g. Meta-+ will work properly when the + is on the numeric
- keypad and NumLock is off. (DLR)
+ keypad and NumLock is off. Also, properly handle combined
+ control character and escape sequences, so that e.g. Esc Esc /
+ will work properly when the / is on the numeric keypad and
+ NumLock is off. (DLR)
- Translate extended keypad keys to their ASCII equivalents even
when we hit Escape once or twice before typing them, for
consistency. (DLR)
diff --git a/src/winio.c b/src/winio.c
@@ -347,11 +347,13 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
/* One escape: wait for more input. */
case 2:
/* Two escapes: wait for more input. */
+ case 3:
+ /* Three escapes: wait for more input. */
break;
default:
- /* More than two escapes: reset the escape counter
- * and wait for more input. */
- escapes = 0;
+ /* More than three escapes: limit the escape counter
+ * to no more than two, and wait for more input. */
+ escapes %= 3;
}
break;
default:
@@ -466,6 +468,24 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
*kbinput);
}
break;
+ case 3:
+ /* Reset the escape counter. */
+ escapes = 0;
+ if (get_key_buffer_len() == 0)
+ /* Three escapes followed by a non-escape, and
+ * there aren't any other keystrokes waiting:
+ * normal input mode. Save the non-escape
+ * character as the result. */
+ retval = *kbinput;
+ else
+ /* Three escapes followed by a non-escape, and
+ * there are other keystrokes waiting: combined
+ * control character and escape sequence mode.
+ * Interpret the escape sequence, and interpret
+ * the result as a control sequence. */
+ retval = get_control_kbinput(
+ parse_escape_seq_kbinput(win,
+ *kbinput));
}
}