aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resize.c10
-rw-r--r--screen-redraw.c4
-rw-r--r--server-client.c2
-rw-r--r--status.c20
-rw-r--r--tmux.h5
-rw-r--r--tty.c36
6 files changed, 33 insertions, 44 deletions
diff --git a/resize.c b/resize.c
index faaa044d..40a1a016 100644
--- a/resize.c
+++ b/resize.c
@@ -85,7 +85,7 @@ default_window_size(struct session *s, struct window *w, u_int *sx, u_int *sy,
continue;
cx = c->tty.sx;
- cy = c->tty.sy - tty_status_lines(&c->tty);
+ cy = c->tty.sy - status_line_size(c);
if (cx > *sx)
*sx = cx;
@@ -105,7 +105,7 @@ default_window_size(struct session *s, struct window *w, u_int *sx, u_int *sy,
continue;
cx = c->tty.sx;
- cy = c->tty.sy - tty_status_lines(&c->tty);
+ cy = c->tty.sy - status_line_size(c);
if (cx < *sx)
*sx = cx;
@@ -167,7 +167,7 @@ recalculate_sizes(void)
if ((flags & CLIENT_CONTROL) && (~flags & CLIENT_SIZECHANGED))
continue;
- if (c->tty.sy <= tty_status_lines(&c->tty))
+ if (c->tty.sy <= status_line_size(c))
c->flags |= CLIENT_STATUSOFF;
else
c->flags &= ~CLIENT_STATUSOFF;
@@ -200,7 +200,7 @@ recalculate_sizes(void)
continue;
cx = c->tty.sx;
- cy = c->tty.sy - tty_status_lines(&c->tty);
+ cy = c->tty.sy - status_line_size(c);
if (cx > sx)
sx = cx;
@@ -222,7 +222,7 @@ recalculate_sizes(void)
continue;
cx = c->tty.sx;
- cy = c->tty.sy - tty_status_lines(&c->tty);
+ cy = c->tty.sy - status_line_size(c);
if (cx < sx)
sx = cx;
diff --git a/screen-redraw.c b/screen-redraw.c
index 118830c7..50862f9e 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -411,7 +411,9 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
memset(ctx, 0, sizeof *ctx);
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)
ctx->top = 1;
ctx->pane_status = options_get_number(wo, "pane-border-status");
diff --git a/server-client.c b/server-client.c
index 49a4b37d..78c917ea 100644
--- a/server-client.c
+++ b/server-client.c
@@ -1252,7 +1252,7 @@ server_client_reset_state(struct client *c)
cy = wp->yoff + s->cy - oy;
if (status_at_line(c) == 0)
- cy += status_line_size(c->session);
+ cy += status_line_size(c);
}
if (!cursor)
mode &= ~MODE_CURSOR;
diff --git a/status.c b/status.c
index e8f890e8..17bc113b 100644
--- a/status.c
+++ b/status.c
@@ -214,17 +214,17 @@ status_at_line(struct client *c)
return (-1);
if (s->statusat != 1)
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 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).
- */
+/* Get size of status line for client's session. 0 means off. */
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)
return (0);
return (1);
@@ -324,7 +324,7 @@ status_redraw(struct client *c)
}
/* No status line? */
- lines = status_line_size(s);
+ lines = status_line_size(c);
if (c->tty.sy == 0 || lines == 0)
return (1);
left = right = NULL;
@@ -659,7 +659,7 @@ status_message_redraw(struct client *c)
return (0);
memcpy(&old_status, &c->status.status, sizeof old_status);
- lines = status_line_size(c->session);
+ lines = status_line_size(c);
if (lines <= 1) {
lines = 1;
screen_init(&c->status.status, c->tty.sx, 1, 0);
@@ -812,7 +812,7 @@ status_prompt_redraw(struct client *c)
return (0);
memcpy(&old_status, &c->status.status, sizeof old_status);
- lines = status_line_size(c->session);
+ lines = status_line_size(c);
if (lines <= 1) {
lines = 1;
screen_init(&c->status.status, c->tty.sx, 1, 0);
diff --git a/tmux.h b/tmux.h
index 2ae71af9..3eb4c174 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1674,7 +1674,6 @@ int tty_window_bigger(struct tty *);
int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *);
void tty_update_window_offset(struct window *);
void tty_update_client_offset(struct client *);
-u_int tty_status_lines(struct tty *);
void tty_raw(struct tty *, const char *);
void tty_attributes(struct tty *, const struct grid_cell *,
const struct window_pane *);
@@ -1933,9 +1932,9 @@ void server_unzoom_window(struct window *);
/* status.c */
void status_timer_start(struct client *);
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 *);
-u_int status_line_size(struct session *);
+u_int status_line_size(struct client *);
struct window *status_get_window_at(struct client *, u_int);
int status_redraw(struct client *);
void printflike(2, 3) status_message_set(struct client *, const char *, ...);
diff --git a/tty.c b/tty.c
index e69929af..9a756d1c 100644
--- a/tty.c
+++ b/tty.c
@@ -703,11 +703,11 @@ tty_repeat_space(struct tty *tty, u_int n)
int
tty_window_bigger(struct tty *tty)
{
- struct window *w = tty->client->session->curw->window;
- u_int lines;
+ struct client *c = tty->client;
+ struct session *s = c->session;
+ struct window *w = s->curw->window;
- lines = tty_status_lines(tty);
- return (tty->sx < w->sx || tty->sy - lines < w->sy);
+ return (tty->sx < w->sx || tty->sy - status_line_size(c) < w->sy);
}
/* 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
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;
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) {
*ox = 0;
*oy = 0;
@@ -804,22 +806,6 @@ tty_update_client_offset(struct client *c)
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
* 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);
if (status_at_line(tty->client) == 0)
- lines = tty_status_lines(tty);
+ lines = status_line_size(tty->client);
else
lines = 0;
+
if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy) {
return (0);
@@ -1354,8 +1341,9 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *),
ctx->xoff = wp->xoff;
ctx->yoff = wp->yoff;
+
if (status_at_line(c) == 0)
- ctx->yoff += status_line_size(c->session);
+ ctx->yoff += status_line_size(c);
cmdfn(&c->tty, ctx);
}