diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-01-04 13:06:39 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-01-04 13:06:39 +0000 |
| commit | a83c9e28137158fe0fb68a0e163e0305ca14ddeb (patch) | |
| tree | 92bc43a1de5d593071a72d07f8ad384b1642138e | |
| parent | selection: rename selection_cell_count -> min_bufsize_for_extraction (diff) | |
selection: min_bufsize_for_extraction: add one extra column for *all* rows
| -rw-r--r-- | selection.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/selection.c b/selection.c index 0df05647..9a574169 100644 --- a/selection.c +++ b/selection.c @@ -162,14 +162,11 @@ min_bufsize_for_extraction(const struct terminal *term) else { size_t cells = 0; - /* First row; start of selection to end of row */ - cells += term->cols - start->col; + /* Add one extra column on each row, for \n */ - /* Full rows; add one extra column for \n */ + cells += term->cols - start->col + 1; cells += (term->cols + 1) * (end->row - start->row - 1); - - /* Final row; start of row to end of selection */ - cells += end->col + 1; + cells += end->col + 1 + 1; return cells; } @@ -184,7 +181,7 @@ min_bufsize_for_extraction(const struct terminal *term) .col = max(start->col, end->col), }; - /* Add one extra column for \n */ + /* Add one extra column on each row, for \n */ int cols = bottom_right.col - top_left.col + 1 + 1; int rows = bottom_right.row - top_left.row + 1; return rows * cols; |
