[geany/geany] f07b54: Simplify fold toggling code using higher-level Scintilla API
Colomban Wendling
git-noreply at xxxxx
Mon Dec 2 22:19:44 UTC 2013
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 02 Dec 2013 22:19:44 UTC
Commit: f07b5457d6505ce8127c4b823b18ee42ffbc7730
https://github.com/geany/geany/commit/f07b5457d6505ce8127c4b823b18ee42ffbc7730
Log Message:
-----------
Simplify fold toggling code using higher-level Scintilla API
Modified Paths:
--------------
src/editor.c
Modified: src/editor.c
41 files changed, 12 insertions(+), 29 deletions(-)
===================================================================
@@ -442,6 +442,7 @@ const GeanyEditorPrefs *editor_get_prefs(GeanyEditor *editor)
void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers)
{
ScintillaObject *sci;
+ gint header;
g_return_if_fail(editor != NULL);
@@ -460,39 +461,21 @@ void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers)
if (first > parent)
SSM(sci, SCI_SETFIRSTVISIBLELINE, parent, 0);
}
- sci_toggle_fold(sci, line);
- /* extra toggling of child fold points
- * use when editor_prefs.unfold_all_children is set and Shift is NOT pressed or when
- * editor_prefs.unfold_all_children is NOT set but Shift is pressed */
+ /* find the fold header of the given line in case the one clicked isn't a fold point */
+ if (sci_get_fold_level(sci, line) & SC_FOLDLEVELHEADERFLAG)
+ header = line;
+ else
+ header = sci_get_fold_parent(sci, line);
+
if ((editor_prefs.unfold_all_children && ! (modifiers & SCMOD_SHIFT)) ||
(! editor_prefs.unfold_all_children && (modifiers & SCMOD_SHIFT)))
{
- gint last_line = SSM(sci, SCI_GETLASTCHILD, line, -1);
- gint i;
-
- if (sci_get_line_is_visible(sci, line + 1))
- { /* unfold all children of the current fold point */
- for (i = line; i <= last_line; i++)
- {
- if (! sci_get_line_is_visible(sci, i))
- {
- sci_toggle_fold(sci, sci_get_fold_parent(sci, i));
- }
- }
- }
- else
- { /* fold all children of the current fold point */
- for (i = line; i <= last_line; i++)
- {
- gint level = sci_get_fold_level(sci, i);
- if (level & SC_FOLDLEVELHEADERFLAG)
- {
- if (sci_get_fold_expanded(sci, i))
- sci_toggle_fold(sci, i);
- }
- }
- }
+ SSM(sci, SCI_FOLDCHILDREN, header, SC_FOLDACTION_TOGGLE);
+ }
+ else
+ {
+ SSM(sci, SCI_FOLDLINE, header, SC_FOLDACTION_TOGGLE);
}
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list