From 7eb990c8b15ca765dce1762ff6fd359a8c5e66b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 17 Apr 2020 22:18:02 +0200 Subject: [PATCH] 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. --- render.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/render.c b/render.c index 7b5391b6..d7dc587d 100644 --- a/render.c +++ b/render.c @@ -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);