1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

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.
This commit is contained in:
Kalle Olavi Niemitalo 2006-08-13 15:32:06 +03:00 committed by Kalle Olavi Niemitalo
parent 6108c3e109
commit de93359a5a
4 changed files with 22 additions and 19 deletions

View File

@ -911,8 +911,7 @@ push_kbdbind_add_button(struct dialog_data *dlg_data,
"Keymap: %s\n" "Keymap: %s\n"
"\n" "\n"
"Keystroke should be written in the format: " "Keystroke should be written in the format: "
"[Prefix-]Key\n" "[Shift-][Ctrl-][Alt-]Key\n"
"Prefix: Shift, Ctrl, Alt\n"
"Key: a,b,c,...,1,2,3,...,Space,Up,PageDown," "Key: a,b,c,...,1,2,3,...,Space,Up,PageDown,"
"Tab,Enter,Insert,F5,..." "Tab,Enter,Insert,F5,..."
"\n\n" "\n\n"

View File

@ -374,24 +374,27 @@ parse_keystroke(const unsigned char *s, struct term_event_keyboard *kbd)
{ {
unsigned char ctrlbuf[2]; unsigned char ctrlbuf[2];
if (!strncasecmp(s, "Shift", 5) && (s[5] == '-' || s[5] == '+')) { kbd->modifier = KBD_MOD_NONE;
/* Shift+a == shiFt-a == Shift-a */ while (1) {
kbd->modifier = KBD_MOD_SHIFT; if (!strncasecmp(s, "Shift", 5) && (s[5] == '-' || s[5] == '+')) {
s += 6; /* Shift+a == shiFt-a == Shift-a */
kbd->modifier |= KBD_MOD_SHIFT;
s += 6;
} else if (!strncasecmp(s, "Ctrl", 4) && (s[4] == '-' || s[4] == '+')) { } else if (!strncasecmp(s, "Ctrl", 4) && (s[4] == '-' || s[4] == '+')) {
/* Ctrl+a == ctRl-a == Ctrl-a */ /* Ctrl+a == ctRl-a == Ctrl-a */
kbd->modifier = KBD_MOD_CTRL; kbd->modifier |= KBD_MOD_CTRL;
s += 5; s += 5;
} else if (!strncasecmp(s, "Alt", 3) && (s[3] == '-' || s[3] == '+')) { } else if (!strncasecmp(s, "Alt", 3) && (s[3] == '-' || s[3] == '+')) {
/* Alt+a == aLt-a == Alt-a */ /* Alt+a == aLt-a == Alt-a */
kbd->modifier = KBD_MOD_ALT; kbd->modifier |= KBD_MOD_ALT;
s += 4; s += 4;
} else { } else {
/* No modifier. */ /* No modifier. */
kbd->modifier = KBD_MOD_NONE; break;
}
} }
if ((kbd->modifier & KBD_MOD_CTRL) != 0 && s[0] && !s[1]) { if ((kbd->modifier & KBD_MOD_CTRL) != 0 && s[0] && !s[1]) {

View File

@ -865,7 +865,7 @@ set_kbd_event(struct interlink_event *ev, int key, int modifier)
default: default:
if (key < ' ') { if (key < ' ') {
key += 'A' - 1; key += 'A' - 1;
modifier = KBD_MOD_CTRL; modifier |= KBD_MOD_CTRL;
} }
} }

View File

@ -1169,7 +1169,8 @@ quit:
if (check_kbd_key(ev, KBD_CTRL_C)) goto 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; struct window *win;
get_kbd_modifier(ev) &= ~KBD_MOD_ALT; get_kbd_modifier(ev) &= ~KBD_MOD_ALT;