SF.net SVN: geany:[4627] branches/geany-0.18.1

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Jan 31 21:52:47 UTC 2010


Revision: 4627
          http://geany.svn.sourceforge.net/geany/?rev=4627&view=rev
Author:   eht16
Date:     2010-01-31 21:52:47 +0000 (Sun, 31 Jan 2010)

Log Message:
-----------
Backport from trunk:
Rename fold_symbol_click() to editor_toggle_fold().
Use editor_toggle_fold() when the 'Toggle current fold' keybinding was used to respect the 'Fold/unfold all children' preference (closes #2935053).

Modified Paths:
--------------
    branches/geany-0.18.1/ChangeLog
    branches/geany-0.18.1/src/editor.c
    branches/geany-0.18.1/src/editor.h
    branches/geany-0.18.1/src/keybindings.c
    branches/geany-0.18.1/src/sciwrappers.c
    branches/geany-0.18.1/src/sciwrappers.h

Modified: branches/geany-0.18.1/ChangeLog
===================================================================
--- branches/geany-0.18.1/ChangeLog	2010-01-31 21:52:32 UTC (rev 4626)
+++ branches/geany-0.18.1/ChangeLog	2010-01-31 21:52:47 UTC (rev 4627)
@@ -10,6 +10,12 @@
    Replace the old icons with smiley icons from the Rodent icon theme.
    Fix showing the same icon for two or more slots.
    Minor cleanups.
+ * src/editor.c, src/editor.h, src/keybindings.c, src/sciwrappers.c,
+   src/sciwrappers.h:
+   Rename fold_symbol_click() to editor_toggle_fold().
+   Use editor_toggle_fold() when the 'Toggle current fold' keybinding
+   was used to respect the 'Fold/unfold all children' preference
+   (closes #2935053).
 
 
 2010-01-18  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: branches/geany-0.18.1/src/editor.c
===================================================================
--- branches/geany-0.18.1/src/editor.c	2010-01-31 21:52:32 UTC (rev 4626)
+++ branches/geany-0.18.1/src/editor.c	2010-01-31 21:52:47 UTC (rev 4627)
@@ -270,27 +270,32 @@
 }
 
 
-static void fold_symbol_click(ScintillaObject *sci, SCNotification *nt)
+void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers)
 {
-	gint line = sci_get_line_from_position(sci, nt->position);
+	ScintillaObject *sci;
 
-	SSM(sci, SCI_TOGGLEFOLD, line, 0);
+	g_return_if_fail(editor != NULL);
+
+	sci = editor->sci;
+
+	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 */
-	if ((editor_prefs.unfold_all_children && ! (nt->modifiers & SCMOD_SHIFT)) ||
-		(! editor_prefs.unfold_all_children && (nt->modifiers & SCMOD_SHIFT)))
+	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 (SSM(sci, SCI_GETLINEVISIBLE, line + 1, 0))
+		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 (! SSM(sci, SCI_GETLINEVISIBLE, i, 0))
+				if (! sci_get_line_is_visible(sci, i))
 				{
-					SSM(sci, SCI_TOGGLEFOLD, SSM(sci, SCI_GETFOLDPARENT, i, 0), 0);
+					sci_toggle_fold(sci, sci_get_fold_parent(sci, i));
 				}
 			}
 		}
@@ -301,8 +306,8 @@
 				gint level = sci_get_fold_level(sci, i);
 				if (level & SC_FOLDLEVELHEADERFLAG)
 				{
-					if (SSM(sci, SCI_GETFOLDEXPANDED, i, 0))
-						SSM(sci, SCI_TOGGLEFOLD, i, 0);
+					if (sci_get_fold_expanded(sci, i))
+						sci_toggle_fold(sci, i);
 				}
 			}
 		}
@@ -310,21 +315,21 @@
 }
 
 
-static void on_margin_click(ScintillaObject *sci, SCNotification *nt)
+static void on_margin_click(GeanyEditor *editor, SCNotification *nt)
 {
 	/* left click to marker margin marks the line */
 	if (nt->margin == 1)
 	{
-		gint line = sci_get_line_from_position(sci, nt->position);
-		gboolean set = sci_is_marker_set_at_line(sci, line, 1);
+		gint line = sci_get_line_from_position(editor->sci, nt->position);
 
 		/*sci_marker_delete_all(editor->sci, 1);*/
-		sci_set_marker_at_line(sci, line, ! set, 1);	/* toggle the marker */
+		sci_toggle_marker_at_line(editor->sci, line, 1);	/* toggle the marker */
 	}
 	/* left click on the folding margin to toggle folding state of current line */
 	else if (nt->margin == 2 && editor_prefs.folding)
 	{
-		fold_symbol_click(sci, nt);
+		gint line = sci_get_line_from_position(editor->sci, nt->position);
+		editor_toggle_fold(editor, line, nt->modifiers);
 	}
 }
 
@@ -830,7 +835,7 @@
 			break;
 		}
 		case SCN_MARGINCLICK:
-			on_margin_click(sci, nt);
+			on_margin_click(editor, nt);
 			break;
 
 		case SCN_UPDATEUI:

Modified: branches/geany-0.18.1/src/editor.h
===================================================================
--- branches/geany-0.18.1/src/editor.h	2010-01-31 21:52:32 UTC (rev 4626)
+++ branches/geany-0.18.1/src/editor.h	2010-01-31 21:52:47 UTC (rev 4627)
@@ -275,4 +275,6 @@
 
 gchar *editor_get_calltip_text(GeanyEditor *editor, const TMTag *tag);
 
+void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers);
+
 #endif

Modified: branches/geany-0.18.1/src/keybindings.c
===================================================================
--- branches/geany-0.18.1/src/keybindings.c	2010-01-31 21:52:32 UTC (rev 4626)
+++ branches/geany-0.18.1/src/keybindings.c	2010-01-31 21:52:47 UTC (rev 4627)
@@ -2236,7 +2236,7 @@
 			if (editor_prefs.folding)
 			{
 				gint line = sci_get_current_line(doc->editor->sci);
-				sci_toggle_fold(doc->editor->sci, line);
+				editor_toggle_fold(doc->editor, line, 0);
 				break;
 			}
 	}

Modified: branches/geany-0.18.1/src/sciwrappers.c
===================================================================
--- branches/geany-0.18.1/src/sciwrappers.c	2010-01-31 21:52:32 UTC (rev 4626)
+++ branches/geany-0.18.1/src/sciwrappers.c	2010-01-31 21:52:47 UTC (rev 4627)
@@ -279,6 +279,14 @@
 }
 
 
+void sci_toggle_marker_at_line(ScintillaObject* sci, gint line, gint marker)
+{
+	gboolean set = sci_is_marker_set_at_line(sci, line, marker);
+
+	sci_set_marker_at_line(sci, line, set, marker);
+}
+
+
 /* Returns the line number of the next marker that matches marker_mask, or -1.
  * marker_mask is a bitor of 1 << marker_index. (See MarkerHandleSet::MarkValue()).
  * Note: If there is a marker on the line, it returns the same line. */

Modified: branches/geany-0.18.1/src/sciwrappers.h
===================================================================
--- branches/geany-0.18.1/src/sciwrappers.h	2010-01-31 21:52:32 UTC (rev 4626)
+++ branches/geany-0.18.1/src/sciwrappers.h	2010-01-31 21:52:47 UTC (rev 4627)
@@ -53,6 +53,7 @@
 void 				sci_zoom_out				(ScintillaObject* sci);
 void 				sci_zoom_off				(ScintillaObject* sci);
 void				sci_set_marker_at_line		(ScintillaObject* sci, gint line_number, gboolean set, gint marker );
+void				sci_toggle_marker_at_line	(ScintillaObject* sci, gint line, gint marker);
 gboolean 			sci_is_marker_set_at_line	(ScintillaObject* sci, gint line, gint marker);
 gint				sci_marker_next				(ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap);
 gint				sci_marker_previous			(ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap);


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