From f102f50ebeca98365b308463c25eb2caffffba51 Mon Sep 17 00:00:00 2001 From: Utkarsh Maheshwari Date: Sat, 19 May 2018 21:03:17 +0530 Subject: multigrid: Change screen_* functions to grid_* functions --- src/nvim/ui.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 0c69e94e5d..a454afad24 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -57,6 +57,7 @@ static int busy = 0; static int mode_idx = SHAPE_IDX_N; static bool pending_mode_info_update = false; static bool pending_mode_update = false; +static GridHandle cursor_grid_handle = 1; #if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL # define UI_LOG(funname, ...) @@ -315,12 +316,18 @@ void ui_set_ext_option(UI *ui, UIExtension ext, bool active) } } -void ui_line(int row, int startcol, int endcol, int clearcol, int clearattr, - bool wrap) +void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol, + int clearattr, bool wrap) { - size_t off = LineOffset[row]+(size_t)startcol; - UI_CALL(raw_line, 1, row, startcol, endcol, clearcol, clearattr, wrap, - (const schar_T *)ScreenLines+off, (const sattr_T *)ScreenAttrs+off); + size_t off = grid->LineOffset[row] + (size_t)startcol; + int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; + int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; + + UI_CALL(raw_line, grid->handle, row_off + row, col_off + startcol, + col_off + endcol, col_off + clearcol, clearattr, wrap, + (const schar_T *)grid->ScreenLines + off, + (const sattr_T *)grid->ScreenAttrs + off); + if (p_wd) { // 'writedelay': flush & delay each time. int old_row = row, old_col = col; // If'writedelay is active, we set the cursor to highlight what was drawn @@ -334,11 +341,20 @@ void ui_line(int row, int startcol, int endcol, int clearcol, int clearattr, void ui_cursor_goto(int new_row, int new_col) { - if (new_row == row && new_col == col) { + ui_grid_cursor_goto(&default_grid, new_row, new_col); +} + +void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col) +{ + int off_row = (ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow); + int off_col = (ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn); + + if (new_row + off_row == row && new_col + off_col == col) { return; } - row = new_row; - col = new_col; + row = new_row + off_row; + col = new_col + off_col; + cursor_grid_handle = grid->handle; pending_cursor_update = true; } @@ -361,7 +377,7 @@ void ui_flush(void) { cmdline_ui_flush(); if (pending_cursor_update) { - ui_call_grid_cursor_goto(1, row, col); + ui_call_grid_cursor_goto(cursor_grid_handle, row, col); pending_cursor_update = false; } if (pending_mode_info_update) { -- cgit From 01555de2da79eaf6e569e5e6ee7244dbf5f709e5 Mon Sep 17 00:00:00 2001 From: Utkarsh Maheshwari Date: Wed, 6 Jun 2018 02:59:11 +0530 Subject: multigrid: Allow UIs to set grid size different from window size --- src/nvim/ui.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index a454afad24..968c3b7b16 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -57,7 +57,7 @@ static int busy = 0; static int mode_idx = SHAPE_IDX_N; static bool pending_mode_info_update = false; static bool pending_mode_update = false; -static GridHandle cursor_grid_handle = 1; +static GridHandle cursor_grid_handle = DEFAULT_GRID_HANDLE; #if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL # define UI_LOG(funname, ...) @@ -197,13 +197,6 @@ void ui_refresh(void) row = col = 0; pending_cursor_update = true; - ui_default_colors_set(); - - int save_p_lz = p_lz; - p_lz = false; // convince redrawing() to return true ... - screen_resize(width, height); - p_lz = save_p_lz; - for (UIExtension i = 0; (int)i < kUIExtCount; i++) { ui_ext[i] = ext_widgets[i]; if (i < kUIGlobalCount) { @@ -211,6 +204,14 @@ void ui_refresh(void) BOOLEAN_OBJ(ext_widgets[i])); } } + + ui_default_colors_set(); + + int save_p_lz = p_lz; + p_lz = false; // convince redrawing() to return true ... + screen_resize(width, height); + p_lz = save_p_lz; + ui_mode_info_set(); pending_mode_update = true; ui_cursor_shape(); @@ -437,3 +438,18 @@ Array ui_array(void) } return all_uis; } + +void ui_grid_resize(GridHandle grid_handle, int width, int height) +{ + win_T *wp = get_win_by_grid_handle(grid_handle); + + if (wp == NULL) { + //TODO(utkarshme): error out + abort(); + return; + } + + wp->w_grid.internal_rows = (int)height; + wp->w_grid.internal_columns = (int)width; + redraw_win_later(wp, SOME_VALID); +} -- cgit From d5754eae020d672b4f6c62b636a56e0d6d56b4dc Mon Sep 17 00:00:00 2001 From: Utkarsh Maheshwari Date: Fri, 15 Jun 2018 02:41:59 +0530 Subject: multigrid: Add win_position event Throttle win_position events --- src/nvim/ui.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 968c3b7b16..24557c5d0b 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -377,6 +377,7 @@ int ui_current_col(void) void ui_flush(void) { cmdline_ui_flush(); + win_ui_flush(); if (pending_cursor_update) { ui_call_grid_cursor_goto(cursor_grid_handle, row, col); pending_cursor_update = false; -- cgit From 0432e1586ef0f9dd5e473cee07787ed5bb880570 Mon Sep 17 00:00:00 2001 From: Utkarsh Maheshwari Date: Tue, 19 Jun 2018 11:45:10 +0530 Subject: multigrid: Put everything on default_grid if not ext_multigrid --- src/nvim/ui.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 24557c5d0b..74814bf0ae 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -440,13 +440,16 @@ Array ui_array(void) return all_uis; } -void ui_grid_resize(GridHandle grid_handle, int width, int height) +void ui_grid_resize(GridHandle grid_handle, int width, int height, Error *error) { - win_T *wp = get_win_by_grid_handle(grid_handle); + if (grid_handle == DEFAULT_GRID_HANDLE) { + screen_resize(width, height); + return; + } + win_T *wp = get_win_by_grid_handle(grid_handle); if (wp == NULL) { - //TODO(utkarshme): error out - abort(); + api_set_error(error, kErrorTypeValidation, "No window with the given handle"); return; } -- cgit From 62be9f39ef9cd8592ac0048ba2840aa65cbc1849 Mon Sep 17 00:00:00 2001 From: Utkarsh Maheshwari Date: Tue, 4 Sep 2018 02:45:29 +0530 Subject: multigrid: Fix sending window grid handle in ext_newline mode --- src/nvim/ui.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 74814bf0ae..89c0069e58 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -347,15 +347,17 @@ void ui_cursor_goto(int new_row, int new_col) void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col) { - int off_row = (ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow); - int off_col = (ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn); + new_row += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; + new_col += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; + int handle = ui_is_external(kUIMultigrid) ? grid->handle : DEFAULT_GRID_HANDLE; - if (new_row + off_row == row && new_col + off_col == col) { + if (new_row == row && new_col == col && handle == cursor_grid_handle) { return; } - row = new_row + off_row; - col = new_col + off_col; - cursor_grid_handle = grid->handle; + + row = new_row; + col = new_col; + cursor_grid_handle = handle; pending_cursor_update = true; } -- cgit From ba6f9f60addb569aa223f6e245df78741eab5adf Mon Sep 17 00:00:00 2001 From: Utkarsh Maheshwari Date: Fri, 21 Sep 2018 18:14:32 +0530 Subject: multigrid: Fix lint errors --- src/nvim/ui.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 89c0069e58..da6a1d0f2a 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -349,7 +349,8 @@ void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col) { new_row += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; new_col += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; - int handle = ui_is_external(kUIMultigrid) ? grid->handle : DEFAULT_GRID_HANDLE; + int handle = ui_is_external(kUIMultigrid) ? grid->handle + : DEFAULT_GRID_HANDLE; if (new_row == row && new_col == col && handle == cursor_grid_handle) { return; @@ -451,7 +452,8 @@ void ui_grid_resize(GridHandle grid_handle, int width, int height, Error *error) win_T *wp = get_win_by_grid_handle(grid_handle); if (wp == NULL) { - api_set_error(error, kErrorTypeValidation, "No window with the given handle"); + api_set_error(error, kErrorTypeValidation, + "No window with the given handle"); return; } -- cgit From 1cec5542a83baf04848e37475b9b0b7f50e47284 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 23 Dec 2018 14:35:23 +0100 Subject: multigrid: reorganize types and global varaibles --- src/nvim/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index da6a1d0f2a..302aa555af 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -57,7 +57,7 @@ static int busy = 0; static int mode_idx = SHAPE_IDX_N; static bool pending_mode_info_update = false; static bool pending_mode_update = false; -static GridHandle cursor_grid_handle = DEFAULT_GRID_HANDLE; +static handle_T cursor_grid_handle = DEFAULT_GRID_HANDLE; #if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL # define UI_LOG(funname, ...) @@ -443,7 +443,7 @@ Array ui_array(void) return all_uis; } -void ui_grid_resize(GridHandle grid_handle, int width, int height, Error *error) +void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error) { if (grid_handle == DEFAULT_GRID_HANDLE) { screen_resize(width, height); -- cgit From dc4430933648c908bdabcd4ed6c782efffbec4f2 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 23 Dec 2018 15:06:28 +0100 Subject: multigrid: rename to grid.row_offset and grid.requested_rows --- src/nvim/ui.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 302aa555af..fd134e626f 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -321,8 +321,8 @@ void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol, int clearattr, bool wrap) { size_t off = grid->LineOffset[row] + (size_t)startcol; - int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; - int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; + int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->row_offset; + int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->col_offset; UI_CALL(raw_line, grid->handle, row_off + row, col_off + startcol, 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) { - new_row += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow; - new_col += ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn; + new_row += ui_is_external(kUIMultigrid) ? 0 : grid->row_offset; + new_col += ui_is_external(kUIMultigrid) ? 0 : grid->col_offset; int handle = ui_is_external(kUIMultigrid) ? grid->handle : DEFAULT_GRID_HANDLE; @@ -457,7 +457,7 @@ void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error) return; } - wp->w_grid.internal_rows = (int)height; - wp->w_grid.internal_columns = (int)width; + wp->w_grid.requested_rows = (int)height; + wp->w_grid.requested_cols = (int)width; redraw_win_later(wp, SOME_VALID); } -- cgit From c72d9ce0a602ba53b99145f64f0d43327a4e3eb3 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 31 Dec 2018 13:29:58 +0100 Subject: multigrid: rename grid->ScreenLines and other grid arrays --- src/nvim/ui.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index fd134e626f..dc81c18b0b 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -320,14 +320,14 @@ void ui_set_ext_option(UI *ui, UIExtension ext, bool active) void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol, int clearattr, bool wrap) { - size_t off = grid->LineOffset[row] + (size_t)startcol; + size_t off = grid->line_offset[row] + (size_t)startcol; int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->row_offset; int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->col_offset; UI_CALL(raw_line, grid->handle, row_off + row, col_off + startcol, col_off + endcol, col_off + clearcol, clearattr, wrap, - (const schar_T *)grid->ScreenLines + off, - (const sattr_T *)grid->ScreenAttrs + off); + (const schar_T *)grid->chars + off, + (const sattr_T *)grid->attrs + off); if (p_wd) { // 'writedelay': flush & delay each time. int old_row = row, old_col = col; -- cgit