[hackers] [st][PATCH] reset the cursor shape to the default with DECSCUSR param 0

From: Koichi Murase <myoga.murase_AT_gmail.com>
Date: Tue, 6 Sep 2022 21:40:21 +0900

The empty parameter or parameter 0 of terminal control functions
typically mean the default. In fact, typical implementations of
DECSCUSR in other terminals (vte, alacritty, mintty, vte, wt, etc.)
treat them as the default cursor shape. See also the discussions in
the code comment of vte [1] and Issue #3293 of xterm.js [2].

However, the current implementation of DECSCUSR in st always treats
them as parameter 1 (blinking block cursor) regardless of the user
setting of the default cursor shape (i.e., the variable "cursorshape"
in config.h). This implementation causes an actual problem: there is
no way to reset the cursor shape to the default after a terminal
application changes the cursor shape by DECSCUSR.

This commit fixes the behavior to reset the cursor shape to the
default instead of hardcoded "blinking block cursor" (which was merely
the initial default of VT but is not even the initial default of
st---"steady block").

[1] https://github.com/GNOME/vte/blob/fb604fe2/src/vteinternal.hh#L173-L184
[2] https://github.com/xtermjs/xterm.js/issues/3293
---
 x.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/x.c b/x.c
index 2a3bd38..aecc6f1 100644
--- a/x.c
+++ b/x.c
_AT_@ -1739,6 +1739,8 @@ xsetcursor(int cursor)
 {
 	if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */
 		return 1;
+	if (cursor == 0)
+		cursor = cursorshape; /* 0: reset to the default */
 	win.cursor = cursor;
 	return 0;
 }
-- 
2.37.2
Received on Tue Sep 06 2022 - 14:40:21 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 06 2022 - 14:48:35 CEST