Revision: 789 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=789&view=rev Author: frlan Date: 2009-06-27 09:52:14 +0000 (Sat, 27 Jun 2009)
Log Message: ----------- GeanyLaTeX: Insert keybndings for inserting common list environments
Modified Paths: -------------- trunk/geanylatex/src/geanylatex.c trunk/geanylatex/src/latexenvironments.c trunk/geanylatex/src/latexenvironments.h trunk/geanylatex/src/latexkeybindings.c trunk/geanylatex/src/latexkeybindings.h
Modified: trunk/geanylatex/src/geanylatex.c =================================================================== --- trunk/geanylatex/src/geanylatex.c 2009-06-27 08:25:43 UTC (rev 788) +++ trunk/geanylatex/src/geanylatex.c 2009-06-27 09:52:14 UTC (rev 789) @@ -85,6 +85,9 @@ KB_LATEX_FORMAT_CENTER, KB_LATEX_FORMAT_LEFT, KB_LATEX_FORMAT_RIGHT, + KB_LATEX_ENVIRONMENT_INSERT_DESCRIPTION, + KB_LATEX_ENVIRONMENT_INSERT_ITEMIZE, + KB_LATEX_ENVIRONMENT_INSERT_ENUMERATE, COUNT_KB };
@@ -1135,7 +1138,16 @@ keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_LEFT, glatex_kb_format_left, 0, 0, "format_left", _("Format selection left-aligned"), NULL); keybindings_set_item(plugin_key_group, KB_LATEX_FORMAT_RIGHT, glatex_kb_format_right, - 0, 0, "format_right", _("Format selection right-aligned "), NULL); + 0, 0, "format_right", _("Format selection right-aligned"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_ENVIRONMENT_INSERT_DESCRIPTION, + glatex_kb_insert_description_list, 0, 0, "insert_description_list", + _("Insert description list"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_ENVIRONMENT_INSERT_ITEMIZE, + glatex_kb_insert_itemize_list, 0, 0, "insert_itemize_list", + _("Insert itemize list"), NULL); + keybindings_set_item(plugin_key_group, KB_LATEX_ENVIRONMENT_INSERT_ENUMERATE, + glatex_kb_insert_enumerate_list, 0, 0, "insert_enumerate_list", + _("Insert enumerate list"), NULL); }
void plugin_help()
Modified: trunk/geanylatex/src/latexenvironments.c =================================================================== --- trunk/geanylatex/src/latexenvironments.c 2009-06-27 08:25:43 UTC (rev 788) +++ trunk/geanylatex/src/latexenvironments.c 2009-06-27 09:52:14 UTC (rev 789) @@ -51,8 +51,14 @@ {0, NULL, NULL}, };
+gchar *glatex_list_environments [] = +{ + "description", + "enumerate", + "itemize" +};
-void glatex_insert_environment(gchar *environment) +void glatex_insert_environment(gchar *environment, gint type) { GeanyDocument *doc = NULL;
@@ -78,11 +84,19 @@ { gint pos = sci_get_current_position(doc->editor->sci); gint len = strlen(environment); + GString *tmpstring = NULL; gchar *tmp = NULL;
- tmp = g_strconcat("\begin{", environment, "}\n\n\end{", - environment, "}\n", NULL); + tmpstring = g_string_new("\begin{"); + g_string_append(tmpstring, environment); + g_string_append(tmpstring, "}\n"); + if (type == GLATEX_ENVIRONMENT_TYPE_LIST) + g_string_append(tmpstring, "\item \n"); + g_string_append(tmpstring, "\end{"); + g_string_append(tmpstring, environment); + g_string_append(tmpstring,"}\n");
+ tmp = g_string_free(tmpstring, FALSE); sci_insert_text(doc->editor->sci, pos, tmp); sci_set_current_position(doc->editor->sci, pos + len + 9, TRUE); g_free(tmp); @@ -97,7 +111,12 @@ { gint env = GPOINTER_TO_INT(gdata);
- glatex_insert_environment(glatex_environment_array[env].latex); + if (glatex_environment_array[env].cat == ENVIRONMENT_CAT_LISTS) + glatex_insert_environment(glatex_environment_array[env].latex, + GLATEX_ENVIRONMENT_TYPE_LIST); + else + glatex_insert_environment(glatex_environment_array[env].latex, + GLATEX_ENVIRONMENT_TYPE_NONE); }
@@ -158,7 +177,8 @@
if (env_string != NULL) { - glatex_insert_environment(env_string); + /* Introduce a check whether an enrivonent is a list */ + glatex_insert_environment(env_string, GLATEX_ENVIRONMENT_TYPE_NONE); g_free(env_string); } } @@ -166,3 +186,7 @@ gtk_widget_destroy(dialog); }
+void glatex_insert_list_environment(gint type) +{ + glatex_insert_environment(glatex_list_environments[type], GLATEX_ENVIRONMENT_TYPE_LIST); +}
Modified: trunk/geanylatex/src/latexenvironments.h =================================================================== --- trunk/geanylatex/src/latexenvironments.h 2009-06-27 08:25:43 UTC (rev 788) +++ trunk/geanylatex/src/latexenvironments.h 2009-06-27 09:52:14 UTC (rev 789) @@ -34,11 +34,22 @@ ENVIRONMENT_CAT_MAX };
+enum { + GLATEX_LIST_DESCRIPTION = 0, + GLATEX_LIST_ENUMERATE, + GLATEX_LIST_ITEMIZE +}; + +enum { + GLATEX_ENVIRONMENT_TYPE_NONE = 0, + GLATEX_ENVIRONMENT_TYPE_LIST +}; + extern SubMenuTemplate glatex_environment_array[];
extern CategoryName glatex_environment_cat_names[];
-void glatex_insert_environment(gchar *environment); +void glatex_insert_environment(gchar *environment, gint type);
void glatex_insert_environment_dialog(G_GNUC_UNUSED GtkMenuItem *menuitem, @@ -48,4 +59,5 @@ glatex_environment_insert_activated (G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata);
+void glatex_insert_list_environment(gint type); #endif
Modified: trunk/geanylatex/src/latexkeybindings.c =================================================================== --- trunk/geanylatex/src/latexkeybindings.c 2009-06-27 08:25:43 UTC (rev 788) +++ trunk/geanylatex/src/latexkeybindings.c 2009-06-27 09:52:14 UTC (rev 789) @@ -110,3 +110,24 @@ return; glatex_insert_latex_format(NULL, GINT_TO_POINTER(LATEX_RIGHT)); } + +void glatex_kb_insert_description_list(G_GNUC_UNUSED guint key_id) +{ + if (NULL == document_get_current()) + return; + glatex_insert_list_environment(GLATEX_LIST_DESCRIPTION); +} + +void glatex_kb_insert_itemize_list(G_GNUC_UNUSED guint key_id) +{ + if (NULL == document_get_current()) + return; + glatex_insert_list_environment(GLATEX_LIST_ITEMIZE); +} + +void glatex_kb_insert_enumerate_list(G_GNUC_UNUSED guint key_id) +{ + if (NULL == document_get_current()) + return; + glatex_insert_list_environment(GLATEX_LIST_ENUMERATE); +}
Modified: trunk/geanylatex/src/latexkeybindings.h =================================================================== --- trunk/geanylatex/src/latexkeybindings.h 2009-06-27 08:25:43 UTC (rev 788) +++ trunk/geanylatex/src/latexkeybindings.h 2009-06-27 09:52:14 UTC (rev 789) @@ -37,5 +37,8 @@ void glatex_kb_format_centering(G_GNUC_UNUSED guint key_id); void glatex_kb_format_left(G_GNUC_UNUSED guint key_id); void glatex_kb_format_right(G_GNUC_UNUSED guint key_id); +void glatex_kb_insert_description_list(G_GNUC_UNUSED guint key_id); +void glatex_kb_insert_itemize_list(G_GNUC_UNUSED guint key_id); +void glatex_kb_insert_enumerate_list(G_GNUC_UNUSED guint key_id);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org