From bd08eb641393cc32268df3b95e4d8b9d9c7c6ae1 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 17 Jun 2022 07:28:05 +0000 Subject: [PATCH] Check cursor options when a pane is created, not just when they are changed. --- usr.bin/tmux/options.c | 17 +++++------------ usr.bin/tmux/tmux.h | 3 ++- usr.bin/tmux/window.c | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c index f9716babf74..f39e2d1a5d3 100644 --- a/usr.bin/tmux/options.c +++ b/usr.bin/tmux/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.68 2022/03/16 17:00:17 nicm Exp $ */ +/* $OpenBSD: options.c,v 1.69 2022/06/17 07:28:05 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -1106,7 +1106,6 @@ options_push_changes(const char *name) struct session *s; struct window *w; struct window_pane *wp; - int c; log_debug("%s: %s", __func__, name); @@ -1119,18 +1118,12 @@ options_push_changes(const char *name) } } if (strcmp(name, "cursor-colour") == 0) { - RB_FOREACH(wp, window_pane_tree, &all_window_panes) { - c = options_get_number(wp->options, name); - wp->screen->default_ccolour = c; - } + RB_FOREACH(wp, window_pane_tree, &all_window_panes) + window_pane_default_cursor(wp); } if (strcmp(name, "cursor-style") == 0) { - RB_FOREACH(wp, window_pane_tree, &all_window_panes) { - wp->screen->default_mode = 0; - screen_set_cursor_style(options_get_number(wp->options, - name), &wp->screen->default_cstyle, - &wp->screen->default_mode); - } + RB_FOREACH(wp, window_pane_tree, &all_window_panes) + window_pane_default_cursor(wp); } if (strcmp(name, "fill-character") == 0) { RB_FOREACH(w, windows, &windows) diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 46bfd0cb8c3..2b38b9f1e5c 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1173 2022/06/09 09:12:55 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1174 2022/06/17 07:28:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2997,6 +2997,7 @@ void *window_pane_get_new_data(struct window_pane *, void window_pane_update_used_data(struct window_pane *, struct window_pane_offset *, size_t); void window_set_fill_character(struct window *); +void window_pane_default_cursor(struct window_pane *); /* layout.c */ u_int layout_count_cells(struct layout_cell *); diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 7ca42aef8c0..44c5b886953 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.280 2022/05/30 12:55:25 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.281 2022/06/17 07:28:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -933,6 +933,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) screen_init(&wp->base, sx, sy, hlimit); wp->screen = &wp->base; + window_pane_default_cursor(wp); screen_init(&wp->status_screen, 1, 1, 0); @@ -1608,3 +1609,17 @@ window_set_fill_character(struct window *w) w->fill_character = ud; } } + +void +window_pane_default_cursor(struct window_pane *wp) +{ + struct screen *s = wp->screen; + int c; + + c = options_get_number(wp->options, "cursor-colour"); + s->default_ccolour = c; + + c = options_get_number(wp->options, "cursor-style"); + s->default_mode = 0; + screen_set_cursor_style(c, &s->default_cstyle, &s->default_mode); +} -- 2.20.1