diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-03-27 14:53:41 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-03-27 14:53:41 +0000 |
| commit | 296e75f4f54f56be7d36fcccb032dca9e5be959b (patch) | |
| tree | f987c1796a20415dad23b0a6b7942ca65eec0a1a /render.c | |
| parent | slave: set $TERM_PROGRAM and $TERM_PROGRAM_VERSION environment variables (diff) | |
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.
Diffstat (limited to 'render.c')
| -rw-r--r-- | render.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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); } |
