diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-10-05 14:44:13 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-10-06 10:16:30 +0200 |
commit | a58bb215449cee65b965b9094e9e996ddfe78315 (patch) | |
tree | d5ed5946e782d4a50b1b94c9de40948a81e07e3b /src/nvim/drawscreen.c | |
parent | f67517bba30b6233bea85e1f6a8505171142d4ca (diff) | |
download | rneovim-a58bb215449cee65b965b9094e9e996ddfe78315.tar.gz rneovim-a58bb215449cee65b965b9094e9e996ddfe78315.tar.bz2 rneovim-a58bb215449cee65b965b9094e9e996ddfe78315.zip |
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)
Diffstat (limited to 'src/nvim/drawscreen.c')
-rw-r--r-- | src/nvim/drawscreen.c | 18 |
1 files changed, 6 insertions, 12 deletions
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; |