version 1.168, 2017/05/29 20:42:53 |
version 1.169, 2017/10/16 19:30:53 |
|
|
{ |
{ |
struct session *s = c->session; |
struct session *s = c->session; |
|
|
|
if (c->flags & CLIENT_STATUSOFF) |
|
return (-1); |
if (s->statusat != 1) |
if (s->statusat != 1) |
return (s->statusat); |
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. */ |
/* Retrieve options for left string. */ |
static char * |
static char * |
status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc, |
status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc, |
|
|
time_t t; |
time_t t; |
char *left, *right; |
char *left, *right; |
const char *sep; |
const char *sep; |
u_int offset, needed; |
u_int offset, needed, lines; |
u_int wlstart, wlwidth, wlavailable, wloffset, wlsize; |
u_int wlstart, wlwidth, wlavailable, wloffset, wlsize; |
size_t llen, rlen, seplen; |
size_t llen, rlen, seplen; |
int larrow, rarrow; |
int larrow, rarrow; |
|
|
} |
} |
|
|
/* No status line? */ |
/* 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); |
return (1); |
left = right = NULL; |
left = right = NULL; |
larrow = rarrow = 0; |
larrow = rarrow = 0; |
|
|
|
|
/* Create the target screen. */ |
/* Create the target screen. */ |
memcpy(&old_status, &c->status, sizeof old_status); |
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); |
screen_write_start(&ctx, NULL, &c->status); |
for (offset = 0; offset < c->tty.sx; offset++) |
screen_write_clearscreen(&ctx, stdgc.bg); |
screen_write_putc(&ctx, &stdgc, ' '); |
|
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
|
|
/* If the height is one line, blank status line. */ |
/* If the height is too small, blank status line. */ |
if (c->tty.sy <= 1) |
if (c->tty.sy < lines) |
goto out; |
goto out; |
|
|
/* Work out left and right strings. */ |
/* Work out left and right strings. */ |
|
|
struct screen old_status; |
struct screen old_status; |
size_t len; |
size_t len; |
struct grid_cell gc; |
struct grid_cell gc; |
|
u_int lines; |
|
|
if (c->tty.sx == 0 || c->tty.sy == 0) |
if (c->tty.sx == 0 || c->tty.sy == 0) |
return (0); |
return (0); |
memcpy(&old_status, &c->status, sizeof old_status); |
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); |
len = screen_write_strlen("%s", c->message_string); |
if (len > c->tty.sx) |
if (len > c->tty.sx) |
len = c->tty.sx; |
len = c->tty.sx; |
|
|
style_apply(&gc, s->options, "message-style"); |
style_apply(&gc, s->options, "message-style"); |
|
|
screen_write_start(&ctx, NULL, &c->status); |
screen_write_start(&ctx, NULL, &c->status); |
|
screen_write_clearscreen(&ctx, gc.bg); |
screen_write_cursormove(&ctx, 0, 0); |
screen_write_cursormove(&ctx, 0, lines - 1); |
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string); |
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); |
screen_write_stop(&ctx); |
|
|
if (grid_compare(c->status.grid, old_status.grid) == 0) { |
if (grid_compare(c->status.grid, old_status.grid) == 0) { |
|
|
struct session *s = c->session; |
struct session *s = c->session; |
struct screen old_status; |
struct screen old_status; |
u_int i, offset, left, start, pcursor, pwidth, width; |
u_int i, offset, left, start, pcursor, pwidth, width; |
|
u_int lines; |
|
size_t len, off; |
struct grid_cell gc, cursorgc; |
struct grid_cell gc, cursorgc; |
|
|
if (c->tty.sx == 0 || c->tty.sy == 0) |
if (c->tty.sx == 0 || c->tty.sy == 0) |
return (0); |
return (0); |
memcpy(&old_status, &c->status, sizeof old_status); |
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) |
if (c->prompt_mode == PROMPT_COMMAND) |
style_apply(&gc, s->options, "message-command-style"); |
style_apply(&gc, s->options, "message-command-style"); |
else |
else |
|
|
start = c->tty.sx; |
start = c->tty.sx; |
|
|
screen_write_start(&ctx, NULL, &c->status); |
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); |
screen_write_nputs(&ctx, start, &gc, "%s", c->prompt_string); |
while (c->status.cx < screen_size_x(&c->status)) |
screen_write_cursormove(&ctx, start, lines - 1); |
screen_write_putc(&ctx, &gc, ' '); |
|
screen_write_cursormove(&ctx, start, 0); |
|
|
|
left = c->tty.sx - start; |
left = c->tty.sx - start; |
if (left == 0) |
if (left == 0) |