Revision: 1651 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1651&view=re... Author: frlan Date: 2010-10-10 17:00:17 +0000 (Sun, 10 Oct 2010)
Log Message: ----------- GeanyLaTeX: Move a generic function to latexutils.[c|h]
Modified Paths: -------------- trunk/geanylatex/src/geanylatex.c trunk/geanylatex/src/latexutils.c trunk/geanylatex/src/latexutils.h
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2010-10-10 16:59:47 UTC (rev 1650) +++ trunk/geanylatex/src/geanylatex.c 2010-10-10 17:00:17 UTC (rev 1651) @@ -746,49 +746,7 @@ }
-void glatex_replace_special_character() -{ - GeanyDocument *doc = NULL; - doc = document_get_current();
- if (doc != NULL && sci_has_selection(doc->editor->sci)) - { - guint selection_len; - gchar *selection = NULL; - GString *replacement = g_string_new(NULL); - guint i; - gchar *new = NULL; - const gchar *entity = NULL; - gchar buf[7]; - gint len; - - selection = sci_get_selection_contents(doc->editor->sci); - - selection_len = strlen(selection); - - for (i = 0; i < selection_len; i++) - { - len = g_unichar_to_utf8(g_utf8_get_char(selection + i), buf); - i = len - 1 + i; - buf[len] = '\0'; - entity = glatex_get_entity(buf); - - if (entity != NULL) - { - replacement = g_string_append(replacement, entity); - } - else - { - replacement = g_string_append(replacement, buf); - } - } - new = g_string_free(replacement, FALSE); - sci_replace_sel(doc->editor->sci, new); - g_free(selection); - g_free(new); - } -} - /* Called when keys were pressed */ static void glatex_kblatex_toggle(G_GNUC_UNUSED guint key_id) {
Modified: trunk/geanylatex/src/latexutils.c =================================================================== --- trunk/geanylatex/src/latexutils.c 2010-10-10 16:59:47 UTC (rev 1650) +++ trunk/geanylatex/src/latexutils.c 2010-10-10 17:00:17 UTC (rev 1651) @@ -119,3 +119,46 @@ } }
+ +void glatex_replace_special_character() +{ + GeanyDocument *doc = NULL; + doc = document_get_current(); + + if (doc != NULL && sci_has_selection(doc->editor->sci)) + { + guint selection_len; + gchar *selection = NULL; + GString *replacement = g_string_new(NULL); + guint i; + gchar *new = NULL; + const gchar *entity = NULL; + gchar buf[7]; + gint len; + + selection = sci_get_selection_contents(doc->editor->sci); + + selection_len = strlen(selection); + + for (i = 0; i < selection_len; i++) + { + len = g_unichar_to_utf8(g_utf8_get_char(selection + i), buf); + i = len - 1 + i; + buf[len] = '\0'; + entity = glatex_get_entity(buf); + + if (entity != NULL) + { + replacement = g_string_append(replacement, entity); + } + else + { + replacement = g_string_append(replacement, buf); + } + } + new = g_string_free(replacement, FALSE); + sci_replace_sel(doc->editor->sci, new); + g_free(selection); + g_free(new); + } +}
Modified: trunk/geanylatex/src/latexutils.h =================================================================== --- trunk/geanylatex/src/latexutils.h 2010-10-10 16:59:47 UTC (rev 1650) +++ trunk/geanylatex/src/latexutils.h 2010-10-10 17:00:17 UTC (rev 1651) @@ -27,5 +27,6 @@ void glatex_usepackage(const gchar *pkg, const gchar *options); void glatex_enter_key_pressed_in_entry(G_GNUC_UNUSED GtkWidget *widget, gpointer dialog); void glatex_insert_string(gchar *string, gboolean reset_position); +void glatex_replace_special_character(void);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.