csi: erase scrollback: cancel selection if it touches the scrollback

This breaks out the scrollback erasing logic for \E[3J from csi.c, and
moves it to the new function term_erase_scrollback(), and changes the
logic to calculate the start and end row (absolute) numbers of the
scrollback, and only iterate those, instead of iterating *all* rows,
filtering out those that are on-screen.

It also adds an intersection range check of the selection range, and
cancels the selection if it touches any of the deleted scrollback
rows.

This fixes a crash when trying to render the next frame, since the
selection now references rows that have been freed.

Closes #633
This commit is contained in:
Daniel Eklöf 2021-07-16 16:45:36 +02:00
parent 34de799f90
commit 5f0ceb72f1
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 66 additions and 23 deletions

View file

@ -662,6 +662,7 @@ void term_damage_scroll(
void term_erase(
struct terminal *term, const struct coord *start, const struct coord *end);
void term_erase_scrollback(struct terminal *term);
int term_row_rel_to_abs(const struct terminal *term, int row);
void term_cursor_home(struct terminal *term);