Handle ctrl/shift modifiers better.

This commit is contained in:
Nicholas Marriott 2009-01-12 21:47:03 +00:00
parent ea8d4d43ab
commit dbbc314cc9
4 changed files with 60 additions and 32 deletions

View File

@ -1,5 +1,6 @@
12 January 2009
* More hacks for key handling.
* Two commands, resize-pane-up and resize-pane-down to resize a pane.
* Make the window pane code handle panes of different sizes, and add a -l
and -p arguments to split-window to specify the new window size in lines
@ -883,7 +884,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.196 2009-01-12 19:23:14 nicm Exp $
$Id: CHANGES,v 1.197 2009-01-12 21:47:03 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB

1
TODO
View File

@ -104,3 +104,4 @@
- should have a repeat-command delay - if you execute a key binding then
press another key within the delay time it is treated as if it was anoth
key binding (ie the ^A prefix is implied)
- key handling sucks a bit and needs to be reworked

View File

@ -1,4 +1,4 @@
/* $Id: input-keys.c,v 1.21 2009-01-11 23:31:46 nicm Exp $ */
/* $Id: input-keys.c,v 1.22 2009-01-12 21:47:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -58,14 +58,25 @@ struct input_key_ent input_keys[] = {
{ KEYC_BTAB, "\033[Z", INPUTKEY_MODIFIER },
/* Arrow keys. Cursor versions must come first. */
{ KEYC_UP, "\033OA", INPUTKEY_MODIFIER|INPUTKEY_CURSOR },
{ KEYC_DOWN, "\033OB", INPUTKEY_MODIFIER|INPUTKEY_CURSOR },
{ KEYC_LEFT, "\033OD", INPUTKEY_MODIFIER|INPUTKEY_CURSOR },
{ KEYC_RIGHT, "\033OC", INPUTKEY_MODIFIER|INPUTKEY_CURSOR },
{ KEYC_UP, "\033[A", INPUTKEY_MODIFIER },
{ KEYC_DOWN, "\033[B", INPUTKEY_MODIFIER },
{ KEYC_LEFT, "\033[D", INPUTKEY_MODIFIER },
{ KEYC_RIGHT, "\033[C", INPUTKEY_MODIFIER },
{ KEYC_UP, "\033OA", INPUTKEY_CURSOR },
{ KEYC_DOWN, "\033OB", INPUTKEY_CURSOR },
{ KEYC_RIGHT, "\033OC", INPUTKEY_CURSOR },
{ KEYC_LEFT, "\033OD", INPUTKEY_CURSOR },
{ KEYC_UP, "\033[A", 0 },
{ KEYC_DOWN, "\033[B", 0 },
{ KEYC_RIGHT, "\033[C", 0 },
{ KEYC_LEFT, "\033[D", 0 },
{ KEYC_ADDCTL(KEYC_UP), "\033Oa", 0 },
{ KEYC_ADDCTL(KEYC_DOWN), "\033Ob", 0 },
{ KEYC_ADDCTL(KEYC_RIGHT), "\033Oc", 0 },
{ KEYC_ADDCTL(KEYC_LEFT), "\033Od", 0 },
{ KEYC_ADDSFT(KEYC_UP), "\033[a", 0 },
{ KEYC_ADDSFT(KEYC_DOWN), "\033[b", 0 },
{ KEYC_ADDSFT(KEYC_RIGHT), "\033[c", 0 },
{ KEYC_ADDSFT(KEYC_LEFT), "\033[d", 0 },
/* Keypad keys. Keypad versions must come first. */
{ KEYC_KP0_1, "/", INPUTKEY_KEYPAD },

View File

@ -1,4 +1,4 @@
/* $Id: tty-keys.c,v 1.18 2009-01-10 18:28:09 nicm Exp $ */
/* $Id: tty-keys.c,v 1.19 2009-01-12 21:47:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -56,18 +56,30 @@ struct tty_key_ent tty_keys[] = {
{ TTYC_KCBT, NULL, KEYC_BTAB, TTYKEY_MODIFIER },
/* Arrow keys. */
{ 0, "\033OA", KEYC_UP, TTYKEY_RAW },
{ 0, "\033OB", KEYC_DOWN, TTYKEY_RAW },
{ 0, "\033OC", KEYC_RIGHT, TTYKEY_RAW },
{ 0, "\033OD", KEYC_LEFT, TTYKEY_RAW },
{ 0, "\033[A", KEYC_UP, TTYKEY_RAW },
{ 0, "\033[B", KEYC_DOWN, TTYKEY_RAW },
{ 0, "\033[C", KEYC_RIGHT, TTYKEY_RAW },
{ 0, "\033[D", KEYC_LEFT, TTYKEY_RAW },
{ 0, "\033Oa", KEYC_ADDCTL(KEYC_UP), TTYKEY_RAW },
{ 0, "\033Ob", KEYC_ADDCTL(KEYC_DOWN), TTYKEY_RAW },
{ 0, "\033Oc", KEYC_ADDCTL(KEYC_RIGHT), TTYKEY_RAW },
{ 0, "\033Od", KEYC_ADDCTL(KEYC_LEFT), TTYKEY_RAW },
{ 0, "\033[a", KEYC_ADDSFT(KEYC_UP), TTYKEY_RAW },
{ 0, "\033[b", KEYC_ADDSFT(KEYC_DOWN), TTYKEY_RAW },
{ 0, "\033[c", KEYC_ADDSFT(KEYC_RIGHT), TTYKEY_RAW },
{ 0, "\033[d", KEYC_ADDSFT(KEYC_LEFT), TTYKEY_RAW },
{ TTYC_KCUU1, NULL, KEYC_UP, TTYKEY_MODIFIER },
{ TTYC_KCUD1, NULL, KEYC_DOWN, TTYKEY_MODIFIER },
{ TTYC_KCUB1, NULL, KEYC_LEFT, TTYKEY_MODIFIER },
{ TTYC_KCUF1, NULL, KEYC_RIGHT, TTYKEY_MODIFIER },
{ 0, "\033OA", KEYC_UP, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033OB", KEYC_DOWN, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033OD", KEYC_LEFT, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033OC", KEYC_RIGHT, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033[A", KEYC_UP, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033[B", KEYC_DOWN, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033[D", KEYC_LEFT, TTYKEY_RAW|TTYKEY_MODIFIER },
{ 0, "\033[C", KEYC_RIGHT, TTYKEY_RAW|TTYKEY_MODIFIER },
/*
* Numeric keypad. termcap and terminfo are totally confusing for this.
@ -231,11 +243,14 @@ tty_keys_next(struct tty *tty, int *key)
return (0);
}
/* Not found. Look for an xterm argument and try again. */
/* Not found. Look xterm-style function keys with an argument. */
if (len < sizeof tmp && len > 4 && buf[len - 3] == ';') {
memcpy(tmp, buf, len);
log_debug("xterm key in: %s", tmp);
arg = tmp[len - 2];
tmp[len - 3] = tmp[len - 1]; /* restore last */
tmp[3] = tmp[len - 1]; /* move last */
tmp[4] = '\0';
log_debug("xterm key out: %s", tmp);
log_debug("argument is: %c", arg);
tk = tty_keys_find(tty, tmp + 1, len - 3, &size);