From e3498abfd8d95dbd083ccfd1d386f9ad37044a43 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 26 Apr 2025 17:46:28 +0300 Subject: support folding via F1 and clicks in the folding margin * Set up the folding margin in the currently empty margin column after the line number. On Gtk, this meant resetting all the marker symbols and their foreground/background colors as well as the margin's colors themselves. This looks like a bug. It's not necessary on Scinterm, which apparently uses the default/linenumber styles by default. Perhaps we should try upgrading Scintilla? * The folding state is considered not to be directly controlled by the language (just like the scroll position and zoom level). That's why we can directly control it by clicking on the margin column. * F1 can be used to toggle all folds globally. * The only support within the C core necessary for folding is to make sure that the current line is unfolded after every keypress. * We might add custom folding commands to the language later on (e.g. F+, F-). In this case, the key macros will have to be changed of course. --- src/interface-gtk/interface.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/interface-gtk') diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 045f9d7..06abe61 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -1429,6 +1429,9 @@ 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); } -- cgit v1.2.3