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)
This commit is contained in:
bfredl
2023-10-05 14:44:13 +02:00
parent f67517bba3
commit a58bb21544
10 changed files with 105 additions and 152 deletions

View File

@@ -2959,15 +2959,15 @@ void os_msg(const char *str)
void msg_moremsg(int full)
{
int attr;
char *s = _("-- More --");
attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M));
grid_puts(&msg_grid_adj, s, -1, Rows - 1, 0, attr);
int attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M));
grid_line_start(&msg_grid_adj, Rows - 1);
int len = grid_line_puts(0, _("-- More --"), -1, attr);
if (full) {
grid_puts(&msg_grid_adj, _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), -1,
Rows - 1, vim_strsize(s), attr);
len += grid_line_puts(len, _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "),
-1, attr);
}
grid_line_cursor_goto(len);
grid_line_flush();
}
/// Repeat the message for the current mode: MODE_ASKMORE, MODE_EXTERNCMD,