From 980dcdaa138a42830af4e2533b7e970d7f5fa3cf Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 2 Feb 2025 16:09:08 +0300 Subject: only scroll the caret if dot changes * Fixes scrolling with default ^KMOUSE macro from fnkeys.tes which adjusts the scroll position without changing dot. The unconditional SCI_SCROLLCARET would effectively prevent scrolling to any position that does not contain dot. --- src/interface-curses/interface.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/interface-curses') diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index fe2b1bb..9480822 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -1572,13 +1572,6 @@ teco_interface_is_interrupted(void) static void teco_interface_refresh(void) { - /* - * Scintilla has been patched to avoid any automatic scrolling since that - * has been benchmarked to be a very costly operation. - * Instead we do it only once after every keypress. - */ - teco_interface_ssm(SCI_SCROLLCARET, 0, 0); - /* * Info window is updated very often which is very * costly, especially when using PDC_set_title(), @@ -1723,6 +1716,9 @@ teco_interface_event_loop_iter(void) ? teco_interface_blocking_getch() : GPOINTER_TO_INT(g_queue_pop_head(teco_interface.input_queue)); + const teco_view_t *last_view = teco_interface_current_view; + sptr_t last_pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0); + switch (key) { case ERR: /* shouldn't really happen */ @@ -1842,6 +1838,14 @@ teco_interface_event_loop_iter(void) } } + /* + * Scintilla has been patched to avoid any automatic scrolling since that + * has been benchmarked to be a very costly operation. + * Instead we do it only once after every keypress. + */ + if (teco_interface_current_view != last_view || + last_pos != teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0)) + teco_interface_ssm(SCI_SCROLLCARET, 0, 0); teco_interface_refresh(); } @@ -1857,6 +1861,7 @@ teco_interface_event_loop(GError **error) static const teco_cmdline_t empty_cmdline; // FIXME teco_interface_cmdline_update(&empty_cmdline); teco_interface_msg_clear(); + teco_interface_ssm(SCI_SCROLLCARET, 0, 0); teco_interface_refresh(); #ifdef EMCURSES -- cgit v1.2.3