From 5adf4c4c8eaad4535fa99cbd905daec4b22f6939 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 11 May 2021 16:35:30 +0200 Subject: [PATCH] Adding default cursor patch --- README.md | 6 ++++++ patches.def.h | 15 +++++++++++++++ x.c | 8 ++++++++ 3 files changed, 29 insertions(+) diff --git a/README.md b/README.md index adf890d..941aedc 100644 --- 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 index 2ca256f..895f127 100644 --- 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 index 39504c1..e408296 100644 --- 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 ||