From a58bb215449cee65b965b9094e9e996ddfe78315 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 5 Oct 2023 14:44:13 +0200 Subject: refactor(grid): get rid of unbatched grid_puts and grid_putchar This finalizes the long running refactor from the old TUI-focused grid implementation where text-drawing cursor was not separated from the visible cursor. Still, the pattern of setting cursor position together with updating a line was convenient. Introduce grid_line_cursor_goto() to still allow this but now being explicit about it. Only having batched drawing functions makes code involving drawing a bit longer. But it is better to be explicit, and this highlights cases where multiple small redraws can be grouped together. This was the case for most of the changed places (messages, lastline, and :intro) --- src/nvim/drawscreen.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/nvim/drawscreen.c') diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index a0cbc60f25..e32a556daa 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -2382,26 +2382,20 @@ static void win_update(win_T *wp, DecorProviders *providers) wp->w_botline = lnum; wp->w_filler_rows = wp->w_grid.rows - srow; } else if (dy_flags & DY_TRUNCATE) { // 'display' has "truncate" - int scr_row = wp->w_grid.rows - 1; - int symbol = wp->w_p_fcs_chars.lastline; - char fillbuf[12]; // 2 characters of 6 bytes - int charlen = utf_char2bytes(symbol, &fillbuf[0]); - utf_char2bytes(symbol, &fillbuf[charlen]); - // Last line isn't finished: Display "@@@" in the last screen line. - grid_puts(&wp->w_grid, fillbuf, MIN(wp->w_grid.cols, 2) * charlen, scr_row, 0, at_attr); - grid_fill(&wp->w_grid, scr_row, scr_row + 1, 2, wp->w_grid.cols, symbol, ' ', at_attr); + grid_line_start(&wp->w_grid, wp->w_grid.rows - 1); + grid_line_fill(0, MIN(wp->w_grid.cols, 3), wp->w_p_fcs_chars.lastline, at_attr); + grid_line_fill(3, wp->w_grid.cols, ' ', at_attr); + grid_line_flush(); set_empty_rows(wp, srow); wp->w_botline = lnum; } else if (dy_flags & DY_LASTLINE) { // 'display' has "lastline" - int start_col = wp->w_grid.cols - 3; - int symbol = wp->w_p_fcs_chars.lastline; - // Last line isn't finished: Display "@@@" at the end. // TODO(bfredl): this display ">@@@" when ">" was a left-halve // maybe "@@@@" is preferred when this happens. grid_line_start(&wp->w_grid, wp->w_grid.rows - 1); - grid_line_fill(MAX(start_col, 0), wp->w_grid.cols, symbol, at_attr); + grid_line_fill(MAX(wp->w_grid.cols - 3, 0), wp->w_grid.cols, + wp->w_p_fcs_chars.lastline, at_attr); grid_line_flush(); set_empty_rows(wp, srow); wp->w_botline = lnum; -- cgit