[PATCH] vt: support ITU-T T.416 color subparameters
From: Ronan Pigott
Date: Sun Mar 01 2026 - 23:43:49 EST
The colon ("bit combination 03/10") is a valid character in parameter
substrings. ECMA-48 says:
Each parameter sub-string consists of one or more bit combinations
from 03/00 to 03/10; the bit combinations from 03/00 to 03/09
represent the digits ZERO to NINE; bit combination 03/10 may be used
as a separator in a parameter sub-string, for example, to separate
the fractional part of a decimal number from the integer part of
that number.
To my knowledge, the only codes where 03/10 is actually used as a
separator are the CSI-m SGR sequences. The colon separated format is
superior as an embedded string for software that doesn't wish to link
ncurses terminal database, because terminals that do not support the
requested SGR sequence can safely skip the sub-parameters rather than
misinterpret them as another sequence. Hence, some software have started
using this "modern" format [1]. We should support the colon separated
format as well.
[1] https://github.com/systemd/systemd/commit/6eabe9f2ff48c1b6924724d5afe64e7b661ccdbf
Signed-off-by: Ronan Pigott <ronan@xxxxxx>
---
drivers/tty/vt/vt.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index c1f152d8b03b..3951bd49bc27 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1644,9 +1644,7 @@ static void rgb_background(struct vc_data *vc, const struct rgb *c)
/*
* ITU T.416 Higher colour modes. They break the usual properties of SGR codes
- * and thus need to be detected and ignored by hand. That standard also
- * wants : rather than ; as separators but sequences containing : are currently
- * completely ignored by the parser.
+ * and thus need to be detected and ignored by hand.
*
* Subcommands 3 (CMY) and 4 (CMYK) are so insane there's no point in
* supporting them.
@@ -1703,6 +1701,7 @@ enum {
CSI_m_BG_COLOR_END = 47,
CSI_m_BG_COLOR = 48,
CSI_m_DEFAULT_BG_COLOR = 49,
+ CSI_m_UNDERLINE_COLOR = 58,
CSI_m_BRIGHT_FG_COLOR_BEG = 90,
CSI_m_BRIGHT_FG_COLOR_END = 97,
CSI_m_BRIGHT_FG_COLOR_OFF = CSI_m_BRIGHT_FG_COLOR_BEG - CSI_m_FG_COLOR_BEG,
@@ -2699,6 +2698,14 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c)
fallthrough;
case ESgetpars: /* ESC [ aka CSI, parameters expected */
switch (c) {
+ case ':': /* ITU-T T.416 color subparameters */
+ if (vc->vc_par[0] != CSI_m_FG_COLOR &&
+ vc->vc_par[0] != CSI_m_BG_COLOR &&
+ vc->vc_par[0] != CSI_m_UNDERLINE_COLOR) {
+ vc->vc_state = EScsiignore;
+ return;
+ }
+ fallthrough;
case ';':
if (vc->vc_npar < NPAR - 1) {
vc->vc_npar++;
--
2.53.0