SF.net SVN: geany: [2427] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Fri Mar 28 16:17:44 UTC 2008
Revision: 2427
http://geany.svn.sourceforge.net/geany/?rev=2427&view=rev
Author: eht16
Date: 2008-03-28 09:16:55 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
Unfold hidden code when the fold point modified (e.g. commented out, fixes #1923350).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-03-27 18:07:43 UTC (rev 2426)
+++ trunk/ChangeLog 2008-03-28 16:16:55 UTC (rev 2427)
@@ -1,3 +1,9 @@
+2008-03-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/editor.c: Unfold hidden code when the fold point modified
+ (e.g. commented out, fixes #1923350).
+
+
2008-03-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* plugins/vcdiff.c:
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-03-27 18:07:43 UTC (rev 2426)
+++ trunk/src/editor.c 2008-03-28 16:16:55 UTC (rev 2427)
@@ -267,6 +267,99 @@
}
+/* expand() and fold_changed() are copied from SciTE (thanks) to fix #1923350. */
+static void expand(ScintillaObject *sci, gint *line, gboolean doExpand,
+ gboolean force, gint visLevels, gint level)
+{
+ gint lineMaxSubord = SSM(sci, SCI_GETLASTCHILD, *line, level & SC_FOLDLEVELNUMBERMASK);
+ gint levelLine = level;
+ (*line)++;
+ while (*line <= lineMaxSubord)
+ {
+ if (force)
+ {
+ if (visLevels > 0)
+ SSM(sci, SCI_SHOWLINES, *line, *line);
+ else
+ SSM(sci, SCI_HIDELINES, *line, *line);
+ }
+ else
+ {
+ if (doExpand)
+ SSM(sci, SCI_SHOWLINES, *line, *line);
+ }
+ if (levelLine == -1)
+ levelLine = SSM(sci, SCI_GETFOLDLEVEL, *line, 0);
+ if (levelLine & SC_FOLDLEVELHEADERFLAG)
+ {
+ if (force)
+ {
+ if (visLevels > 1)
+ SSM(sci, SCI_SETFOLDEXPANDED, *line, 1);
+ else
+ SSM(sci, SCI_SETFOLDEXPANDED, *line, 0);
+ expand(sci, line, doExpand, force, visLevels - 1, -1);
+ }
+ else
+ {
+ if (doExpand)
+ {
+ if (!SSM(sci, SCI_GETFOLDEXPANDED, *line, 0))
+ SSM(sci, SCI_SETFOLDEXPANDED, *line, 1);
+ expand(sci, line, TRUE, force, visLevels - 1, -1);
+ }
+ else
+ {
+ expand(sci, line, FALSE, force, visLevels - 1, -1);
+ }
+ }
+ }
+ else
+ {
+ (*line)++;
+ }
+ }
+}
+
+
+static void fold_changed(ScintillaObject *sci, gint line, gint levelNow, gint levelPrev)
+{
+ if (levelNow & SC_FOLDLEVELHEADERFLAG)
+ {
+ if (! (levelPrev & SC_FOLDLEVELHEADERFLAG))
+ {
+ /* Adding a fold point */
+ SSM(sci, SCI_SETFOLDEXPANDED, line, 1);
+ expand(sci, &line, TRUE, FALSE, 0, levelPrev);
+ }
+ }
+ else if (levelPrev & SC_FOLDLEVELHEADERFLAG)
+ {
+ if (! SSM(sci, SCI_GETFOLDEXPANDED, line, 0))
+ { /* Removing the fold from one that has been contracted so should expand
+ * otherwise lines are left invisible with no way to make them visible */
+ SSM(sci, SCI_SETFOLDEXPANDED, line, 1);
+ expand(sci, &line, TRUE, FALSE, 0, levelPrev);
+ }
+ }
+ else if (! (levelNow & SC_FOLDLEVELWHITEFLAG) &&
+ ((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK)))
+ {
+ /* See if should still be hidden */
+ gint parentLine = SSM(sci, SCI_GETFOLDPARENT, line, 0);
+ if (parentLine < 0)
+ {
+ SSM(sci, SCI_SHOWLINES, line, line);
+ }
+ else if (SSM(sci, SCI_GETFOLDEXPANDED, parentLine, 0) &&
+ SSM(sci, SCI_GETLINEVISIBLE, parentLine, 0))
+ {
+ SSM(sci, SCI_SHOWLINES, line, line);
+ }
+ }
+}
+
+
static void ensure_range_visible(ScintillaObject *sci, gint posStart, gint posEnd,
gboolean enforcePolicy)
{
@@ -326,6 +419,11 @@
/* get notified about undo changes */
document_undo_add(idx, UNDO_SCINTILLA, NULL);
}
+ if (editor_prefs.folding && (nt->modificationType & SC_MOD_CHANGEFOLD) != 0)
+ {
+ /* handle special fold cases, e.g. #1923350 */
+ fold_changed(sci, nt->line, nt->foldLevelNow, nt->foldLevelPrev);
+ }
break;
}
case SCN_CHARADDED:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list