mirror of
https://github.com/tmux/tmux.git
synced 2024-11-12 23:28:52 +00:00
Cache status line position to reduce option lookups during output.
This commit is contained in:
parent
75adf8368a
commit
5e6a8177e5
@ -248,6 +248,8 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
RB_FOREACH(w, windows, &windows)
|
RB_FOREACH(w, windows, &windows)
|
||||||
layout_fix_panes(w, w->sx, w->sy);
|
layout_fix_panes(w, w->sx, w->sy);
|
||||||
}
|
}
|
||||||
|
RB_FOREACH (s, sessions, &sessions)
|
||||||
|
status_update_saved(s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update sizes and redraw. May not always be necessary but do it
|
* Update sizes and redraw. May not always be necessary but do it
|
||||||
|
2
resize.c
2
resize.c
@ -89,6 +89,8 @@ recalculate_sizes(void)
|
|||||||
|
|
||||||
s->sx = ssx;
|
s->sx = ssx;
|
||||||
s->sy = ssy;
|
s->sy = ssy;
|
||||||
|
|
||||||
|
status_update_saved(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_FOREACH(w, windows, &windows) {
|
RB_FOREACH(w, windows, &windows) {
|
||||||
|
@ -131,6 +131,8 @@ session_create(const char *name, int argc, char **argv, const char *path,
|
|||||||
s->options = options_create(global_s_options);
|
s->options = options_create(global_s_options);
|
||||||
s->hooks = hooks_create(global_hooks);
|
s->hooks = hooks_create(global_hooks);
|
||||||
|
|
||||||
|
status_update_saved(s);
|
||||||
|
|
||||||
s->tio = NULL;
|
s->tio = NULL;
|
||||||
if (tio != NULL) {
|
if (tio != NULL) {
|
||||||
s->tio = xmalloc(sizeof *s->tio);
|
s->tio = xmalloc(sizeof *s->tio);
|
||||||
|
19
status.c
19
status.c
@ -192,17 +192,26 @@ status_timer_start_all(void)
|
|||||||
status_timer_start(c);
|
status_timer_start(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update status cache. */
|
||||||
|
void
|
||||||
|
status_update_saved(struct session *s)
|
||||||
|
{
|
||||||
|
if (!options_get_number(s->options, "status"))
|
||||||
|
s->statusat = -1;
|
||||||
|
else if (options_get_number(s->options, "status-position") == 0)
|
||||||
|
s->statusat = 0;
|
||||||
|
else
|
||||||
|
s->statusat = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get screen line of status line. -1 means off. */
|
/* Get screen line of status line. -1 means off. */
|
||||||
int
|
int
|
||||||
status_at_line(struct client *c)
|
status_at_line(struct client *c)
|
||||||
{
|
{
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
|
|
||||||
if (!options_get_number(s->options, "status"))
|
if (s->statusat != 1)
|
||||||
return (-1);
|
return (s->statusat);
|
||||||
|
|
||||||
if (options_get_number(s->options, "status-position") == 0)
|
|
||||||
return (0);
|
|
||||||
return (c->tty.sy - 1);
|
return (c->tty.sy - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
tmux.h
4
tmux.h
@ -545,7 +545,6 @@ struct grid_cell {
|
|||||||
int fg;
|
int fg;
|
||||||
int bg;
|
int bg;
|
||||||
struct utf8_data data;
|
struct utf8_data data;
|
||||||
|
|
||||||
};
|
};
|
||||||
struct grid_cell_entry {
|
struct grid_cell_entry {
|
||||||
u_char flags;
|
u_char flags;
|
||||||
@ -936,6 +935,8 @@ struct session {
|
|||||||
struct winlink_stack lastw;
|
struct winlink_stack lastw;
|
||||||
struct winlinks windows;
|
struct winlinks windows;
|
||||||
|
|
||||||
|
int statusat;
|
||||||
|
|
||||||
struct hooks *hooks;
|
struct hooks *hooks;
|
||||||
struct options *options;
|
struct options *options;
|
||||||
|
|
||||||
@ -1864,6 +1865,7 @@ 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);
|
||||||
int status_at_line(struct client *);
|
int status_at_line(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 *);
|
||||||
|
Loading…
Reference in New Issue
Block a user