Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: adapt .zle.sgr for CSI sequences that use : instead of ;
- X-seq: zsh-workers 53329
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: adapt .zle.sgr for CSI sequences that use : instead of ;
- Date: Sun, 26 Jan 2025 19:41:02 +0100
- Archived-at: <https://zsh.org/workers/53329>
- List-id: <zsh-workers.zsh.org>
When trying a different terminal, I found that .zle.sgr was not working
correctly. The CSI escape sequences in terminfo for that terminal used
colon-delimited numbers rather than them being semi-colon delimited.
Variables like GREP_COLORS, LS_COLORS and JQ_COLORS need semi-colons
because they use colons to separate different fields. The whole point of
.zle.sgr is as a way to convert attributes so e.g. fg=#008700,italic is
turned into 3;38;5;28. The terminal doesn't actually care whether it gets
colons or semi-colons in the escape sequence.
So the following patch accepts colons in the input escape sequence but
produces semi-colons for the SGR value.
Oliver
diff --git a/Src/Modules/hlgroup.c b/Src/Modules/hlgroup.c
index 082762623..6c5a4bec4 100644
--- a/Src/Modules/hlgroup.c
+++ b/Src/Modules/hlgroup.c
@@ -50,9 +50,14 @@ convertattr(char *attrstr, int sgr)
char *c = s, *t = s - 1;
while (c[0] == '\033' && c[1] == '[') {
- c += 2;
- while (isdigit(*c) || *c == ';')
- *++t = *c++;
+ for (c += 2; ; c++) {
+ if (isdigit(*c))
+ *++t = *c;
+ else if (*c == ';' || *c == ':')
+ *++t = ';';
+ else
+ break;
+ }
t++;
if (*c != 'm')
break;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author