diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/curses/gui-curses-keyboard.c | 1 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 107 | ||||
-rw-r--r-- | src/gui/gui-bar-item.h | 4 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 8 | ||||
-rw-r--r-- | src/gui/gui-input.c | 24 | ||||
-rw-r--r-- | src/gui/gui-input.h | 2 | ||||
-rw-r--r-- | src/gui/gui-keyboard.c | 2 |
7 files changed, 143 insertions, 5 deletions
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; @@ -618,6 +620,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 */ @@ -658,6 +699,50 @@ gui_bar_item_default_input_prompt (void *data, struct t_gui_bar_item *item, } /* + * 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 @@ -48,6 +48,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" */ @@ -78,6 +88,16 @@ gui_input_text_cursor_moved_signal () } /* + * 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 (); } /* |