From d0984b890b84c2fac9cdcfbc44121c1171e06531 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 21 Nov 2007 19:53:57 +0000 Subject: [PATCH] Sort out cursors with a new flag - BACKGROUND - for window modes. Free text on more exit. --- screen.c | 4 ++-- server-fn.c | 4 ++-- status.c | 4 ++-- tmux.h | 5 +++-- window-more.c | 14 ++++++++++---- window-scroll.c | 8 +++++--- window.c | 4 +--- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/screen.c b/screen.c index 9b1a67b8..cf5d8167 100644 --- a/screen.c +++ b/screen.c @@ -1,4 +1,4 @@ -/* $Id: screen.c,v 1.32 2007-11-21 18:24:49 nicm Exp $ */ +/* $Id: screen.c,v 1.33 2007-11-21 19:53:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -250,7 +250,7 @@ screen_draw_stop(struct screen_draw_ctx *ctx) if (ctx->attr != s->attr || ctx->colr != s->colr) input_store_two(b, CODE_ATTRIBUTES, s->attr, s->colr); - if (s->mode & MODE_CURSOR) + if (!(s->mode & MODE_BACKGROUND) && s->mode & MODE_CURSOR) input_store_zero(b, CODE_CURSORON); } diff --git a/server-fn.c b/server-fn.c index af651a81..d02fffd5 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.27 2007-11-21 13:11:41 nicm Exp $ */ +/* $Id: server-fn.c,v 1.28 2007-11-21 19:53:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -180,7 +180,7 @@ server_clear_client(struct client *c) input_store_zero(c->out, CODE_CLEARLINE); } input_store_two(c->out, CODE_CURSORMOVE, s->cy + 1, s->cx + 1); - if (s->mode & MODE_CURSOR) + if (!(s->mode & MODE_BACKGROUND) && s->mode & MODE_CURSOR) input_store_zero(c->out, CODE_CURSORON); size = BUFFER_USED(c->out) - size; diff --git a/status.c b/status.c index e1bb046a..8892b652 100644 --- a/status.c +++ b/status.c @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.10 2007-11-21 13:11:41 nicm Exp $ */ +/* $Id: status.c,v 1.11 2007-11-21 19:53:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -57,7 +57,7 @@ status_write(struct client *c) input_store_two(b, CODE_ATTRIBUTES, s->attr, s->colr); input_store_two(b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1); - if (!(s->mode & MODE_HIDDEN) && s->mode & MODE_CURSOR) + if (!(s->mode & MODE_BACKGROUND) && s->mode & MODE_CURSOR) input_store_zero(b, CODE_CURSORON); } diff --git a/tmux.h b/tmux.h index 96632eac..deff2cc2 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.89 2007-11-21 19:44:05 nicm Exp $ */ +/* $Id: tmux.h,v 1.90 2007-11-21 19:53:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -340,6 +340,7 @@ struct msg_resize_data { #define MODE_KKEYPAD 0x08 #define MODE_SAVED 0x10 #define MODE_HIDDEN 0x20 +#define MODE_BACKGROUND 0x40 /* * Virtual screen. This is stored as three blocks of 8-bit values, one for @@ -407,7 +408,7 @@ struct screen_draw_ctx { #define screen_in_y(s, y) ((y) < screen_size_y(s)) #define screen_in_region(s, y) ((y) >= (s)->rupper && (y) <= (s)->rlower) -#define screen_hidden(s) ((s)->mode & MODE_HIDDEN) +#define screen_hidden(s) ((s)->mode & (MODE_HIDDEN|MODE_BACKGROUND)) /* Screen default contents. */ #define SCREEN_DEFDATA ' ' diff --git a/window-more.c b/window-more.c index 2dd657ec..00ace798 100644 --- a/window-more.c +++ b/window-more.c @@ -1,4 +1,4 @@ -/* $Id: window-more.c,v 1.1 2007-11-21 19:44:05 nicm Exp $ */ +/* $Id: window-more.c,v 1.2 2007-11-21 19:53:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -73,6 +73,8 @@ window_more_init(struct window *w) w->modedata = data = xmalloc(sizeof *data); ARRAY_INIT(&data->list); data->top = 0; + + w->screen.mode |= MODE_BACKGROUND; } void @@ -167,7 +169,7 @@ void window_more_key(struct window *w, int key) { struct window_more_mode_data *data = w->modedata; - u_int top, sy; + u_int top, sy, i; sy = screen_size_y(&w->screen); @@ -176,9 +178,15 @@ window_more_key(struct window *w, int key) switch (key) { case 'Q': case 'q': + for (i = 0; i < ARRAY_LENGTH(&data->list); i++) + xfree(ARRAY_ITEM(&data->list, i)); + ARRAY_FREE(&data->list); + w->mode = NULL; xfree(w->modedata); + w->screen.mode &= ~MODE_BACKGROUND; + recalculate_sizes(); server_redraw_window_all(w); return; @@ -243,7 +251,6 @@ window_more_up_1(struct window *w) window_more_draw_position(w, &ctx); window_more_draw_line(w, &ctx, 1); screen_draw_stop(&ctx); - input_store_zero(c->out, CODE_CURSOROFF); size = BUFFER_USED(c->out) - size; hdr.type = MSG_DATA; @@ -284,7 +291,6 @@ window_more_down_1(struct window *w) window_more_draw_line(w, &ctx, screen_last_y(s)); window_more_draw_position(w, &ctx); screen_draw_stop(&ctx); - input_store_zero(c->out, CODE_CURSOROFF); size = BUFFER_USED(c->out) - size; hdr.type = MSG_DATA; diff --git a/window-scroll.c b/window-scroll.c index c9ded460..2d37f0d0 100644 --- a/window-scroll.c +++ b/window-scroll.c @@ -1,4 +1,4 @@ -/* $Id: window-scroll.c,v 1.8 2007-11-21 19:44:05 nicm Exp $ */ +/* $Id: window-scroll.c,v 1.9 2007-11-21 19:53:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -55,6 +55,8 @@ window_scroll_init(struct window *w) w->modedata = data = xmalloc(sizeof *data); data->ox = data->oy = 0; data->size = w->screen.hsize; + + w->screen.mode |= MODE_BACKGROUND; } void @@ -128,6 +130,8 @@ window_scroll_key(struct window *w, int key) w->mode = NULL; xfree(w->modedata); + w->screen.mode &= ~MODE_BACKGROUND; + recalculate_sizes(); server_redraw_window_all(w); return; @@ -200,7 +204,6 @@ window_scroll_up_1(struct window *w) window_scroll_draw_position(w, &ctx); screen_draw_line(&ctx, 1); /* nuke old position display */ screen_draw_stop(&ctx); - input_store_zero(c->out, CODE_CURSOROFF); size = BUFFER_USED(c->out) - size; hdr.type = MSG_DATA; @@ -241,7 +244,6 @@ window_scroll_down_1(struct window *w) screen_draw_line(&ctx, screen_last_y(s)); window_scroll_draw_position(w, &ctx); screen_draw_stop(&ctx); - input_store_zero(c->out, CODE_CURSOROFF); size = BUFFER_USED(c->out) - size; hdr.type = MSG_DATA; diff --git a/window.c b/window.c index 111f8109..bb2611a2 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.30 2007-11-21 18:24:49 nicm Exp $ */ +/* $Id: window.c,v 1.31 2007-11-21 19:53:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -276,8 +276,6 @@ window_resize(struct window *w, u_int sx, u_int sy) void window_parse(struct window *w, struct buffer *b) { - if (w->mode != NULL) - w->screen.mode |= MODE_HIDDEN; input_parse(w, b); }