This resolves several problems with handling of the saved cursor when
switching between primary and alternate screen. Additionally ref-tests
are also added for all common interactions to make sure the behavior
does not regress.
The behavior is based on XTerm's behavior except for interaction with
`reset`. XTerm does not reset the alternate screen's saved cursor on
`reset`, but VTE does. Since a `reset` should reset as much as possible,
Alacritty copies VTE here instead of XTerm.
While neither VTE, URxvt nor Kitty handle this, preserving the linewrap
flag across alternate screen switches seems like the correct thing to
do. XTerm also does handle this correctly, which indicates that it is a
bug and not a feature.
This works around a bug where the optimized version of the
`Grid::scroll_down` function would just rotate the entire grid down if
the scrolling region starts at the top of the screen, even if there is
history available.
Since rotations of scrolling regions should not affect the scrollback
history, this optimized version is now only called when the max
scrollback size is 0, making it impossible for the grid to have any
history while it is used.
Since the main usecase of this is the alternate screen buffer, which
never has any history, the performance should not be affected negatively
by this change.
Fixes#3582.
This fixes a bug where a row would always get reset completely if its
background does not equal the default terminal background. This leads to
big performance bottlenecks when running commands like `echo "\e[41m" &&
yes`.
Instead of resetting the entire row whenever the template cell is not
empty, the template cell is now compared to the last cell in the row.
The last cell will always be equal to the previous template cell when
`row.occ < row.inner.len()` and if `occ` is equal to the row's length,
the entire row is always reset anyways.
Fixes#2989.
This covers the behavior of clearing the screen and a row with colored
cells.
This covers a bug discovered in #2329 which was not detected in any
existing ref tests.
This fixes a bug that would clear the cells with the current template
cell with just the `flags` reset, to make sure the colors are correct.
However, the cell foreground was not reset, leading to cells counting as
occupied when resizing.
With this change both cell flags and foreground color are ignored when
clearing both the whole screen and inside the line, allowing us to
accurately keep track of cell occupation.
Fixes#2866.
Instead of ignoring unexpected intermediates in CSI escape sequences,
the intermediates are now explicitly checked and the escape sequence is
rejected when an unexpected intermediate is found.
Fixes#2171.
Since ref tests were only stored whenever winit requested the window
close, they would not get stored properly when the terminal was closed
through Alacritty using `exit`, Ctrl+D or similar.
This moves the ref test code to the and of the main entry point, which
will always be executed regardless of how the terminal was shutdown.
Fixes#2613.