multigrid: rename to grid.row_offset and grid.requested_rows

This commit is contained in:
Björn Linse
2018-12-23 15:06:28 +01:00
parent 1cec5542a8
commit dc44309336
3 changed files with 41 additions and 40 deletions

View File

@@ -41,17 +41,17 @@ typedef struct {
unsigned *LineOffset; unsigned *LineOffset;
char_u *LineWraps; char_u *LineWraps;
// the size of the allocated grid // the size of the allocated grid.
int Rows; int Rows;
int Columns; int Columns;
// offsets for the grid relative to the global screen // offsets for the grid relative to the global screen
int OffsetRow; int row_offset;
int OffsetColumn; int col_offset;
// the size expected to be allocated to the internal grid // grid size requested by the UI. Used for window grids only.
int internal_rows; int requested_rows;
int internal_columns; int requested_cols;
int was_resized; int was_resized;
} ScreenGrid; } ScreenGrid;

View File

@@ -4269,7 +4269,7 @@ win_line (
// if we're not in ext_multigrid mode, grid has not been allocated; keep // if we're not in ext_multigrid mode, grid has not been allocated; keep
// working on the default_grid. // working on the default_grid.
if (!ui_is_external(kUIMultigrid)) { if (!ui_is_external(kUIMultigrid)) {
current_row += grid->OffsetRow; current_row += grid->row_offset;
current_grid = &default_grid; current_grid = &default_grid;
} }
@@ -4397,8 +4397,8 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol,
// If UI is not externalized, merge the contents of global and window grids // If UI is not externalized, merge the contents of global and window grids
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->row_offset;
coloff += grid->OffsetColumn; coloff += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -5303,8 +5303,8 @@ static int grid_off2cells(ScreenGrid *grid, size_t off, size_t max_off)
bool grid_lefthalve(ScreenGrid *grid, int row, int col) bool grid_lefthalve(ScreenGrid *grid, int row, int col)
{ {
if (!ui_is_external(kUIMultigrid)) { if (!ui_is_external(kUIMultigrid)) {
row += grid->OffsetRow; row += grid->row_offset;
col += grid->OffsetColumn; col += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -5318,8 +5318,8 @@ int grid_fix_col(ScreenGrid *grid, int col, int row)
{ {
int coloff = 0; int coloff = 0;
if (!ui_is_external(kUIMultigrid)) { if (!ui_is_external(kUIMultigrid)) {
row += grid->OffsetRow; row += grid->row_offset;
coloff = grid->OffsetColumn; coloff = grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -5348,8 +5348,8 @@ void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes,
unsigned off; unsigned off;
if (!ui_is_external(kUIMultigrid)) { if (!ui_is_external(kUIMultigrid)) {
row += grid->OffsetRow; row += grid->row_offset;
col += grid->OffsetColumn; col += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -5410,8 +5410,8 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row,
// If UI is not externalized, keep working on the default grid // If UI is not externalized, keep working on the default grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->row_offset;
col += grid->OffsetColumn; col += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -5870,10 +5870,10 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
// if grids are not externalized, keep working on the default_grid // if grids are not externalized, keep working on the default_grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
start_row += grid->OffsetRow; start_row += grid->row_offset;
end_row += grid->OffsetRow; end_row += grid->row_offset;
start_col += grid->OffsetColumn; start_col += grid->col_offset;
end_col += grid->OffsetColumn; end_col += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -5999,13 +5999,13 @@ int screen_valid(int doclear)
void win_grid_alloc(win_T *wp) void win_grid_alloc(win_T *wp)
{ {
ScreenGrid *grid = &wp->w_grid; ScreenGrid *grid = &wp->w_grid;
int rows = grid->internal_rows;
int columns = grid->internal_columns;
int was_resized = false;
int rows = grid->requested_rows;
if (rows == 0) { if (rows == 0) {
rows = wp->w_height; rows = wp->w_height;
} }
int columns = grid->requested_cols;
if (columns == 0) { if (columns == 0) {
columns = wp->w_width; columns = wp->w_width;
} }
@@ -6018,6 +6018,7 @@ void win_grid_alloc(win_T *wp)
grid_invalidate(grid); grid_invalidate(grid);
} }
int was_resized = false;
if ((has_allocation != want_allocation) if ((has_allocation != want_allocation)
|| grid->Rows != rows || grid->Rows != rows
|| grid->Columns != columns) { || grid->Columns != columns) {
@@ -6035,8 +6036,8 @@ void win_grid_alloc(win_T *wp)
was_resized = true; was_resized = true;
} }
grid->OffsetRow = wp->w_winrow; grid->row_offset = wp->w_winrow;
grid->OffsetColumn = wp->w_wincol; grid->col_offset = wp->w_wincol;
// send grid resize event if: // send grid resize event if:
// - a grid was just resized // - a grid was just resized
@@ -6141,8 +6142,8 @@ retry:
tab_page_click_defs = new_tab_page_click_defs; tab_page_click_defs = new_tab_page_click_defs;
tab_page_click_defs_size = default_grid.Columns; tab_page_click_defs_size = default_grid.Columns;
default_grid.OffsetRow = 0; default_grid.row_offset = 0;
default_grid.OffsetColumn = 0; default_grid.col_offset = 0;
default_grid.handle = DEFAULT_GRID_HANDLE; default_grid.handle = DEFAULT_GRID_HANDLE;
must_redraw = CLEAR; /* need to clear the screen later */ must_redraw = CLEAR; /* need to clear the screen later */
@@ -6413,9 +6414,9 @@ int grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
// If UI is not externalized, keep working on default grid // If UI is not externalized, keep working on default grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->row_offset;
end += grid->OffsetRow; end += grid->row_offset;
col += grid->OffsetColumn; col += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }
@@ -6468,9 +6469,9 @@ int grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
// If UI is not externalized, keep working on default grid // If UI is not externalized, keep working on default grid
if (!ui_is_external(kUIMultigrid) && grid != &default_grid) { if (!ui_is_external(kUIMultigrid) && grid != &default_grid) {
row += grid->OffsetRow; row += grid->row_offset;
end += grid->OffsetRow; end += grid->row_offset;
col += grid->OffsetColumn; col += grid->col_offset;
grid = &default_grid; grid = &default_grid;
} }

View File

@@ -321,8 +321,8 @@ void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol,
int clearattr, bool wrap) int clearattr, bool wrap)
{ {
size_t off = grid->LineOffset[row] + (size_t)startcol; size_t off = grid->LineOffset[row] + (size_t)startcol;
int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->row_offset;
int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->col_offset;
UI_CALL(raw_line, grid->handle, row_off + row, col_off + startcol, UI_CALL(raw_line, grid->handle, row_off + row, col_off + startcol,
col_off + endcol, col_off + clearcol, clearattr, wrap, col_off + endcol, col_off + clearcol, clearattr, wrap,
@@ -347,8 +347,8 @@ void ui_cursor_goto(int new_row, int new_col)
void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col) void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col)
{ {
new_row += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; new_row += ui_is_external(kUIMultigrid) ? 0 : grid->row_offset;
new_col += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; new_col += ui_is_external(kUIMultigrid) ? 0 : grid->col_offset;
int handle = ui_is_external(kUIMultigrid) ? grid->handle int handle = ui_is_external(kUIMultigrid) ? grid->handle
: DEFAULT_GRID_HANDLE; : DEFAULT_GRID_HANDLE;
@@ -457,7 +457,7 @@ void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error)
return; return;
} }
wp->w_grid.internal_rows = (int)height; wp->w_grid.requested_rows = (int)height;
wp->w_grid.internal_columns = (int)width; wp->w_grid.requested_cols = (int)width;
redraw_win_later(wp, SOME_VALID); redraw_win_later(wp, SOME_VALID);
} }