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).
This commit is contained in:
		
							
								
								
									
										5
									
								
								st.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								st.c
									
									
									
									
									
								
							| @@ -1132,6 +1132,7 @@ csiparse(void) | |||||||
| { | { | ||||||
| 	char *p = csiescseq.buf, *np; | 	char *p = csiescseq.buf, *np; | ||||||
| 	long int v; | 	long int v; | ||||||
|  | 	int sep = ';'; /* colon or semi-colon, but not both */ | ||||||
|  |  | ||||||
| 	csiescseq.narg = 0; | 	csiescseq.narg = 0; | ||||||
| 	if (*p == '?') { | 	if (*p == '?') { | ||||||
| @@ -1149,7 +1150,9 @@ csiparse(void) | |||||||
| 			v = -1; | 			v = -1; | ||||||
| 		csiescseq.arg[csiescseq.narg++] = v; | 		csiescseq.arg[csiescseq.narg++] = v; | ||||||
| 		p = np; | 		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; | 			break; | ||||||
| 		p++; | 		p++; | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user