commit 5adf4c4c8eaad4535fa99cbd905daec4b22f6939
parent 2d59f2127133c5f12e951179bf0411276c6c1ad0
Author: bakkeby <bakkeby@gmail.com>
Date: Tue, 11 May 2021 16:35:30 +0200
Adding default cursor patch
Diffstat:
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
+2021-05-11 - Added default cursor patch
+
2021-05-10 - Upgrade to 46b02f, 2021-03-28
2021-05-09 - Added the sync, alpha-focus-hightlight and vim browse patches
@@ -98,6 +100,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- this patch allows you to select and copy the last URL displayed with Mod+l
- multiple invocations cycle through the available URLs
+ - default-cursor
+ - minor change allowing escape sequences like `\e[ q` or `\e[0 q` to set the cursor back to default configuration instead of a blinking block
+ - while many terminals do this the behaviour is not according to the specification
+
- [delkey](https://st.suckless.org/patches/delkey/)
- return BS on pressing backspace and DEL on pressing the delete key
diff --git a/patches.def.h b/patches.def.h
@@ -80,6 +80,21 @@
*/
#define COPYURL_HIGHLIGHT_SELECTED_URLS_PATCH 0
+/* According to the specification (see link in BLINKING_CURSOR_PATCH) the "Set cursor style
+ * (DECSCUSR), VT520." escape sequences define both values of 0 and 1 as a blinking block,
+ * with 1 being the default.
+ *
+ * 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.
+ */
+#define DEFAULT_CURSOR_PATCH 0
+
/* Return BS on pressing backspace and DEL on pressing the delete key.
* https://st.suckless.org/patches/delkey/
*/
diff --git a/x.c b/x.c
@@ -2405,7 +2405,15 @@ xsetcursor(int cursor)
if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */
#endif // BLINKING_CURSOR_PATCH
return 1;
+ #if DEFAULT_CURSOR_PATCH
+ #if BLINKING_CURSOR_PATCH
+ win.cursor = (cursor ? cursor : cursorstyle);
+ #else
+ win.cursor = (cursor ? cursor : cursorshape);
+ #endif // BLINKING_CURSOR_PATCH
+ #else
win.cursor = cursor;
+ #endif // DEFAULT_CURSOR_PATCH
#if BLINKING_CURSOR_PATCH
cursorblinks = win.cursor == 0 || win.cursor == 1 ||
win.cursor == 3 || win.cursor == 5 ||