mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-12 04:27:51 -05:00
selection: handle viewport wrap around correctly
When the viewport wraps around, the selection points may be "incorrect".
This commit is contained in:
parent
550667a9ea
commit
08588cd0fc
5 changed files with 64 additions and 49 deletions
28
selection.c
28
selection.c
|
|
@ -69,6 +69,34 @@ selection_on_rows(const struct terminal *term, int row_start, int row_end)
|
|||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
selection_view_up(struct terminal *term, int new_view)
|
||||
{
|
||||
if (likely(term->selection.start.row < 0))
|
||||
return;
|
||||
|
||||
if (likely(new_view < term->grid->view))
|
||||
return;
|
||||
|
||||
term->selection.start.row += term->grid->num_rows;
|
||||
if (term->selection.end.row >= 0)
|
||||
term->selection.end.row += term->grid->num_rows;
|
||||
}
|
||||
|
||||
void
|
||||
selection_view_down(struct terminal *term, int new_view)
|
||||
{
|
||||
if (likely(term->selection.start.row < 0))
|
||||
return;
|
||||
|
||||
if (likely(new_view > term->grid->view))
|
||||
return;
|
||||
|
||||
term->selection.start.row &= term->grid->num_rows - 1;
|
||||
if (term->selection.end.row >= 0)
|
||||
term->selection.end.row &= term->grid->num_rows - 1;
|
||||
}
|
||||
|
||||
static void
|
||||
foreach_selected_normal(
|
||||
struct terminal *term, struct coord _start, struct coord _end,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue