SF.net SVN: geany-plugins:[531] trunk/geanylatex
frlan at users.sourceforge.net
frlan at xxxxx
Fri Mar 6 19:16:08 UTC 2009
Revision: 531
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=531&view=rev
Author: frlan
Date: 2009-03-06 19:16:08 +0000 (Fri, 06 Mar 2009)
Log Message:
-----------
GeanyLaTeX: Insert environment now supports selections by position \begin{} and \end{} around
Modified Paths:
--------------
trunk/geanylatex/ChangeLog
trunk/geanylatex/src/latexenvironments.c
Modified: trunk/geanylatex/ChangeLog
===================================================================
--- trunk/geanylatex/ChangeLog 2009-03-05 22:31:36 UTC (rev 530)
+++ trunk/geanylatex/ChangeLog 2009-03-06 19:16:08 UTC (rev 531)
@@ -1,3 +1,9 @@
+2009-03-06 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+
+ * Insert environment now supports selections by position \begin{} and
+ \end{} around
+
+
2009-02-28 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* Don't react on some keybindings in case of no document is open.
Modified: trunk/geanylatex/src/latexenvironments.c
===================================================================
--- trunk/geanylatex/src/latexenvironments.c 2009-03-05 22:31:36 UTC (rev 530)
+++ trunk/geanylatex/src/latexenvironments.c 2009-03-06 19:16:08 UTC (rev 531)
@@ -41,7 +41,7 @@
{ENVIRONMENT_CAT_LISTS, "itemize", "itemize"},
{ENVIRONMENT_CAT_LISTS, "enumerate", "enumerate"},
{ENVIRONMENT_CAT_LISTS, "description", "description"},
-
+
{0, NULL, NULL},
};
@@ -55,17 +55,33 @@
/* Only do anything if it is realy needed to */
if (doc != NULL && environment != NULL)
{
- gint pos = sci_get_current_position(doc->editor->sci);
- gint len = strlen(environment);
- gchar *tmp = NULL;
+ if (sci_has_selection(doc->editor->sci))
+ {
+ gint selection_len = sci_get_selected_text_length(doc->editor->sci);
+ gchar *selection = g_malloc(selection_len + 1);
+ const gchar *replacement = NULL;
- tmp = g_strconcat("\\begin{", environment, "}\n\n\\end{",
+ sci_get_selected_text(doc->editor->sci, selection);
+
+ replacement = g_strconcat("\\begin{", environment, "}\n",
+ selection,"\n\\end{", environment, "}\n", NULL);
+
+ sci_replace_sel(doc->editor->sci, replacement);
+ g_free(selection);
+ }
+ else
+ {
+ gint pos = sci_get_current_position(doc->editor->sci);
+ gint len = strlen(environment);
+ gchar *tmp = NULL;
+
+ tmp = g_strconcat("\\begin{", environment, "}\n\n\\end{",
environment, "}\n", NULL);
- sci_insert_text(doc->editor->sci, pos, tmp);
- sci_set_current_position(doc->editor->sci, pos + len + 9, TRUE);
-
- g_free(tmp);
+ sci_insert_text(doc->editor->sci, pos, tmp);
+ sci_set_current_position(doc->editor->sci, pos + len + 9, TRUE);
+ g_free(tmp);
+ }
}
}
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