SF.net SVN: geany-plugins:[1207] trunk/geanylatex/src/formatutils.c

frlan at users.sourceforge.net frlan at xxxxx
Sat Mar 27 01:37:16 UTC 2010


Revision: 1207
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1207&view=rev
Author:   frlan
Date:     2010-03-27 01:37:16 +0000 (Sat, 27 Mar 2010)

Log Message:
-----------
GeanyLaTeX: Support normal selections on inserting font size

Modified Paths:
--------------
    trunk/geanylatex/src/formatutils.c

Modified: trunk/geanylatex/src/formatutils.c
===================================================================
--- trunk/geanylatex/src/formatutils.c	2010-03-27 01:36:53 UTC (rev 1206)
+++ trunk/geanylatex/src/formatutils.c	2010-03-27 01:37:16 UTC (rev 1207)
@@ -66,10 +66,27 @@
 
 	if (doc != NULL)
 	{
-		sci_start_undo_action(doc->editor->sci);
-		glatex_insert_string(glatex_fontsize_pattern[size], TRUE);
-		glatex_insert_string(" ", TRUE);
-		sci_end_undo_action(doc->editor->sci);
+		if (sci_has_selection(doc->editor->sci))
+		{
+			gchar *selection;
+			gchar *replacement = NULL;
+
+			selection = sci_get_selection_contents(doc->editor->sci);
+
+			replacement = g_strconcat("{",glatex_fontsize_pattern[size],
+				" ", selection, "}", NULL);
+
+			sci_replace_sel(doc->editor->sci, replacement);
+			g_free(selection);
+			g_free(replacement);
+		}
+		else
+		{
+			sci_start_undo_action(doc->editor->sci);
+			glatex_insert_string(glatex_fontsize_pattern[size], TRUE);
+			glatex_insert_string(" ", TRUE);
+			sci_end_undo_action(doc->editor->sci);
+		}
 	}
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list