render: resize: need to translate selection coordinates

While it *looked* like the selection was working before, it really
wasn't.

When rendering, we're looking at the cells' attributes to determine
whether they have been selected or not.

When copying text however, we use the terminal's 'selection' state,
which consists of 'start' and 'end' coordinates.

These need to be translated when reflowing text.
This commit is contained in:
Daniel Eklöf 2020-04-17 22:18:02 +02:00
parent 5e2e59679b
commit 7eb990c8b1
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -25,6 +25,7 @@
#define TIME_FRAME_RENDERING 0
#define TIME_SCROLL_DAMAGE 0
#define ALEN(v) (sizeof(v) / sizeof(v[0]))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
@ -1751,9 +1752,21 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
goto damage_view;
}
struct coord *const tracking_points[] = {
&term->selection.start,
&term->selection.end,
};
/* Reflow grids */
grid_reflow(&term->normal, new_normal_grid_rows, new_cols, old_rows, new_rows, 0, NULL);
grid_reflow(&term->alt, new_alt_grid_rows, new_cols, old_rows, new_rows, 0, NULL);
grid_reflow(
&term->normal, new_normal_grid_rows, new_cols, old_rows, new_rows,
term->grid == &term->normal ? ALEN(tracking_points) : 0,
term->grid == &term->normal ? tracking_points : NULL);
grid_reflow(
&term->alt, new_alt_grid_rows, new_cols, old_rows, new_rows,
term->grid == &term->alt ? ALEN(tracking_points) : 0,
term->grid == &term->alt ? tracking_points : NULL);
/* Reset tab stops */
tll_free(term->tab_stops);