Download raw body.
tmux: add an option to use the "hardware" cursor in the status line
Hello, tech@!
At the moment the cursor behaviour in different tmux modes is not very
consistent. You can set the cursor-style option, but that will only work
inside a pane. In command prompt, for example, the cursor gets hidden,
and is emulated with GRID_ATTR_REVERSE instead.
I wondered how hard it would be to add an option to avoid the behaviour,
and it turns out not that hard. The diff below adds a boolean option
status-emulate-cursor.
I'd like to know if there's any interest in adding such options.
Comments?
Thank you.
--
lexu
Index: options-table.c
===================================================================
RCS file: /var/cvs/src/usr.bin/tmux/options-table.c,v
diff -u -p -r1.175 options-table.c
--- options-table.c 4 Aug 2024 09:35:30 -0000 1.175
+++ options-table.c 11 Aug 2024 10:01:03 -0000
@@ -798,6 +798,13 @@ const struct options_table_entry options
.text = "Style of the status line."
},
+ { .name = "status-emulate-cursor",
+ .type = OPTIONS_TABLE_FLAG,
+ .scope = OPTIONS_TABLE_SERVER,
+ .default_num = 1,
+ .text = "Whether to emulate the status line cursor."
+ },
+
{ .name = "update-environment",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_SESSION,
Index: server-client.c
===================================================================
RCS file: /var/cvs/src/usr.bin/tmux/server-client.c,v
diff -u -p -r1.405 server-client.c
--- server-client.c 10 Apr 2024 07:29:15 -0000 1.405
+++ server-client.c 11 Aug 2024 09:49:41 -0000
@@ -2396,7 +2396,8 @@ server_client_reset_state(struct client
cy = tty->sy - n;
}
cx = c->prompt_cursor;
- mode &= ~MODE_CURSOR;
+ if (options_get_number(global_options, "status-emulate-cursor"))
+ mode &= ~MODE_CURSOR;
} else if (c->overlay_draw == NULL) {
cursor = 0;
tty_window_offset(tty, &ox, &oy, &sx, &sy);
Index: status.c
===================================================================
RCS file: /var/cvs/src/usr.bin/tmux/status.c,v
diff -u -p -r1.242 status.c
--- status.c 15 May 2024 08:39:30 -0000 1.242
+++ status.c 11 Aug 2024 09:49:47 -0000
@@ -644,8 +644,11 @@ status_prompt_set(struct client *c, stru
c->prompt_type = prompt_type;
c->prompt_mode = PROMPT_ENTRY;
- if (~flags & PROMPT_INCREMENTAL)
- c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
+ if (~flags & PROMPT_INCREMENTAL) {
+ if (options_get_number(global_options, "status-emulate-cursor"))
+ c->tty.flags |= TTY_NOCURSOR;
+ c->tty.flags |= TTY_FREEZE;
+ }
c->flags |= CLIENT_REDRAWSTATUS;
if (flags & PROMPT_INCREMENTAL)
@@ -744,7 +747,8 @@ status_prompt_redraw(struct client *c)
format_free(ft);
memcpy(&cursorgc, &gc, sizeof cursorgc);
- cursorgc.attr ^= GRID_ATTR_REVERSE;
+ if (options_get_number(global_options, "status-emulate-cursor"))
+ cursorgc.attr ^= GRID_ATTR_REVERSE;
start = format_width(c->prompt_string);
if (start > c->tty.sx)
Index: tmux.1
===================================================================
RCS file: /var/cvs/src/usr.bin/tmux/tmux.1,v
diff -u -p -r1.947 tmux.1
--- tmux.1 4 Aug 2024 09:01:18 -0000 1.947
+++ tmux.1 11 Aug 2024 09:59:42 -0000
@@ -4349,6 +4349,13 @@ For how to specify
see the
.Sx STYLES
section.
+.It Xo Ic status-emulate-cursor
+.Op Ic on | off
+.Xc
+If enabled (the default), the status line cursor is emulated with reverse-video.
+Otherwise, the normal
+.Qq hardware
+cursor is used.
.It Ic update-environment[] Ar variable
Set list of environment variables to be copied into the session environment
when a new session is created or an existing session is attached.
tmux: add an option to use the "hardware" cursor in the status line