diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-09-27 16:07:27 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-09-27 16:07:27 +0200 |
commit | bd7ae6d5a79991d7f65bc12091b61bcdc4bc5b49 (patch) | |
tree | 6f64ab14e1cc42cf88a79a9f49390f7f67594477 /src | |
parent | 91343167cdd144c1373bfd2551ff76021691a02b (diff) | |
download | weechat-bd7ae6d5a79991d7f65bc12091b61bcdc4bc5b49.zip |
Add new option weechat.look.input_share (task #9228)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-config.c | 7 | ||||
-rw-r--r-- | src/core/wee-config.h | 1 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 12 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 25 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 1 | ||||
-rw-r--r-- | src/gui/gui-input.c | 40 | ||||
-rw-r--r-- | src/gui/gui-input.h | 2 |
7 files changed, 81 insertions, 7 deletions
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 @@ -324,6 +324,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 @@ -240,6 +240,46 @@ gui_input_insert_string (struct t_gui_buffer *buffer, const char *string, } /* + * 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); |