Skip to content

Commit

Permalink
GeanyLaTeX: Added a feature to convert selection to lowercase in case…
Browse files Browse the repository at this point in the history
… of inserting \textsc{}
  • Loading branch information
frlan committed Mar 24, 2012
2 parents ec51ba3 + 5fac938 commit e8887ea
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
Binary file modified geanylatex/doc/geanylatex.pdf
Binary file not shown.
13 changes: 12 additions & 1 deletion geanylatex/doc/geanylatex.tex
Expand Up @@ -94,7 +94,8 @@ \section{About the plugin}
\section{News \& ChangeLog}
\subsection{Geany\LaTeX{} 0.7}
\begin{itemize}
\item None by now.
\item Added a feature to lower selection before inserting
\texttt{\textbackslash{}textsc\{\}}
\end{itemize}
\subsection{Geany\LaTeX{} 0.6 -- 2011-10-15}
\begin{itemize}
Expand Down Expand Up @@ -538,6 +539,16 @@ \subsection{Inserting \textbackslash{}usepackage\{\}-entry to header}
\caption{Dialog for inserting \textbackslash{}usepackage\{\}}
\end{figure}

\subsection{Lower selection before inserting \textbackslash{}textsc\{\}}

With this feature, converting a normal text to \LaTeX{} is getting a
bit easier. If you start a document as plain text, with
abbreviations in it like ABC. You import it into \LaTeX{}, and want
the abbreviations in small caps. Geany\LaTeX{} converts the
selection to just use lower case letters. So \texttt{ABC} is
becoming \texttt{\textbackslash{}textsc\{abc\}} and later \textsc
{abc}. This can be configured via the plugin configuration dialog
and default value is turned off.

\section{Configuration}

Expand Down
10 changes: 10 additions & 0 deletions geanylatex/src/formatutils.c
Expand Up @@ -20,6 +20,7 @@
*/

#include "formatutils.h"
#include "string.h"


void glatex_insert_latex_format(G_GNUC_UNUSED GtkMenuItem * menuitem,
Expand All @@ -38,6 +39,15 @@ void glatex_insert_latex_format(G_GNUC_UNUSED GtkMenuItem * menuitem,

selection = sci_get_selection_contents(doc->editor->sci);

if (format == LATEX_SMALLCAPS &&
glatex_lowercase_on_smallcaps == TRUE)
{
gchar *new_selection = NULL;
new_selection = g_utf8_strdown(selection, -1);
g_free(selection);
selection = g_strdup(new_selection);
g_free(new_selection);
}
replacement = g_strconcat(glatex_format_pattern[format],"{",
selection, "}", NULL);

Expand Down
15 changes: 15 additions & 0 deletions geanylatex/src/geanylatex.c
Expand Up @@ -93,6 +93,8 @@ static gboolean glatex_autocompletion_active = FALSE;
static gint glatex_autocompletion_context_size;
static gboolean glatex_autocompletion_only_for_latex;
gboolean glatex_autobraces_active = TRUE;
gboolean glatex_lowercase_on_smallcaps = FALSE;


/* Function will be deactivated, when only loaded */
static gboolean toggle_active = FALSE;
Expand Down Expand Up @@ -146,6 +148,7 @@ static struct
GtkWidget *glatex_autocompletion_active;
GtkWidget *glatex_capitalize_sentence;
GtkWidget *wizard_to_generic_toolbar;
GtkWidget *lower_selection_on_smallcaps;
}
config_widgets;

Expand Down Expand Up @@ -201,6 +204,8 @@ on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.glatex_capitalize_sentence));
glatex_wizard_to_generic_toolbar =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.wizard_to_generic_toolbar));
glatex_lowercase_on_smallcaps =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.lower_selection_on_smallcaps));

/* Check the response code for geanyLaTeX's autocompletion functions.
* Due compatibility with oder Geany versions cass 0 will be treated
Expand All @@ -221,6 +226,8 @@ on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response,
glatex_set_toolbar_active);
g_key_file_set_boolean(config, "general", "glatex_set_autocompletion",
glatex_autocompletion_active);
g_key_file_set_boolean(config, "general", "glatex_lowercase_on_smallcaps",
glatex_lowercase_on_smallcaps);
g_key_file_set_boolean(config, "autocompletion",
"glatex_capitalize_sentence_starts", glatex_capitalize_sentence_starts);
g_key_file_set_boolean(config, "toolbar", "glatex_wizard_to_generic_toolbar",
Expand Down Expand Up @@ -295,6 +302,8 @@ plugin_configure(GtkDialog * dialog)
_("Capitalize sentence on typing"));
config_widgets.wizard_to_generic_toolbar = gtk_check_button_new_with_label(
_("Add a wizard icon to Geany's main toolbar"));
config_widgets.lower_selection_on_smallcaps = gtk_check_button_new_with_label(
_("Lower selection when formating smallcaps (\\textsc{})"));

config_widgets.glatex_autocompletion_active = gtk_combo_box_new_text();
gtk_combo_box_insert_text(GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active), 0,
Expand All @@ -310,6 +319,7 @@ plugin_configure(GtkDialog * dialog)
tmp = 1;
else
tmp = 0;

gtk_combo_box_set_active(GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active), tmp);

label_autocompletion = gtk_label_new(_("Modus of autocompletion"));
Expand All @@ -328,6 +338,9 @@ plugin_configure(GtkDialog * dialog)
gtk_box_pack_start(GTK_BOX(vbox), config_widgets.glatex_capitalize_sentence, FALSE, FALSE, 2);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.wizard_to_generic_toolbar),
glatex_wizard_to_generic_toolbar);
gtk_box_pack_start(GTK_BOX(vbox), config_widgets.lower_selection_on_smallcaps, FALSE, FALSE, 2);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.lower_selection_on_smallcaps),
glatex_lowercase_on_smallcaps);
gtk_box_pack_start(GTK_BOX(vbox), config_widgets.wizard_to_generic_toolbar, FALSE, FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox_autocompletion, FALSE, FALSE, 2);

Expand Down Expand Up @@ -1998,6 +2011,8 @@ static void glatex_init_configuration()
"glatex_set_autocompletion", TRUE);
glatex_autobraces_active = utils_get_setting_boolean(config, "autocompletion",
"glatex_set_autobraces", TRUE);
glatex_lowercase_on_smallcaps = utils_get_setting_boolean(config, "general",
"glatex_lowercase_on_smallcaps", FALSE);

/* Hidden preferences. Can be set directly via configuration file*/
glatex_autocompletion_context_size = utils_get_setting_integer(config, "autocompletion",
Expand Down
1 change: 1 addition & 0 deletions geanylatex/src/geanylatex.h
Expand Up @@ -60,6 +60,7 @@ extern GeanyFunctions *geany_functions;

extern LaTeXWizard glatex_wizard;
extern gboolean glatex_autobraces_active;
extern gboolean glatex_lowercase_on_smallcaps;

gint glatex_count_menu_entries(SubMenuTemplate *tmp, gint categorie);
void glatex_wizard_activated(G_GNUC_UNUSED GtkMenuItem * menuitem,
Expand Down

0 comments on commit e8887ea

Please sign in to comment.