summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/screen-redraw.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-01-29 09:37:03 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-01-29 09:37:03 +0000
commit4a96d6dfb62a58267d3ce34851e37e97aa3338ca (patch)
tree9ee015684b211fcc816b39f3decbd272bf45aa49 /usr.bin/tmux/screen-redraw.c
parent0ea62aa939f3e8a6aebe45cd30d760e5f7a6616f (diff)
Add an option to move the status line to the top of the screen,
requested by many.
Diffstat (limited to 'usr.bin/tmux/screen-redraw.c')
-rw-r--r--usr.bin/tmux/screen-redraw.c63
1 files changed, 44 insertions, 19 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c
index 6e8994882d6..e2cdd144dca 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.20 2012/01/21 23:45:44 nicm Exp $ */
+/* $OpenBSD: screen-redraw.c,v 1.21 2012/01/29 09:37:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -170,25 +170,33 @@ void
screen_redraw_screen(struct client *c, int status_only, int borders_only)
{
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;
- int status, fg, bg;
+ u_int i, j, type, top;
+ int status, spos, fg, bg;
/* Suspended clients should not be updated. */
if (c->flags & CLIENT_SUSPENDED)
return;
/* Get status line, er, status. */
+ spos = options_get_number(oo, "status-position");
if (c->message_string != NULL || c->prompt_string != NULL)
status = 1;
else
- status = options_get_number(&c->session->options, "status");
+ status = options_get_number(oo, "status");
+ top = 0;
+ if (status && spos == 0)
+ top = 1;
/* If only drawing status and it is present, don't need the rest. */
if (status_only && status) {
- tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
+ 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);
return;
}
@@ -198,19 +206,23 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
memcpy(&active_gc, &grid_default_cell, sizeof active_gc);
active_gc.data = other_gc.data = 'x'; /* not space */
active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET;
- fg = options_get_number(&c->session->options, "pane-border-fg");
+ fg = options_get_number(oo, "pane-border-fg");
colour_set_fg(&other_gc, fg);
- bg = options_get_number(&c->session->options, "pane-border-bg");
+ bg = options_get_number(oo, "pane-border-bg");
colour_set_bg(&other_gc, bg);
- fg = options_get_number(&c->session->options, "pane-active-border-fg");
+ fg = options_get_number(oo, "pane-active-border-fg");
colour_set_fg(&active_gc, fg);
- bg = options_get_number(&c->session->options, "pane-active-border-bg");
+ bg = options_get_number(oo, "pane-active-border-bg");
colour_set_bg(&active_gc, bg);
/* Draw background and borders. */
for (j = 0; j < tty->sy - status; j++) {
- if (status_only && j != tty->sy - 1)
- continue;
+ 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);
if (type == CELL_INSIDE)
@@ -219,7 +231,7 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
tty_attributes(tty, &active_gc);
else
tty_attributes(tty, &other_gc);
- tty_cursor(tty, i, j);
+ tty_cursor(tty, i, top + j);
tty_putc(tty, CELL_BORDERS[type]);
}
}
@@ -233,17 +245,26 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
if (!window_pane_visible(wp))
continue;
for (i = 0; i < wp->sy; i++) {
- if (status_only && wp->yoff + i != tty->sy - 1)
- continue;
- tty_draw_line(tty, wp->screen, i, wp->xoff, wp->yoff);
+ 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);
}
if (c->flags & CLIENT_IDENTIFY)
screen_redraw_draw_number(c, wp);
}
/* Draw the status line. */
- if (status)
- tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
+ 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);
}
@@ -251,10 +272,14 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
void
screen_redraw_pane(struct client *c, struct window_pane *wp)
{
- u_int i;
+ u_int i, yoff;
+
+ 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, wp->yoff);
+ tty_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff);
tty_reset(&c->tty);
}