diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-01-31 14:19:25 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-01-31 14:19:25 +0000 |
commit | eab9a7645c946f96c9980063a89a9935dd77b134 (patch) | |
tree | f281a236a2f51f8487c8b129c78976de9f4a50e2 /usr.bin/tmux | |
parent | 438a95e2ebf7c0539074dd1afb73624254d563f7 (diff) |
Break up and simplify screen_redraw_screen.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 131 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
3 files changed, 75 insertions, 68 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index 4840c680a26..2cbe0bb3299 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.25 2014/01/28 23:07:09 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.26 2014/01/31 14:19:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,6 +29,9 @@ int screen_redraw_check_cell(struct client *, u_int, u_int, int screen_redraw_check_active(u_int, u_int, int, struct window *, struct window_pane *); +void screen_redraw_draw_borders(struct client *, int, u_int); +void screen_redraw_draw_panes(struct client *, u_int); +void screen_redraw_draw_status(struct client *, u_int); void screen_redraw_draw_number(struct client *, struct window_pane *); #define CELL_INSIDE 0 @@ -216,15 +219,13 @@ screen_redraw_check_active(u_int px, u_int py, int type, struct window *w, /* Redraw entire screen. */ void -screen_redraw_screen(struct client *c, int status_only, int borders_only) +screen_redraw_screen(struct client *c, int draw_panes, int draw_status, + int draw_borders) { - struct window *w = c->session->curw->window; - struct options *oo = &c->session->options; - struct tty *tty = &c->tty; - struct window_pane *wp; - struct grid_cell active_gc, other_gc; - u_int i, j, type, top; - int status, spos; + struct options *oo = &c->session->options; + struct tty *tty = &c->tty; + u_int top; + int status, spos; /* Suspended clients should not be updated. */ if (c->flags & CLIENT_SUSPENDED) @@ -239,30 +240,52 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only) top = 0; if (status && spos == 0) top = 1; + if (!status) + draw_status = 0; + + if (draw_borders) + screen_redraw_draw_borders(c, status, top); + if (draw_panes) + screen_redraw_draw_panes(c, top); + if (draw_status) + screen_redraw_draw_status(c, top); + tty_reset(tty); +} - /* If only drawing status and it is present, don't need the rest. */ - if (status_only && status) { - if (top) - tty_draw_line(tty, &c->status, 0, 0, 0); - else - tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1); - tty_reset(tty); +/* Draw a single pane. */ +void +screen_redraw_pane(struct client *c, struct window_pane *wp) +{ + u_int i, yoff; + + if (!window_pane_visible(wp)) return; - } - /* Set up pane border attributes. */ + yoff = wp->yoff; + if (status_at_line(c) == 0) + yoff++; + + for (i = 0; i < wp->sy; i++) + tty_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff); + tty_reset(&c->tty); +} + +/* Draw the borders. */ +void +screen_redraw_draw_borders(struct client *c, int status, u_int top) +{ + struct window *w = c->session->curw->window; + struct options *oo = &c->session->options; + struct tty *tty = &c->tty; + struct window_pane *wp; + struct grid_cell active_gc, other_gc; + u_int i, j, type; + style_apply(&other_gc, oo, "pane-border-style"); style_apply(&active_gc, oo, "pane-active-border-style"); - active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET; /* nuke existing */ + active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET; - /* Draw background and borders. */ for (j = 0; j < tty->sy - status; j++) { - if (status_only) { - if (spos == 1 && j != tty->sy - 1) - continue; - else if (spos == 0 && j != 0) - break; - } for (i = 0; i < tty->sx; i++) { type = screen_redraw_check_cell(c, i, j, &wp); if (type == CELL_INSIDE) @@ -275,55 +298,39 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only) tty_putc(tty, CELL_BORDERS[type]); } } +} - /* If only drawing borders, that's it. */ - if (borders_only) - return; +/* Draw the panes. */ +void +screen_redraw_draw_panes(struct client *c, u_int top) +{ + struct window *w = c->session->curw->window; + struct tty *tty = &c->tty; + struct window_pane *wp; + struct screen *s; + u_int i; - /* Draw the panes, if necessary. */ TAILQ_FOREACH(wp, &w->panes, entry) { if (!window_pane_visible(wp)) continue; - for (i = 0; i < wp->sy; i++) { - if (status_only) { - if (spos == 1 && wp->yoff + i != tty->sy - 1) - continue; - else if (spos == 0 && wp->yoff + i != 0) - break; - } - tty_draw_line( - tty, wp->screen, i, wp->xoff, top + wp->yoff); - } + s = wp->screen; + for (i = 0; i < wp->sy; i++) + tty_draw_line(tty, s, i, wp->xoff, top + wp->yoff); if (c->flags & CLIENT_IDENTIFY) screen_redraw_draw_number(c, wp); } - - /* Draw the status line. */ - if (status) { - if (top) - tty_draw_line(tty, &c->status, 0, 0, 0); - else - tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1); - } - tty_reset(tty); } -/* Draw a single pane. */ +/* Draw the status line. */ void -screen_redraw_pane(struct client *c, struct window_pane *wp) +screen_redraw_draw_status(struct client *c, u_int top) { - u_int i, yoff; + struct tty *tty = &c->tty; - if (!window_pane_visible(wp)) - return; - - yoff = wp->yoff; - if (status_at_line(c) == 0) - yoff++; - - for (i = 0; i < wp->sy; i++) - tty_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff); - tty_reset(&c->tty); + if (top) + tty_draw_line(tty, &c->status, 0, 0, 0); + else + tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1); } /* Draw number on a pane. */ diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 16f30e552a2..3c6de928d9a 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.114 2013/11/13 20:43:37 benno Exp $ */ +/* $OpenBSD: server-client.c,v 1.115 2014/01/31 14:19:24 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -743,7 +743,7 @@ server_client_check_redraw(struct client *c) } if (c->flags & CLIENT_REDRAW) { - screen_redraw_screen(c, 0, 0); + screen_redraw_screen(c, 1, 1, 1); c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS); } else if (c->flags & CLIENT_REDRAWWINDOW) { TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) @@ -757,10 +757,10 @@ server_client_check_redraw(struct client *c) } if (c->flags & CLIENT_BORDERS) - screen_redraw_screen(c, 0, 1); + screen_redraw_screen(c, 0, 0, 1); if (c->flags & CLIENT_STATUS) - screen_redraw_screen(c, 1, 0); + screen_redraw_screen(c, 0, 1, 0); c->tty.flags |= flags; diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 6ba486db2c0..188b629a848 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.435 2014/01/28 23:07:09 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.436 2014/01/31 14:19:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -2084,7 +2084,7 @@ void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int); void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int); /* screen-redraw.c */ -void screen_redraw_screen(struct client *, int, int); +void screen_redraw_screen(struct client *, int, int, int); void screen_redraw_pane(struct client *, struct window_pane *); /* screen.c */ |