aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-07-12 16:23:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 18:58:27 -0400
commit3415097ff0529eac264b8ccfa06572871e45c090 (patch)
tree7d93c983e0d0e9b83beb905d40b41a24a32b79f4 /drivers/tty
parent64545880927e15d5e82a9f33c3fd0704c775bd80 (diff)
vt: properly ignore xterm-256 colour codes
This is not a bug on our side, but a misdesign in ITU T.416, yet with all popular terminals supporting these codes, people consider this to be a bug in Linux. By breaking the design principles behind SGR codes (gracefully ignoring unsupported ones should not require knowing about them), 256 colour ones tend to turn blinking on before invoking an arbitrary unrelated command. This commit doesn't add such support, merely skips such codes without ill effects. Signed-off-by: Adam Borowski <kilobyte@angband.pl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/vt/vt.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index ef95c6c1698f..61b1137d7e56 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1300,6 +1300,28 @@ static void csi_m(struct vc_data *vc)
1300 case 27: 1300 case 27:
1301 vc->vc_reverse = 0; 1301 vc->vc_reverse = 0;
1302 break; 1302 break;
1303 case 38:
1304 case 48: /* ITU T.416
1305 * Higher colour modes.
1306 * They break the usual properties of SGR codes
1307 * and thus need to be detected and ignored by
1308 * hand. Strictly speaking, that standard also
1309 * wants : rather than ; as separators, contrary
1310 * to ECMA-48, but no one produces such codes
1311 * and almost no one accepts them.
1312 */
1313 i++;
1314 if (i > vc->vc_npar)
1315 break;
1316 if (vc->vc_par[i] == 5) /* 256 colours */
1317 i++; /* ubiquitous */
1318 else if (vc->vc_par[i] == 2) /* 24 bit colours */
1319 i += 3; /* extremely rare */
1320 /* Subcommands 3 (CMY) and 4 (CMYK) are so insane
1321 * that detecting them is not worth the few extra
1322 * bytes of kernel's size.
1323 */
1324 break;
1303 case 39: 1325 case 39:
1304 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); 1326 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0);
1305 break; 1327 break;