This commit is contained in:
Nicholas Marriott 2010-03-15 12:51:23 +00:00
parent b1a3090877
commit 9f5b9ba0d6
3 changed files with 1295 additions and 1232 deletions

2397
input.c

File diff suppressed because it is too large Load Diff

53
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.547 2010-03-08 15:02:07 tcunha Exp $ */
/* $Id: tmux.h,v 1.548 2010-03-15 12:51:23 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -718,43 +718,36 @@ struct screen_write_ctx {
#define screen_hsize(s) ((s)->grid->hsize)
#define screen_hlimit(s) ((s)->grid->hlimit)
/* Input parser sequence argument. */
struct input_arg {
u_char data[64];
size_t used;
};
/* Input parser context. */
struct input_ctx {
struct window_pane *wp;
struct window_pane *wp;
struct screen_write_ctx ctx;
u_char *buf;
size_t len;
size_t off;
size_t was;
struct grid_cell cell;
struct grid_cell cell;
struct grid_cell old_cell;
u_int old_cx;
u_int old_cy;
struct grid_cell saved_cell;
u_int saved_cx;
u_int saved_cy;
u_char interm_buf[4];
size_t interm_len;
#define MAXSTRINGLEN 1024
u_char *string_buf;
size_t string_len;
int string_type;
#define STRING_SYSTEM 0
#define STRING_APPLICATION 1
#define STRING_NAME 2
u_char param_buf[64];
size_t param_len;
struct utf8_data utf8data;
u_char input_buf[256];
size_t input_len;
u_char intermediate;
void *(*state)(u_char, struct input_ctx *);
int param_list[24]; /* -1 not present */
u_int param_list_len;
u_char private;
ARRAY_DECL(, struct input_arg) args;
struct utf8_data utf8data;
int ch;
int flags;
#define INPUT_DISCARD 0x1
const struct input_state *state;
};
/*
@ -1824,6 +1817,10 @@ int window_pane_spawn(struct window_pane *, const char *,
const char *, const char *, struct environ *,
struct termios *, char **);
void window_pane_resize(struct window_pane *, u_int, u_int);
void window_pane_alternate_on(
struct window_pane *, struct grid_cell *);
void window_pane_alternate_off(
struct window_pane *, struct grid_cell *);
int window_pane_set_mode(
struct window_pane *, const struct window_mode *);
void window_pane_reset_mode(struct window_pane *);

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.126 2010-02-08 18:10:07 tcunha Exp $ */
/* $Id: window.c,v 1.127 2010-03-15 12:51:23 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -630,6 +630,81 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
fatal("ioctl failed");
}
/*
* Enter alternative screen mode. A copy of the visible screen is saved and the
* history is not updated
*/
void
window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc)
{
struct screen *s = &wp->base;
u_int sx, sy;
if (wp->saved_grid != NULL)
return;
if (!options_get_number(&wp->window->options, "alternate-screen"))
return;
sx = screen_size_x(s);
sy = screen_size_y(s);
wp->saved_grid = grid_create(sx, sy, 0);
grid_duplicate_lines(wp->saved_grid, 0, s->grid, screen_hsize(s), sy);
wp->saved_cx = s->cx;
wp->saved_cy = s->cy;
memcpy(&wp->saved_cell, gc, sizeof wp->saved_cell);
grid_view_clear(s->grid, 0, 0, sx, sy);
wp->base.grid->flags &= ~GRID_HISTORY;
wp->flags |= PANE_REDRAW;
}
/* Exit alternate screen mode and restore the copied grid. */
void
window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc)
{
struct screen *s = &wp->base;
u_int sx, sy;
if (wp->saved_grid == NULL)
return;
if (!options_get_number(&wp->window->options, "alternate-screen"))
return;
sx = screen_size_x(s);
sy = screen_size_y(s);
/*
* If the current size is bigger, temporarily resize to the old size
* before copying back.
*/
if (sy > wp->saved_grid->sy)
screen_resize(s, sx, wp->saved_grid->sy);
/* Restore the grid, cursor position and cell. */
grid_duplicate_lines(s->grid, screen_hsize(s), wp->saved_grid, 0, sy);
s->cx = wp->saved_cx;
if (s->cx > screen_size_x(s) - 1)
s->cx = screen_size_x(s) - 1;
s->cy = wp->saved_cy;
if (s->cy > screen_size_y(s) - 1)
s->cy = screen_size_y(s) - 1;
memcpy(gc, &wp->saved_cell, sizeof *gc);
/*
* Turn history back on (so resize can use it) and then resize back to
* the current size.
*/
wp->base.grid->flags |= GRID_HISTORY;
if (sy > wp->saved_grid->sy)
screen_resize(s, sx, sy);
grid_destroy(wp->saved_grid);
wp->saved_grid = NULL;
wp->flags |= PANE_REDRAW;
}
int
window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode)
{