1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 00:03:12 +02:00

Add new option weechat.look.input_share (task #9228)

This commit is contained in:
Sebastien Helleu
2010-09-27 16:07:27 +02:00
parent 91343167cd
commit bd7ae6d5a7
21 changed files with 160 additions and 18 deletions
+7
View File
@@ -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",
+1
View File
@@ -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;
+12
View File
@@ -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);
}
}
/*
+18 -7
View File
@@ -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;
+1
View File
@@ -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,
+40
View File
@@ -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
*/
+2
View File
@@ -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);