You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
patches/st/st-default_cursor-0.9-20230...

49 lines
1.7 KiB
Diff

From 1080661abe54eb51480a960949309d99f3d3f88d Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Wed, 12 May 2021 09:13:47 +0200
Subject: [PATCH] Make st interpret cursor 0 as the default cursor.
According to the specification the "Set cursor style
(DECSCUSR), VT520." escape sequences define both values of 0 and 1 as a blinking block,
with 1 being the default.
Refer to:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
This patch allows the default cursor to be set when value 0 is used, as opposed to
setting the cursor to a blinking block.
This allows a command like this to restore the cursor to what st is configured with:
$ echo -ne "\e[ q"
While many terminal emulators do this it is not adhering to specification. xterm is an
example terminal that sets a blinking block instead of the configured one, same as st.
Example use case is changing cursor shape in vim depending on what mode is used:
https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes
https://askubuntu.com/questions/42663/how-to-make-cursor-change-from-thin-line-to-block-based-on-normal-or-insert-mode
The alternative in this case would be to explicitly set the cursor back to what you expect
it to be (underline, bar) in the vim configuration.
---
x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/x.c b/x.c
index aa09997..f569bb1 100644
--- a/x.c
+++ b/x.c
@@ -1739,7 +1739,7 @@ xsetcursor(int cursor)
{
if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */
return 1;
- win.cursor = cursor;
+ win.cursor = (cursor ? cursor : cursorshape);
return 0;
}
--
2.41.0