diff options
author | nicm <nicm> | 2020-12-03 07:12:11 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-12-03 07:12:11 +0000 |
commit | fd451aa7962f399250fd166f207451fcf4b9cb94 (patch) | |
tree | b53be085bcb45f9a88b478fe00c6449f98c1a0c5 | |
parent | f0c1233d4f97b499dd51688b089ad7c485c14b2a (diff) | |
download | rtmux-fd451aa7962f399250fd166f207451fcf4b9cb94.tar.gz rtmux-fd451aa7962f399250fd166f207451fcf4b9cb94.tar.bz2 rtmux-fd451aa7962f399250fd166f207451fcf4b9cb94.zip |
Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.
-rw-r--r-- | server-client.c | 24 | ||||
-rw-r--r-- | tmux.1 | 2 | ||||
-rw-r--r-- | tmux.h | 1 | ||||
-rw-r--r-- | tty.c | 4 | ||||
-rw-r--r-- | window-buffer.c | 12 | ||||
-rw-r--r-- | window-client.c | 12 | ||||
-rw-r--r-- | window-tree.c | 12 |
7 files changed, 64 insertions, 3 deletions
diff --git a/server-client.c b/server-client.c index 3e256a92..f85304a6 100644 --- a/server-client.c +++ b/server-client.c @@ -42,6 +42,7 @@ static void server_client_repeat_timer(int, short, void *); static void server_client_click_timer(int, short, void *); static void server_client_check_exit(struct client *); static void server_client_check_redraw(struct client *); +static void server_client_check_modes(struct client *); static void server_client_set_title(struct client *); static void server_client_reset_state(struct client *); static int server_client_assume_paste(struct session *); @@ -1355,6 +1356,7 @@ server_client_loop(void) TAILQ_FOREACH(c, &clients, entry) { server_client_check_exit(c); if (c->session != NULL) { + server_client_check_modes(c); server_client_check_redraw(c); server_client_reset_state(c); } @@ -1810,6 +1812,28 @@ server_client_redraw_timer(__unused int fd, __unused short events, log_debug("redraw timer fired"); } +/* + * Check if modes need to be updated. Only modes in the current window are + * updated and it is done when the status line is redrawn. + */ +static void +server_client_check_modes(struct client *c) +{ + struct window *w = c->session->curw->window; + struct window_pane *wp; + struct window_mode_entry *wme; + + if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) + return; + if (~c->flags & CLIENT_REDRAWSTATUS) + return; + TAILQ_FOREACH(wp, &w->panes, entry) { + wme = TAILQ_FIRST(&wp->modes); + if (wme != NULL && wme->mode->update != NULL) + wme->mode->update(wme); + } +} + /* Check for client redraws. */ static void server_client_check_redraw(struct client *c) @@ -4643,7 +4643,7 @@ special characters or with an suffix, escape hash characters (so .Ql # becomes -.Ql ## ). +.Ql ## ) . .Ql E:\& will expand the format twice, for example .Ql #{E:status-left} @@ -887,6 +887,7 @@ struct window_mode { struct cmd_find_state *, struct args *); void (*free)(struct window_mode_entry *); void (*resize)(struct window_mode_entry *, u_int, u_int); + void (*update)(struct window_mode_entry *); void (*key)(struct window_mode_entry *, struct client *, struct session *, struct winlink *, key_code, struct mouse_event *); @@ -2447,7 +2447,7 @@ tty_check_fg(struct tty *tty, int *palette, struct grid_cell *gc) /* Is this a 256-colour colour? */ if (gc->fg & COLOUR_FLAG_256) { /* And not a 256 colour mode? */ - if (colours != 256) { + if (colours < 256) { gc->fg = colour_256to16(gc->fg); if (gc->fg & 8) { gc->fg &= 7; @@ -2500,7 +2500,7 @@ tty_check_bg(struct tty *tty, int *palette, struct grid_cell *gc) * palette. Bold background doesn't exist portably, so just * discard the bold bit if set. */ - if (colours != 256) { + if (colours < 256) { gc->bg = colour_256to16(gc->bg); if (gc->bg & 8) { gc->bg &= 7; diff --git a/window-buffer.c b/window-buffer.c index ae6f13ce..4599cbc5 100644 --- a/window-buffer.c +++ b/window-buffer.c @@ -31,6 +31,7 @@ static struct screen *window_buffer_init(struct window_mode_entry *, static void window_buffer_free(struct window_mode_entry *); static void window_buffer_resize(struct window_mode_entry *, u_int, u_int); +static void window_buffer_update(struct window_mode_entry *); static void window_buffer_key(struct window_mode_entry *, struct client *, struct session *, struct winlink *, key_code, struct mouse_event *); @@ -63,6 +64,7 @@ const struct window_mode window_buffer_mode = { .init = window_buffer_init, .free = window_buffer_free, .resize = window_buffer_resize, + .update = window_buffer_update, .key = window_buffer_key, }; @@ -336,6 +338,16 @@ window_buffer_resize(struct window_mode_entry *wme, u_int sx, u_int sy) } static void +window_buffer_update(struct window_mode_entry *wme) +{ + struct window_buffer_modedata *data = wme->data; + + mode_tree_build(data->data); + mode_tree_draw(data->data); + data->wp->flags |= PANE_REDRAW; +} + +static void window_buffer_do_delete(void *modedata, void *itemdata, __unused struct client *c, __unused key_code key) { diff --git a/window-client.c b/window-client.c index 5e02462b..ec3c646a 100644 --- a/window-client.c +++ b/window-client.c @@ -30,6 +30,7 @@ static struct screen *window_client_init(struct window_mode_entry *, static void window_client_free(struct window_mode_entry *); static void window_client_resize(struct window_mode_entry *, u_int, u_int); +static void window_client_update(struct window_mode_entry *); static void window_client_key(struct window_mode_entry *, struct client *, struct session *, struct winlink *, key_code, struct mouse_event *); @@ -59,6 +60,7 @@ const struct window_mode window_client_mode = { .init = window_client_init, .free = window_client_free, .resize = window_client_resize, + .update = window_client_update, .key = window_client_key, }; @@ -312,6 +314,16 @@ window_client_resize(struct window_mode_entry *wme, u_int sx, u_int sy) } static void +window_client_update(struct window_mode_entry *wme) +{ + struct window_client_modedata *data = wme->data; + + mode_tree_build(data->data); + mode_tree_draw(data->data); + data->wp->flags |= PANE_REDRAW; +} + +static void window_client_do_detach(void *modedata, void *itemdata, __unused struct client *c, key_code key) { diff --git a/window-tree.c b/window-tree.c index a687af16..1498b337 100644 --- a/window-tree.c +++ b/window-tree.c @@ -29,6 +29,7 @@ static struct screen *window_tree_init(struct window_mode_entry *, static void window_tree_free(struct window_mode_entry *); static void window_tree_resize(struct window_mode_entry *, u_int, u_int); +static void window_tree_update(struct window_mode_entry *); static void window_tree_key(struct window_mode_entry *, struct client *, struct session *, struct winlink *, key_code, struct mouse_event *); @@ -79,6 +80,7 @@ const struct window_mode window_tree_mode = { .init = window_tree_init, .free = window_tree_free, .resize = window_tree_resize, + .update = window_tree_update, .key = window_tree_key, }; @@ -937,6 +939,16 @@ window_tree_resize(struct window_mode_entry *wme, u_int sx, u_int sy) mode_tree_resize(data->data, sx, sy); } +static void +window_tree_update(struct window_mode_entry *wme) +{ + struct window_tree_modedata *data = wme->data; + + mode_tree_build(data->data); + mode_tree_draw(data->data); + data->wp->flags |= PANE_REDRAW; +} + static char * window_tree_get_target(struct window_tree_itemdata *item, struct cmd_find_state *fs) |