SF.net SVN: geany-plugins:[1867] trunk/geanylatex

frlan at users.sourceforge.net frlan at xxxxx
Sun Jan 23 11:25:21 UTC 2011


Revision: 1867
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1867&view=rev
Author:   frlan
Date:     2011-01-23 11:25:21 +0000 (Sun, 23 Jan 2011)

Log Message:
-----------
GeanyLaTeX: Adding a fist step of feature to convert tabulator separated list to a LaTeX like table

Modified Paths:
--------------
    trunk/geanylatex/ChangeLog
    trunk/geanylatex/TODO
    trunk/geanylatex/doc/geanylatex.tex
    trunk/geanylatex/src/geanylatex.c
    trunk/geanylatex/src/latexkeybindings.c
    trunk/geanylatex/src/latexkeybindings.h
    trunk/geanylatex/src/latexutils.c
    trunk/geanylatex/src/latexutils.h

Modified: trunk/geanylatex/ChangeLog
===================================================================
--- trunk/geanylatex/ChangeLog	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/ChangeLog	2011-01-23 11:25:21 UTC (rev 1867)
@@ -1,3 +1,9 @@
+2011-01-23  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>
+
+ * Adding a feature which is converting a tabulator separated list into
+   a LaTeX-like table.
+
+
 2011-01-02  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>
 
  * Correction of some typos (Thanks to André Glória for reporting)

Modified: trunk/geanylatex/TODO
===================================================================
--- trunk/geanylatex/TODO	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/TODO	2011-01-23 11:25:21 UTC (rev 1867)
@@ -27,6 +27,9 @@
 * Adding support for dtx
 * Automatically inserting no breaking spaces (~) in particular situations
 * Converting tabulator seperated list to table
+	* Set position of table (dialos?)
+	* Set colums of table (dialog?)
+	* Make sepeatorconfigurable
 
 Generell:
 * Cleaning up code

Modified: trunk/geanylatex/doc/geanylatex.tex
===================================================================
--- trunk/geanylatex/doc/geanylatex.tex	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/doc/geanylatex.tex	2011-01-23 11:25:21 UTC (rev 1867)
@@ -103,6 +103,7 @@
 		  toolbar
 	\item Added a dialog for inserting BibTeX references based on
 		  available *.bib-files
+	\item Convert a tab separated block into \LaTeX{}-table
 	\item Upgrade plugin API to version 199
 \end{itemize}
 
@@ -567,6 +568,28 @@
 	\caption{Dialog for inserting \textbackslash{}usepackage\{\}}
 \end{figure}
 
+\subsection{Convert selected block to \LaTeX{}-table}
+
+This feature allows to convert a tabular formated block into \LaTeX{}-compatible
+table. In detail the feature replaces all occurrences of tabulator with \&
+surrounded by some spaces as well as adding \textbackslash{}\textbackslash{}
+at the end of each line. Nevertheless it also adds \texttt{tabular} environments
+around the selected passage.
+
+It will enclose your selection with an \texttt{tabular} environment.
+\begin{figure}[h!]
+\begin{lstlisting}
+\begin{tabular}
+	% selection converted to table
+\end{tabular}
+\end{lstlisting}
+\end{figure}
+
+After this has been done you will need to add the missing paramters
+for \texttt{tabular} like position and columns definitions as
+tabular environment is defined as to be used with
+\texttt{\textbackslash{}begin\{tabular\}[pos]\{table spec\}}.
+
 \section{Configuration}
 
 GeanyLaTeX{} can be configured in three major ways:

Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/src/geanylatex.c	2011-01-23 11:25:21 UTC (rev 1867)
@@ -1967,6 +1967,9 @@
 	keybindings_set_item(key_group, KB_LATEX_INSERT_CITE,
 		glatex_kb_insert_bibtex_cite, 0, 0, "insert_cite_dialog",
 		_("Insert BibTeX reference dialog"), menu_latex_insert_bibtex_cite);
+	keybindings_set_item(key_group, KB_LATEX_CONVERT_TO_TABLE,
+		glatex_kb_convert_to_table, 0, 0, "convert_to_table",
+		_("Convert selection to table"), NULL);
 }
 
 

Modified: trunk/geanylatex/src/latexkeybindings.c
===================================================================
--- trunk/geanylatex/src/latexkeybindings.c	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/src/latexkeybindings.c	2011-01-23 11:25:21 UTC (rev 1867)
@@ -163,3 +163,9 @@
 	g_return_if_fail(document_get_current != NULL);
 	on_insert_bibtex_dialog_activate(NULL, NULL);
 }
+
+void glatex_kb_convert_to_table(G_GNUC_UNUSED guint key_id)
+{
+	g_return_if_fail(document_get_current != NULL);
+	glatex_convert_to_table();
+}

Modified: trunk/geanylatex/src/latexkeybindings.h
===================================================================
--- trunk/geanylatex/src/latexkeybindings.h	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/src/latexkeybindings.h	2011-01-23 11:25:21 UTC (rev 1867)
@@ -49,6 +49,7 @@
 	KB_LATEX_USEPACKAGE_DIALOG,
 	KB_LATEX_INSERT_COMMAND,
 	KB_LATEX_INSERT_CITE,
+	KB_LATEX_CONVERT_TO_TABLE,
 	COUNT_KB
 };
 
@@ -74,5 +75,6 @@
 void glatex_kb_usepackage_dialog(G_GNUC_UNUSED guint key_id);
 void glatex_kb_insert_command_dialog(G_GNUC_UNUSED guint key_id);
 void glatex_kb_insert_bibtex_cite(G_GNUC_UNUSED guint key_id);
+void glatex_kb_convert_to_table(G_GNUC_UNUSED guint key_id);
 
 #endif

Modified: trunk/geanylatex/src/latexutils.c
===================================================================
--- trunk/geanylatex/src/latexutils.c	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/src/latexutils.c	2011-01-23 11:25:21 UTC (rev 1867)
@@ -162,3 +162,40 @@
 		g_free(new);
 	}
 }
+
+
+void glatex_convert_to_table()
+{
+	GeanyDocument *doc = NULL;
+	doc = document_get_current();
+
+	g_return_if_fail(doc != NULL);
+
+	if (sci_has_selection(doc->editor->sci))
+	{
+		gchar *selection = NULL;
+		gchar *new = NULL;
+		gchar *rowending = NULL;
+		GString *table = NULL;
+		GString *inner_table = NULL;
+
+		selection = sci_get_selection_contents(doc->editor->sci);
+		inner_table = g_string_new(selection);
+		utils_string_replace_all(inner_table, "\t", "  &  ");
+		rowending = g_strconcat(" \\\\", editor_get_eol_char(doc->editor), NULL);
+		utils_string_replace_all(inner_table, editor_get_eol_char(doc->editor), rowending);
+		new = g_string_free(inner_table, FALSE);
+
+		table = g_string_new(NULL);
+		g_string_printf(table, "\\begin{tabular}\n%s\n\\end{tabular}", new);
+
+		g_free(new);
+		
+		new = g_string_free(table, FALSE);
+		sci_replace_sel(doc->editor->sci, new);
+
+		g_free(selection);
+		g_free(new);
+		g_free(rowending);
+	}
+}

Modified: trunk/geanylatex/src/latexutils.h
===================================================================
--- trunk/geanylatex/src/latexutils.h	2011-01-23 11:24:50 UTC (rev 1866)
+++ trunk/geanylatex/src/latexutils.h	2011-01-23 11:25:21 UTC (rev 1867)
@@ -28,5 +28,6 @@
 void glatex_enter_key_pressed_in_entry(G_GNUC_UNUSED GtkWidget *widget, gpointer dialog);
 void glatex_insert_string(const gchar *string, gboolean reset_position);
 void glatex_replace_special_character(void);
+void glatex_convert_to_table();
 
 #endif


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