Skip to content

Commit

Permalink
tui: Disable BCE almost always. neovim#7624
Browse files Browse the repository at this point in the history
133ae5e implemented BCE (background color erase). But we can't
trust terminfo, so it is safer disable BCE if we are not certain.

Per kovidgoyal/kitty#160 (comment)
terminal support for BCE seems to be (1) optional and (2) inconsistent.

ref neovim#4210 neovim#4421 neovim#7035 neovim#7337 neovim#7381 neovim#7425 neovim#7618
  • Loading branch information
justinmk committed Nov 24, 2017
1 parent 9888a54 commit b838ad5
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/nvim/tui/tui.c
Expand Up @@ -1234,11 +1234,9 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name)
return -1;
}

/// Several entries in terminfo are known to be deficient or outright wrong,
/// unfortunately; and several terminal emulators falsely announce incorrect
/// terminal types. So patch the terminfo records after loading from an
/// external or a built-in database. In an ideal world, the real terminfo data
/// would be correct and complete, and this function would be almost empty.
/// Patches the terminfo records after loading from system or built-in db.
/// Several entries in terminfo are known to be deficient or outright wrong;
/// and several terminal emulators falsely announce incorrect terminal types.
static void patch_terminfo_bugs(TUIData *data, const char *term,
const char *colorterm, long vte_version,
bool konsole, bool iterm_env)
Expand Down Expand Up @@ -1304,6 +1302,11 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
}
}

if (!true_xterm) {
// Cannot trust terminfo; safer to disable BCE. #7624
unibi_set_bool(ut, unibi_back_color_erase, false);
}

if (xterm) {
// Termit, LXTerminal, GTKTerm2, GNOME Terminal, MATE Terminal, roxterm,
// and EvilVTE falsely claim to be xterm and do not support important xterm
Expand Down Expand Up @@ -1397,11 +1400,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
#define XTERM_SETAB_16 \
"\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m"

// Terminals where there is actually 256-colour SGR support despite what
// the terminfo record may say.
// Terminals with 256-colour SGR support despite what terminfo says.
if (unibi_get_num(ut, unibi_max_colors) < 256) {
// See http://fedoraproject.org/wiki/Features/256_Color_Terminals for
// more on this.
// See http://fedoraproject.org/wiki/Features/256_Color_Terminals
if (true_xterm || iterm || iterm_pretending_xterm) {
unibi_set_num(ut, unibi_max_colors, 256);
unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_COLON);
Expand All @@ -1417,8 +1418,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256);
}
}
// Terminals where there is actually 16-colour SGR support despite what
// the terminfo record may say.
// Terminals with 16-colour SGR support despite what terminfo says.
if (unibi_get_num(ut, unibi_max_colors) < 16) {
if (colorterm) {
unibi_set_num(ut, unibi_max_colors, 16);
Expand All @@ -1427,9 +1427,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
}
}

// Some terminals can not currently be trusted to report if they support
// DECSCUSR or not. So we need to have a blacklist for when we should not
// trust the reported features.
// Some terminals cannot be trusted to report DECSCUSR support. So we keep
// blacklist for when we should not trust the reported features.
if (!((vte_version != 0 && vte_version < 3900) || konsole)) {
// Dickey ncurses terminfo has included the Ss and Se capabilities,
// pioneered by tmux, since 2011-07-14. So adding them to terminal types,
Expand Down

0 comments on commit b838ad5

Please sign in to comment.