diff options
| author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2024-05-01 20:45:39 +0200 |
|---|---|---|
| committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2024-05-01 20:45:39 +0200 |
| commit | 5dbcca49263be094fc38159c297458ae323ef647 (patch) | |
| tree | a96e2e2c91be152faaba7cf54698c8104d799b67 | |
| parent | bump version to 0.9.2 (diff) | |
| download | st-5dbcca49263be094fc38159c297458ae323ef647.tar.gz st-5dbcca49263be094fc38159c297458ae323ef647.zip | |
support colons in SGR character attributes
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.c | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -1132,6 +1132,7 @@ csiparse(void) | |||
| 1132 | { | 1132 | { |
| 1133 | char *p = csiescseq.buf, *np; | 1133 | char *p = csiescseq.buf, *np; |
| 1134 | long int v; | 1134 | long int v; |
| 1135 | int sep = ';'; /* colon or semi-colon, but not both */ | ||
| 1135 | 1136 | ||
| 1136 | csiescseq.narg = 0; | 1137 | csiescseq.narg = 0; |
| 1137 | if (*p == '?') { | 1138 | if (*p == '?') { |
| @@ -1149,7 +1150,9 @@ csiparse(void) | |||
| 1149 | v = -1; | 1150 | v = -1; |
| 1150 | csiescseq.arg[csiescseq.narg++] = v; | 1151 | csiescseq.arg[csiescseq.narg++] = v; |
| 1151 | p = np; | 1152 | p = np; |
| 1152 | if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ) | 1153 | if (sep == ';' && *p == ':') |
| 1154 | sep = ':'; /* allow override to colon once */ | ||
| 1155 | if (*p != sep || csiescseq.narg == ESC_ARG_SIZ) | ||
| 1153 | break; | 1156 | break; |
| 1154 | p++; | 1157 | p++; |
| 1155 | } | 1158 | } |
