summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2024-05-01 20:45:39 +0200
committerRafael Marçalo <raroma09@gmail.com>2024-05-02 18:59:15 +0100
commite624fbfe051b7c5dc042f56ce857108af7d74e54 (patch)
tree6d05f4cc4c6cd157c1ebc1dda471e47fd8fbdce6
parente1b431523e0914822e69a9128e81dc81919c9b3f (diff)
support colons in SGR character attributesHEADmaster
Patch by Mikhail Kot <to@myrrc.dev> 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).
-rw-r--r--st.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/st.c b/st.c
index 356d1da..f875097 100644
--- a/st.c
+++ b/st.c
@@ -1191,6 +1191,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 == '?') {
@@ -1208,7 +1209,9 @@ csiparse(void)
v = -1;
csiescseq.arg[csiescseq.narg++] = v;
p = np;
- 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++;
}