multigrid: Clean whole grid when it was just resized

This commit is contained in:
Utkarsh Maheshwari
2018-08-18 15:39:22 +05:30
committed by Björn Linse
parent 0bab611a96
commit 4f1dcf7c28
3 changed files with 16 additions and 8 deletions

View File

@@ -157,7 +157,7 @@ typedef off_t off_T;
/// Note: before the screen is initialized and when out of memory these can be /// Note: before the screen is initialized and when out of memory these can be
/// NULL. /// NULL.
EXTERN ScreenGrid default_grid INIT(= { 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, EXTERN ScreenGrid default_grid INIT(= { 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0,
0, 0 }); 0, 0, 0 });
#define DEFAULT_GRID_HANDLE 1 /* handle for the default_grid */ #define DEFAULT_GRID_HANDLE 1 /* handle for the default_grid */

View File

@@ -1573,6 +1573,8 @@ static void win_update(win_T *wp)
} }
} }
wp->w_grid.was_resized = false;
/* restore got_int, unless CTRL-C was hit while redrawing */ /* restore got_int, unless CTRL-C was hit while redrawing */
if (!got_int) if (!got_int)
got_int = save_got_int; got_int = save_got_int;
@@ -5832,8 +5834,12 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
} }
} }
int dirty_first = INT_MAX; // if grid was resized (in ext_multigrid mode), the UI has no redraw updates
int dirty_last = 0; // for the newly resized grid. It is better mark everything as dirty and
// send all the updates.
int dirty_first = grid->was_resized ? start_col : INT_MAX;
int dirty_last = grid->was_resized ? grid->Columns : 0;
int col = start_col; int col = start_col;
schar_from_char(sc, c1); schar_from_char(sc, c1);
int lineoff = grid->LineOffset[row]; int lineoff = grid->LineOffset[row];
@@ -5846,8 +5852,10 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
if (dirty_first == INT_MAX) { if (dirty_first == INT_MAX) {
dirty_first = col; dirty_first = col;
} }
if (!grid->was_resized) {
dirty_last = col+1; dirty_last = col+1;
} }
}
if (col == start_col) { if (col == start_col) {
schar_from_char(sc, c2); schar_from_char(sc, c2);
} }
@@ -5920,7 +5928,6 @@ void win_grid_alloc(win_T *wp, int doclear)
ScreenGrid *grid = &wp->w_grid; ScreenGrid *grid = &wp->w_grid;
int rows = grid->internal_rows; int rows = grid->internal_rows;
int columns = grid->internal_columns; int columns = grid->internal_columns;
int was_resized = 0;
if (rows == 0) { if (rows == 0) {
rows = wp->w_height; rows = wp->w_height;
@@ -5935,7 +5942,7 @@ void win_grid_alloc(win_T *wp, int doclear)
grid_alloc(grid, rows, columns, doclear); grid_alloc(grid, rows, columns, doclear);
win_free_lsize(wp); win_free_lsize(wp);
win_alloc_lines(wp); win_alloc_lines(wp);
was_resized = true; grid->was_resized = true;
} }
grid->OffsetRow = wp->w_winrow; grid->OffsetRow = wp->w_winrow;
@@ -5947,10 +5954,9 @@ void win_grid_alloc(win_T *wp, int doclear)
// - a grid was just resized // - a grid was just resized
// - screen_resize was called and all grid sizes must be sent // - screen_resize was called and all grid sizes must be sent
// - the UI wants multigrid event (necessary) // - the UI wants multigrid event (necessary)
if ((send_grid_resize || was_resized) if ((send_grid_resize || grid->was_resized)
&& ui_is_external(kUIMultigrid)) { && ui_is_external(kUIMultigrid)) {
ui_call_grid_resize(grid->handle, grid->Columns, grid->Rows); ui_call_grid_resize(grid->handle, grid->Columns, grid->Rows);
was_resized = false;
} }
} }

View File

@@ -43,6 +43,8 @@ typedef struct {
// the size expected to be allocated to the internal grid // the size expected to be allocated to the internal grid
int internal_rows; int internal_rows;
int internal_columns; int internal_columns;
int was_resized;
} ScreenGrid; } ScreenGrid;
#endif // NVIM_TYPES_H #endif // NVIM_TYPES_H