mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-01 07:15:32 -04:00
render: coord_is_selected: handle block selections
This commit is contained in:
parent
d706e68280
commit
cb9ae4f6a1
1 changed files with 22 additions and 8 deletions
30
render.c
30
render.c
|
|
@ -350,16 +350,30 @@ coord_is_selected(const struct terminal *term, int col, int row)
|
||||||
|
|
||||||
row += term->grid->view;
|
row += term->grid->view;
|
||||||
|
|
||||||
if (start->row == end->row) {
|
switch (term->selection.kind) {
|
||||||
return row == start->row && col >= start->col && col <= end->col;
|
case SELECTION_NORMAL:
|
||||||
} else {
|
if (start->row == end->row) {
|
||||||
if (row == start->row)
|
return row == start->row && col >= start->col && col <= end->col;
|
||||||
return col >= start->col;
|
} else {
|
||||||
else if (row == end->row)
|
if (row == start->row)
|
||||||
return col <= end->col;
|
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
|
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
|
static int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue