summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd-set-option.c2
-rw-r--r--resize.c2
-rw-r--r--screen-redraw.c2
-rw-r--r--server-client.c2
-rw-r--r--session.c2
-rw-r--r--status.c111
-rw-r--r--tmux.h7
-rw-r--r--window-client.c6
8 files changed, 77 insertions, 57 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index c4b82004..a55472ca 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -264,7 +264,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
layout_fix_panes(w);
}
RB_FOREACH(s, sessions, &sessions)
- status_update_saved(s);
+ status_update_cache(s);
/*
* Update sizes and redraw. May not always be necessary but do it
diff --git a/resize.c b/resize.c
index 3726298f..868ddac8 100644
--- a/resize.c
+++ b/resize.c
@@ -162,7 +162,7 @@ recalculate_sizes(void)
*/
RB_FOREACH(s, sessions, &sessions) {
s->attached = 0;
- status_update_saved(s);
+ status_update_cache(s);
}
/*
diff --git a/screen-redraw.c b/screen-redraw.c
index 0c537630..e8a62ea5 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -569,7 +569,7 @@ screen_redraw_draw_status(struct screen_redraw_ctx *ctx)
struct client *c = ctx->c;
struct window *w = c->session->curw->window;
struct tty *tty = &c->tty;
- struct screen *s = &c->status.status;
+ struct screen *s = &c->status.screen;
u_int i, y;
log_debug("%s: %s @%u", __func__, c->name, w->id);
diff --git a/server-client.c b/server-client.c
index b436267d..fe79163f 100644
--- a/server-client.c
+++ b/server-client.c
@@ -204,7 +204,7 @@ server_client_create(int fd)
c->tty.sx = 80;
c->tty.sy = 24;
- screen_init(&c->status.status, c->tty.sx, 1, 0);
+ status_init(c);
c->message_string = NULL;
TAILQ_INIT(&c->message_log);
diff --git a/session.c b/session.c
index 061ff499..43ca321a 100644
--- a/session.c
+++ b/session.c
@@ -136,7 +136,7 @@ session_create(const char *prefix, const char *name, int argc, char **argv,
s->options = oo;
s->hooks = hooks_create(global_hooks);
- status_update_saved(s);
+ status_update_cache(s);
s->tio = NULL;
if (tio != NULL) {
diff --git a/status.c b/status.c
index 65579a26..3065415d 100644
--- a/status.c
+++ b/status.c
@@ -194,7 +194,7 @@ status_timer_start_all(void)
/* Update status cache. */
void
-status_update_saved(struct session *s)
+status_update_cache(struct session *s)
{
if (!options_get_number(s->options, "status"))
s->statusat = -1;
@@ -296,6 +296,15 @@ status_get_window_at(struct client *c, u_int x)
return (NULL);
}
+/* Initialize status line. */
+void
+status_init(struct client *c)
+{
+ struct status_line *sl = &c->status;
+
+ screen_init(&sl->screen, c->tty.sx, 1, 0);
+}
+
/* Free status line. */
void
status_free(struct client *c)
@@ -305,10 +314,31 @@ status_free(struct client *c)
if (event_initialized(&sl->timer))
evtimer_del(&sl->timer);
- screen_free(&sl->status);
- if (sl->old_status != NULL) {
- screen_free(sl->old_status);
- free(sl->old_status);
+ screen_free(&sl->screen);
+ if (sl->old_screen != NULL) {
+ screen_free(sl->old_screen);
+ free(sl->old_screen);
+ }
+}
+
+/* Save as old status line. */
+static void
+status_save_old(struct status_line *sl)
+{
+ if (sl->old_screen == NULL) {
+ sl->old_screen = xmalloc(sizeof *sl->old_screen);
+ memcpy(sl->old_screen, &sl->screen, sizeof *sl->old_screen);
+ }
+}
+
+/* Free old status line. */
+static void
+status_free_old(struct status_line *sl)
+{
+ if (sl->old_screen != NULL) {
+ screen_free(sl->old_screen);
+ free(sl->old_screen);
+ sl->old_screen = NULL;
}
}
@@ -316,10 +346,11 @@ status_free(struct client *c)
int
status_redraw(struct client *c)
{
+ struct status_line *sl = &c->status;
struct screen_write_ctx ctx;
struct session *s = c->session;
struct winlink *wl;
- struct screen old_status, window_list;
+ struct screen old_screen, window_list;
struct grid_cell stdgc, lgc, rgc, gc;
struct options *oo;
char *left, *right;
@@ -330,11 +361,7 @@ status_redraw(struct client *c)
int larrow, rarrow;
/* Delete the saved status line, if any. */
- if (c->status.old_status != NULL) {
- screen_free(c->status.old_status);
- free(c->status.old_status);
- c->status.old_status = NULL;
- }
+ status_free_old(sl);
/* No status line? */
lines = status_line_size(c);
@@ -347,9 +374,9 @@ status_redraw(struct client *c)
style_apply(&stdgc, s->options, "status-style");
/* Create the target screen. */
- memcpy(&old_status, &c->status.status, sizeof old_status);
- screen_init(&c->status.status, c->tty.sx, lines, 0);
- screen_write_start(&ctx, NULL, &c->status.status);
+ memcpy(&old_screen, &sl->screen, sizeof old_screen);
+ screen_init(&sl->screen, c->tty.sx, lines, 0);
+ screen_write_start(&ctx, NULL, &sl->screen);
for (offset = 0; offset < lines * c->tty.sx; offset++)
screen_write_putc(&ctx, &stdgc, ' ');
screen_write_stop(&ctx);
@@ -472,7 +499,7 @@ status_redraw(struct client *c)
draw:
/* Begin drawing. */
- screen_write_start(&ctx, NULL, &c->status.status);
+ screen_write_start(&ctx, NULL, &sl->screen);
/* Draw the left string and arrow. */
screen_write_cursormove(&ctx, 0, 0, 0);
@@ -516,14 +543,14 @@ draw:
wloffset++;
/* Copy the window list. */
- c->status.window_list_offset = -wloffset + wlstart;
+ sl->window_list_offset = -wloffset + wlstart;
screen_write_cursormove(&ctx, wloffset, 0, 0);
screen_write_fast_copy(&ctx, &window_list, wlstart, 0, wlwidth, 1);
screen_free(&window_list);
/* Save left and right size. */
- c->status.left_size = llen;
- c->status.right_size = rlen;
+ sl->left_size = llen;
+ sl->right_size = rlen;
screen_write_stop(&ctx);
@@ -531,11 +558,11 @@ out:
free(left);
free(right);
- if (grid_compare(c->status.status.grid, old_status.grid) == 0) {
- screen_free(&old_status);
+ if (grid_compare(sl->screen.grid, old_screen.grid) == 0) {
+ screen_free(&old_screen);
return (0);
}
- screen_free(&old_status);
+ screen_free(&old_screen);
return (1);
}
@@ -603,12 +630,8 @@ status_message_set(struct client *c, const char *fmt, ...)
status_message_clear(c);
- if (c->status.old_status == NULL) {
- c->status.old_status = xmalloc(sizeof *c->status.old_status);
- memcpy(c->status.old_status, &c->status.status,
- sizeof *c->status.old_status);
- screen_init(&c->status.status, c->tty.sx, 1, 0);
- }
+ status_save_old(&c->status);
+ screen_init(&c->status.screen, c->tty.sx, 1, 0);
va_start(ap, fmt);
xvasprintf(&c->message_string, fmt, ap);
@@ -645,7 +668,7 @@ status_message_clear(struct client *c)
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
- screen_reinit(&c->status.status);
+ screen_reinit(&c->status.screen);
}
/* Clear status line message after timer expires. */
@@ -670,14 +693,14 @@ status_message_redraw(struct client *c)
if (c->tty.sx == 0 || c->tty.sy == 0)
return (0);
- memcpy(&old_status, &c->status.status, sizeof old_status);
+ memcpy(&old_status, &c->status.screen, sizeof old_status);
lines = status_line_size(c);
if (lines <= 1) {
lines = 1;
- screen_init(&c->status.status, c->tty.sx, 1, 0);
+ screen_init(&c->status.screen, c->tty.sx, 1, 0);
} else
- screen_init(&c->status.status, c->tty.sx, lines, 0);
+ screen_init(&c->status.screen, c->tty.sx, lines, 0);
len = screen_write_strlen("%s", c->message_string);
if (len > c->tty.sx)
@@ -685,7 +708,7 @@ status_message_redraw(struct client *c)
style_apply(&gc, s->options, "message-style");
- screen_write_start(&ctx, NULL, &c->status.status);
+ screen_write_start(&ctx, NULL, &c->status.screen);
screen_write_cursormove(&ctx, 0, 0, 0);
for (offset = 0; offset < lines * c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
@@ -693,7 +716,7 @@ status_message_redraw(struct client *c)
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
screen_write_stop(&ctx);
- if (grid_compare(c->status.status.grid, old_status.grid) == 0) {
+ if (grid_compare(c->status.screen.grid, old_status.grid) == 0) {
screen_free(&old_status);
return (0);
}
@@ -722,12 +745,8 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
status_message_clear(c);
status_prompt_clear(c);
- if (c->status.old_status == NULL) {
- c->status.old_status = xmalloc(sizeof *c->status.old_status);
- memcpy(c->status.old_status, &c->status.status,
- sizeof *c->status.old_status);
- screen_init(&c->status.status, c->tty.sx, 1, 0);
- }
+ status_save_old(&c->status);
+ screen_init(&c->status.screen, c->tty.sx, 1, 0);
c->prompt_string = format_expand_time(ft, msg);
@@ -779,7 +798,7 @@ status_prompt_clear(struct client *c)
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
- screen_reinit(&c->status.status);
+ screen_reinit(&c->status.screen);
}
/* Update status line prompt with a new prompt string. */
@@ -822,14 +841,14 @@ status_prompt_redraw(struct client *c)
if (c->tty.sx == 0 || c->tty.sy == 0)
return (0);
- memcpy(&old_status, &c->status.status, sizeof old_status);
+ memcpy(&old_status, &c->status.screen, sizeof old_status);
lines = status_line_size(c);
if (lines <= 1) {
lines = 1;
- screen_init(&c->status.status, c->tty.sx, 1, 0);
+ screen_init(&c->status.screen, c->tty.sx, 1, 0);
} else
- screen_init(&c->status.status, c->tty.sx, lines, 0);
+ screen_init(&c->status.screen, c->tty.sx, lines, 0);
if (c->prompt_mode == PROMPT_COMMAND)
style_apply(&gc, s->options, "message-command-style");
@@ -843,7 +862,7 @@ status_prompt_redraw(struct client *c)
if (start > c->tty.sx)
start = c->tty.sx;
- screen_write_start(&ctx, NULL, &c->status.status);
+ screen_write_start(&ctx, NULL, &c->status.screen);
screen_write_cursormove(&ctx, 0, 0, 0);
for (offset = 0; offset < lines * c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
@@ -889,14 +908,14 @@ status_prompt_redraw(struct client *c)
screen_write_cell(&ctx, &cursorgc);
}
}
- if (c->status.status.cx < screen_size_x(&c->status.status) &&
+ if (c->status.screen.cx < screen_size_x(&c->status.screen) &&
c->prompt_index >= i)
screen_write_putc(&ctx, &cursorgc, ' ');
finished:
screen_write_stop(&ctx);
- if (grid_compare(c->status.status.grid, old_status.grid) == 0) {
+ if (grid_compare(c->status.screen.grid, old_status.grid) == 0) {
screen_free(&old_status);
return (0);
}
diff --git a/tmux.h b/tmux.h
index 4b16eb83..3b0f7d5b 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1314,8 +1314,8 @@ struct cmd_entry {
struct status_line {
struct event timer;
- struct screen status;
- struct screen *old_status;
+ struct screen screen;
+ struct screen *old_screen;
int window_list_offset;
@@ -1967,10 +1967,11 @@ 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 *);
+void status_update_cache(struct session *);
int status_at_line(struct client *);
u_int status_line_size(struct client *);
struct window *status_get_window_at(struct client *, u_int);
+void status_init(struct client *);
void status_free(struct client *);
int status_redraw(struct client *);
void printflike(2, 3) status_message_set(struct client *, const char *, ...);
diff --git a/window-client.c b/window-client.c
index f86d8676..2e977184 100644
--- a/window-client.c
+++ b/window-client.c
@@ -229,10 +229,10 @@ window_client_draw(__unused void *modedata, void *itemdata,
screen_write_hline(ctx, sx, 0, 0);
screen_write_cursormove(ctx, cx, cy + sy - 1, 0);
- if (c->status.old_status != NULL)
- screen_write_fast_copy(ctx, c->status.old_status, 0, 0, sx, 1);
+ if (c->status.old_screen != NULL)
+ screen_write_fast_copy(ctx, c->status.old_screen, 0, 0, sx, 1);
else
- screen_write_fast_copy(ctx, &c->status.status, 0, 0, sx, 1);
+ screen_write_fast_copy(ctx, &c->status.screen, 0, 0, sx, 1);
}
static struct screen *