Revision: 1135
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1135&view=rev
Author: frlan
Date: 2010-01-17 16:29:29 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
GeanyLaTeX: Don't try to toggle toolbaritems if toolbar is not active at all
Modified Paths:
--------------
trunk/geanylatex/src/geanylatex.c
Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c 2010-01-17 16:29:02 UTC (rev 1134)
+++ trunk/geanylatex/src/geanylatex.c 2010-01-17 16:29:29 UTC (rev 1135)
@@ -298,7 +298,8 @@
static void toggle_toolbar_items_by_file_type(gint id)
{
- if (glatex_deactivate_toolbaritems_with_non_latex == TRUE)
+ if (glatex_set_toolbar_active == TRUE &&
+ glatex_deactivate_toolbaritems_with_non_latex == TRUE)
{
if (id != GEANY_FILETYPES_LATEX)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1132
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1132&view=rev
Author: frlan
Date: 2010-01-17 16:02:55 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
GeanyLaTeX: Make usage of plugin API v170 and use the new "geany-startup-complete" signal to initially update the toolbar items with correct status on startup.
Modified Paths:
--------------
trunk/geanylatex/INSTALL
trunk/geanylatex/doc/geanylatex.tex
trunk/geanylatex/src/geanylatex.c
Modified: trunk/geanylatex/INSTALL
===================================================================
--- trunk/geanylatex/INSTALL 2010-01-17 15:24:04 UTC (rev 1131)
+++ trunk/geanylatex/INSTALL 2010-01-17 16:02:55 UTC (rev 1132)
@@ -1,7 +1,7 @@
These installation instructions are written for a Linux system, but
should work also on other plattforms as Windows is.
-Building the plugin requires Geany 0.19 or above (Geany Plugin API v169
+Building the plugin requires Geany 0.19 or above (Geany Plugin API v170
or higher).
You need for compliling the plugin the Geany header files installed.
Modified: trunk/geanylatex/doc/geanylatex.tex
===================================================================
--- trunk/geanylatex/doc/geanylatex.tex 2010-01-17 15:24:04 UTC (rev 1131)
+++ trunk/geanylatex/doc/geanylatex.tex 2010-01-17 16:02:55 UTC (rev 1132)
@@ -147,7 +147,7 @@
you used a prepared package e.g. from your distribution you probably
need to install an additional package, this might be called geany-dev
or geany-devel. Please note that in order to compile and use this
-plugin, you need Geany 0.19svn or later (Geany Plugin API v169 or higher).
+plugin, you need Geany 0.19svn or later (Geany Plugin API v170 or higher).
Furthermore you need, of course, a C compiler and python installed. The
GNU version of the C compiler is recommended. Also there should be a
Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c 2010-01-17 15:24:04 UTC (rev 1131)
+++ trunk/geanylatex/src/geanylatex.c 2010-01-17 16:02:55 UTC (rev 1132)
@@ -28,7 +28,7 @@
#include "geanylatex.h"
#include "ctype.h"
-PLUGIN_VERSION_CHECK(169)
+PLUGIN_VERSION_CHECK(170)
PLUGIN_SET_INFO(_("GeanyLaTeX"), _("Plugin to provide better LaTeX support"),
VERSION,"Frank Lanitz <frank(a)frank.uvena.de>")
@@ -154,7 +154,6 @@
return toolbar;
}
-
static void
on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response,
G_GNUC_UNUSED gpointer user_data)
@@ -340,6 +339,20 @@
}
+static void
+on_geany_startup_complete(G_GNUC_UNUSED GObject *obj, G_GNUC_UNUSED gpointer user_data)
+{
+ GeanyDocument *doc = NULL;
+
+ doc = document_get_current();
+
+ if (doc != NULL)
+ {
+ toggle_toolbar_items_by_file_type(doc->file_type->id);
+ }
+}
+
+
static gboolean on_document_filetype_set(GObject *obj, GeanyDocument *doc,
GeanyFiletype *filetype_old, gpointer user_data)
{
@@ -579,6 +592,7 @@
{ "document-activate", (GCallback) &on_document_activate, FALSE, NULL },
{ "document-filetype-set", (GCallback) &on_document_filetype_set, FALSE, NULL },
{ "document-new", (GCallback) &on_document_new, FALSE, NULL},
+ { "geany-startup-complete", (GCallback) &on_geany_startup_complete, FALSE, NULL },
{ NULL, NULL, FALSE, NULL }
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1128
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1128&view=rev
Author: eht16
Date: 2010-01-17 12:57:34 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
Add missing header include
Modified Paths:
--------------
trunk/geany-plugins/addons/src/ao_tasks.c
Modified: trunk/geany-plugins/addons/src/ao_tasks.c
===================================================================
--- trunk/geany-plugins/addons/src/ao_tasks.c 2010-01-17 12:54:09 UTC (rev 1127)
+++ trunk/geany-plugins/addons/src/ao_tasks.c 2010-01-17 12:57:34 UTC (rev 1128)
@@ -21,6 +21,7 @@
*/
+#include <string.h>
#include <gtk/gtk.h>
#include <glib-object.h>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1126
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1126&view=rev
Author: frlan
Date: 2010-01-16 19:40:47 +0000 (Sat, 16 Jan 2010)
Log Message:
-----------
GeanyLaTeX: Move LaTeX specific autocompletion function from Geany core into plugin
Modified Paths:
--------------
trunk/geanylatex/ChangeLog
trunk/geanylatex/INSTALL
trunk/geanylatex/doc/geanylatex.pdf
trunk/geanylatex/doc/geanylatex.tex
trunk/geanylatex/src/geanylatex.c
Modified: trunk/geanylatex/ChangeLog
===================================================================
--- trunk/geanylatex/ChangeLog 2010-01-16 14:00:38 UTC (rev 1125)
+++ trunk/geanylatex/ChangeLog 2010-01-16 19:40:47 UTC (rev 1126)
@@ -1,24 +1,29 @@
+2010-01-16 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+
+ * Took over functionality to automatic close \begin{} and \begingroup{}
+ from Geany core
+
+
2009-01-03 Frank Lanitz <frank(a)frank.uvena.de>
- * Dpn't deactivate wizard icon if no document is open
+ * Don't deactivate wizard icon if no document is open
-
2009-01-01 Frank Lanitz <frank(a)frank.uvena.de>
- * Make text used for inserting references configurable.
- Please check documentation for details on how to do it.
+ * Make text used for inserting references configurable.
+ Please check documentation for details on how to do it.
2009-12-26 Frank Lanitz <frank(a)frank.uvena.de>
- * Deactivate icons of toolbar, if no LaTeX document is open. Behavior
- can be deactivated via hidden pref.
+ * Deactivate icons of toolbar, if no LaTeX document is open. Behavior
+ can be deactivated via hidden pref.
2009-12-23 Frank Lanitz <frank(a)frank.uvena.de>
- * Do only special character replacement in case of we really have
+ * Do only special character replacement in case of we really have
an LaTeX file here.
Modified: trunk/geanylatex/INSTALL
===================================================================
--- trunk/geanylatex/INSTALL 2010-01-16 14:00:38 UTC (rev 1125)
+++ trunk/geanylatex/INSTALL 2010-01-16 19:40:47 UTC (rev 1126)
@@ -1,7 +1,7 @@
-These installation instructions are written for a Linux system, but
+These installation instructions are written for a Linux system, but
should work also on other plattforms as Windows is.
-Building the plugin requires Geany 0.19 or above (Geany Plugin API v166
+Building the plugin requires Geany 0.19 or above (Geany Plugin API v169
or higher).
You need for compliling the plugin the Geany header files installed.
@@ -15,4 +15,4 @@
./waf configure with --prefix=/path/to/dir option. ./waf install will
install all files to your new target. For more detailed information
please check documentation inside doc-folder which should be shippid
-with this archive.
+with this archive.
Modified: trunk/geanylatex/doc/geanylatex.pdf
===================================================================
(Binary files differ)
Modified: trunk/geanylatex/doc/geanylatex.tex
===================================================================
--- trunk/geanylatex/doc/geanylatex.tex 2010-01-16 14:00:38 UTC (rev 1125)
+++ trunk/geanylatex/doc/geanylatex.tex 2010-01-16 19:40:47 UTC (rev 1126)
@@ -55,7 +55,6 @@
\begin{document}
-\newpage
\dedication{\normalsize \textbf{Note:} Please note the document has been created on
\today. If you are using devel version from SVN, please compile and check
\texttt{doc/geanylatex.tex} from sources. Please check page \pageref
@@ -65,6 +64,7 @@
\maketitle
\tableofcontents
\listoftables
+\listoffigures
\newpage
\pagenumbering{arabic}
\section{About the plugin}
@@ -88,9 +88,11 @@
\item Shortcuts for inserting \textbackslash item and
\textbackslash newline
\item Toolbar with often used format options
+ \item A couple of useful autocompletion functions during typing
\end{itemize}
-\section{News}
+\newpage
+\section{News \& ChangeLog}
\subsection*{Since 0.4}
\begin{itemize}
@@ -102,21 +104,30 @@
\item Some general bugfixes and improvments. As always, see
ChangeLog or svn log.
\item Switch to waf for building the plugin
- \item Increasing depency for plugin to Geany Plugin API v166
+ \item Move some \LaTeX{}-specific stuff out of Geany's core into the
+ plugin. This is effecting e.g. this functions
+ \begin{itemize}
+ \item Autocompletion of \texttt{\textbackslash{}end\{\}}
+ and \texttt{\textbackslash{}endgroup\{\}}
+ \end{itemize}
+ \item Increasing dependency for plugin to Geany Plugin API v166
+ \item Make inserting text for references configurable.
\end{itemize}
\subsection*{GeanyLaTeX{} 0.4 -- 2009-05-26}
\begin{itemize}
\item Adding a toolbar with often used format commands
- \item Adding a configuration dialog to configure basic options of plugin
+ \item Adding a configuration dialog to configure basic options
+ of plugin
\item Moved documentation into a \TeX{}-document
- \item Replace \textbackslash{}u-UTF-8 letters by octal coded chars to
- don't depend on C99 anymore.
+ \item Replace \textbackslash{}u-UTF-8 letters by octal coded
+ chars to don't depend on C99 anymore.
\item Added a function to bulk replace special characters
- inside marked text by keybinding
+ inside marked text by keybinding
\item Added a function to replace special characters on typing
\end{itemize}
+\newpage
\section{Requirements}
\small{\textbf{Please note:} This section of documentation is only
@@ -136,7 +147,7 @@
you used a prepared package e.g. from your distribution you probably
need to install an additional package, this might be called geany-dev
or geany-devel. Please note that in order to compile and use this
-plugin, you need Geany 0.19svn or later (Geany Plugin API v166 or higher).
+plugin, you need Geany 0.19svn or later (Geany Plugin API v169 or higher).
Furthermore you need, of course, a C compiler and python installed. The
GNU version of the C compiler is recommended. Also there should be a
@@ -421,7 +432,7 @@
\begin{figure}[h!]
\begin{lstlisting}
\begin{your_environment}
- % ... selected text ...
+ ... selected text ...
\end{your_environment}
\end{lstlisting}
\end{figure}
@@ -475,6 +486,31 @@
\item right-aligned
\end{itemize}
+\subsection{Autocompletion of \textbackslash{}begin and \textbackslash{}begingroup}
+
+Since version 0.5 GeanyLaTeX{} is supporting autocompletion for
+closing \textbackslash{}end and \textbackslash{}endgroup for begin
+commands. Before Geany 0.19 this has been part of the Geany core
+but has been moved out as it is something \LaTeX{} specific.
+
+\subsubsection{Usage of feature}
+
+After the feature has been enabled (Please check \ref
+{sec:modus_of_autocompletion}, page \pageref
+{sec:modus_of_autocompletion} here for more detailed information),
+in every case you enter a \texttt{\textbackslash{}begin\{\}} or
+\texttt{\textbackslash {}begingroup\{\}} the plugin will
+automatically add the fitting \texttt{\textbackslash{}end\{\}} or
+\texttt{\textbackslash{}endgroup\{\}} if its not finding a closing
+tag within the definded context length -- by default this means
+inside following 5 lines. If you like to change this size, please
+check chapter \ref {sec:hidden_pref_autocompletion_context}, page
+\pageref {sec:hidden_pref_autocompletion_context}.
+
+This feature is by default file type depending, so it will only work
+on \TeX{}-like file types.
+
+
\section{Configuration}
GeanyLaTeX{} can be configured in two major ways:
@@ -502,6 +538,16 @@
\caption{Plugin toolbar of Geany\LaTeX{} 0.5}
\end{figure}
+\subsubsection{Modus of autocompletion}
+\label{sec:modus_of_autocompletion}
+Here you can choose, whether the Geany\LaTeX{} should do some
+autocompletion or not. Values are either
+\begin{enumerate}
+ \item Don't care about this inside plugin or
+ \item Always perform autocompletion on LaTeX
+\end{enumerate}
+
+
\subsection{Key bindings}
Keybindings which are available:
@@ -538,10 +584,10 @@
Insert description list & Inserts an description environment as well as a 1\up{st} \textbackslash{}item element.\\\hline
Insert itemize list & Inserts an itemize environment as well as a 1\up{st} \textbackslash{}item element.\\\hline
Insert enumerate list & Inserts an enumerate environment as well as a 1\up{st} \textbackslash{}item element.\\\hline
-
\end{tabular}
\end{table}
+
\subsection{Hidden preferencess}
As not all users need to configure everything on there plugin, Geany
\LaTeX{} has some hidden preferences which can be set through
@@ -572,18 +618,57 @@
Please ensure, you reload the plugin once this option has been changed.
+\subsubsection{Size of context for autocompletion}
+\label{sec:hidden_pref_autocompletion_context}
+Inside configuration file you can add a value to adjust the size of
+context, which is being searched for autocompletion of \texttt{
+\textbackslash{}end} and \texttt{\textbackslash{}endgroup}. The
+default value is 5. If you want to reset it, just add a new line to
+your configuration file with
+\texttt{glatex\_set\_autocompletion\_contextsize} followed by an integer
+value. An example could look like this:
+
+\begin{figure}[h!]
+\begin{lstlisting}
+[general]
+glatex_set_koma_active=true
+glatex_set_toolbar_active=false
+glatex_set_autocompletion=true
+
+[autocompletion]
+glatex_set_autocompletion_contextsize=2
+\end{lstlisting}
+\caption{general.conf example for contextsize}
+\end{figure}
+
+\subsubsection{Apply autocompletion only to \TeX{}-like files}
+With this option, you can force Geany\LaTeX{} to apply all autocompletion functions also to non-\TeX{} file types as for example an C-source code file. As this is only in a very low number of cases a really good idea, the option is by default turned on.
+
+\begin{figure}[h!]
+\begin{lstlisting}
+[general]
+glatex_set_koma_active=true
+glatex_set_toolbar_active=false
+glatex_set_autocompletion=true
+
+[autocompletion]
+glatex_autocompletion_only_for_latex=false
+\end{lstlisting}
+\caption{general.conf example for deactivating file type specific restrictions for autocompletion}
+\end{figure}
+
\subsubsection{Customized reference strings}
-Geany\LaTeX{} is able to insert references to a label where its
-using some default value. As this value is not always optimal, it
-can be changed using a hidden preference by setting
-\texttt{glatex\_reference\_page}, \texttt{glatex\_reference\_chapter} or
-\texttt{glatex\_reference\_all} inside configuration file as shown inside
-the example configuration snippet.
+Geany\LaTeX{} is able to insert references to a label where its
+using some default value. As this value is not always optimal, it
+can be changed using a hidden preference by setting
+\texttt{glatex\_reference\_page}, \texttt{glatex\_reference\_chapter} or
+\texttt{glatex\_reference\_all} inside configuration file as shown inside
+the example configuration snippet.
-\begin{lstlisting}
-[general]
-glatex_set_koma_active=true
+\begin{lstlisting}
+[general]
+glatex_set_koma_active=true
glatex_set_toolbar_active=true
[reference]
@@ -591,16 +676,15 @@
glatex_reference_chapter=\\textbf{\\ref{{{reference}}}}
glatex_reference_all=\\textbf{\\ref{{{reference}}}, page \pageref{{{reference}}}}\end{lstlisting}
-Please take care in this case \texttt{\{\{reference\}\}} will be
-replace by label name.
+Please take care in this case \texttt{\{\{reference\}\}} will be
+replace by label name.
-Also \texttt{\textbackslash{}t}, \texttt{\textbackslash{}r},
-\texttt{\textbackslash{}n} will be handled as known from C so you will
-need to add a second \textbackslash{} in front of in such cases. Even
-this seems to be annyoing on the first hand, it allows you to insert some
-more complicated constructs over here which might require a new line inside.
+Also \texttt{\textbackslash{}t}, \texttt{\textbackslash{}r},
+\texttt{\textbackslash{}n} will be handled as known from C so you will
+need to add a second \textbackslash{} in front of in such cases. Even
+this seems to be annyoing on the first hand, it allows you to insert some
+more complicated constructs over here which might require a new line inside.
-
\section{Contribution to the plugin}
If you like the plugin, there are a number of ways, how to
contribute to the development of the plugin.
Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c 2010-01-16 14:00:38 UTC (rev 1125)
+++ trunk/geanylatex/src/geanylatex.c 2010-01-16 19:40:47 UTC (rev 1126)
@@ -2,6 +2,9 @@
* geanylatex.c - Plugin to let Geany better work together with LaTeX
*
* Copyright 2007-2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ * Copyright 2005-2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ * Copyright 2006-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+ *
* For long list of friendly supporters please have a look at THANKS.
*
* This program is free software; you can redistribute it and/or modify
@@ -59,6 +62,14 @@
static gchar *glatex_ref_all_string = NULL;
static gboolean glatex_set_toolbar_active = FALSE;
+/* We want to keep this deactivated by default as the
+ * user needs to know what he is doing here.... */
+static gboolean glatex_autocompletion_active = FALSE;
+/* Value how many line should be search for autocompletion of \end{}
+ * and \endgroup{}. */
+static gint glatex_autocompletion_context_size;
+static glatex_autocompletion_only_for_latex;
+
/* Function will be deactivated, when only loaded */
static gboolean toggle_active = FALSE;
@@ -108,6 +119,7 @@
{
GtkWidget *koma_active;
GtkWidget *toolbar_active;
+ GtkWidget *glatex_autocompletion_active;
}
config_widgets;
@@ -151,6 +163,7 @@
GKeyFile *config = g_key_file_new();
gchar *data;
gchar *config_dir = g_path_get_dirname(config_file);
+ gint glatex_autocompletion_active_response;
config_file = g_strconcat(geany->app->configdir,
G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
@@ -160,6 +173,16 @@
glatex_set_toolbar_active =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.toolbar_active));
+ /* Check the response code for geanyLaTeX's autocompletion functions.
+ * Due compatibility with oder Geany versions cass 0 will be treated
+ * as FALSE, which means autocompletion is deactivated. */
+ glatex_autocompletion_active_response = gtk_combo_box_get_active(
+ GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active));
+ if (glatex_autocompletion_active_response == 0)
+ glatex_autocompletion_active = FALSE;
+ else
+ glatex_autocompletion_active = TRUE;
+
/* write stuff to file */
g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
@@ -167,6 +190,8 @@
glatex_set_koma_active);
g_key_file_set_boolean(config, "general", "glatex_set_toolbar_active",
glatex_set_toolbar_active);
+ g_key_file_set_boolean(config, "general", "glatex_set_autocompletion",
+ glatex_autocompletion_active);
if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR)
&& utils_mkdir(config_dir, TRUE) != 0)
@@ -210,6 +235,9 @@
plugin_configure(GtkDialog * dialog)
{
GtkWidget *vbox;
+ GtkWidget *table = NULL;
+ GtkWidget *label_autocompletion = NULL;
+ gint tmp;
vbox = gtk_vbox_new(FALSE, 6);
@@ -217,12 +245,34 @@
_("Use KOMA script by default"));
config_widgets.toolbar_active = gtk_check_button_new_with_label(
_("Show extra plugin toolbar"));
+
+ config_widgets.glatex_autocompletion_active = gtk_combo_box_new_text();
+ gtk_combo_box_insert_text(GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active), 0,
+ _("Don't care about this inside plugin"));
+ gtk_combo_box_insert_text(GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active), 1,
+ _("Always perform autocompletion on LaTeX"));
+
+ /* Dirty workarround for transferring boolean into a valid interger value */
+ if (glatex_autocompletion_active == TRUE)
+ tmp = 1;
+ else
+ tmp = 0;
+ gtk_combo_box_set_active(GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active), tmp);
+ /* Adding table for autocompletion configuration */
+ table = gtk_table_new(1, 2, FALSE);
+ label_autocompletion = gtk_label_new(_("Modus of autocompletion"));
+ gtk_misc_set_alignment(GTK_MISC(label_autocompletion), 0, 0);
+
+ gtk_table_attach_defaults(GTK_TABLE(table), label_autocompletion, 0, 1, 0, 1);
+ gtk_table_attach_defaults(GTK_TABLE(table), config_widgets.glatex_autocompletion_active, 1, 2, 0, 1);
+
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.koma_active),
glatex_set_koma_active);
gtk_box_pack_start(GTK_BOX(vbox), config_widgets.koma_active, FALSE, FALSE, 2);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.toolbar_active),
glatex_set_toolbar_active);
gtk_box_pack_start(GTK_BOX(vbox), config_widgets.toolbar_active, FALSE, FALSE, 2);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 2);
gtk_widget_show_all(vbox);
g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), NULL);
@@ -301,17 +351,144 @@
static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *editor,
SCNotification *nt, G_GNUC_UNUSED gpointer data)
{
+ ScintillaObject* sci;
+ gint pos;
+ static gchar indent[100];
+
g_return_val_if_fail(editor != NULL, FALSE);
- /* Check whether this is a LaTeX file at all. If not, we mot likely
- * don't want to do anything */
- if (editor->document->file_type->id != GEANY_FILETYPES_LATEX)
+ /* Check whether this is a LaTeX file at all. If not, we most
+ likely don't want to do anything. However, there is only one
+ exception: In case of user really wants to do so and is forcing
+ us with hidden preference */
+ if (glatex_autocompletion_only_for_latex == TRUE &&
+ editor->document->file_type->id != GEANY_FILETYPES_LATEX)
+ {
return FALSE;
+ }
- if (toggle_active == TRUE)
+ sci = editor->sci;
+ pos = sci_get_current_position(sci);
+
+ /* Autocompletion for LaTeX specific stuff:
+ * Introducing \end{} or \endgroup{} after a \begin{}
+ *
+ * Function has been taken from Geany's core under terms of GPLv2+
+ * where it was original developed. */
+ if (glatex_autocompletion_active == TRUE)
{
if (nt->nmhdr.code == SCN_CHARADDED)
{
+ switch (nt->ch)
+ {
+ case '\n':
+ case '\r':
+ {
+ if (sci_get_char_at(sci, pos - (editor_get_eol_char_len (editor) + 1)) == '}'||
+ sci_get_char_at(sci, pos - (editor_get_eol_char_len (editor) + 1)) == ']')
+ {
+ gchar *buf, *construct;
+ /* TODO: Make possible to have longer than a 50 chars environment */
+ gchar env[50];
+ gint line = sci_get_line_from_position(sci, pos - (editor_get_eol_char_len (editor) + 1));
+ gint line_len = sci_get_line_length(sci, line);
+ gint i, start;
+
+ /* get the line */
+ buf = sci_get_line(sci, line);
+
+ /* get to the first non-blank char (some kind of ltrim()) */
+ start = 0;
+ while (isspace(buf[start]) && buf[start] != '\0')
+ start++;
+
+ /* check for begin */
+ if (strncmp(buf + start, "\\begin", 6) == 0)
+ {
+ gchar full_cmd[15];
+ guint j = 0;
+
+ /* take also "\begingroup" (or whatever there can be) and
+ * append "\endgroup" and so on. */
+ i = start + 6;
+ while (i < line_len && buf[i] != '{' && j < (sizeof(full_cmd) - 1))
+ {
+ /* copy all between "\begin" and "{" to full_cmd */
+ full_cmd[j] = buf[i];
+ i++;
+ j++;
+ }
+ full_cmd[j] = '\0';
+
+ /* go through the line and get the environment */
+ for (i = start + j; i < line_len; i++)
+ {
+ if (buf[i] == '{')
+ {
+ j = 0;
+ i++;
+ while (buf[i] != '}' && j < (sizeof(env) - 1))
+ { /* this could be done in a shorter way, but so it remains readable ;-) */
+ env[j] = buf[i];
+ j++;
+ i++;
+ }
+ env[j] = '\0';
+ break;
+ }
+ }
+ /* Search whether the environment is closed within the next
+ * lines. We assume, no \end is needed in such cases */
+ /* TODO using sci_find_text() should be way faster than getting
+ * the line buffer and performing string comparisons */
+ for (i = 1; i < glatex_autocompletion_context_size; i++)
+ {
+ gchar *tmp;
+ gchar *end_construct;
+ tmp = sci_get_line(sci, line + i);
+
+ /* Again get to the first non-blank char */
+ start = 0;
+ while (isspace(buf[start]) && buf[start] != '\0')
+ start++;
+ end_construct = g_strdup_printf("\\end%s{%s}", full_cmd, env);
+ if (strstr(tmp, end_construct) != NULL)
+ {
+ /* Clean up everything and quit as nothing
+ * needs to be done */
+ g_free(tmp);
+ g_free(buf);
+ g_free(end_construct);
+ return;
+ }
+ g_free(tmp);
+ }
+
+ /* get the indentation */
+ /*if (editor->auto_indent)
+ read_indent(editor, pos); */
+ /* TODO: Find a way respecting ident */
+
+ construct = g_strdup_printf("\t\n\\end%s{%s}", full_cmd, env);
+
+ editor_insert_text_block(editor, construct, pos,
+ 1, -1, TRUE);
+ g_free(construct);
+ }
+ }
+ break;
+ } /* Closing case \r or \n */
+ } /* Closing switch */
+ /* later there could be some else ifs for other keywords */
+ }
+ } /* End of latex autocpletion */
+
+ /* Toggle special characters on input */
+ if (editor->document->file_type->id != GEANY_FILETYPES_LATEX &&
+ toggle_active == TRUE)
+ {
+ if (nt->nmhdr.code == SCN_CHARADDED)
+ {
gchar buf[7];
gint len;
@@ -1332,13 +1509,37 @@
glatex_set_koma_active = utils_get_setting_boolean(config, "general",
"glatex_set_koma_active", FALSE);
-
glatex_set_toolbar_active = utils_get_setting_boolean(config, "general",
"glatex_set_toolbar_active", FALSE);
+ glatex_autocompletion_active = utils_get_setting_boolean(config, "general",
+ "glatex_set_autocompletion", FALSE);
/* Hidden preferences. Can be set directly via configuration file*/
+ glatex_autocompletion_context_size = utils_get_setting_integer(config, "autocompletion",
+ "glatex_set_autocompletion_contextsize", 5);
+
+ /* Doing some input validation */
+ if (glatex_autocompletion_active == TRUE &&
+ glatex_autocompletion_context_size <= 0)
+ {
+ glatex_autocompletion_context_size = 5;
+ g_warning(_("glatex_set_autocompletion_contextsize has been "
+ "initialized with an invalid value. Default value taken. "
+ "Please check your configuration file"));
+ }
+ /* Increase value by an offset as we add a new line so 2 really means 2 */
+ glatex_autocompletion_context_size = glatex_autocompletion_context_size + 2;
+ glatex_autocompletion_only_for_latex = utils_get_setting_boolean(config, "autocompletion",
+ "glatex_autocompletion_only_for_latex", TRUE);
+
glatex_deactivate_toolbaritems_with_non_latex = utils_get_setting_boolean(config, "toolbar",
"glatex_deactivate_toolbaritems_with_non_latex", TRUE);
+ glatex_ref_page_string = utils_get_setting_string(config, "reference",
+ "glatex_reference_page", _("page \\pageref{{{reference}}}"));
+ glatex_ref_chapter_string = utils_get_setting_string(config, "reference",
+ "glatex_reference_chapter", "\\ref{{{reference}}}");
+ glatex_ref_all_string = utils_get_setting_string(config, "reference",
+ "glatex_reference_all", _("\\ref{{{reference}}}, page \\pageref{{{reference}}}"));
glatex_ref_page_string = utils_get_setting_string(config, "reference",
"glatex_reference_page", _("page \\pageref{{{reference}}}"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.