refactor(grid): unify the two put-text-on-the-screen code paths

The screen grid refactors will continue until morale improves.
Jokes aside, this is quite a central installment in the series.

Before this refactor, there were two fundamentally distinct codepaths
for getting some text on the screen:

- the win_line() -> grid_put_linebuf() -> ui_line() call chain used for
  buffer text, with linebuf_char as a temporary scratch buffer
- the grid_line_start/grid_line_puts/grid_line_flush() -> ui_line()
  path used for every thing else: statuslines, messages and the command line.
  Here the grid->chars[] array itself doubles as a scratch buffer.

With this refactor, the later family of functions still exist, however
they now as well render to linebuf_char just like win_line() did, and
grid_put_linebuf() is called in the end to calculate delta changes.
This means we don't need any duplicate logic for delta calculations anymore.

Later down the line, it will be possible to share more logic operating
on this scratch buffer, like doing 'rightleft' reversal and arabic
shaping as a post-processing step.
This commit is contained in:
bfredl
2023-09-20 10:08:05 +02:00
parent af7d317f3f
commit e33269578b
7 changed files with 201 additions and 247 deletions

View File

@@ -2087,7 +2087,7 @@ static void display_showcmd(void)
// clear the rest of an old message by outputting up to SHOWCMD_COLS spaces
grid_line_puts(sc_col + len, (char *)" " + len, -1, HL_ATTR(HLF_MSG));
grid_line_flush(false);
grid_line_flush();
}
/// When "check" is false, prepare for commands that scroll the window.