input: motion: scroll up/down while selecting

If the cursor moves above the grid top, or below the grid bottom,
while selecting text, scroll up/down the scrollback before updating
the selection.

TODO: this only scrolls when the mouse is *moved*. I.e. you can’t move
the cursor outside the grid once and for all, and then let foot
auto-scroll.
This commit is contained in:
Daniel Eklöf 2020-10-11 12:03:20 +02:00
parent c650862b0d
commit 2303affc87
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

14
input.c
View file

@ -1325,10 +1325,22 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
= old_col != seat->mouse.col || old_row != seat->mouse.row;
/* Cursor is inside the grid, i.e. *not* in the margins */
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
const bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
const bool scroll_up = y < term->margins.top;
const bool scroll_down = y >= term->height - term->margins.bottom;
/* Update selection */
if (!term->is_searching) {
if (scroll_up || scroll_down) {
if (scroll_up)
cmd_scrollback_up(term, 1);
if (scroll_down)
cmd_scrollback_down(term, 1);
cursor_is_on_new_cell = true;
}
if (cursor_is_on_new_cell || term->selection.end.row < 0)
selection_update(term, selection_col, selection_row);
}