From 7fedf2f80160d4cb96b77ae58137573b78cbfeee Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 11 Oct 2020 15:44:20 +0200 Subject: selection: auto-scroll: selection keeps scrolling while mouse is outside grid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moving the mouse outside the grid while we have an on-going selection now starts a timer. The interval of this timer depends on the mouse’s distance from the grid - the further away the mouse is, the shorter interval. On each timer timeout, we scroll one line, and update the selection. Thus, the shorter the interval, the faster we scroll. The timer is canceled as soon as the mouse enters the grid again, or the selection is either canceled or finalized. The timer FD is created and destroyed on-demand. Most of the logic is now in selection.c. The exception is the calculation of the timer interval, which depends on the mouse’s position. Thus, this is done in input.c. The scroll+selection update logic needs to know a) which direction we’re scrolling in, and b) which *column* the selection should be updated with. If the mouse is outside the grid’s left or right margins, the stored mouse column will be -1. I.e. we don’t know whether the mouse is on the left or right side of the grid. This is why the caller, that starts the timer, must provide this value. The same applies to top and bottom margins, but since we already have the scroll *direction*, which row value to use can be derived from this. --- selection.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'selection.h') diff --git a/selection.h b/selection.h index 547da2fc..888b2f05 100644 --- a/selection.h +++ b/selection.h @@ -74,3 +74,8 @@ void text_from_primary( struct seat *seat, struct terminal *term, void (*cb)(const char *data, size_t size, void *user), void (*dont)(void *user), void *user); + +void selection_start_scroll_timer( + struct terminal *term, int interval_ns, + enum selection_scroll_direction direction, int col); +void selection_stop_scroll_timer(struct terminal *term); -- cgit v1.3