From 052c2d0a0f68a210038123608c00d4e0ff360161 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Wed, 3 May 2017 19:47:03 +0100 Subject: tui: Also fix "linux*" terminfo entries. #6673 The terminfo entry for linux only advertises 8 colours, but nvim tries to make it display 16 colours anyway, resulting in erroneous SGR control sequences for colours 8 and above. The Linux kernel terminal emulator itself has actually understood the 256-colour control sequences since version 4.8 and the 16-colour control sequences since version 4.9. Thus we apply the same terminfo fixup as we apply for *xterm* and *256*, to emit the 16-colour and 256-colour control sequences even if terminfo's setaf and setab do not advertise them. --- src/nvim/tui/tui.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index d4b34e82f8..399d6c74ca 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1016,9 +1016,11 @@ static void fix_terminfo(TUIData *data) "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" if ((colorterm && strstr(colorterm, "256")) + || STARTS_WITH(term, "linux") || strstr(term, "256") || strstr(term, "xterm")) { - // Assume TERM=~xterm or COLORTERM=~256 supports 256 colors. + // Linux 4.8+ supports 256-color SGR, but terminfo has 8-color setaf/setab. + // Assume TERM=~xterm|linux or COLORTERM=~256 supports 256 colors. unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB); -- cgit