aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-05-02 07:33:28 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-05-02 11:59:31 +0300
commit62eb87b149166588d766d5a272e5232ecf86be5d (patch)
treef959c7812c30ab947a556177813ac836076a02fb
parentcb1ef4788be0117f57497299ba008652f62cba24 (diff)
downloadsciteco-62eb87b149166588d766d5a272e5232ecf86be5d.tar.gz
auto-expand folds even after mouse events
The ^KMOUSE macro can also change dot and it was possible to place dot into invisible areas at the end of the document.
-rw-r--r--src/interface-curses/interface.c5
-rw-r--r--src/interface-gtk/interface.c5
-rw-r--r--src/interface.h8
3 files changed, 12 insertions, 6 deletions
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c
index e3013fb..bccc90d 100644
--- a/src/interface-curses/interface.c
+++ b/src/interface-curses/interface.c
@@ -2078,6 +2078,7 @@ teco_interface_event_loop_iter(void)
* Do not auto-scroll on mouse events, so you can scroll the view manually
* in the ^KMOUSE macro, allowing dot to be outside of the view.
*/
+ teco_interface_unfold();
teco_interface_refresh();
return;
#endif
@@ -2134,9 +2135,7 @@ teco_interface_event_loop_iter(void)
*/
if (teco_interface_current_view == last_view)
teco_interface_ssm(SCI_SETFIRSTVISIBLELINE, last_vpos, 0);
- /* also unfold automatically */
- sptr_t dot = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_interface_ssm(SCI_ENSUREVISIBLE, teco_interface_ssm(SCI_LINEFROMPOSITION, dot, 0), 0);
+ teco_interface_unfold();
teco_interface_ssm(SCI_SCROLLCARET, 0, 0);
teco_interface_refresh();
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c
index 06abe61..9241767 100644
--- a/src/interface-gtk/interface.c
+++ b/src/interface-gtk/interface.c
@@ -1416,6 +1416,8 @@ teco_interface_input_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
teco_interrupted = FALSE;
teco_interface_refresh(teco_interface_current_view != last_view);
+ /* always expand folds, even after mouse clicks */
+ teco_interface_unfold();
/*
* Scintilla has been patched to avoid any automatic scrolling since that
* has been benchmarked to be a very costly operation.
@@ -1429,9 +1431,6 @@ teco_interface_input_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
if (event->type == GDK_KEY_PRESS) {
if (teco_interface_current_view == last_view)
teco_interface_ssm(SCI_SETFIRSTVISIBLELINE, last_vpos, 0);
- /* also unfold automatically */
- sptr_t dot = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_interface_ssm(SCI_ENSUREVISIBLE, teco_interface_ssm(SCI_LINEFROMPOSITION, dot, 0), 0);
teco_interface_ssm(SCI_SCROLLCARET, 0, 0);
}
diff --git a/src/interface.h b/src/interface.h
index 33b094b..b1ad2b8 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -93,6 +93,14 @@ teco_interface_ssm(unsigned int iMessage, uptr_t wParam, sptr_t lParam)
*/
void undo__teco_interface_ssm(unsigned int, uptr_t, sptr_t);
+/** Expand folds, so that dot is always visible. */
+static inline void
+teco_interface_unfold(void)
+{
+ sptr_t dot = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
+ teco_interface_ssm(SCI_ENSUREVISIBLE, teco_interface_ssm(SCI_LINEFROMPOSITION, dot, 0), 0);
+}
+
/** @pure */
void teco_interface_info_update_qreg(const teco_qreg_t *reg);
/** @pure */