From d7ad1780ad0d0f594ef957e35102f4c07688dd95 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 10 Jun 2009 19:13:38 +0200 Subject: [PATCH] Add infolist with commands history --- doc/en/autogen/plugin_api/infolists.txt | 2 ++ doc/fr/autogen/plugin_api/infolists.txt | 2 ++ po/cs.po | 6 +++++- po/de.po | 6 +++++- po/es.po | 6 +++++- po/fr.po | 7 +++++-- po/hu.po | 6 +++++- po/pl.po | 6 +++++- po/ru.po | 6 +++++- po/weechat.pot | 5 ++++- src/gui/gui-history.c | 26 +++++++++++++++++++++++++ src/gui/gui-history.h | 5 ++++- src/plugins/plugin-api.c | 26 +++++++++++++++++++++++++ 13 files changed, 99 insertions(+), 10 deletions(-) diff --git a/doc/en/autogen/plugin_api/infolists.txt b/doc/en/autogen/plugin_api/infolists.txt index 1d2c157e5..29fe8db69 100644 --- a/doc/en/autogen/plugin_api/infolists.txt +++ b/doc/en/autogen/plugin_api/infolists.txt @@ -37,6 +37,8 @@ | weechat | filter | list of filters +| weechat | history | history of commands + | weechat | hook | list of hooks | weechat | hotlist | list of buffers in hotlist diff --git a/doc/fr/autogen/plugin_api/infolists.txt b/doc/fr/autogen/plugin_api/infolists.txt index 0e75f8653..225ec774d 100644 --- a/doc/fr/autogen/plugin_api/infolists.txt +++ b/doc/fr/autogen/plugin_api/infolists.txt @@ -37,6 +37,8 @@ | weechat | filter | liste des filtres +| weechat | history | historique des commandes + | weechat | hook | liste des hooks | weechat | hotlist | liste des tampons dans la hotlist diff --git a/po/cs.po b/po/cs.po index 90ca68e25..0c1363e40 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: 2009-05-11 13:02+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -4972,6 +4972,10 @@ msgstr "nevalidní délka pro buffer" msgid "list of filters" msgstr "Seznam pro aliasy:\n" +#, fuzzy +msgid "history of commands" +msgstr "Další příkazy:" + #, fuzzy msgid "list of hooks" msgstr "Seznam pro aliasy:\n" diff --git a/po/de.po b/po/de.po index 4ee3d1083..961aa8e13 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: 2009-05-11 13:02+0200\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -4922,6 +4922,10 @@ msgstr "konnte den Puffer nicht laden" msgid "list of filters" msgstr "Liste der Aliases:\n" +#, fuzzy +msgid "history of commands" +msgstr "%s interne Befehle:\n" + #, fuzzy msgid "list of hooks" msgstr "Liste der Aliases:\n" diff --git a/po/es.po b/po/es.po index 49bc54087..6b46f4519 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: 2009-05-11 13:02+0200\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -4911,6 +4911,10 @@ msgstr "falló al cargar el búfer" msgid "list of filters" msgstr "Lista de alias:\n" +#, fuzzy +msgid "history of commands" +msgstr "Comandos internos %s :\n" + #, fuzzy msgid "list of hooks" msgstr "Lista de alias:\n" diff --git a/po/fr.po b/po/fr.po index 378014555..f098632f0 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" -"PO-Revision-Date: 2009-06-10 13:05+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" +"PO-Revision-Date: 2009-06-10 19:09+0200\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -5136,6 +5136,9 @@ msgstr "lignes d'un tampon" msgid "list of filters" msgstr "liste des filtres" +msgid "history of commands" +msgstr "historique des commandes" + msgid "list of hooks" msgstr "liste des hooks" diff --git a/po/hu.po b/po/hu.po index b135177ce..de789ad56 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: 2009-05-11 13:02+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4982,6 +4982,10 @@ msgstr "puffer betöltése sikertelen" msgid "list of filters" msgstr "Aliaszok listája:\n" +#, fuzzy +msgid "history of commands" +msgstr "%s belső parancsok:\n" + #, fuzzy msgid "list of hooks" msgstr "Aliaszok listája:\n" diff --git a/po/pl.po b/po/pl.po index 3d92000f3..fe101fddd 100644 --- a/po/pl.po +++ b/po/pl.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: 2009-05-11 13:02+0200\n" "Last-Translator: \n" "Language-Team: Polish\n" @@ -4299,6 +4299,10 @@ msgstr "" msgid "list of filters" msgstr "" +#, fuzzy +msgid "history of commands" +msgstr "Pozostałe komendy:" + msgid "list of hooks" msgstr "" diff --git a/po/ru.po b/po/ru.po index 30e26098a..e460aa23a 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: 2009-05-11 13:02+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -4955,6 +4955,10 @@ msgstr "загрузка буфера не удалась" msgid "list of filters" msgstr "Список сокращений:\n" +#, fuzzy +msgid "history of commands" +msgstr "Внутренние команды %s:\n" + #, fuzzy msgid "list of hooks" msgstr "Список сокращений:\n" diff --git a/po/weechat.pot b/po/weechat.pot index fa856c3bc..e8f27fca2 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-06-10 13:00+0200\n" +"POT-Creation-Date: 2009-06-10 19:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4262,6 +4262,9 @@ msgstr "" msgid "list of filters" msgstr "" +msgid "history of commands" +msgstr "" + msgid "list of hooks" msgstr "" diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c index 6c32626f6..e8e316b25 100644 --- a/src/gui/gui-history.c +++ b/src/gui/gui-history.c @@ -28,6 +28,7 @@ #include "../core/weechat.h" #include "../core/wee-config.h" +#include "../core/wee-infolist.h" #include "../core/wee-string.h" #include "gui-history.h" #include "gui-buffer.h" @@ -185,3 +186,28 @@ gui_history_buffer_free (struct t_gui_buffer *buffer) buffer->ptr_history = NULL; buffer->num_history = 0; } + +/* + * gui_history_add_to_infolist: add history of commands in an infolist + * if buffer is NULL, global history is returned + * return 1 if ok, 0 if error + */ + +int +gui_history_add_to_infolist (struct t_infolist *infolist, + struct t_gui_history *history) +{ + struct t_infolist_item *ptr_item; + + if (!infolist || !history) + return 0; + + ptr_item = infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (!infolist_new_var_string (ptr_item, "text", history->text)) + return 0; + + return 1; +} diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h index 501c201e2..e51c0072d 100644 --- a/src/gui/gui-history.h +++ b/src/gui/gui-history.h @@ -33,9 +33,12 @@ extern struct t_gui_history *history_global; extern struct t_gui_history *last_history_global; extern struct t_gui_history *history_global_ptr; -extern void gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string); +extern void gui_history_buffer_add (struct t_gui_buffer *buffer, + const char *string); extern void gui_history_global_add (const char *string); extern void gui_history_global_free (); extern void gui_history_buffer_free (struct t_gui_buffer *buffer); +extern int gui_history_add_to_infolist (struct t_infolist *infolist, + struct t_gui_history *history); #endif /* gui-history.h */ diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 754f75ae2..215462426 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -45,6 +45,7 @@ #include "../gui/gui-chat.h" #include "../gui/gui-color.h" #include "../gui/gui-filter.h" +#include "../gui/gui-history.h" #include "../gui/gui-hotlist.h" #include "../gui/gui-keyboard.h" #include "../gui/gui-line.h" @@ -334,6 +335,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, struct t_gui_bar_window *ptr_bar_window; struct t_gui_buffer *ptr_buffer; struct t_gui_line *ptr_line; + struct t_gui_history *ptr_history; struct t_gui_filter *ptr_filter; struct t_gui_window *ptr_window; struct t_gui_hotlist *ptr_hotlist; @@ -567,6 +569,28 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, return ptr_infolist; } } + else if (string_strcasecmp (infolist_name, "history") == 0) + { + /* invalid buffer pointer ? */ + if (pointer && (!gui_buffer_valid (pointer))) + return NULL; + + ptr_infolist = infolist_new (); + if (ptr_infolist) + { + for (ptr_history = (pointer) ? + ((struct t_gui_buffer *)pointer)->history : history_global; + ptr_history; ptr_history = ptr_history->next_history) + { + if (!gui_history_add_to_infolist (ptr_infolist, ptr_history)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; + } + } else if (string_strcasecmp (infolist_name, "hook") == 0) { ptr_infolist = infolist_new (); @@ -918,6 +942,8 @@ plugin_api_init () &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "filter", N_("list of filters"), &plugin_api_infolist_get_internal, NULL); + hook_infolist (NULL, "history", N_("history of commands"), + &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "hook", N_("list of hooks"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"),