Merge #7624 'tui: disable BCE almost always'

closes #7035
closes #7337
This commit is contained in:
Justin M. Keyes 2017-11-25 22:36:34 +01:00 committed by GitHub
commit 303e1df13f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@ -194,7 +194,7 @@ static void terminfo_start(UI *ui)
const char *term = os_getenv("TERM");
data->ut = unibi_from_env();
if (!data->ut) {
data->ut = load_builtin_terminfo(term);
data->ut = terminfo_from_builtin(term);
}
// None of the following work over SSH; see :help TERM .
const char *colorterm = os_getenv("COLORTERM");
@ -940,9 +940,10 @@ static void tui_scroll(UI *ui, Integer count)
}
cursor_goto(ui, saved_row, saved_col);
if (!scroll_clears_to_current_colour) {
// This is required because scrolling will leave wrong background in the
// cleared area on non-bge terminals.
if (!scroll_clears_to_current_colour && grid->bg != -1) {
// Scrolling may leave wrong background in the cleared area on non-bge
// terminals. Update the cleared area of the terminal if its builtin
// scrolling facility was used and bg color is not the default.
clear_region(ui, clear_top, clear_bot, grid->left, grid->right);
}
} else {
@ -1234,11 +1235,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 +1303,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 +1401,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 +1419,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 +1428,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,