diff options
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r-- | src/nvim/ui.c | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 0c69e94e5d..9c91192a8b 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 handle_T cursor_grid_handle = DEFAULT_GRID_HANDLE; #if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL # define UI_LOG(funname, ...) @@ -196,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) { @@ -210,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(); @@ -315,30 +317,41 @@ 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->line_offset[row] + (size_t)startcol; + + UI_CALL(raw_line, grid->handle, row, startcol, endcol, clearcol, clearattr, + wrap, (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; + handle_T old_grid = cursor_grid_handle; // If'writedelay is active, we set the cursor to highlight what was drawn - ui_cursor_goto(row, MIN(clearcol, (int)Columns-1)); + ui_grid_cursor_goto(grid->handle, row, MIN(clearcol, (int)Columns-1)); ui_flush(); uint64_t wd = (uint64_t)labs(p_wd); os_microdelay(wd * 1000u, true); - ui_cursor_goto(old_row, old_col); + ui_grid_cursor_goto(old_grid, old_row, old_col); } } void ui_cursor_goto(int new_row, int new_col) { - if (new_row == row && new_col == col) { + ui_grid_cursor_goto(DEFAULT_GRID_HANDLE, new_row, new_col); +} + +void ui_grid_cursor_goto(handle_T grid_handle, int new_row, int new_col) +{ + if (new_row == row && new_col == col && grid_handle == cursor_grid_handle) { return; } + row = new_row; col = new_col; + cursor_grid_handle = grid_handle; pending_cursor_update = true; } @@ -360,8 +373,9 @@ int ui_current_col(void) void ui_flush(void) { cmdline_ui_flush(); + win_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) { @@ -421,3 +435,22 @@ Array ui_array(void) } return all_uis; } + +void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error) +{ + if (grid_handle == DEFAULT_GRID_HANDLE) { + screen_resize(width, height); + return; + } + + win_T *wp = get_win_by_grid_handle(grid_handle); + if (wp == NULL) { + api_set_error(error, kErrorTypeValidation, + "No window with the given handle"); + return; + } + + wp->w_grid.requested_rows = (int)height; + wp->w_grid.requested_cols = (int)width; + redraw_win_later(wp, SOME_VALID); +} |