mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 18:38:48 +00:00
Support keypad mode, and get rid of SCREEN_DEF*. Meant to commit these separately but forgot :-/.
This commit is contained in:
parent
815b217482
commit
3337dfcae5
12
CHANGES
12
CHANGES
@ -1,11 +1,9 @@
|
||||
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
|
||||
entries and parts do not. I'm not sure I've got it right but this seems to
|
||||
work.
|
||||
* Finally lose inconsistently-used SCREEN_DEF* defines.
|
||||
* If cursor mode is on, switch the arrow keys from \033[A to \033OA.
|
||||
* Support the numeric keypad in both application and numbers mode. This is
|
||||
different from screen which always keeps it in application mode.
|
||||
|
||||
19 July 2008
|
||||
|
||||
@ -623,4 +621,4 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.153 2008-07-24 00:03:15 nicm Exp $
|
||||
$Id: CHANGES,v 1.154 2008-07-24 21:42:40 nicm Exp $
|
||||
|
2
TODO
2
TODO
@ -42,9 +42,7 @@
|
||||
- cfg file improvements (env vars particularly)
|
||||
- better mode features: search, back word, forward word, etc
|
||||
- flags to centre screen in window
|
||||
- get rid of DEFDATA etc
|
||||
- better terminal emulation (identify, insert mode, some other bits)
|
||||
- should we support kkeypad? looks like screen doesn't. what is kcursor?
|
||||
|
||||
-- For 0.5 --------------------------------------------------------------------
|
||||
|
||||
|
36
input-keys.c
36
input-keys.c
@ -1,4 +1,4 @@
|
||||
/* $Id: input-keys.c,v 1.13 2008-07-24 00:03:15 nicm Exp $ */
|
||||
/* $Id: input-keys.c,v 1.14 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -50,17 +50,33 @@ struct {
|
||||
{ KEYC_PPAGE, "\033[5~", 0 },
|
||||
{ KEYC_SELECT, "\033[4~", 0 },
|
||||
|
||||
/* Keypad + cursor versions must come first. */
|
||||
{ KEYC_UP, "\033OA", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
|
||||
{ KEYC_DOWN, "\033OB", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
|
||||
{ KEYC_LEFT, "\033OD", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
|
||||
{ KEYC_RIGHT, "\033OC", INPUTKEY_KEYPAD|INPUTKEY_CURSOR },
|
||||
|
||||
/* Arrow keys. Cursor versions must come first. */
|
||||
{ KEYC_UP, "\033OA", INPUTKEY_CURSOR },
|
||||
{ KEYC_DOWN, "\033OB", INPUTKEY_CURSOR },
|
||||
{ KEYC_LEFT, "\033OD", INPUTKEY_CURSOR },
|
||||
{ KEYC_RIGHT, "\033OC", INPUTKEY_CURSOR },
|
||||
{ KEYC_UP, "\033[A", 0 },
|
||||
{ KEYC_DOWN, "\033[B", 0 },
|
||||
{ KEYC_LEFT, "\033[D", 0 },
|
||||
{ KEYC_RIGHT, "\033[C", 0 },
|
||||
|
||||
/* Keypad keys. Keypad versions must come first. */
|
||||
{ KEYC_KP0_1, "/", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP0_2, "*", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP0_3, "-", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP1_0, "7", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP1_1, "8", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP1_2, "9", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP1_3, "+", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP2_0, "4", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP2_1, "5", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP2_2, "6", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP3_0, "1", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP3_1, "2", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP3_2, "3", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP3_3, "\n", INPUTKEY_KEYPAD }, /* this can be CRLF too? */
|
||||
{ KEYC_KP4_0, "0", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP4_2, ".", INPUTKEY_KEYPAD },
|
||||
{ KEYC_KP0_1, "\033Oo", 0 },
|
||||
{ KEYC_KP0_2, "\033Oj", 0 },
|
||||
{ KEYC_KP0_3, "\033Om", 0 },
|
||||
@ -86,7 +102,7 @@ input_key(struct window *w, int key)
|
||||
{
|
||||
u_int i;
|
||||
|
||||
log_debug2("writing key %x", key);
|
||||
log_debug2("writing key 0x%x", key);
|
||||
|
||||
if (KEYC_ISESCAPE(key)) {
|
||||
buffer_write8(w->out, '\033');
|
||||
@ -109,10 +125,10 @@ input_key(struct window *w, int key)
|
||||
break;
|
||||
}
|
||||
if (i == NINPUTKEYS) {
|
||||
log_debug2("key %d missing", key);
|
||||
log_debug2("key 0x%x missing", key);
|
||||
return;
|
||||
}
|
||||
|
||||
log_debug2("found key %d: \"%s\"", key, input_keys[i].data);
|
||||
log_debug2("found key 0x%x: \"%s\"", key, input_keys[i].data);
|
||||
buffer_write(w->out, input_keys[i].data, strlen(input_keys[i].data));
|
||||
}
|
||||
|
6
input.c
6
input.c
@ -1,4 +1,4 @@
|
||||
/* $Id: input.c,v 1.51 2008-07-23 23:44:50 nicm Exp $ */
|
||||
/* $Id: input.c,v 1.52 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -1055,7 +1055,7 @@ input_handle_sequence_sgr(struct input_ctx *ictx)
|
||||
n = ARRAY_LENGTH(&ictx->args);
|
||||
if (n == 0) {
|
||||
attr = 0;
|
||||
colr = SCREEN_DEFCOLR;
|
||||
colr = 0x88;
|
||||
} else {
|
||||
attr = s->attr;
|
||||
colr = s->colr;
|
||||
@ -1066,7 +1066,7 @@ input_handle_sequence_sgr(struct input_ctx *ictx)
|
||||
case 0:
|
||||
case 10:
|
||||
attr &= ATTR_CHARSET;
|
||||
colr = SCREEN_DEFCOLR;
|
||||
colr = 0x88;
|
||||
break;
|
||||
case 1:
|
||||
attr |= ATTR_BRIGHT;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: screen-display.c,v 1.17 2008-06-18 22:21:51 nicm Exp $ */
|
||||
/* $Id: screen-display.c,v 1.18 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -39,9 +39,9 @@ screen_display_make_lines(struct screen *s, u_int py, u_int ny)
|
||||
return;
|
||||
}
|
||||
screen_make_lines(s, screen_y(s, py), ny);
|
||||
if (s->attr != SCREEN_DEFATTR || s->colr != SCREEN_DEFCOLR) {
|
||||
if (s->attr != 0 || s->colr != 0x88) {
|
||||
screen_display_fill_area(s, 0, py,
|
||||
screen_size_x(s), ny, SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_size_x(s), ny, ' ', s->attr, s->colr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ screen_display_insert_characters(struct screen *s, u_int px, u_int py, u_int nx)
|
||||
memmove(&s->grid_colr[py][px + nx], &s->grid_colr[py][px], mx);
|
||||
}
|
||||
|
||||
memset(&s->grid_data[py][px], SCREEN_DEFDATA, nx);
|
||||
memset(&s->grid_data[py][px], ' ', nx);
|
||||
memset(&s->grid_attr[py][px], s->attr, nx);
|
||||
memset(&s->grid_colr[py][px], s->colr, nx);
|
||||
}
|
||||
@ -420,7 +420,7 @@ screen_display_delete_characters(struct screen *s, u_int px, u_int py, u_int nx)
|
||||
memmove(&s->grid_colr[py][px], &s->grid_colr[py][px + nx], mx);
|
||||
}
|
||||
|
||||
memset(&s->grid_data[py][screen_size_x(s) - nx], SCREEN_DEFDATA, nx);
|
||||
memset(&s->grid_data[py][screen_size_x(s) - nx], ' ', nx);
|
||||
memset(&s->grid_attr[py][screen_size_x(s) - nx], s->attr, nx);
|
||||
memset(&s->grid_colr[py][screen_size_x(s) - nx], s->colr, nx);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: screen-write.c,v 1.9 2008-07-23 23:44:50 nicm Exp $ */
|
||||
/* $Id: screen-write.c,v 1.10 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -381,9 +381,9 @@ screen_write_fill_end_of_screen(struct screen_write_ctx *ctx)
|
||||
u_int i;
|
||||
|
||||
screen_display_fill_area(s, s->cx, s->cy,
|
||||
screen_right_x(s, s->cx), 1, SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_right_x(s, s->cx), 1, ' ', s->attr, s->colr);
|
||||
screen_display_fill_area(s, 0, s->cy + 1, screen_size_x(s),
|
||||
screen_below_y(s, s->cy + 1), SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_below_y(s, s->cy + 1), ' ', s->attr, s->colr);
|
||||
|
||||
if (ctx->write != NULL) {
|
||||
ctx->write(ctx->data, TTY_CLEARENDOFLINE);
|
||||
@ -402,8 +402,8 @@ screen_write_fill_screen(struct screen_write_ctx *ctx)
|
||||
struct screen *s = ctx->s;
|
||||
u_int i;
|
||||
|
||||
screen_display_fill_area(s, 0, 0, screen_size_x(s), screen_size_y(s),
|
||||
SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_display_fill_area(s, 0, 0,
|
||||
screen_size_x(s), screen_size_y(s), ' ', s->attr, s->colr);
|
||||
|
||||
if (ctx->write != NULL) {
|
||||
for (i = 0; i < screen_size_y(s); i++) {
|
||||
@ -421,7 +421,7 @@ screen_write_fill_end_of_line(struct screen_write_ctx *ctx)
|
||||
struct screen *s = ctx->s;
|
||||
|
||||
screen_display_fill_area(s, s->cx, s->cy,
|
||||
screen_right_x(s, s->cx), 1, SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_right_x(s, s->cx), 1, ' ', s->attr, s->colr);
|
||||
|
||||
if (ctx->write != NULL)
|
||||
ctx->write(ctx->data, TTY_CLEARENDOFLINE);
|
||||
@ -434,7 +434,7 @@ screen_write_fill_start_of_line(struct screen_write_ctx *ctx)
|
||||
struct screen *s = ctx->s;
|
||||
|
||||
screen_display_fill_area(s, 0, s->cy,
|
||||
screen_left_x(s, s->cx), 1, SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_left_x(s, s->cx), 1, ' ', s->attr, s->colr);
|
||||
|
||||
if (ctx->write != NULL)
|
||||
ctx->write(ctx->data, TTY_CLEARSTARTOFLINE);
|
||||
@ -447,7 +447,7 @@ screen_write_fill_line(struct screen_write_ctx *ctx)
|
||||
struct screen *s = ctx->s;
|
||||
|
||||
screen_display_fill_area(s, 0, s->cy,
|
||||
screen_size_x(s), s->cy, SCREEN_DEFDATA, s->attr, s->colr);
|
||||
screen_size_x(s), s->cy, ' ', s->attr, s->colr);
|
||||
|
||||
if (ctx->write != NULL)
|
||||
ctx->write(ctx->data, TTY_CLEARLINE);
|
||||
|
22
screen.c
22
screen.c
@ -1,4 +1,4 @@
|
||||
/* $Id: screen.c,v 1.65 2008-07-24 07:01:57 nicm Exp $ */
|
||||
/* $Id: screen.c,v 1.66 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -141,8 +141,8 @@ screen_create(struct screen *s, u_int dx, u_int dy, u_int hlimit)
|
||||
s->hsize = 0;
|
||||
s->hlimit = hlimit;
|
||||
|
||||
s->attr = SCREEN_DEFATTR;
|
||||
s->colr = SCREEN_DEFCOLR;
|
||||
s->attr = 0;
|
||||
s->colr = 0x88;
|
||||
|
||||
s->mode = MODE_CURSOR;
|
||||
s->title = xstrdup("");
|
||||
@ -166,8 +166,8 @@ screen_reset(struct screen *s)
|
||||
s->rupper = 0;
|
||||
s->rlower = s->dy - 1;
|
||||
|
||||
s->attr = SCREEN_DEFATTR;
|
||||
s->colr = SCREEN_DEFCOLR;
|
||||
s->attr = 0;
|
||||
s->colr = 0x88;
|
||||
|
||||
s->mode = MODE_CURSOR;
|
||||
|
||||
@ -276,11 +276,11 @@ screen_expand_line(struct screen *s, u_int py, u_int nx)
|
||||
s->grid_size[py] = nx;
|
||||
|
||||
s->grid_data[py] = xrealloc(s->grid_data[py], 1, nx);
|
||||
memset(&s->grid_data[py][ox], SCREEN_DEFDATA, nx - ox);
|
||||
memset(&s->grid_data[py][ox], ' ', nx - ox);
|
||||
s->grid_attr[py] = xrealloc(s->grid_attr[py], 1, nx);
|
||||
memset(&s->grid_attr[py][ox], SCREEN_DEFATTR, nx - ox);
|
||||
memset(&s->grid_attr[py][ox], 0, nx - ox);
|
||||
s->grid_colr[py] = xrealloc(s->grid_colr[py], 1, nx);
|
||||
memset(&s->grid_colr[py][ox], SCREEN_DEFCOLR, nx - ox);
|
||||
memset(&s->grid_colr[py][ox], 0x88, nx - ox);
|
||||
}
|
||||
|
||||
/* Reduce line. */
|
||||
@ -300,9 +300,9 @@ screen_get_cell(struct screen *s,
|
||||
u_int cx, u_int cy, u_char *data, u_char *attr, u_char *colr)
|
||||
{
|
||||
if (cx >= s->grid_size[cy]) {
|
||||
*data = SCREEN_DEFDATA;
|
||||
*attr = SCREEN_DEFATTR;
|
||||
*colr = SCREEN_DEFCOLR;
|
||||
*data = ' ';
|
||||
*attr = 0;
|
||||
*colr = 0x88;
|
||||
} else {
|
||||
*data = s->grid_data[cy][cx];
|
||||
*attr = s->grid_attr[cy][cx];
|
||||
|
7
tmux.h
7
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.176 2008-07-23 23:44:50 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.177 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -517,11 +517,6 @@ struct screen_write_ctx {
|
||||
n, m, o, p); \
|
||||
} while (0)
|
||||
|
||||
/* Screen default contents. */
|
||||
#define SCREEN_DEFDATA ' '
|
||||
#define SCREEN_DEFATTR 0
|
||||
#define SCREEN_DEFCOLR 0x88 /* default on default ;-) */
|
||||
|
||||
/* Input parser sequence argument. */
|
||||
struct input_arg {
|
||||
u_char data[64];
|
||||
|
14
tty-keys.c
14
tty-keys.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tty-keys.c,v 1.8 2008-07-24 00:03:15 nicm Exp $ */
|
||||
/* $Id: tty-keys.c,v 1.9 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -179,10 +179,14 @@ struct {
|
||||
{ "pmous", KEYC_MOUSE },
|
||||
|
||||
/*
|
||||
* Numeric keypad.
|
||||
*
|
||||
* This is totally confusing and I still don't quite understand how it
|
||||
* all fits together in relation to termcap...
|
||||
* Numeric keypad. termcap and terminfo are totally confusing for this.
|
||||
* There are definitions for some keypad keys and for function keys,
|
||||
* but these seem to now be used for the real function keys rather than
|
||||
* for the keypad keys in application mode (which is different from
|
||||
* what it says in the termcap file). So, we just hardcode the vt100
|
||||
* escape sequences here and always put the terminal into keypad_xmit
|
||||
* mode. Translation of numbers mode/applications mode is done in
|
||||
* input-keys.c.
|
||||
*/
|
||||
{ "-\033Oo", KEYC_KP0_1 },
|
||||
{ "-\033Oj", KEYC_KP0_2 },
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-copy.c,v 1.26 2008-07-02 21:22:57 nicm Exp $ */
|
||||
/* $Id: window-copy.c,v 1.27 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -215,8 +215,7 @@ window_copy_write_line(
|
||||
screen_write_move_cursor(ctx, 0, 0);
|
||||
size = screen_write_put_string_rjust(
|
||||
ctx, "[%u,%u/%u]", data->ox, data->oy, w->base.hsize);
|
||||
screen_write_set_attributes(
|
||||
ctx, SCREEN_DEFATTR, SCREEN_DEFCOLR);
|
||||
screen_write_set_attributes(ctx, 0, 0x88);
|
||||
} else
|
||||
size = 0;
|
||||
screen_write_move_cursor(ctx, 0, py);
|
||||
@ -458,7 +457,7 @@ window_copy_find_length(struct window *w, u_int py)
|
||||
u_int px;
|
||||
|
||||
px = w->base.grid_size[py];
|
||||
while (px > 0 && w->base.grid_data[py][px - 1] == SCREEN_DEFDATA)
|
||||
while (px > 0 && w->base.grid_data[py][px - 1] == ' ')
|
||||
px--;
|
||||
return (px);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-more.c,v 1.15 2008-07-02 21:22:57 nicm Exp $ */
|
||||
/* $Id: window-more.c,v 1.16 2008-07-24 21:42:40 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -176,7 +176,7 @@ window_more_write_line(struct window *w, struct screen_write_ctx *ctx, u_int py)
|
||||
} else
|
||||
size = 0;
|
||||
|
||||
screen_write_set_attributes(ctx, SCREEN_DEFATTR, SCREEN_DEFCOLR);
|
||||
screen_write_set_attributes(ctx, 0, 0x88);
|
||||
screen_write_move_cursor(ctx, 0, py);
|
||||
if (data->top + py < ARRAY_LENGTH(&data->list)) {
|
||||
msg = ARRAY_ITEM(&data->list, data->top + py);
|
||||
@ -184,7 +184,7 @@ window_more_write_line(struct window *w, struct screen_write_ctx *ctx, u_int py)
|
||||
ctx, "%.*s", (int) (screen_size_x(s) - size), msg);
|
||||
}
|
||||
while (s->cx < screen_size_x(s) - size)
|
||||
screen_write_put_character(ctx, SCREEN_DEFDATA);
|
||||
screen_write_put_character(ctx, ' ');
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user