aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-08-15 13:02:20 +0200
committerGitHub <noreply@github.com>2018-08-15 13:02:20 +0200
commitb5cfac089409faf17a290d4bfe1b669212e2984e (patch)
tree699f9527a25913e4e409e64fbcf127bc5168295f
parentac2d661450f2e54652b6f557b5c1d374e88d006c (diff)
parent5a0d0286ff4d9ea2cc4621d9b514722922e77c78 (diff)
downloadrneovim-b5cfac089409faf17a290d4bfe1b669212e2984e.tar.gz
rneovim-b5cfac089409faf17a290d4bfe1b669212e2984e.tar.bz2
rneovim-b5cfac089409faf17a290d4bfe1b669212e2984e.zip
Merge pull request #8806 from bfredl/bce
tui: fix resize and use BCE more often
-rw-r--r--src/nvim/tui/tui.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index df14ddf988..0781b03965 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -88,6 +88,7 @@ typedef struct {
bool cont_received;
UGrid grid;
kvec_t(Rect) invalid_regions;
+ bool did_resize;
int row, col;
int out_fd;
bool scroll_region_is_full_screen;
@@ -95,6 +96,7 @@ typedef struct {
bool can_set_lr_margin;
bool can_set_left_right_margin;
bool immediate_wrap_after_last_column;
+ bool bce;
bool mouse_enabled;
bool busy, is_invisible;
bool cork, overflow;
@@ -236,6 +238,7 @@ static void terminfo_start(UI *ui)
data->immediate_wrap_after_last_column =
terminfo_is_term_family(term, "cygwin")
|| terminfo_is_term_family(term, "interix");
+ data->bce = unibi_get_bool(data->ut, unibi_back_color_erase);
data->normlen = unibi_pre_fmt_str(data, unibi_cursor_normal,
data->norm, sizeof data->norm);
data->invislen = unibi_pre_fmt_str(data, unibi_cursor_invisible,
@@ -435,6 +438,12 @@ static bool attrs_differ(HlAttrs a1, HlAttrs a2, bool rgb)
}
}
+static bool no_bg(UI *ui, HlAttrs attrs)
+{
+ return ui->rgb ? attrs.rgb_bg_color == -1
+ : attrs.cterm_bg_color == 0;
+}
+
static void update_attrs(UI *ui, HlAttrs attrs)
{
TUIData *data = ui->data;
@@ -597,8 +606,6 @@ static void cursor_goto(UI *ui, int row, int col)
if (row == grid->row && col == grid->col) {
return;
}
- grid->row = row;
- grid->col = col;
if (0 == row && 0 == col) {
unibi_out(ui, unibi_cursor_home);
ugrid_goto(grid, row, col);
@@ -693,10 +700,11 @@ static void clear_region(UI *ui, int top, int bot, int left, int right,
UGrid *grid = &data->grid;
bool cleared = false;
- // TODO(bfredl): support BCE for non-default background
- bool nobg = ui->rgb ? attrs.rgb_bg_color == -1
- : attrs.cterm_bg_color == 0;
- if (nobg && right == ui->width -1) {
+
+ // non-BCE terminals can't clear with non-default background color
+ bool can_clear = data->bce || no_bg(ui, attrs);
+
+ if (can_clear && right == ui->width -1) {
// Background is set to the default color and the right edge matches the
// screen end, try to use terminal codes for clearing the requested area.
update_attrs(ui, attrs);
@@ -729,6 +737,14 @@ static void clear_region(UI *ui, int top, int bot, int left, int right,
cursor_goto(ui, row, col);
print_cell(ui, cell);
});
+
+ if (data->did_resize && top == 0) {
+ // TODO(bfredl): the first line of the screen doesn't gets properly
+ // cleared after resize by the loop above, so redraw the final state
+ // after the next flush.
+ invalidate(ui, 0, bot, left, right);
+ data->did_resize = false;
+ }
}
// restore cursor
@@ -804,6 +820,7 @@ static void tui_grid_resize(UI *ui, Integer g, Integer width, Integer height)
TUIData *data = ui->data;
UGrid *grid = &data->grid;
ugrid_resize(grid, (int)width, (int)height);
+ data->did_resize = true;
// resize might not always be followed by a clear before flush
// so clip the invalid region
@@ -984,18 +1001,13 @@ static void tui_grid_scroll(UI *ui, Integer g, Integer top, Integer bot,
ugrid_scroll(grid, (int)rows, &clear_top, &clear_bot);
if (can_use_scroll(ui)) {
- bool scroll_clears_to_current_colour =
- unibi_get_bool(data->ut, unibi_back_color_erase);
-
// Change terminal scroll region and move cursor to the top
if (!data->scroll_region_is_full_screen) {
set_scroll_region(ui);
}
cursor_goto(ui, grid->top, grid->left);
// also set default color attributes or some terminals can become funny
- if (scroll_clears_to_current_colour) {
- update_attrs(ui, data->clear_attrs);
- }
+ update_attrs(ui, data->clear_attrs);
if (rows > 0) {
if (rows == 1) {
@@ -1019,7 +1031,7 @@ static void tui_grid_scroll(UI *ui, Integer g, Integer top, Integer bot,
}
cursor_goto(ui, data->row, data->col);
- if (!scroll_clears_to_current_colour) {
+ if (!(data->bce || no_bg(ui, data->clear_attrs))) {
// Scrolling will leave wrong background in the cleared area on non-BCE
// terminals. Update the cleared area.
clear_region(ui, clear_top, clear_bot, grid->left, grid->right,
@@ -1382,6 +1394,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
bool roxterm = !!os_getenv("ROXTERM_ID");
#endif
bool xterm = terminfo_is_term_family(term, "xterm");
+ bool kitty = terminfo_is_term_family(term, "xterm-kitty");
bool linuxvt = terminfo_is_term_family(term, "linux");
bool rxvt = terminfo_is_term_family(term, "rxvt");
bool teraterm = terminfo_is_term_family(term, "teraterm");
@@ -1437,8 +1450,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
}
}
- if (!true_xterm) {
- // Cannot trust terminfo; safer to disable BCE. #7624
+ if (tmux || screen || kitty) {
+ // Disable BCE in some cases we know it is not working. #8806
unibi_set_bool(ut, unibi_back_color_erase, false);
}