Revision: 1181 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1181&view=re... Author: frlan Date: 2010-03-19 23:59:21 +0000 (Fri, 19 Mar 2010)
Log Message: ----------- GeanyLaTeX: Insert a function to insert \usepackage{} into header.
Modified Paths: -------------- trunk/geanylatex/src/latexutils.c trunk/geanylatex/src/latexutils.h trunk/geanylatex/src/letters.c
Modified: trunk/geanylatex/src/latexutils.c =================================================================== --- trunk/geanylatex/src/latexutils.c 2010-03-18 18:23:24 UTC (rev 1180) +++ trunk/geanylatex/src/latexutils.c 2010-03-19 23:59:21 UTC (rev 1181) @@ -40,3 +40,42 @@
return result; } + +void glatex_usepackage(const gchar *pkg) +{ + GeanyDocument *doc = NULL; + gint i; + gint line_number; + gint document_number_of_lines; + gchar *tmp_line; + + doc = document_get_current(); + + /* Checking whether we have a document */ + g_return_if_fail(doc != NULL); + + /* Iterating through document to find \begin{document} + * Do nothing, if its not available at all */ + document_number_of_lines = sci_get_line_count(doc->editor->sci); + for (i = 0; i < document_number_of_lines; i++) + { + tmp_line = sci_get_line(doc->editor->sci, i); + if (utils_str_equal(tmp_line, "\begin{document}\n")) + { + gint pos; + gchar *packagestring; + + pos = sci_get_position_from_line(doc->editor->sci, i); + + /* Building up package string and inserting it */ + packagestring = g_strconcat("\usepackage{", pkg, "}\n", NULL); + sci_insert_text(doc->editor->sci, pos, packagestring); + + g_free(tmp_line); + g_free(packagestring); + + break; + } + g_free(tmp_line); + } +}
Modified: trunk/geanylatex/src/latexutils.h =================================================================== --- trunk/geanylatex/src/latexutils.h 2010-03-18 18:23:24 UTC (rev 1180) +++ trunk/geanylatex/src/latexutils.h 2010-03-19 23:59:21 UTC (rev 1181) @@ -25,4 +25,6 @@
gchar **glatex_read_file_in_array(const gchar *filename);
+void glatex_usepackage(const gchar *pkg); + #endif
Modified: trunk/geanylatex/src/letters.c =================================================================== --- trunk/geanylatex/src/letters.c 2010-03-18 18:23:24 UTC (rev 1180) +++ trunk/geanylatex/src/letters.c 2010-03-19 23:59:21 UTC (rev 1181) @@ -1,5 +1,5 @@ /* - * letters.c + * letters.c * * Copyright 2008-2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org