1
0
mirror of https://github.com/tmux/tmux.git synced 2025-03-24 14:58:47 +00:00

Handle kcursor+kkeypad (switch to OA from [A).

This commit is contained in:
Nicholas Marriott 2008-07-24 00:03:15 +00:00
parent e00736b811
commit ee8a9d2458
4 changed files with 63 additions and 45 deletions

View File

@ -1,5 +1,8 @@
24 July 2008 24 July 2008
* If keypad mode and cursor mode are on, switch the arrow keys from \033[A to
\033OA. Not sure what else keypad mode is meant to do. Something with the
keypad keys I think, but screen doesn't seem to do anything...
* Support the numeric keypad. This is really confusing: parts of it have termcap * Support the numeric keypad. This is really confusing: parts of it have termcap
entries and parts do not. I'm not sure I've got it right but this seems to entries and parts do not. I'm not sure I've got it right but this seems to
work. work.
@ -620,4 +623,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.152 2008-07-23 23:46:51 nicm Exp $ $Id: CHANGES,v 1.153 2008-07-24 00:03:15 nicm Exp $

View File

@ -1,4 +1,4 @@
/* $Id: input-keys.c,v 1.12 2008-07-23 23:46:51 nicm Exp $ */ /* $Id: input-keys.c,v 1.13 2008-07-24 00:03:15 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -24,50 +24,59 @@
#include "tmux.h" #include "tmux.h"
#define INPUTKEY_KEYPAD 0x1
#define INPUTKEY_CURSOR 0x2
struct { struct {
int key; int key;
const char *data; const char *data;
int flags;
} input_keys[] = { } input_keys[] = {
{ KEYC_F1, "\033OP" }, { KEYC_F1, "\033OP", 0 },
{ KEYC_F2, "\033OQ" }, { KEYC_F2, "\033OQ", 0 },
{ KEYC_F3, "\033OR" }, { KEYC_F3, "\033OR", 0 },
{ KEYC_F4, "\033OS" }, { KEYC_F4, "\033OS", 0 },
{ KEYC_F5, "\033[15~" }, { KEYC_F5, "\033[15~", 0 },
{ KEYC_F6, "\033[17~" }, { KEYC_F6, "\033[17~", 0 },
{ KEYC_F7, "\033[18~" }, { KEYC_F7, "\033[18~", 0 },
{ KEYC_F8, "\033[19~" }, { KEYC_F8, "\033[19~", 0 },
{ KEYC_F9, "\033[20~" }, { KEYC_F9, "\033[20~", 0 },
{ KEYC_F10, "\033[21~" }, { KEYC_F10, "\033[21~", 0 },
{ KEYC_F11, "\033[23~" }, { KEYC_F11, "\033[23~", 0 },
{ KEYC_F12, "\033[24~" }, { KEYC_F12, "\033[24~", 0 },
{ KEYC_FIND, "\033[1~" }, { KEYC_FIND, "\033[1~", 0 },
{ KEYC_DC, "\033[3~" }, { KEYC_DC, "\033[3~", 0 },
{ KEYC_IC, "\033[2~" }, { KEYC_IC, "\033[2~", 0 },
{ KEYC_NPAGE, "\033[6~" }, { KEYC_NPAGE, "\033[6~", 0 },
{ KEYC_PPAGE, "\033[5~" }, { KEYC_PPAGE, "\033[5~", 0 },
{ KEYC_SELECT, "\033[4~" }, { KEYC_SELECT, "\033[4~", 0 },
{ KEYC_UP, "\033OA" }, /* Keypad + cursor versions must come first. */
{ KEYC_DOWN, "\033OB" }, { KEYC_UP, "\033OA", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
{ KEYC_LEFT, "\033OD" }, { KEYC_DOWN, "\033OB", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
{ KEYC_RIGHT, "\033OC" }, { KEYC_LEFT, "\033OD", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
{ KEYC_RIGHT, "\033OC", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
{ KEYC_KP0_1, "\033Oo" }, { KEYC_UP, "\033[A", 0 },
{ KEYC_KP0_2, "\033Oj" }, { KEYC_DOWN, "\033[B", 0 },
{ KEYC_KP0_3, "\033Om" }, { KEYC_LEFT, "\033[D", 0 },
{ KEYC_KP1_0, "\033Ow" }, { KEYC_RIGHT, "\033[C", 0 },
{ KEYC_KP1_1, "\033Ox" },
{ KEYC_KP1_2, "\033Oy" }, { KEYC_KP0_1, "\033Oo", 0 },
{ KEYC_KP1_3, "\033Ok" }, { KEYC_KP0_2, "\033Oj", 0 },
{ KEYC_KP2_0, "\033Ot" }, { KEYC_KP0_3, "\033Om", 0 },
{ KEYC_KP2_1, "\033Ou" }, { KEYC_KP1_0, "\033Ow", 0 },
{ KEYC_KP2_2, "\033Ov" }, { KEYC_KP1_1, "\033Ox", 0 },
{ KEYC_KP3_0, "\033Oq" }, { KEYC_KP1_2, "\033Oy", 0 },
{ KEYC_KP3_1, "\033Or" }, { KEYC_KP1_3, "\033Ok", 0 },
{ KEYC_KP3_2, "\033Os" }, { KEYC_KP2_0, "\033Ot", 0 },
{ KEYC_KP3_3, "\033OM" }, { KEYC_KP2_1, "\033Ou", 0 },
{ KEYC_KP4_0, "\033Op" }, { KEYC_KP2_2, "\033Ov", 0 },
{ KEYC_KP4_2, "\033On" }, { KEYC_KP3_0, "\033Oq", 0 },
{ KEYC_KP3_1, "\033Or", 0 },
{ KEYC_KP3_2, "\033Os", 0 },
{ KEYC_KP3_3, "\033OM", 0 },
{ KEYC_KP4_0, "\033Op", 0 },
{ KEYC_KP4_2, "\033On", 0 },
}; };
#define NINPUTKEYS (sizeof input_keys / sizeof input_keys[0]) #define NINPUTKEYS (sizeof input_keys / sizeof input_keys[0])
@ -90,6 +99,12 @@ input_key(struct window *w, int key)
} }
for (i = 0; i < NINPUTKEYS; i++) { for (i = 0; i < NINPUTKEYS; i++) {
if ((input_keys[i].flags & INPUTKEY_KEYPAD) &&
!(w->screen->mode & MODE_KKEYPAD))
continue;
if ((input_keys[i].flags & INPUTKEY_CURSOR) &&
!(w->screen->mode & MODE_KCURSOR))
continue;
if (input_keys[i].key == key) if (input_keys[i].key == key)
break; break;
} }

View File

@ -1,4 +1,4 @@
/* $Id: screen.c,v 1.63 2008-06-29 07:04:30 nicm Exp $ */ /* $Id: screen.c,v 1.64 2008-07-24 00:03:15 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -144,7 +144,7 @@ screen_create(struct screen *s, u_int dx, u_int dy, u_int hlimit)
s->attr = SCREEN_DEFATTR; s->attr = SCREEN_DEFATTR;
s->colr = SCREEN_DEFCOLR; s->colr = SCREEN_DEFCOLR;
s->mode = MODE_CURSOR|MODE_KCURSOR|MODE_KKEYPAD; s->mode = MODE_CURSOR|MODE_KCURSOR;
s->title = xstrdup(""); s->title = xstrdup("");
s->grid_data = xmalloc(dy * (sizeof *s->grid_data)); s->grid_data = xmalloc(dy * (sizeof *s->grid_data));
@ -169,7 +169,7 @@ screen_reset(struct screen *s)
s->attr = SCREEN_DEFATTR; s->attr = SCREEN_DEFATTR;
s->colr = SCREEN_DEFCOLR; s->colr = SCREEN_DEFCOLR;
s->mode = MODE_CURSOR|MODE_KCURSOR|MODE_KKEYPAD; s->mode = MODE_CURSOR|MODE_KCURSOR;
screen_display_fill_area(s, 0, 0, screen_display_fill_area(s, 0, 0,
screen_size_x(s), screen_size_y(s), ' ', 0, 0x88); screen_size_x(s), screen_size_y(s), ' ', 0, 0x88);

View File

@ -1,4 +1,4 @@
/* $Id: tty-keys.c,v 1.7 2008-07-23 23:44:50 nicm Exp $ */ /* $Id: tty-keys.c,v 1.8 2008-07-24 00:03:15 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -179,7 +179,7 @@ struct {
{ "pmous", KEYC_MOUSE }, { "pmous", KEYC_MOUSE },
/* /*
* Number keypad. * Numeric keypad.
* *
* This is totally confusing and I still don't quite understand how it * This is totally confusing and I still don't quite understand how it
* all fits together in relation to termcap... * all fits together in relation to termcap...