From 349371197cfca4d70ba40bc68047a5d6e47f6f85 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 10 Oct 2008 15:58:11 +0200 Subject: [PATCH] Add 2 new default bar items (input_paste and input_search), used by default input bar --- po/cs.po | 14 +++- po/de.po | 14 +++- po/es.po | 12 ++- po/fr.po | 14 +++- po/hu.po | 14 +++- po/ru.po | 14 +++- po/weechat.pot | 12 ++- src/gui/curses/gui-curses-keyboard.c | 1 + src/gui/gui-bar-item.c | 107 ++++++++++++++++++++++++++- src/gui/gui-bar-item.h | 4 +- src/gui/gui-bar.c | 8 +- src/gui/gui-input.c | 24 ++++++ src/gui/gui-input.h | 2 + src/gui/gui-keyboard.c | 2 + 14 files changed, 229 insertions(+), 13 deletions(-) diff --git a/po/cs.po b/po/cs.po index 79b08fc3d..2c510a4d6 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-10-08 13:12+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" "PO-Revision-Date: 2008-09-17 16:19+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -1963,6 +1963,18 @@ msgstr "Seznam pro aliasy:\n" msgid "Bar \"%s\" updated" msgstr "Alias \"%s\" => \"%s\" vytvořen\n" +#, fuzzy, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr " Vložit %d řádků ? [ctrl-Y] Ano [ctrl-N] Ne" + +#, fuzzy +msgid "Text search" +msgstr "Vyhledávání textu: " + +#, fuzzy +msgid "Text search (exact)" +msgstr "Vyhledávání textu (rozlišování velikosti znaků): " + #, fuzzy msgid "filtered" msgstr "uživatel byl zablokován" diff --git a/po/de.po b/po/de.po index aee9a132c..6a3d208af 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-10-08 13:12+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -1910,6 +1910,18 @@ msgstr "Liste der Aliases:\n" msgid "Bar \"%s\" updated" msgstr "Alias \"%s\" => \"%s\" angelegt\n" +#, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr "" + +#, fuzzy +msgid "Text search" +msgstr "Textsuche" + +#, fuzzy +msgid "Text search (exact)" +msgstr "Textsuche (genau)" + #, fuzzy msgid "filtered" msgstr "/users wurde deaktiviert" diff --git a/po/es.po b/po/es.po index a05cac423..2779c2480 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-10-08 13:12+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -1892,6 +1892,16 @@ msgstr "Lista de alias:\n" msgid "Bar \"%s\" updated" msgstr "Alias \"%s\" => \"%s\" creado\n" +#, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr "" + +msgid "Text search" +msgstr "" + +msgid "Text search (exact)" +msgstr "" + #, fuzzy msgid "filtered" msgstr "los usuarios han sido desactivados" diff --git a/po/fr.po b/po/fr.po index a93f5d414..6c1037531 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-10-08 13:12+0200\n" -"PO-Revision-Date: 2008-10-08 13:13+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" +"PO-Revision-Date: 2008-10-10 15:52+0200\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -1914,6 +1914,16 @@ msgstr "objets de la barre" msgid "Bar \"%s\" updated" msgstr "Barre \"%s\" mise à jour" +#, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr "%sColler %d lignes ? [ctrl-Y] Oui [ctrl-N] Non" + +msgid "Text search" +msgstr "Recherche texte" + +msgid "Text search (exact)" +msgstr "Recherche texte (exact)" + msgid "filtered" msgstr "filtré" diff --git a/po/hu.po b/po/hu.po index 5a0b3c7af..56c11dce7 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-10-08 13:12+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1917,6 +1917,18 @@ msgstr "Aliaszok listája:\n" msgid "Bar \"%s\" updated" msgstr "A \"%s\" => \"%s\" aliasz elkészült\n" +#, fuzzy, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr " Beszúrható %d sor? [ctrl-Y] Igen [ctrl-N] Nem" + +#, fuzzy +msgid "Text search" +msgstr "Szöveg keresése: " + +#, fuzzy +msgid "Text search (exact)" +msgstr "Szöveg keresése (pontos): " + #, fuzzy msgid "filtered" msgstr "a felhasználók le lettek tiltva" diff --git a/po/ru.po b/po/ru.po index fcd5bc6ad..70fccb8e0 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-10-08 13:12+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -1921,6 +1921,18 @@ msgstr "Список сокращений:\n" msgid "Bar \"%s\" updated" msgstr "Сокращение \"%s\" => \"%s\" создано\n" +#, fuzzy, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr " Вставить %d строк ? [ctrl-Y] Да [ctrl-N] Нет" + +#, fuzzy +msgid "Text search" +msgstr "Поиск текста: " + +#, fuzzy +msgid "Text search (exact)" +msgstr "Поиск текста (регистрозависимый): " + #, fuzzy msgid "filtered" msgstr "команда users отключена" diff --git a/po/weechat.pot b/po/weechat.pot index d9fba2559..b75a153e2 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: 2008-10-08 13:12+0200\n" +"POT-Creation-Date: 2008-10-10 15:52+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1607,6 +1607,16 @@ msgstr "" msgid "Bar \"%s\" updated" msgstr "" +#, c-format +msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No" +msgstr "" + +msgid "Text search" +msgstr "" + +msgid "Text search (exact)" +msgstr "" + msgid "filtered" msgstr "" diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index 02f9b6023..dfb9b57d2 100644 --- a/src/gui/curses/gui-curses-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -413,6 +413,7 @@ gui_keyboard_read_cb (void *data) { gui_keyboard_paste_pending = 1; gui_input_draw (gui_current_window->buffer, 1); + gui_input_paste_pending_signal (); } } } diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index f2c2dcea3..12d35fb5b 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -42,6 +42,7 @@ #include "gui-completion.h" #include "gui-filter.h" #include "gui-hotlist.h" +#include "gui-keyboard.h" #include "gui-nicklist.h" #include "gui-window.h" @@ -49,9 +50,10 @@ struct t_gui_bar_item *gui_bar_items = NULL; /* first bar item */ struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] = -{ "input_prompt", "input_text", "time", "buffer_count", "buffer_plugin", - "buffer_name", "buffer_filter", "buffer_nicklist_count", "scroll", "hotlist", - "completion", "buffer_title", "buffer_nicklist" +{ "input_paste", "input_prompt", "input_search", "input_text", "time", + "buffer_count", "buffer_plugin", "buffer_name", "buffer_filter", + "buffer_nicklist_count", "scroll", "hotlist", "completion", "buffer_title", + "buffer_nicklist" }; struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL; struct t_hook *gui_bar_item_timer = NULL; @@ -617,6 +619,45 @@ gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin) } } +/* + * gui_bar_item_default_input_paste: default item for input paste question + */ + +char * +gui_bar_item_default_input_paste (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + int max_width, int max_height) +{ + char *text_paste_pending = N_("%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No"); + char *ptr_message, *buf; + int length; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) max_width; + (void) max_height; + + if (!window) + return NULL; + + if (window != gui_current_window) + return NULL; + + if (!gui_keyboard_paste_pending) + return NULL; + + ptr_message = _(text_paste_pending); + length = strlen (ptr_message) + 16 + 1; + buf = malloc (length); + if (buf) + snprintf (buf, length, ptr_message, + gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_input_actions))), + gui_keyboard_get_paste_lines ()); + + return buf; +} + /* * gui_bar_item_default_input_prompt: default item for input prompt */ @@ -657,6 +698,50 @@ gui_bar_item_default_input_prompt (void *data, struct t_gui_bar_item *item, return buf; } +/* + * gui_bar_item_default_input_search: default item for input search status + */ + +char * +gui_bar_item_default_input_search (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + int max_width, int max_height) +{ + char *text_search = N_("Text search"); + char *text_search_exact = N_("Text search (exact)"); + char *ptr_message, *buf; + int length; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) max_width; + (void) max_height; + + if (!window) + window = gui_current_window; + + if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED) + return NULL; + + ptr_message = (window->buffer->text_search_exact) ? + _(text_search_exact) : _(text_search); + length = 16 + strlen (ptr_message) + 1; + buf = malloc (length); + if (buf) + { + snprintf (buf, length, "%s%s", + (window->buffer->text_search_found + || !window->buffer->input_buffer + || !window->buffer->input_buffer[0]) ? + gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_input))) : + gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_input_text_not_found))), + ptr_message); + } + + return buf; +} + /* * gui_bar_item_default_input_text: default item for input text */ @@ -1218,6 +1303,13 @@ gui_bar_item_hook_signal (const char *signal, const char *item) void gui_bar_item_init () { + /* input paste */ + gui_bar_item_new (NULL, + gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE], + &gui_bar_item_default_input_paste, NULL); + gui_bar_item_hook_signal ("input_paste_pending", + gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE]); + /* input prompt */ gui_bar_item_new (NULL, gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT], @@ -1225,6 +1317,15 @@ gui_bar_item_init () gui_bar_item_hook_signal ("input_prompt_changed", gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT]); + /* input search */ + gui_bar_item_new (NULL, + gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH], + &gui_bar_item_default_input_search, NULL); + gui_bar_item_hook_signal ("input_search", + gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH]); + gui_bar_item_hook_signal ("input_text_changed", + gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH]); + /* input text */ gui_bar_item_new (NULL, gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index e522921c4..bd522c4a2 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -22,7 +22,9 @@ enum t_gui_bar_item_weechat { - GUI_BAR_ITEM_INPUT_PROMPT = 0, + GUI_BAR_ITEM_INPUT_PASTE = 0, + GUI_BAR_ITEM_INPUT_PROMPT, + GUI_BAR_ITEM_INPUT_SEARCH, GUI_BAR_ITEM_INPUT_TEXT, GUI_BAR_ITEM_TIME, GUI_BAR_ITEM_BUFFER_COUNT, diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 2438518f7..9580a5b6d 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -1670,15 +1670,21 @@ gui_bar_create_default_input () { /* create input bar */ length = 1 /* "[" */ + + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE]) + + 3 /* "],[" */ + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT]) + + 3 /* "],[" */ + + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH]) + 2 /* "]," */ + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]) + 1 /* \0 */; buf = malloc (length); if (buf) { - snprintf (buf, length, "[%s],%s", + snprintf (buf, length, "[%s],[%s],[%s],%s", + gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE], gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT], + gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH], gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]); if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_INPUT, "0", /* hidden */ diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 7e99d6a73..0ad9a4880 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -47,6 +47,16 @@ char *gui_input_clipboard = NULL; /* clipboard content */ +/* + * gui_input_paste_pending_signal: send signal "input_paste_pending" + */ + +void +gui_input_paste_pending_signal () +{ + hook_signal_send ("input_paste_pending", WEECHAT_HOOK_SIGNAL_STRING, NULL); +} + /* * gui_input_prompt_changed_signal: send signal "input_prompt_changed" */ @@ -77,6 +87,16 @@ gui_input_text_cursor_moved_signal () hook_signal_send ("input_text_cursor_moved", WEECHAT_HOOK_SIGNAL_STRING, NULL); } +/* + * gui_input_search_signal: send signal "input_search" + */ + +void +gui_input_search_signal () +{ + hook_signal_send ("input_search", WEECHAT_HOOK_SIGNAL_STRING, NULL); +} + /* * gui_input_optimize_size: optimize input buffer size by adding * or deleting data block (predefined size) @@ -334,7 +354,10 @@ gui_input_return () if (gui_current_window->buffer->input) { if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED) + { gui_window_search_stop (gui_current_window); + gui_input_search_signal (); + } else if (gui_current_window->buffer->input_buffer_size > 0) { gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0'; @@ -539,6 +562,7 @@ gui_input_search_text () gui_window_search_restart (gui_current_window); gui_buffer_ask_input_refresh (gui_current_window->buffer, 1); } + gui_input_search_signal (); } } diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index d8d5fe796..1bc6ef2b5 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -28,8 +28,10 @@ extern char *gui_input_clipboard; /* input functions */ +extern void gui_input_paste_pending_signal (); extern void gui_input_prompt_changed_signal (); extern void gui_input_text_changed_signal (); +extern void gui_input_search_signal (); extern void gui_input_optimize_size (struct t_gui_buffer *buffer); extern void gui_input_init_color_mask (struct t_gui_buffer *buffer); extern void gui_input_move (struct t_gui_buffer *buffer, char *target, diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index 5c8b027af..d93d49748 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -635,6 +635,7 @@ void gui_keyboard_paste_accept () { gui_keyboard_paste_pending = 0; + gui_input_paste_pending_signal (); } @@ -647,6 +648,7 @@ gui_keyboard_paste_cancel () { gui_keyboard_buffer_reset (); gui_keyboard_paste_pending = 0; + gui_input_paste_pending_signal (); } /*