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/version.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/version.c')
-rw-r--r-- | src/nvim/version.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/nvim/version.c b/src/nvim/version.c index 20bbcb2f8a..c3bfad4706 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -2827,7 +2827,7 @@ void intro_message(int colon) } if (*mesg != NUL) { - do_intro_line(row, mesg, 0); + do_intro_line((int)row, mesg, 0); } row++; @@ -2838,14 +2838,13 @@ void intro_message(int colon) } } -static void do_intro_line(long row, char *mesg, int attr) +static void do_intro_line(int row, char *mesg, int attr) { char *p; int l; - int clen; // Center the message horizontally. - long col = vim_strsize(mesg); + int col = vim_strsize(mesg); col = (Columns - col) / 2; @@ -2853,21 +2852,18 @@ static void do_intro_line(long row, char *mesg, int attr) col = 0; } + grid_line_start(&default_grid, row); // Split up in parts to highlight <> items differently. for (p = mesg; *p != NUL; p += l) { - clen = 0; - for (l = 0; p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); l++) { - clen += ptr2cells(p + l); l += utfc_ptr2len(p + l) - 1; } assert(row <= INT_MAX && col <= INT_MAX); - grid_puts(&default_grid, p, l, (int)row, (int)col, - *p == '<' ? HL_ATTR(HLF_8) : attr); - col += clen; + col += grid_line_puts(col, p, l, *p == '<' ? HL_ATTR(HLF_8) : attr); } + grid_line_flush(); } /// ":intro": clear screen, display intro screen and wait for return. |