From ef52ed8a109af7512bd9e9ed62d74e36ae2deb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 17 Apr 2020 21:04:32 +0200 Subject: [PATCH] grid: reflow: caller may now pass a list of coordinates that should be translated --- grid.c | 7 ++++++- grid.h | 4 +++- render.c | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/grid.c b/grid.c index 3e34c891..b50a095d 100644 --- a/grid.c +++ b/grid.c @@ -55,7 +55,9 @@ grid_row_free(struct row *row) void grid_reflow(struct grid *grid, int new_rows, int new_cols, - int old_screen_rows, int new_screen_rows) + int old_screen_rows, int new_screen_rows, + size_t tracking_points_count, + struct coord *_tracking_points[static tracking_points_count]) { struct row *const *old_grid = grid->rows; const int old_rows = grid->num_rows; @@ -90,6 +92,9 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, tll_push_back(tracking_points, &cursor); tll_push_back(tracking_points, &saved_cursor); + for (size_t i = 0; i < tracking_points_count; i++) + tll_push_back(tracking_points, _tracking_points[i]); + /* * Walk the old grid */ diff --git a/grid.h b/grid.h index d4045189..a2ff4b99 100644 --- a/grid.h +++ b/grid.h @@ -8,7 +8,9 @@ struct row *grid_row_alloc(int cols, bool initialize); void grid_row_free(struct row *row); void grid_reflow( struct grid *grid, int new_rows, int new_cols, - int old_screen_rows, int new_screen_rows); + int old_screen_rows, int new_screen_rows, + size_t tracking_points_count, + struct coord *tracking_points[static tracking_points_count]); static inline int grid_row_absolute(const struct grid *grid, int row_no) diff --git a/render.c b/render.c index ef0f0608..ca0342f2 100644 --- a/render.c +++ b/render.c @@ -1754,8 +1754,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force) } /* Reflow grids */ - grid_reflow(&term->normal, new_normal_grid_rows, new_cols, old_rows, new_rows); - grid_reflow(&term->alt, new_alt_grid_rows, new_cols, old_rows, new_rows); + 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); /* Reset tab stops */ tll_free(term->tab_stops);