mc/mc-multi-press-f-keys.patch

59 lines
2.0 KiB
Diff
Raw Normal View History

http://www.midnight-commander.org/ticket/287
Index: lib/tty/key.c
===================================================================
--- lib/tty/key.c.orig 2010-07-07 17:32:15.521891000 +0200
+++ lib/tty/key.c 2010-07-07 17:32:15.897891000 +0200
@@ -897,10 +897,13 @@ correct_key_code (int code)
mod = 0;
}
- /* F0 is the same as F10 for out purposes */
+ /* F0 is the same as F10 for our purposes */
if (c == KEY_F (0))
c = KEY_F (10);
+ if (c == KEY_F_IMMUTABLE (0))
+ c = KEY_F_IMMUTABLE (10);
+
/*
* We are not interested if Ctrl was pressed when entering control
* characters, so assume that it was. When checking for such keys,
@@ -965,6 +968,16 @@ correct_key_code (int code)
mod &= ~KEY_M_SHIFT;
}
+ /*
+ * Numerals may require modifilers with some keymaps or on obscure
+ * keyboards (e. g. F4 = Esc Shift+4). We have to ignore all
+ * modifiers while interpreting Esc + Numeral.
+ */
+ if (c >= KEY_F_IMMUTABLE (1) && c <= KEY_F_IMMUTABLE (10)) {
+ c += KEY_F (0) - KEY_F_IMMUTABLE (0);
+ mod &= ~KEY_M_MASK;
+ }
+
if (!alternate_plus_minus)
switch (c) {
case KEY_KP_ADD:
@@ -1613,7 +1626,7 @@ get_key_code (int no_delay)
if ((parent != NULL) && (parent->action == MCKEY_ESCAPE)) {
/* Convert escape-digits to F-keys */
if (g_ascii_isdigit (c))
- c = KEY_F (c - '0');
+ c = KEY_F_IMMUTABLE (c - '0');
else if (c == ' ')
c = ESC_CHAR;
else
Index: lib/tty/tty-slang.h
===================================================================
--- lib/tty/tty-slang.h.orig 2010-07-05 21:12:51.000000000 +0200
+++ lib/tty/tty-slang.h 2010-07-07 17:33:45.962779000 +0200
@@ -16,6 +16,7 @@ enum {
};
#define KEY_F(x) (1000 + x)
+#define KEY_F_IMMUTABLE(x) (970+x)
#define ACS_VLINE SLSMG_VLINE_CHAR
#define ACS_HLINE SLSMG_HLINE_CHAR