aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-01-03 22:34:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-01-03 22:34:58 +0000
commitcb9ae4f6a13f9e4001539dfed359f55a200c758c (patch)
treedcb0769a7655388ce094ba75ce129c80d46cdce1 /render.c
parentselection: track selection type; normal or block selection (diff)
render: coord_is_selected: handle block selections
Diffstat (limited to 'render.c')
-rw-r--r--render.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/render.c b/render.c
index ba70aee0..755304ea 100644
--- a/render.c
+++ b/render.c
@@ -350,16 +350,30 @@ coord_is_selected(const struct terminal *term, int col, int row)
row += term->grid->view;
- if (start->row == end->row) {
- return row == start->row && col >= start->col && col <= end->col;
- } else {
- if (row == start->row)
- return col >= start->col;
- else if (row == end->row)
- return col <= end->col;
+ switch (term->selection.kind) {
+ case SELECTION_NORMAL:
+ if (start->row == end->row) {
+ return row == start->row && col >= start->col && col <= end->col;
+ } else {
+ if (row == start->row)
+ return col >= start->col;
+ else if (row == end->row)
+ return col <= end->col;
+ else
+ return row >= start->row && row <= end->row;
+ }
+
+ case SELECTION_BLOCK:
+ if (start->col <= end->col)
+ return row >= start->row && row <= end->row &&
+ col >= start->col && col <= end->col;
else
- return row >= start->row && row <= end->row;
+ return row >= start->row && row <= end->row &&
+ col <= start->col && col >= end->col;
}
+
+ assert(false);
+ return false;
}
static int