summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2014-01-31 14:19:24 +0000
committernicm <nicm>2014-01-31 14:19:24 +0000
commit9f02feb9d089b1a4639afb52ab0e8212eeb55a7c (patch)
treeed38ce53a7d8887a569e50fe848774555d8fd327
parent72d1be5ddd0dbc87f99d5430bb4ee4a295ea193b (diff)
Break up and simplify screen_redraw_screen.
-rw-r--r--screen-redraw.c129
-rw-r--r--server-client.c6
-rw-r--r--tmux.h2
3 files changed, 72 insertions, 65 deletions
diff --git a/screen-redraw.c b/screen-redraw.c
index a67cb952..3a082cbf 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -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/server-client.c b/server-client.c
index c6257edb..5a6cb7d9 100644
--- a/server-client.c
+++ b/server-client.c
@@ -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/tmux.h b/tmux.h
index b8fd445c..c6919622 100644
--- a/tmux.h
+++ b/tmux.h
@@ -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 */