=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.168 retrieving revision 1.169 diff -u -r1.168 -r1.169 --- src/usr.bin/tmux/status.c 2017/05/29 20:42:53 1.168 +++ src/usr.bin/tmux/status.c 2017/10/16 19:30:53 1.169 @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.168 2017/05/29 20:42:53 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.169 2017/10/16 19:30:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -210,11 +210,26 @@ { struct session *s = c->session; + if (c->flags & CLIENT_STATUSOFF) + return (-1); if (s->statusat != 1) return (s->statusat); - return (c->tty.sy - 1); + return (c->tty.sy - status_line_size(s)); } +/* + * Get size of status line for session. 0 means off. Note that status line may + * be forced off for an individual client if it is too small (the + * CLIENT_STATUSOFF flag is set for this). + */ +u_int +status_line_size(struct session *s) +{ + if (s->statusat == -1) + return (0); + return (1); +} + /* Retrieve options for left string. */ static char * status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc, @@ -296,7 +311,7 @@ time_t t; char *left, *right; const char *sep; - u_int offset, needed; + u_int offset, needed, lines; u_int wlstart, wlwidth, wlavailable, wloffset, wlsize; size_t llen, rlen, seplen; int larrow, rarrow; @@ -309,7 +324,8 @@ } /* No status line? */ - if (c->tty.sy == 0 || !options_get_number(s->options, "status")) + lines = status_line_size(s); + if (c->tty.sy == 0 || lines == 0) return (1); left = right = NULL; larrow = rarrow = 0; @@ -322,14 +338,13 @@ /* Create the target screen. */ memcpy(&old_status, &c->status, sizeof old_status); - screen_init(&c->status, c->tty.sx, 1, 0); + screen_init(&c->status, c->tty.sx, lines, 0); screen_write_start(&ctx, NULL, &c->status); - for (offset = 0; offset < c->tty.sx; offset++) - screen_write_putc(&ctx, &stdgc, ' '); + screen_write_clearscreen(&ctx, stdgc.bg); screen_write_stop(&ctx); - /* If the height is one line, blank status line. */ - if (c->tty.sy <= 1) + /* If the height is too small, blank status line. */ + if (c->tty.sy < lines) goto out; /* Work out left and right strings. */ @@ -637,12 +652,18 @@ struct screen old_status; size_t len; struct grid_cell gc; + u_int lines; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); - screen_init(&c->status, c->tty.sx, 1, 0); + lines = status_line_size(c->session); + if (lines <= 1) + screen_init(&c->status, c->tty.sx, 1, 0); + else + screen_init(&c->status, c->tty.sx, lines, 0); + len = screen_write_strlen("%s", c->message_string); if (len > c->tty.sx) len = c->tty.sx; @@ -650,12 +671,9 @@ style_apply(&gc, s->options, "message-style"); screen_write_start(&ctx, NULL, &c->status); - - screen_write_cursormove(&ctx, 0, 0); + screen_write_clearscreen(&ctx, gc.bg); + screen_write_cursormove(&ctx, 0, lines - 1); screen_write_nputs(&ctx, len, &gc, "%s", c->message_string); - for (; len < c->tty.sx; len++) - screen_write_putc(&ctx, &gc, ' '); - screen_write_stop(&ctx); if (grid_compare(c->status.grid, old_status.grid) == 0) { @@ -782,13 +800,25 @@ struct session *s = c->session; struct screen old_status; u_int i, offset, left, start, pcursor, pwidth, width; + u_int lines; + size_t len, off; struct grid_cell gc, cursorgc; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); - screen_init(&c->status, c->tty.sx, 1, 0); + lines = status_line_size(c->session); + if (lines <= 1) + screen_init(&c->status, c->tty.sx, 1, 0); + else + screen_init(&c->status, c->tty.sx, lines, 0); + + len = screen_write_strlen("%s", c->prompt_string); + if (len > c->tty.sx) + len = c->tty.sx; + off = 0; + if (c->prompt_mode == PROMPT_COMMAND) style_apply(&gc, s->options, "message-command-style"); else @@ -802,11 +832,10 @@ start = c->tty.sx; screen_write_start(&ctx, NULL, &c->status); - screen_write_cursormove(&ctx, 0, 0); + screen_write_clearscreen(&ctx, gc.bg); + screen_write_cursormove(&ctx, 0, lines - 1); screen_write_nputs(&ctx, start, &gc, "%s", c->prompt_string); - while (c->status.cx < screen_size_x(&c->status)) - screen_write_putc(&ctx, &gc, ' '); - screen_write_cursormove(&ctx, start, 0); + screen_write_cursormove(&ctx, start, lines - 1); left = c->tty.sx - start; if (left == 0)