diff options
Diffstat (limited to 'screen-redraw.c')
-rw-r--r-- | screen-redraw.c | 174 |
1 files changed, 85 insertions, 89 deletions
diff --git a/screen-redraw.c b/screen-redraw.c index fc90c3a2..7c989cca 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1,4 +1,4 @@ -/* $Id: screen-redraw.c,v 1.30 2009-03-31 18:39:45 nicm Exp $ */ +/* $Id: screen-redraw.c,v 1.31 2009-04-01 18:21:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -22,119 +22,115 @@ #include "tmux.h" -void screen_redraw_blankx(struct client *, u_int, u_int); -void screen_redraw_blanky(struct client *, u_int, u_int, char); -void screen_redraw_line(struct client *, struct screen *, u_int, u_int); +int screen_redraw_check_cell(struct client *, u_int, u_int); -/* Redraw entire screen.. */ -void -screen_redraw_screen(struct client *c, struct screen *s) +/* Check if cell inside a pane. */ +int +screen_redraw_check_cell(struct client *c, u_int px, u_int py) { struct window *w = c->session->curw->window; struct window_pane *wp; - u_int i, cx, cy, sy; - int status; - /* Override the normal screen if one is given. */ - if (s != NULL) { - for (i = 0; i < screen_size_y(s); i++) - screen_redraw_line(c, s, 0, i); - screen_redraw_status(c); - return; - } - - status = options_get_number(&c->session->options, "status"); + if (px > w->sx || py > w->sy) + return (0); - /* Fill in empty space on the right. */ - if (w->sx < c->tty.sx) - screen_redraw_blankx(c, w->sx, c->tty.sx - w->sx); - - /* Draw the panes. */ TAILQ_FOREACH(wp, &w->panes, entry) { - s = wp->screen; - - sy = screen_size_y(s); - - cx = s->cx; - cy = s->cy; - if (wp->yoff + sy <= w->sy) { - for (i = 0; i < sy; i++) { - if (wp->yoff + i != c->tty.sy - 1) - screen_redraw_line(c, s, wp->yoff, i); - } - if (TAILQ_NEXT(wp, entry) != NULL) - screen_redraw_blanky(c, wp->yoff + sy, 1, '-'); + /* Inside pane. */ + if (px >= wp->xoff && px < wp->xoff + wp->sx && + py >= wp->yoff && py < wp->yoff + wp->sy) + return (1); + + /* Left/right borders. */ + if (py >= wp->yoff && py < wp->yoff + wp->sy) { + if (wp->xoff != 0 && px == wp->xoff - 1) + return (1); + if (px == wp->xoff + wp->sx) + return (1); } - s->cx = cx; - s->cy = cy; - } - - /* Fill in empty space below. */ - if (w->sy < c->tty.sy - status) - screen_redraw_blanky(c, w->sy, c->tty.sy - status - w->sy, '='); - /* Draw right border line. */ - if (w->sx < c->tty.sx) { - for (i = 0; i < c->tty.sy; i++) { - tty_putcode2(&c->tty, TTYC_CUP, i, w->sx); - tty_putc(&c->tty, '|'); + /* Top/bottom borders. */ + if (px >= wp->xoff && px < wp->xoff + wp->sx) { + if (wp->yoff != 0 && py == wp->yoff - 1) + return (1); + if (py == wp->yoff + wp->sy) + return (1); } } - /* Draw the status line. */ - screen_redraw_status(c); + return (0); } -/* Draw the status line. */ +/* Redraw entire screen.. */ void -screen_redraw_status(struct client *c) +screen_redraw_screen(struct client *c) { - screen_redraw_line(c, &c->status, c->tty.sy - 1, 0); -} + struct window *w = c->session->curw->window; + struct tty *tty = &c->tty; + struct window_pane *wp; + struct screen *s; + u_int i, j, sx, sy; + int status; -/* Draw blank columns. */ -void -screen_redraw_blankx(struct client *c, u_int ox, u_int nx) -{ - u_int i, j; + /* Get status line, er, status. */ + status = options_get_number(&c->session->options, "status"); - tty_putcode(&c->tty, TTYC_SGR0); - for (j = 0; j < c->tty.sy; j++) { - tty_putcode2(&c->tty, TTYC_CUP, j, ox); - for (i = 0; i < nx; i++) - tty_putc(&c->tty, ' '); + /* Clear the screen. */ + tty_reset(tty); + for (j = 0; j < tty->sy - status; j++) { + for (i = 0; i < tty->sx; i++) { + if (!screen_redraw_check_cell(c, i, j)) { + tty_cursor(tty, i, j, 0, 0); + tty_putc(tty, '.'); + } + } } - c->tty.cx = UINT_MAX; - c->tty.cy = UINT_MAX; - memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell); -} + /* Draw the panes. */ + TAILQ_FOREACH(wp, &w->panes, entry) { + tty_reset(tty); -/* Draw blank lines. */ -void -screen_redraw_blanky(struct client *c, u_int oy, u_int ny, char ch) -{ - u_int i, j; - - tty_putcode(&c->tty, TTYC_SGR0); - for (j = 0; j < ny; j++) { - tty_putcode2(&c->tty, TTYC_CUP, oy + j, 0); - for (i = 0; i < c->tty.sx; i++) { - if (j == 0) - tty_putc(&c->tty, ch); - else - tty_putc(&c->tty, ' '); + s = wp->screen; + sx = wp->sx; + sy = wp->sy; + + /* Draw left and right borders. */ + if (wp->xoff > 0) { + for (i = wp->yoff; i < wp->yoff + sy; i++) { + tty_cursor(tty, wp->xoff - 1, i, 0, 0); + tty_putc(tty, '|'); + } + } + if (wp->xoff + sx < tty->sx) { + for (i = wp->yoff; i < wp->yoff + sy; i++) { + tty_cursor(tty, wp->xoff + sx, i, 0, 0); + tty_putc(&c->tty, '|'); + } } - } - c->tty.cx = UINT_MAX; - c->tty.cy = UINT_MAX; - memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell); + /* Draw top and bottom borders. */ + if (wp->yoff > 0) { + tty_cursor(tty, wp->xoff, wp->yoff - 1, 0, 0); + for (i = 0; i < sx; i++) + tty_putc(tty, '-'); + } + if (wp->yoff + sy < tty->sy) { + tty_cursor(tty, wp->xoff, wp->yoff + sy, 0, 0); + 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); + } + + /* Draw the status line. */ + screen_redraw_status(c); } -/* Draw a line. */ +/* Draw the status line. */ void -screen_redraw_line(struct client *c, struct screen *s, u_int oy, u_int py) +screen_redraw_status(struct client *c) { - tty_draw_line(&c->tty, s, py, oy); + tty_draw_line(&c->tty, &c->status, 0, 0, c->tty.sy - 1); } |