From de93359a5af1378358d704940f0b3861a025b1a7 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 13 Aug 2006 15:32:06 +0300 Subject: [PATCH] Support Ctrl-Alt-letter key combinations. Actions can now be bound to e.g. Ctrl-Alt-A. The keybinding code also supports other combinations of modifiers, like Shift-Ctrl-Up, but the escape sequence decoder doesn't yet. Don't let Ctrl-Alt-letter combinations open menus. --- src/config/dialogs.c | 3 +-- src/config/kbdbind.c | 39 +++++++++++++++++++++------------------ src/terminal/kbd.c | 2 +- src/viewer/text/view.c | 3 ++- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/config/dialogs.c b/src/config/dialogs.c index 46b37b6e..3dca10e3 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -911,8 +911,7 @@ push_kbdbind_add_button(struct dialog_data *dlg_data, "Keymap: %s\n" "\n" "Keystroke should be written in the format: " - "[Prefix-]Key\n" - "Prefix: Shift, Ctrl, Alt\n" + "[Shift-][Ctrl-][Alt-]Key\n" "Key: a,b,c,...,1,2,3,...,Space,Up,PageDown," "Tab,Enter,Insert,F5,..." "\n\n" diff --git a/src/config/kbdbind.c b/src/config/kbdbind.c index 1fd78341..c630c12c 100644 --- a/src/config/kbdbind.c +++ b/src/config/kbdbind.c @@ -374,24 +374,27 @@ parse_keystroke(const unsigned char *s, struct term_event_keyboard *kbd) { unsigned char ctrlbuf[2]; - if (!strncasecmp(s, "Shift", 5) && (s[5] == '-' || s[5] == '+')) { - /* Shift+a == shiFt-a == Shift-a */ - kbd->modifier = KBD_MOD_SHIFT; - s += 6; - - } else if (!strncasecmp(s, "Ctrl", 4) && (s[4] == '-' || s[4] == '+')) { - /* Ctrl+a == ctRl-a == Ctrl-a */ - kbd->modifier = KBD_MOD_CTRL; - s += 5; - - } else if (!strncasecmp(s, "Alt", 3) && (s[3] == '-' || s[3] == '+')) { - /* Alt+a == aLt-a == Alt-a */ - kbd->modifier = KBD_MOD_ALT; - s += 4; - - } else { - /* No modifier. */ - kbd->modifier = KBD_MOD_NONE; + kbd->modifier = KBD_MOD_NONE; + while (1) { + if (!strncasecmp(s, "Shift", 5) && (s[5] == '-' || s[5] == '+')) { + /* Shift+a == shiFt-a == Shift-a */ + kbd->modifier |= KBD_MOD_SHIFT; + s += 6; + + } else if (!strncasecmp(s, "Ctrl", 4) && (s[4] == '-' || s[4] == '+')) { + /* Ctrl+a == ctRl-a == Ctrl-a */ + kbd->modifier |= KBD_MOD_CTRL; + s += 5; + + } else if (!strncasecmp(s, "Alt", 3) && (s[3] == '-' || s[3] == '+')) { + /* Alt+a == aLt-a == Alt-a */ + kbd->modifier |= KBD_MOD_ALT; + s += 4; + + } else { + /* No modifier. */ + break; + } } if ((kbd->modifier & KBD_MOD_CTRL) != 0 && s[0] && !s[1]) { diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index 229cf4de..07fd3056 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -865,7 +865,7 @@ set_kbd_event(struct interlink_event *ev, int key, int modifier) default: if (key < ' ') { key += 'A' - 1; - modifier = KBD_MOD_CTRL; + modifier |= KBD_MOD_CTRL; } } diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 14a28783..d383d16e 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -1169,7 +1169,8 @@ quit: if (check_kbd_key(ev, KBD_CTRL_C)) goto quit; - if (get_kbd_modifier(ev) & KBD_MOD_ALT) { + /* Ctrl-Alt-F should not open the File menu like Alt-f does. */ + if (check_kbd_modifier(ev, KBD_MOD_ALT)) { struct window *win; get_kbd_modifier(ev) &= ~KBD_MOD_ALT; -- 2.11.4.GIT