From bd7ae6d5a79991d7f65bc12091b61bcdc4bc5b49 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 27 Sep 2010 16:07:27 +0200 Subject: [PATCH] Add new option weechat.look.input_share (task #9228) --- ChangeLog | 3 +- doc/de/autogen/user/weechat_options.txt | 5 ++++ doc/en/autogen/user/weechat_options.txt | 5 ++++ doc/fr/autogen/user/weechat_options.txt | 5 ++++ doc/it/autogen/user/weechat_options.txt | 5 ++++ po/cs.po | 7 ++++- po/de.po | 7 ++++- po/es.po | 7 ++++- po/fr.po | 11 +++++-- po/hu.po | 7 ++++- po/it.po | 7 ++++- po/pl.po | 7 ++++- po/ru.po | 7 ++++- po/weechat.pot | 7 ++++- src/core/wee-config.c | 7 +++++ src/core/wee-config.h | 1 + src/gui/curses/gui-curses-window.c | 12 ++++++++ src/gui/gui-buffer.c | 25 +++++++++++----- src/gui/gui-buffer.h | 1 + src/gui/gui-input.c | 40 +++++++++++++++++++++++++ src/gui/gui-input.h | 2 ++ 21 files changed, 160 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dad5d448..063bffdc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,13 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.4-dev, 2010-09-23 +v0.3.4-dev, 2010-09-27 Version 0.3.4 (under dev!) -------------------------- +* core: add new option weechat.look.input_share (task #9228) * core: use similar behaviour for keys bound to local or global history (bug #30759) * api: add priority for hooks (task #10550) diff --git a/doc/de/autogen/user/weechat_options.txt b/doc/de/autogen/user/weechat_options.txt index 954cadf5e..1b6773143 100644 --- a/doc/de/autogen/user/weechat_options.txt +++ b/doc/de/autogen/user/weechat_options.txt @@ -423,6 +423,11 @@ ** Typ: integer ** Werte: group_time_asc, group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc (Standardwert: `group_time_asc`) +* *weechat.look.input_share* +** Beschreibung: `if set, there is only one input shared on all buffers (but still local history for each buffer)` +** Typ: boolesch +** Werte: on, off (Standardwert: `off`) + * *weechat.look.input_undo_max* ** Beschreibung: `maximale Anzahl für "Zurücknahme" von Befehlen im Verlauf, pro Buffer (0: Rückgängig machen deaktiviert)` ** Typ: integer diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index 97ff0792a..d4653c129 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -423,6 +423,11 @@ ** type: integer ** values: group_time_asc, group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc (default value: `group_time_asc`) +* *weechat.look.input_share* +** description: `if set, there is only one input shared on all buffers (but still local history for each buffer)` +** type: boolean +** values: on, off (default value: `off`) + * *weechat.look.input_undo_max* ** description: `max number of "undo" for command line, by buffer (0 = undo disabled)` ** type: integer diff --git a/doc/fr/autogen/user/weechat_options.txt b/doc/fr/autogen/user/weechat_options.txt index 90caf7f01..8420a59c3 100644 --- a/doc/fr/autogen/user/weechat_options.txt +++ b/doc/fr/autogen/user/weechat_options.txt @@ -423,6 +423,11 @@ ** type: entier ** valeurs: group_time_asc, group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc (valeur par défaut: `group_time_asc`) +* *weechat.look.input_share* +** description: `si défini, il y a une seule entrée commune à tous les tampons (mais toujours un historique local sur chaque tampon)` +** type: booléen +** valeurs: on, off (valeur par défaut: `off`) + * *weechat.look.input_undo_max* ** description: `nombre maximum de "undo" pour la ligne de commande, par tampon (0 = undo désactivé)` ** type: entier diff --git a/doc/it/autogen/user/weechat_options.txt b/doc/it/autogen/user/weechat_options.txt index 6daead63b..754d25add 100644 --- a/doc/it/autogen/user/weechat_options.txt +++ b/doc/it/autogen/user/weechat_options.txt @@ -423,6 +423,11 @@ ** tipo: intero ** valori: group_time_asc, group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc (valore predefinito: `group_time_asc`) +* *weechat.look.input_share* +** descrizione: `if set, there is only one input shared on all buffers (but still local history for each buffer)` +** tipo: bool +** valori: on, off (valore predefinito: `off`) + * *weechat.look.input_undo_max* ** descrizione: `numero massimo di righe nella cronologia per buffer (0 = nessun limite)` ** tipo: intero diff --git a/po/cs.po b/po/cs.po index 5271ce16c..a74f2e0f9 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -1809,6 +1809,11 @@ msgstr "" "[skupina_číslo_vzestupně], group_number_desc [skupina_číslo_sestupně], " "number_asc [číslo_vzestupně], number_desc [číslo_sestupně] ) " +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" "maximální počet \"undo\" pro příkazovou řádku pro bufferu (0 = vypnuto)" diff --git a/po/de.po b/po/de.po index 4be447568..260b7d589 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-09-08 22:15+0200\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev \n" @@ -1885,6 +1885,11 @@ msgstr "" "Sortierung der Hotlist (group_time_asc (Standardwert), group_time_desc, " "group_number_asc, group_number_desc, number_asc, number_desc)" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" "maximale Anzahl für \"Zurücknahme\" von Befehlen im Verlauf, pro Buffer (0: " diff --git a/po/es.po b/po/es.po index 38a6cba48..7afea3e9c 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -1827,6 +1827,11 @@ msgstr "" "group_time_desc, group_number_asc, group_number_desc, number_asc, " "number_desc)" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" "número máximo de niveles de deshaces en la línea de comando, por buffer (0 = " diff --git a/po/fr.po b/po/fr.po index a3a76ed92..5c5c57e9a 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" -"PO-Revision-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" +"PO-Revision-Date: 2010-09-27 16:02+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -1844,6 +1844,13 @@ msgstr "" "group_time_desc, group_number_asc, group_number_desc, number_asc, " "number_desc)" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" +"si défini, il y a une seule entrée commune à tous les tampons (mais toujours " +"un historique local sur chaque tampon)" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" "nombre maximum de \"undo\" pour la ligne de commande, par tampon (0 = undo " diff --git a/po/hu.po b/po/hu.po index f0a9470ce..c0a26c71e 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1593,6 +1593,11 @@ msgid "" "group_number_asc, group_number_desc, number_asc, number_desc)" msgstr "" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + #, fuzzy msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" diff --git a/po/it.po b/po/it.po index 497c61933..fbd773170 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-21 17:29+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-09-22 15:27+0200\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -1833,6 +1833,11 @@ msgstr "" "group_time_desc, group_number_asc, group_number_desc, number_asc, " "number_desc)" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" "numero massimo di righe nella cronologia per buffer (0 = nessun limite)" diff --git a/po/pl.po b/po/pl.po index 96543a682..7ea4a433b 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Krzysztof Koroscik \n" "Language-Team: weechat-dev \n" @@ -1834,6 +1834,11 @@ msgstr "" "typ sortowania hotlisty (group_time_asc (domyślny), group_time_desc, " "group_number_asc, group_number_desc, number_asc, number_desc)" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" "maksymalna ilość \"cofnięć\" dla lini poleceń dla bufora (0 = wyłączone)" diff --git a/po/ru.po b/po/ru.po index 06b43490d..c3e22fcda 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -1608,6 +1608,11 @@ msgstr "" "тип сортировки хотлиста (group_time_asc (по-умолчанию), group_time_desc, " "group_number_asc, group_number_desc, number_asc, number_desc)" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + #, fuzzy msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "максимальное количество команд в истории (0 = не ограничено)" diff --git a/po/weechat.pot b/po/weechat.pot index c4c3ae9ac..8f2d4353e 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: 2010-09-20 22:26+0200\n" +"POT-Creation-Date: 2010-09-27 16:01+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1375,6 +1375,11 @@ msgid "" "group_number_asc, group_number_desc, number_asc, number_desc)" msgstr "" +msgid "" +"if set, there is only one input shared on all buffers (but still local " +"history for each buffer)" +msgstr "" + msgid "max number of \"undo\" for command line, by buffer (0 = undo disabled)" msgstr "" diff --git a/src/core/wee-config.c b/src/core/wee-config.c index f29aa81ff..c4d4a235f 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -89,6 +89,7 @@ struct t_config_option *config_look_hotlist_names_level; struct t_config_option *config_look_hotlist_names_merged_buffers; struct t_config_option *config_look_hotlist_short_names; struct t_config_option *config_look_hotlist_sort; +struct t_config_option *config_look_input_share; struct t_config_option *config_look_input_undo_max; struct t_config_option *config_look_item_time_format; struct t_config_option *config_look_jump_current_to_previous_buffer; @@ -1344,6 +1345,12 @@ config_weechat_init_options () "group_time_asc|group_time_desc|group_number_asc|" "group_number_desc|number_asc|number_desc", 0, 0, "group_time_asc", NULL, 0, NULL, NULL, &config_change_hotlist, NULL, NULL, NULL); + config_look_input_share = config_file_new_option ( + weechat_config_file, ptr_section, + "input_share", "boolean", + N_("if set, there is only one input shared on all buffers (but still " + "local history for each buffer)"), + NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_look_input_undo_max = config_file_new_option ( weechat_config_file, ptr_section, "input_undo_max", "integer", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 9e63a8a7d..24c3e0421 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -111,6 +111,7 @@ extern struct t_config_option *config_look_hotlist_names_level; extern struct t_config_option *config_look_hotlist_names_merged_buffers; extern struct t_config_option *config_look_hotlist_short_names; extern struct t_config_option *config_look_hotlist_sort; +extern struct t_config_option *config_look_input_share; extern struct t_config_option *config_look_input_undo_max; extern struct t_config_option *config_look_item_time_format; extern struct t_config_option *config_look_jump_current_to_previous_buffer; diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index aa2d0a1f3..10003758d 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -576,6 +576,12 @@ gui_window_switch_to_buffer (struct t_gui_window *window, window->buffer->lines->last_read_line = window->buffer->lines->last_line; } + if (CONFIG_BOOLEAN(config_look_input_share) + && (old_buffer != window->buffer)) + { + gui_input_move_to_buffer (old_buffer, window->buffer); + } + hook_signal_send ("buffer_switch", WEECHAT_HOOK_SIGNAL_POINTER, buffer); } @@ -608,6 +614,12 @@ gui_window_switch (struct t_gui_window *window) gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); + + if (CONFIG_BOOLEAN(config_look_input_share) + && (old_window->buffer != window->buffer)) + { + gui_input_move_to_buffer (old_window->buffer, window->buffer); + } } /* diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 8b4d68291..affaefad7 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -323,6 +323,23 @@ gui_buffer_insert (struct t_gui_buffer *buffer) } } +/* + * gui_buffer_input_buffer_init: initialize input_buffer_* variables + * in a buffer + */ + +void +gui_buffer_input_buffer_init (struct t_gui_buffer *buffer) +{ + buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE; + buffer->input_buffer = malloc (GUI_BUFFER_INPUT_BLOCK_SIZE); + buffer->input_buffer[0] = '\0'; + buffer->input_buffer_size = 0; + buffer->input_buffer_length = 0; + buffer->input_buffer_pos = 0; + buffer->input_buffer_1st_display = 0; +} + /* * gui_buffer_new: create a new buffer in current window */ @@ -405,13 +422,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, new_buffer->input_callback = input_callback; new_buffer->input_callback_data = input_callback_data; new_buffer->input_get_unknown_commands = 0; - new_buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE; - new_buffer->input_buffer = malloc (GUI_BUFFER_INPUT_BLOCK_SIZE); - new_buffer->input_buffer[0] = '\0'; - new_buffer->input_buffer_size = 0; - new_buffer->input_buffer_length = 0; - new_buffer->input_buffer_pos = 0; - new_buffer->input_buffer_1st_display = 0; + gui_buffer_input_buffer_init (new_buffer); /* undo for input */ (new_buffer->input_undo_snap).data = NULL; diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 20cd4e8f6..17be7ed1d 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -201,6 +201,7 @@ extern char *gui_buffer_properties_set[]; /* buffer functions */ extern void gui_buffer_notify_set_all (); +extern void gui_buffer_input_buffer_init (struct t_gui_buffer *buffer); extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin, const char *name, int (*input_callback)(void *data, diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index cea9c5f56..9e61d65ad 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -239,6 +239,46 @@ gui_input_insert_string (struct t_gui_buffer *buffer, const char *string, return 0; } +/* + * gui_input_move_to_buffer: move input content and undo data from + * a buffer to another buffer + */ + +void +gui_input_move_to_buffer (struct t_gui_buffer *from_buffer, + struct t_gui_buffer *to_buffer) +{ + /* only possible for two different buffers */ + if (!from_buffer || !to_buffer || (from_buffer == to_buffer)) + return; + + /* move input_buffer */ + if (to_buffer->input_buffer) + free (to_buffer->input_buffer); + to_buffer->input_buffer = from_buffer->input_buffer; + to_buffer->input_buffer_alloc = from_buffer->input_buffer_alloc; + to_buffer->input_buffer_size = from_buffer->input_buffer_size; + to_buffer->input_buffer_length = from_buffer->input_buffer_length; + to_buffer->input_buffer_pos = from_buffer->input_buffer_pos; + to_buffer->input_buffer_1st_display = from_buffer->input_buffer_1st_display; + gui_buffer_input_buffer_init (from_buffer); + + /* move undo data */ + gui_buffer_undo_free_all (to_buffer); + (to_buffer->input_undo_snap).data = (from_buffer->input_undo_snap).data; + (to_buffer->input_undo_snap).pos = (from_buffer->input_undo_snap).pos; + to_buffer->input_undo = from_buffer->input_undo; + to_buffer->last_input_undo = from_buffer->last_input_undo; + to_buffer->ptr_input_undo = from_buffer->ptr_input_undo; + to_buffer->input_undo_count = from_buffer->input_undo_count; + (from_buffer->input_undo_snap).data = NULL; + (from_buffer->input_undo_snap).pos = 0; + from_buffer->input_undo = NULL; + from_buffer->last_input_undo = NULL; + from_buffer->ptr_input_undo = NULL; + from_buffer->input_undo_count = 0; +} + /* * gui_input_clipboard_copy: copy string into clipboard */ diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index c5421b8e7..d6ba7d738 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -39,6 +39,8 @@ extern void gui_input_move (struct t_gui_buffer *buffer, char *target, extern void gui_input_set_pos (struct t_gui_buffer *buffer, int pos); extern int gui_input_insert_string (struct t_gui_buffer *buffer, const char *string, int pos); +extern void gui_input_move_to_buffer (struct t_gui_buffer *from_buffer, + struct t_gui_buffer *to_buffer); extern void gui_input_clipboard_paste (struct t_gui_window *window); extern void gui_input_return (struct t_gui_window *window); extern void gui_input_complete_next (struct t_gui_window *window);