From dbf52facd2fa678a9705428d881a9d99188d401d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 2 Apr 2009 21:08:15 +0000 Subject: [PATCH] Change scroll/pane redraws to only redraw the single pane affected rather than the entire window. --- CHANGES | 6 +++--- screen-redraw.c | 20 +++++++++++++++----- server.c | 36 ++++++++++++++++++++++++++++-------- tmux.h | 4 +++- tty.c | 6 ++---- 5 files changed, 51 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index 635dc812..af260d39 100644 --- a/CHANGES +++ b/CHANGES @@ -1,12 +1,12 @@ 02 April 2009 +* Change scroll/pane redraws to only redraw the single pane affected rather + than the entire window. * If redrawing the region would mean redrawing > half the pane, just schedule to redraw the entire window. Also add a flag to skip updating the window any further if it is scheduled to be redrawn. This has the effect of batching multiple redraws together. - Redraws should be moved to the pane level later. - 01 April 2009 * Basic horizontal splitting and layout management. Still some redraw and other @@ -1194,7 +1194,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.269 2009-04-02 20:30:17 nicm Exp $ +$Id: CHANGES,v 1.270 2009-04-02 21:08:13 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 ms diff --git a/screen-redraw.c b/screen-redraw.c index dda04f85..99db773b 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1,4 +1,4 @@ -/* $Id: screen-redraw.c,v 1.33 2009-04-01 21:09:01 nicm Exp $ */ +/* $Id: screen-redraw.c,v 1.34 2009-04-02 21:08:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -109,7 +109,7 @@ screen_redraw_screen(struct client *c) tty_putc(&c->tty, '|'); } } - + /* Draw top and bottom borders. */ if (wp->yoff > 0) { tty_cursor(tty, wp->xoff, wp->yoff - 1, 0, 0); @@ -121,16 +121,26 @@ screen_redraw_screen(struct client *c) for (i = 0; i < sx; i++) tty_putc(tty, '-'); } - + /* Draw the pane. */ - for (i = 0; i < sy; i++) - tty_draw_line(tty, s, i, wp->xoff, wp->yoff); + screen_redraw_pane(c, wp); } /* Draw the status line. */ screen_redraw_status(c); } +/* Draw a single pane. */ +void +screen_redraw_pane(struct client *c, struct window_pane *wp) +{ + u_int i; + + for (i = 0; i < wp->sy; i++) + tty_draw_line(&c->tty, wp->screen, i, wp->xoff, wp->yoff); +} + + /* Draw the status line. */ void screen_redraw_status(struct client *c) diff --git a/server.c b/server.c index 0ce5395d..2324f50e 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.135 2009-04-02 20:30:20 nicm Exp $ */ +/* $Id: server.c,v 1.136 2009-04-02 21:08:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -480,9 +480,10 @@ server_handle_windows(struct pollfd **pfd) void server_check_redraw(struct client *c) { - struct session *s; - char title[512]; - int flags, redraw; + struct session *s; + struct window_pane *wp; + char title[512]; + int flags, redraw; if (c == NULL || c->session == NULL) return; @@ -520,6 +521,11 @@ server_check_redraw(struct client *c) else screen_redraw_screen(c); c->flags &= ~CLIENT_STATUS; + } else { + TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { + if (wp->flags & PANE_REDRAW) + screen_redraw_pane(c, wp); + } } if (c->flags & CLIENT_STATUS) @@ -602,8 +608,10 @@ server_check_timers(struct client *c) void server_fill_clients(struct pollfd **pfd) { - struct client *c; - u_int i; + struct client *c; + struct window *w; + struct window_pane *wp; + u_int i; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); @@ -632,6 +640,20 @@ server_fill_clients(struct pollfd **pfd) } (*pfd)++; } + + /* + * Clear any window redraw flags (will have been redrawn as part of * + * client). + */ + for (i = 0; i < ARRAY_LENGTH(&windows); i++) { + w = ARRAY_ITEM(&windows, i); + if (w == NULL) + continue; + + w->flags &= ~WINDOW_REDRAW; + TAILQ_FOREACH(wp, &w->panes, entry) + wp->flags &= ~PANE_REDRAW; + } } /* Handle client pollfds. */ @@ -921,8 +943,6 @@ server_check_window(struct window *w) wp = wq; } - w->flags &= ~WINDOW_REDRAW; /* redrawn as part of client */ - if (!destroyed) return; diff --git a/tmux.h b/tmux.h index 1277c5b1..b6f3d087 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.296 2009-04-02 20:30:20 nicm Exp $ */ +/* $Id: tmux.h,v 1.297 2009-04-02 21:08:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -656,6 +656,7 @@ struct window_pane { int flags; #define PANE_HIDDEN 0x1 #define PANE_RESTART 0x2 +#define PANE_REDRAW 0x4 char *cmd; char *cwd; @@ -1466,6 +1467,7 @@ void screen_write_cell( /* screen-redraw.c */ void screen_redraw_screen(struct client *); +void screen_redraw_pane(struct client *, struct window_pane *); void screen_redraw_status(struct client *); /* screen.c */ diff --git a/tty.c b/tty.c index 9c4f1484..3376c605 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.91 2009-04-02 20:30:23 nicm Exp $ */ +/* $Id: tty.c,v 1.92 2009-04-02 21:08:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -395,11 +395,9 @@ tty_redraw_region(struct tty *tty, struct window_pane *wp) * most cases, this is likely to be followed by some more scrolling - * without this, the entire pane ends up being redrawn many times which * can be much more data. - * - * XXX Should just schedule to redraw this pane... */ if (s->old_rupper - s->old_rlower >= screen_size_y(s) / 2) { - server_redraw_window(wp->window); + wp->flags |= PANE_REDRAW; return; }