Revision: 1599 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1599&view=re... Author: frlan Date: 2010-09-20 17:21:54 +0000 (Mon, 20 Sep 2010)
Log Message: ----------- GeanyLaTeX: Added a first proof on concept of a feature that inserts capital letters on first letter of a sentence
Modified Paths: -------------- trunk/geanylatex/ChangeLog trunk/geanylatex/doc/geanylatex.pdf trunk/geanylatex/doc/geanylatex.tex trunk/geanylatex/src/geanylatex.c
Modified: trunk/geanylatex/ChangeLog =================================================================== --- trunk/geanylatex/ChangeLog 2010-09-19 19:59:37 UTC (rev 1598) +++ trunk/geanylatex/ChangeLog 2010-09-20 17:21:54 UTC (rev 1599) @@ -1,3 +1,10 @@ +2010-09-20 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + + * Added a feature that inserts capital letters on first letter of a + sentence. This is not working with multibyte characters as German + Umlauts. + + 2010-09-14 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* Place LaTeX menu in front of help menu entry.
Modified: trunk/geanylatex/doc/geanylatex.pdf =================================================================== (Binary files differ)
Modified: trunk/geanylatex/doc/geanylatex.tex =================================================================== --- trunk/geanylatex/doc/geanylatex.tex 2010-09-19 19:59:37 UTC (rev 1598) +++ trunk/geanylatex/doc/geanylatex.tex 2010-09-20 17:21:54 UTC (rev 1599) @@ -96,6 +96,8 @@ \subsection{Upcoming Geany\LaTeX{} 0.6} \begin{itemize} \item Moved \LaTeX{} menu to a separate menu inside Geany main menu + \item Added a feature to autocapetlise letters on typing on begin of + a sentence \end{itemize}
\subsection{Geany\LaTeX{} 0.5 -- 2010-06-13} @@ -568,6 +570,17 @@ \caption{Plugin toolbar of Geany\LaTeX{} 0.5} \end{figure}
+ +\subsubsection{Capitalize letters on sentence begin} + +If this option is enabled, Geany\LaTeX{} will look for \textsc{.}, +\textsc{!} or \textsc{?} followed by a space. The next letter will +be inserted in capital letters. Currenty this is not working for +multichar letters as German Umlauts as well as the overwriting is +not supported very well at this point. In case of you don't want to +have the capital version of a letter in a particular case, just hit +undo (Ctrl + z in most cases). + \subsubsection{Modus of autocompletion} \label{sec:modus_of_autocompletion} Here you can choose, whether the Geany\LaTeX{} should do some
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2010-09-19 19:59:37 UTC (rev 1598) +++ trunk/geanylatex/src/geanylatex.c 2010-09-20 17:21:54 UTC (rev 1599) @@ -74,6 +74,7 @@ static gchar *glatex_ref_page_string = NULL; static gchar *glatex_ref_all_string = NULL; static gboolean glatex_set_toolbar_active = FALSE; +static gboolean glatex_capitalize_sentence_starts = FALSE;
/* We want to keep this deactivated by default as the * user needs to know what he is doing here.... */ @@ -136,6 +137,7 @@ GtkWidget *koma_active; GtkWidget *toolbar_active; GtkWidget *glatex_autocompletion_active; + GtkWidget *glatex_capitalize_sentence; } config_widgets;
@@ -183,6 +185,8 @@ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.koma_active)); glatex_set_toolbar_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.toolbar_active)); + glatex_capitalize_sentence_starts = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.glatex_capitalize_sentence));
/* Check the response code for geanyLaTeX's autocompletion functions. * Due compatibility with oder Geany versions cass 0 will be treated @@ -203,6 +207,8 @@ glatex_set_toolbar_active); g_key_file_set_boolean(config, "general", "glatex_set_autocompletion", glatex_autocompletion_active); + g_key_file_set_boolean(config, "autocompletion", + "glatex_capitalize_sentence_starts", glatex_capitalize_sentence_starts);
if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0) @@ -256,6 +262,8 @@ _("Use KOMA script by default")); config_widgets.toolbar_active = gtk_check_button_new_with_label( _("Show extra plugin toolbar")); + config_widgets.glatex_capitalize_sentence = gtk_check_button_new_with_label( + _("Capitalize sentense on typing"));
config_widgets.glatex_autocompletion_active = gtk_combo_box_new_text(); gtk_combo_box_insert_text(GTK_COMBO_BOX(config_widgets.glatex_autocompletion_active), 0, @@ -284,6 +292,9 @@ 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_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_widgets.glatex_capitalize_sentence), + glatex_capitalize_sentence_starts); + gtk_box_pack_start(GTK_BOX(vbox), config_widgets.glatex_capitalize_sentence, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox), hbox_autocompletion, FALSE, FALSE, 2);
gtk_widget_show_all(vbox); @@ -455,7 +466,7 @@ gint pos;
g_return_val_if_fail(editor != NULL, FALSE); - + sci = editor->sci; /* Autocompletion for LaTeX specific stuff: * Introducing \end{} or \endgroup{} after a \begin{}
@@ -468,7 +479,6 @@ !(glatex_autocompletion_only_for_latex == TRUE && editor->document->file_type->id != GEANY_FILETYPES_LATEX)) { - sci = editor->sci; pos = sci_get_current_position(sci);
if (nt->nmhdr.code == SCN_CHARADDED) @@ -623,8 +633,8 @@ } break; } /* Closing case \r or \n */ - case '_': - case '^': + case '_': + case '^': { if (glatex_autobraces_active == TRUE) { @@ -633,6 +643,31 @@ } break; } + default: + { + if (glatex_capitalize_sentence_starts == TRUE) + { + if (sci_get_char_at(sci, pos -2) == ' ' && + (sci_get_char_at(sci, pos -3) == '.' || + sci_get_char_at(sci, pos -3) == '!' || + sci_get_char_at(sci, pos -3) == '?' )) + { + gchar *upperLtr = NULL; + gchar *selection = NULL; + + sci_set_selection_start(sci, pos - 1); + sci_set_selection_end(sci, pos); + + selection = sci_get_selection_contents(sci); + upperLtr = g_utf8_strup(selection, -1); + sci_replace_sel(sci, upperLtr); + + g_free(upperLtr); + g_free(selection); + } + break; + } + } } /* Closing switch */ /* later there could be some else ifs for other keywords */ } @@ -1953,6 +1988,8 @@
glatex_autocompletion_only_for_latex = utils_get_setting_boolean(config, "autocompletion", "glatex_autocompletion_only_for_latex", TRUE); + glatex_capitalize_sentence_starts = utils_get_setting_boolean(config, "autocompletion", + "glatex_capitalize_sentence_starts", FALSE);
glatex_deactivate_toolbaritems_with_non_latex = utils_get_setting_boolean(config, "toolbar", "glatex_deactivate_toolbaritems_with_non_latex", TRUE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.