From aa5957495d315a2aca2a846a48ba9f7557353ec5 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Thu, 2 May 2024 09:28:20 +0200 Subject: [PATCH] support colons in SGR character attributes Patch by Mikhail Kot With some modifications to behave more like xterm (see note below). Example: printf '\033[48;2;255:0:0mtest\n' https://invisible-island.net/xterm/ctlseqs/ctlseqs.html Some notes: "CSI Pm m Character Attributes (SGR). [...] o xterm allows either colons (standard) or semicolons (legacy) to separate the subparameters (but after the first colon, colons must be used). --- README.md | 2 +- config.mk | 2 +- st.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98a63d3..4d174f5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this st 0.9.1 (497a756, 2024-04-03) project has a different take on st patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. +Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this st 0.9.2 (5dbcca4, 2024-05-01) project has a different take on st patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/st-flexipatch/blob/master/patches.def.h): ```c diff --git a/config.mk b/config.mk index ca09e0b..ffcd3cb 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # st version -VERSION = 0.9.1 +VERSION = 0.9.2 # Customize below to fit your system diff --git a/st.c b/st.c index b2a96f5..e643239 100644 --- a/st.c +++ b/st.c @@ -1498,6 +1498,7 @@ csiparse(void) { char *p = csiescseq.buf, *np; long int v; + int sep = ';'; /* colon or semi-colon, but not both */ csiescseq.narg = 0; if (*p == '?') { @@ -1518,7 +1519,9 @@ csiparse(void) #if UNDERCURL_PATCH readcolonargs(&p, csiescseq.narg-1, csiescseq.carg); #endif // UNDERCURL_PATCH - if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ) + if (sep == ';' && *p == ':') + sep = ':'; /* allow override to colon once */ + if (*p != sep || csiescseq.narg == ESC_ARG_SIZ) break; p++; }