mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
render: fix glitchy selection while resizing the ‘normal’ screen
The selection coordinates are in absolute row numbers. As such, selection breaks when interactively resizing the normal grid, since we then instantiate a temporary grid mapping directly to the current viewport (for performance reason, to avoid reflowing the entire grid over and over again). Fix by stashing the actual selection coordinates, and ajusting the "active" ones to the temporary grid.
This commit is contained in:
parent
5b2f02d826
commit
296e75f4f5
2 changed files with 7 additions and 0 deletions
6
render.c
6
render.c
|
|
@ -3976,6 +3976,7 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
|||
term->interactive_resizing.old_hide_cursor = term->hide_cursor;
|
||||
term->interactive_resizing.grid = xmalloc(sizeof(*term->interactive_resizing.grid));
|
||||
*term->interactive_resizing.grid = term->normal;
|
||||
term->interactive_resizing.selection_coords = term->selection.coords;
|
||||
} else {
|
||||
/* We’ll replace the current temporary grid, with a new
|
||||
* one (again based on the original grid) */
|
||||
|
|
@ -4013,6 +4014,9 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
|||
.kitty_kbd = orig->kitty_kbd,
|
||||
};
|
||||
|
||||
term->selection.coords.start.row -= orig->view;
|
||||
term->selection.coords.end.row -= orig->view;
|
||||
|
||||
for (size_t i = 0, j = orig->view;
|
||||
i < term->interactive_resizing.old_screen_rows;
|
||||
i++, j = (j + 1) & (orig->num_rows - 1))
|
||||
|
|
@ -4069,6 +4073,7 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
|||
free(term->interactive_resizing.grid);
|
||||
|
||||
term->hide_cursor = term->interactive_resizing.old_hide_cursor;
|
||||
term->selection.coords = term->interactive_resizing.selection_coords;
|
||||
|
||||
old_rows = term->interactive_resizing.old_screen_rows;
|
||||
|
||||
|
|
@ -4076,6 +4081,7 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
|||
term->interactive_resizing.old_screen_rows = 0;
|
||||
term->interactive_resizing.new_rows = 0;
|
||||
term->interactive_resizing.old_hide_cursor = false;
|
||||
term->interactive_resizing.selection_coords = (struct range){{-1, -1}, {-1, -1}};
|
||||
term_ptmx_resume(term);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -604,6 +604,7 @@ struct terminal {
|
|||
int old_cols; /* term->cols before resize started */
|
||||
int old_hide_cursor; /* term->hide_cursor before resize started */
|
||||
int new_rows; /* New number of scrollback rows */
|
||||
struct range selection_coords;
|
||||
} interactive_resizing;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue