There may be more SGR sequences after the 256-color/24-bit
sequence. Thus, check that we have *enough* parameters to parse the
256-color/24-bit SGR. It doesn't have to be *exactly* the required
number of parameters though.
Fixes issues with sequences like: \e[38;2;1;48;2;1m
If a client writes to the PTY "too slow", we often end up flashing the
screen. This could for example be caused by a client first erasing a
line, then we render that frame, followed by the client updating the
just-erased line. When we render _that_ frame, it will be perceived as
a flash.
Mitigate this by trying to read client data again, after finishing
processing one batch, but before rendering.
To avoid hanging on client output (and never rendering anything),
limit this to at most 3 iterations. This may have to be tweaked.
This optimizes the normal scrolling case; updates are done at the
bottom of the screen and then scrolled up.
In this case, the damage list will be a more or less sorted list of
updates, oldest first.
If we're scrolling a lot, the oldest updates will eventually scroll
off screen. In this case, there's no need to keep them in the damage
list.
So, when scrolling, loop the damage list and adjust/remove updates
that have scrolled off screen (either partially, or completely).
Stop looping as soon as we see an update that has *not* scrolled off
screen.
Note that this means there may be update items in the damage list
that *has* scrolled off screen. This is especially true for random
screen writes (i.e. typical to some synthetic benchmarks).
This adds a pointer to the first cell on the current line. This
pointer must be updated every time the row changes.
The advantage is mainly that PRINT doesn't have to call
grid_get_range(), which is fairly expensive.
Since horizontal cursor movement is clamped to the current line, we
can calculate the new linear cursor without any expensive
multiplications and/or divisions.
Cache rendered glyph masks for each font combo. When rendering text,
use these when possible (standard ASCII).
For now, use the cached glyph as a mask. This allows colors to just
work. It would be faster to cache a completely pre-rendered image, but
then we would need one image for each background/foreground combo.