tui: Disable BCE almost always. #7624

133ae5eeef implemented BCE (background color erase). But we can't
trust terminfo, so it is safer disable BCE if we are not certain.

Per https://github.com/kovidgoyal/kitty/issues/160#issuecomment-346470545
terminal support for BCE seems to be (1) optional and (2) inconsistent.

ref #4210 #4421 #7035 #7337 #7381 #7425 #7618
This commit is contained in:
Justin M. Keyes
2017-11-23 21:21:05 +01:00
parent 9888a54f15
commit b838ad5b7a

View File

@@ -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)
@@ -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
@@ -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);
@@ -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);
@@ -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,