[geany/geany] 00714d: Improve collapsing fold behaviour when start point is offscreen

Nick Treleaven git-noreply at xxxxx
Wed Sep 5 16:13:34 UTC 2012


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Wed, 05 Sep 2012 16:13:34
Commit:      00714db69c3ce8f8ba2d40be62c596045f1001d7
             https://github.com/geany/geany/commit/00714db69c3ce8f8ba2d40be62c596045f1001d7

Log Message:
-----------
Improve collapsing fold behaviour when start point is offscreen

When collapsing a fold range whose starting line is offscreen,
scroll the starting line to display at the top of the view.
Otherwise it can be confusing when the document scrolls down to hide
the folded lines.


Modified Paths:
--------------
    src/editor.c
    src/sciwrappers.c

Modified: src/editor.c
13 files changed, 13 insertions(+), 0 deletions(-)
===================================================================
@@ -444,7 +444,20 @@ void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers)
 	g_return_if_fail(editor != NULL);
 
 	sci = editor->sci;
+	/* When collapsing a fold range whose starting line is offscreen,
+	 * scroll the starting line to display at the top of the view.
+	 * Otherwise it can be confusing when the document scrolls down to hide
+	 * the folded lines. */
+	if ((sci_get_fold_level(sci, line) & SC_FOLDLEVELNUMBERMASK) > SC_FOLDLEVELBASE &&
+		!(sci_get_fold_level(sci, line) & SC_FOLDLEVELHEADERFLAG))
+	{
+		gint parent = sci_get_fold_parent(sci, line);
+		gint first = sci_get_first_visible_line(sci);
 
+		parent = SSM(sci, SCI_VISIBLEFROMDOCLINE, parent, 0);
+		if (first > parent)
+			SSM(sci, SCI_SETFIRSTVISIBLELINE, parent, 0);
+	}
 	sci_toggle_fold(sci, line);
 
 	/* extra toggling of child fold points


Modified: src/sciwrappers.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -682,7 +682,7 @@ gint sci_get_fold_parent(ScintillaObject *sci, gint start_line)
 
 void sci_toggle_fold(ScintillaObject *sci, gint line)
 {
-	SSM(sci, SCI_TOGGLEFOLD, (uptr_t) line, 1);
+	SSM(sci, SCI_TOGGLEFOLD, (uptr_t) line, 0);
 }
 
 


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list