From 6ebf55572e765394e90c96b5fec0e2c55b3b434e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 28 Jul 2022 18:31:11 +0200 Subject: [PATCH] selection: foreach_selected_*(): refactor: use grid_row_abs_to_sb() --- selection.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/selection.c b/selection.c index 36f4078f..fd821c06 100644 --- a/selection.c +++ b/selection.c @@ -181,14 +181,14 @@ foreach_selected_normal( const struct coord *start = &_start; const struct coord *end = &_end; - const int scrollback_start = term->grid->offset + term->rows; const int grid_rows = term->grid->num_rows; + /* Start/end rows, relative to the scrollback start */ /* Start/end rows, relative to the scrollback start */ const int rel_start_row = - (start->row - scrollback_start + grid_rows) & (grid_rows - 1); + grid_row_abs_to_sb(term->grid, term->rows, start->row); const int rel_end_row = - (end->row - scrollback_start + grid_rows) & (grid_rows - 1); + grid_row_abs_to_sb(term->grid, term->rows, end->row); int start_row, end_row; int start_col, end_col; @@ -244,14 +244,13 @@ foreach_selected_block( const struct coord *start = &_start; const struct coord *end = &_end; - const int scrollback_start = term->grid->offset + term->rows; const int grid_rows = term->grid->num_rows; /* Start/end rows, relative to the scrollback start */ const int rel_start_row = - (start->row - scrollback_start + grid_rows) & (grid_rows - 1); + grid_row_abs_to_sb(term->grid, term->rows, start->row); const int rel_end_row = - (end->row - scrollback_start + grid_rows) & (grid_rows - 1); + grid_row_abs_to_sb(term->grid, term->rows, end->row); struct coord top_left = { .row = (rel_start_row < rel_end_row