Only screen-redraw.c needs to adjust for message or prompt when the

status line is off, get rid of tty_status_lines and just pass the
client into status_line_size so it can check the CLIENT_STATUSOFF flag
as well.
This commit is contained in:
Nicholas Marriott 2018-08-20 20:05:34 +01:00
parent 458b4b7701
commit 9f39470b38
6 changed files with 33 additions and 44 deletions

View File

@ -85,7 +85,7 @@ default_window_size(struct session *s, struct window *w, u_int *sx, u_int *sy,
continue; continue;
cx = c->tty.sx; cx = c->tty.sx;
cy = c->tty.sy - tty_status_lines(&c->tty); cy = c->tty.sy - status_line_size(c);
if (cx > *sx) if (cx > *sx)
*sx = cx; *sx = cx;
@ -105,7 +105,7 @@ default_window_size(struct session *s, struct window *w, u_int *sx, u_int *sy,
continue; continue;
cx = c->tty.sx; cx = c->tty.sx;
cy = c->tty.sy - tty_status_lines(&c->tty); cy = c->tty.sy - status_line_size(c);
if (cx < *sx) if (cx < *sx)
*sx = cx; *sx = cx;
@ -167,7 +167,7 @@ recalculate_sizes(void)
if ((flags & CLIENT_CONTROL) && (~flags & CLIENT_SIZECHANGED)) if ((flags & CLIENT_CONTROL) && (~flags & CLIENT_SIZECHANGED))
continue; continue;
if (c->tty.sy <= tty_status_lines(&c->tty)) if (c->tty.sy <= status_line_size(c))
c->flags |= CLIENT_STATUSOFF; c->flags |= CLIENT_STATUSOFF;
else else
c->flags &= ~CLIENT_STATUSOFF; c->flags &= ~CLIENT_STATUSOFF;
@ -200,7 +200,7 @@ recalculate_sizes(void)
continue; continue;
cx = c->tty.sx; cx = c->tty.sx;
cy = c->tty.sy - tty_status_lines(&c->tty); cy = c->tty.sy - status_line_size(c);
if (cx > sx) if (cx > sx)
sx = cx; sx = cx;
@ -222,7 +222,7 @@ recalculate_sizes(void)
continue; continue;
cx = c->tty.sx; cx = c->tty.sx;
cy = c->tty.sy - tty_status_lines(&c->tty); cy = c->tty.sy - status_line_size(c);
if (cx < sx) if (cx < sx)
sx = cx; sx = cx;

View File

@ -411,7 +411,9 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
memset(ctx, 0, sizeof *ctx); memset(ctx, 0, sizeof *ctx);
ctx->c = c; ctx->c = c;
ctx->lines = tty_status_lines(&c->tty); ctx->lines = status_line_size(c);
if (c->message_string != NULL || c->prompt_string != NULL)
ctx->lines = (ctx->lines == 0) ? 1 : ctx->lines;
if (ctx->lines != 0 && options_get_number(oo, "status-position") == 0) if (ctx->lines != 0 && options_get_number(oo, "status-position") == 0)
ctx->top = 1; ctx->top = 1;
ctx->pane_status = options_get_number(wo, "pane-border-status"); ctx->pane_status = options_get_number(wo, "pane-border-status");

View File

@ -1252,7 +1252,7 @@ server_client_reset_state(struct client *c)
cy = wp->yoff + s->cy - oy; cy = wp->yoff + s->cy - oy;
if (status_at_line(c) == 0) if (status_at_line(c) == 0)
cy += status_line_size(c->session); cy += status_line_size(c);
} }
if (!cursor) if (!cursor)
mode &= ~MODE_CURSOR; mode &= ~MODE_CURSOR;

View File

@ -214,17 +214,17 @@ status_at_line(struct client *c)
return (-1); return (-1);
if (s->statusat != 1) if (s->statusat != 1)
return (s->statusat); return (s->statusat);
return (c->tty.sy - status_line_size(s)); return (c->tty.sy - status_line_size(c));
} }
/* /* Get size of status line for client's session. 0 means off. */
* 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 u_int
status_line_size(struct session *s) status_line_size(struct client *c)
{ {
struct session *s = c->session;
if (c->flags & CLIENT_STATUSOFF)
return (0);
if (s->statusat == -1) if (s->statusat == -1)
return (0); return (0);
return (1); return (1);
@ -324,7 +324,7 @@ status_redraw(struct client *c)
} }
/* No status line? */ /* No status line? */
lines = status_line_size(s); lines = status_line_size(c);
if (c->tty.sy == 0 || lines == 0) if (c->tty.sy == 0 || lines == 0)
return (1); return (1);
left = right = NULL; left = right = NULL;
@ -659,7 +659,7 @@ status_message_redraw(struct client *c)
return (0); return (0);
memcpy(&old_status, &c->status.status, sizeof old_status); memcpy(&old_status, &c->status.status, sizeof old_status);
lines = status_line_size(c->session); lines = status_line_size(c);
if (lines <= 1) { if (lines <= 1) {
lines = 1; lines = 1;
screen_init(&c->status.status, c->tty.sx, 1, 0); screen_init(&c->status.status, c->tty.sx, 1, 0);
@ -812,7 +812,7 @@ status_prompt_redraw(struct client *c)
return (0); return (0);
memcpy(&old_status, &c->status.status, sizeof old_status); memcpy(&old_status, &c->status.status, sizeof old_status);
lines = status_line_size(c->session); lines = status_line_size(c);
if (lines <= 1) { if (lines <= 1) {
lines = 1; lines = 1;
screen_init(&c->status.status, c->tty.sx, 1, 0); screen_init(&c->status.status, c->tty.sx, 1, 0);

5
tmux.h
View File

@ -1674,7 +1674,6 @@ int tty_window_bigger(struct tty *);
int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *); int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *);
void tty_update_window_offset(struct window *); void tty_update_window_offset(struct window *);
void tty_update_client_offset(struct client *); void tty_update_client_offset(struct client *);
u_int tty_status_lines(struct tty *);
void tty_raw(struct tty *, const char *); void tty_raw(struct tty *, const char *);
void tty_attributes(struct tty *, const struct grid_cell *, void tty_attributes(struct tty *, const struct grid_cell *,
const struct window_pane *); const struct window_pane *);
@ -1933,9 +1932,9 @@ void server_unzoom_window(struct window *);
/* status.c */ /* status.c */
void status_timer_start(struct client *); void status_timer_start(struct client *);
void status_timer_start_all(void); void status_timer_start_all(void);
void status_update_saved(struct session *s); void status_update_saved(struct session *);
int status_at_line(struct client *); int status_at_line(struct client *);
u_int status_line_size(struct session *); u_int status_line_size(struct client *);
struct window *status_get_window_at(struct client *, u_int); struct window *status_get_window_at(struct client *, u_int);
int status_redraw(struct client *); int status_redraw(struct client *);
void printflike(2, 3) status_message_set(struct client *, const char *, ...); void printflike(2, 3) status_message_set(struct client *, const char *, ...);

36
tty.c
View File

@ -703,11 +703,11 @@ tty_repeat_space(struct tty *tty, u_int n)
int int
tty_window_bigger(struct tty *tty) tty_window_bigger(struct tty *tty)
{ {
struct window *w = tty->client->session->curw->window; struct client *c = tty->client;
u_int lines; struct session *s = c->session;
struct window *w = s->curw->window;
lines = tty_status_lines(tty); return (tty->sx < w->sx || tty->sy - status_line_size(c) < w->sy);
return (tty->sx < w->sx || tty->sy - lines < w->sy);
} }
/* What offset should this window be drawn at? */ /* What offset should this window be drawn at? */
@ -726,11 +726,13 @@ tty_window_offset(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
static int static int
tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy) tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
{ {
struct window *w = tty->client->session->curw->window; struct client *c = tty->client;
struct window *w = c->session->curw->window;
struct window_pane *wp = w->active; struct window_pane *wp = w->active;
u_int cx, cy, lines; u_int cx, cy, lines;
lines = tty_status_lines(tty); lines = status_line_size(c);
if (tty->sx >= w->sx && tty->sy - lines >= w->sy) { if (tty->sx >= w->sx && tty->sy - lines >= w->sy) {
*ox = 0; *ox = 0;
*oy = 0; *oy = 0;
@ -804,22 +806,6 @@ tty_update_client_offset(struct client *c)
c->flags |= CLIENT_REDRAWWINDOW; c->flags |= CLIENT_REDRAWWINDOW;
} }
/* How many lines are taken up by the status line on this client? */
u_int
tty_status_lines(struct tty *tty)
{
struct client *c = tty->client;
u_int lines;
if (c->flags & CLIENT_STATUSOFF)
lines = 0;
else
lines = status_line_size(c->session);
if (c->message_string != NULL || c->prompt_string != NULL)
lines = (lines == 0) ? 1 : lines;
return (lines);
}
/* /*
* Is the region large enough to be worth redrawing once later rather than * Is the region large enough to be worth redrawing once later rather than
* probably several times now? Currently yes if it is more than 50% of the * probably several times now? Currently yes if it is more than 50% of the
@ -895,9 +881,10 @@ tty_is_visible(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
return (1); return (1);
if (status_at_line(tty->client) == 0) if (status_at_line(tty->client) == 0)
lines = tty_status_lines(tty); lines = status_line_size(tty->client);
else else
lines = 0; lines = 0;
if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx || if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy) { yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy) {
return (0); return (0);
@ -1354,8 +1341,9 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *),
ctx->xoff = wp->xoff; ctx->xoff = wp->xoff;
ctx->yoff = wp->yoff; ctx->yoff = wp->yoff;
if (status_at_line(c) == 0) if (status_at_line(c) == 0)
ctx->yoff += status_line_size(c->session); ctx->yoff += status_line_size(c);
cmdfn(&c->tty, ctx); cmdfn(&c->tty, ctx);
} }