diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core-command.c | 106 | ||||
-rw-r--r-- | src/core/core-input.c | 23 | ||||
-rw-r--r-- | src/core/core-input.h | 3 | ||||
-rw-r--r-- | src/core/core-signal.c | 2 | ||||
-rw-r--r-- | src/core/core-upgrade.c | 2 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 36 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 1 | ||||
-rw-r--r-- | src/gui/gui-input.c | 2 | ||||
-rw-r--r-- | src/gui/gui-key.c | 4 |
9 files changed, 148 insertions, 31 deletions
diff --git a/src/core/core-command.c b/src/core/core-command.c index f17abd01f..bfd38b1a9 100644 --- a/src/core/core-command.c +++ b/src/core/core-command.c @@ -131,7 +131,13 @@ COMMAND_CALLBACK(allbuf) { ptr_buffer = (struct t_gui_buffer *)arraylist_get (all_buffers, i); if (gui_buffer_valid (ptr_buffer)) - (void) input_data (ptr_buffer, argv_eol[1], NULL, 0); + { + (void) input_data (ptr_buffer, + argv_eol[1], + NULL, + 0, /* split_newline */ + 0); /* user_data */ + } } arraylist_free (all_buffers); @@ -1642,7 +1648,11 @@ COMMAND_CALLBACK(color) if (string_strcmp (argv[1], "-o") == 0) { gui_color_info_term_colors (str_color, sizeof (str_color)); - (void) input_data (buffer, str_color, NULL, 0); + (void) input_data (buffer, + str_color, + NULL, + 0, /* split_newline */ + 0); /* user_data */ return WEECHAT_RC_OK; } @@ -1837,7 +1847,11 @@ COMMAND_CALLBACK(command) { for (i = 0; commands[i]; i++) { - (void) input_data (buffer, commands[i], NULL, 0); + (void) input_data (buffer, + commands[i], + NULL, + 0, /* split_newline */ + 0); /* user_data */ } string_free_split_command (commands); } @@ -2221,7 +2235,11 @@ COMMAND_CALLBACK(debug) { COMMAND_MIN_ARGS(3, "time"); gettimeofday (&time_start, NULL); - (void) input_data (buffer, argv_eol[2], NULL, 0); + (void) input_data (buffer, + argv_eol[2], + NULL, + 0, /* split_newline */ + 0); /* user_data */ gettimeofday (&time_end, NULL); debug_display_time_elapsed (&time_start, &time_end, argv_eol[2], 1); return WEECHAT_RC_OK; @@ -2418,7 +2436,11 @@ COMMAND_CALLBACK(eval) options); if (result) { - (void) input_data (buffer, result, NULL, 0); + (void) input_data (buffer, + result, + NULL, + 0, /* split_newline */ + 0); /* user_data */ free (result); } else @@ -2441,7 +2463,11 @@ COMMAND_CALLBACK(eval) result = eval_expression (ptr_args, pointers, NULL, options); if (result) { - (void) input_data (buffer, result, NULL, 0); + (void) input_data (buffer, + result, + NULL, + 0, /* split_newline */ + 0); /* user_data */ free (result); } else @@ -3638,7 +3664,13 @@ COMMAND_CALLBACK(input) gui_input_insert (buffer, argv_eol[2]); } else if (string_strcmp (argv[1], "send") == 0) - (void) input_data (buffer, argv_eol[2], NULL, 0); + { + (void) input_data (buffer, + argv_eol[2], + NULL, + 0, /* split_newline */ + 0); /* user_data */ + } else if (string_strcmp (argv[1], "undo") == 0) gui_input_undo (buffer); else if (string_strcmp (argv[1], "redo") == 0) @@ -3679,10 +3711,22 @@ COMMAND_CALLBACK(input) gui_hotlist_restore_all_buffers (); /* since WeeChat 3.8: "/buffer set unread" */ else if (string_strcmp (argv[1], "set_unread_current_buffer") == 0) - (void) input_data (buffer, "/buffer set unread", NULL, 0); + { + (void) input_data (buffer, + "/buffer set unread", + NULL, + 0, /* split_newline */ + 0); /* user_data */ + } /* since WeeChat 3.8: "/allbuf /buffer set unread" */ else if (string_strcmp (argv[1], "set_unread") == 0) - (void) input_data (buffer, "/allbuf /buffer set unread", NULL, 0); + { + (void) input_data (buffer, + "/allbuf /buffer set unread", + NULL, + 0, /* split_newline */ + 0); /* user_data */ + } /* since WeeChat 3.8: "/buffer switch" */ else if (string_strcmp (argv[1], "switch_active_buffer") == 0) gui_buffer_switch_active_buffer (buffer); @@ -5019,7 +5063,11 @@ command_plugin_list_input (struct t_gui_buffer *buffer, if (send_to_buffer) { - (void) input_data (buffer, *buf, NULL, 0); + (void) input_data (buffer, + *buf, + NULL, + 0, /* split_newline */ + 0); /* user_data */ } else { @@ -5775,7 +5823,8 @@ command_repeat_exec (struct t_command_repeat *command_repeat) (void) input_data (ptr_buffer, cmd_eval, command_repeat->commands_allowed, - 0); /* split_newline */ + 0, /* split_newline */ + 0); /* user_data */ free (cmd_eval); } @@ -7078,7 +7127,11 @@ command_upgrade_display (struct t_gui_buffer *buffer, } } - (void) input_data (buffer, string, NULL, 0); + (void) input_data (buffer, + string, + NULL, + 0, /* split_newline */ + 0); /* user_data */ } /* @@ -7327,7 +7380,11 @@ COMMAND_CALLBACK(uptime) minutes, seconds, str_first_start); - (void) input_data (buffer, string, NULL, 0); + (void) input_data (buffer, + string, + NULL, + 0, /* split_newline */ + 0); /* user_data */ } else if ((argc >= 2) && (string_strcmp (argv[1], "-ol") == 0)) { @@ -7340,7 +7397,11 @@ COMMAND_CALLBACK(uptime) minutes, seconds, util_get_time_string (&weechat_first_start_time)); - (void) input_data (buffer, string, NULL, 0); + (void) input_data (buffer, + string, + NULL, + 0, /* split_newline */ + 0); /* user_data */ } else { @@ -7391,7 +7452,11 @@ command_version_display (struct t_gui_buffer *buffer, _("compiled on"), version_get_compilation_date (), version_get_compilation_time ()); - (void) input_data (buffer, string, NULL, 0); + (void) input_data (buffer, + string, + NULL, + 0, /* split_newline */ + 0); /* user_data */ } else { @@ -7401,7 +7466,11 @@ command_version_display (struct t_gui_buffer *buffer, "compiled on", version_get_compilation_date (), version_get_compilation_time ()); - (void) input_data (buffer, string, NULL, 0); + (void) input_data (buffer, + string, + NULL, + 0, /* split_newline */ + 0); /* user_data */ } } else @@ -9605,7 +9674,10 @@ command_exec_list (const char *command_list) if (command_eval) { (void) input_data (gui_buffer_search_main (), - command_eval, NULL, 0); + command_eval, + NULL, + 0, /* split_newline */ + 0); /* user_data */ free (command_eval); } } diff --git a/src/core/core-input.c b/src/core/core-input.c index d09f0aad8..8781a049c 100644 --- a/src/core/core-input.c +++ b/src/core/core-input.c @@ -246,7 +246,7 @@ end: int input_data (struct t_gui_buffer *buffer, const char *data, - const char *commands_allowed, int split_newline) + const char *commands_allowed, int split_newline, int user_data) { char *pos, *buf, str_buffer[128], *new_data, *buffer_full_name; const char *ptr_data, *ptr_data_for_buffer; @@ -331,8 +331,20 @@ input_data (struct t_gui_buffer *buffer, const char *data, else { /* input string is a command */ - rc = input_exec_command (buffer, 1, buffer->plugin, ptr_data, - commands_allowed); + if (user_data && buffer->input_get_any_user_data) + { + /* + * if data is sent from user and buffer catches any user data: + * send it to callback + */ + input_exec_data (buffer, ptr_data); + } + else + { + /* execute command on buffer */ + rc = input_exec_command (buffer, 1, buffer->plugin, ptr_data, + commands_allowed); + } } if (pos) @@ -384,7 +396,8 @@ input_data_timer_cb (const void *pointer, void *data, int remaining_calls) ptr_buffer, timer_args[1], timer_args[2], - (string_strcmp (timer_args[3], "1") == 0) ? 1 : 0); + (string_strcmp (timer_args[3], "1") == 0) ? 1 : 0, + 0); /* user_data */ } } @@ -417,7 +430,7 @@ input_data_delayed (struct t_gui_buffer *buffer, const char *data, char **timer_args, *new_commands_allowed; if (delay < 1) - return input_data (buffer, data, commands_allowed, split_newline); + return input_data (buffer, data, commands_allowed, split_newline, 0); timer_args = malloc (4 * sizeof (*timer_args)); if (!timer_args) diff --git a/src/core/core-input.h b/src/core/core-input.h index 57ab5d10e..3302983c2 100644 --- a/src/core/core-input.h +++ b/src/core/core-input.h @@ -31,7 +31,8 @@ extern int input_exec_command (struct t_gui_buffer *buffer, const char *string, const char *commands_allowed); extern int input_data (struct t_gui_buffer *buffer, const char *data, - const char *commands_allowed, int split_newline); + const char *commands_allowed, int split_newline, + int user_data); extern int input_data_delayed (struct t_gui_buffer *buffer, const char *data, const char *commands_allowed, int split_newline, long delay); diff --git a/src/core/core-signal.c b/src/core/core-signal.c index 3f28fe8e8..dbc48d926 100644 --- a/src/core/core-signal.c +++ b/src/core/core-signal.c @@ -228,7 +228,7 @@ signal_exec_command (int signal_index, const char *command) if (signal_upper) free (signal_upper); (void) input_data (gui_buffer_search_main (), - command_eval, NULL, 0); + command_eval, NULL, 0, 0); free (command_eval); } } diff --git a/src/core/core-upgrade.c b/src/core/core-upgrade.c index bca288aea..b5c6f2ca7 100644 --- a/src/core/core-upgrade.c +++ b/src/core/core-upgrade.c @@ -540,6 +540,8 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist) /* input */ ptr_buffer->input = infolist_integer (infolist, "input"); + ptr_buffer->input_get_any_user_data = + infolist_integer (infolist, "input_get_any_user_data"); ptr_buffer->input_get_unknown_commands = infolist_integer (infolist, "input_get_unknown_commands"); ptr_buffer->input_get_empty = diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index a5d60d1e6..8941affea 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -101,7 +101,7 @@ char *gui_buffer_properties_get_integer[] = "nicklist_display_groups", "nicklist_count", "nicklist_visible_count", "nicklist_groups_count", "nicklist_groups_visible_count", "nicklist_nicks_count", "nicklist_nicks_visible_count", - "input", "input_get_unknown_commands", + "input", "input_get_any_user_data", "input_get_unknown_commands", "input_get_empty", "input_multiline", "input_size", "input_length", "input_pos", "input_1st_display", "num_history", "text_search", "text_search_direction", "text_search_exact", "text_search_regex", @@ -128,8 +128,8 @@ char *gui_buffer_properties_set[] = "highlight_words_del", "highlight_disable_regex", "highlight_regex", "highlight_tags_restrict", "highlight_tags", "hotlist_max_level_nicks", "hotlist_max_level_nicks_add", "hotlist_max_level_nicks_del", - "input", "input_pos", "input_get_unknown_commands", "input_get_empty", - "input_multiline", + "input", "input_pos", "input_get_any_user_data", "input_get_unknown_commands", + "input_get_empty", "input_multiline", NULL }; @@ -898,6 +898,7 @@ gui_buffer_new_props_with_id (long long id, new_buffer->input_callback = input_callback; new_buffer->input_callback_pointer = input_callback_pointer; new_buffer->input_callback_data = input_callback_data; + new_buffer->input_get_any_user_data = 0; new_buffer->input_get_unknown_commands = 0; new_buffer->input_get_empty = 0; new_buffer->input_multiline = 0; @@ -1470,6 +1471,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property) return buffer->nicklist_nicks_visible_count; else if (strcmp (property, "input") == 0) return buffer->input; + else if (strcmp (property, "input_get_any_user_data") == 0) + return buffer->input_get_any_user_data; else if (strcmp (property, "input_get_unknown_commands") == 0) return buffer->input_get_unknown_commands; else if (strcmp (property, "input_get_empty") == 0) @@ -2247,6 +2250,20 @@ gui_buffer_remove_hotlist_max_level_nicks (struct t_gui_buffer *buffer, } /* + * Sets flag "input_get_any_user_data" for a buffer. + */ + +void +gui_buffer_set_input_get_any_user_data (struct t_gui_buffer *buffer, + int input_get_any_user_data) +{ + if (!buffer) + return; + + buffer->input_get_any_user_data = (input_get_any_user_data) ? 1 : 0; +} + +/* * Sets flag "input_get_unknown_commands" for a buffer. */ @@ -2258,8 +2275,8 @@ gui_buffer_set_input_get_unknown_commands (struct t_gui_buffer *buffer, return; buffer->input_get_unknown_commands = (input_get_unknown_commands) ? 1 : 0; -} +} /* * Sets flag "input_get_empty" for a buffer. */ @@ -2676,6 +2693,13 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property, if (error && !error[0]) gui_input_set_pos (buffer, number); } + else if (strcmp (property, "input_get_any_user_data") == 0) + { + error = NULL; + number = strtol (value, &error, 10); + if (error && !error[0]) + gui_buffer_set_input_get_any_user_data (buffer, number); + } else if (strcmp (property, "input_get_unknown_commands") == 0) { error = NULL; @@ -5171,6 +5195,7 @@ gui_buffer_hdata_buffer_cb (const void *pointer, void *data, HDATA_VAR(struct t_gui_buffer, input_callback, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, input_callback_pointer, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, input_callback_data, POINTER, 0, NULL, NULL); + HDATA_VAR(struct t_gui_buffer, input_get_any_user_data, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, input_get_unknown_commands, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, input_get_empty, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, input_multiline, INTEGER, 0, NULL, NULL); @@ -5386,6 +5411,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist, return 0; if (!infolist_new_var_integer (ptr_item, "input", buffer->input)) return 0; + if (!infolist_new_var_integer (ptr_item, "input_get_any_user_data", buffer->input_get_any_user_data)) + return 0; if (!infolist_new_var_integer (ptr_item, "input_get_unknown_commands", buffer->input_get_unknown_commands)) return 0; if (!infolist_new_var_integer (ptr_item, "input_get_empty", buffer->input_get_empty)) @@ -5623,6 +5650,7 @@ gui_buffer_print_log () log_printf (" input_callback. . . . . : %p", ptr_buffer->input_callback); log_printf (" input_callback_pointer. : %p", ptr_buffer->input_callback_pointer); log_printf (" input_callback_data . . : %p", ptr_buffer->input_callback_data); + log_printf (" input_get_any_user_data : %d", ptr_buffer->input_get_any_user_data); log_printf (" input_get_unknown_cmd . : %d", ptr_buffer->input_get_unknown_commands); log_printf (" input_get_empty . . . . : %d", ptr_buffer->input_get_empty); log_printf (" input_multiline . . . . : %d", ptr_buffer->input_multiline); diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 643f5ec85..f3de457b6 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -186,6 +186,7 @@ struct t_gui_buffer const void *input_callback_pointer; /* pointer for callback */ void *input_callback_data; /* data for callback */ /* to this buffer */ + int input_get_any_user_data; /* get any user data, including cmds */ int input_get_unknown_commands; /* 1 if unknown commands are sent to */ /* input_callback */ int input_get_empty; /* 1 if empty input is sent to */ diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 72c9cd937..6a6607c0d 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -333,7 +333,7 @@ gui_input_send_data_to_buffer (struct t_gui_buffer *buffer, char *data) gui_input_text_changed_modifier_and_signal (buffer, 0, /* save undo */ 1); /* stop completion */ - (void) input_data (buffer, data, NULL, 1); + (void) input_data (buffer, data, NULL, 1, 1); } /* diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 6340566ee..d1a450cb9 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -2161,7 +2161,7 @@ gui_key_focus_command (const char *key, int context, command, ptr_buffer->full_name); } - (void) input_data (ptr_buffer, command, NULL, 0); + (void) input_data (ptr_buffer, command, NULL, 0, 0); free (command); } } @@ -2537,7 +2537,7 @@ gui_key_pressed (const char *key_str) for (i = 0; commands[i]; i++) { (void) input_data (gui_current_window->buffer, - commands[i], NULL, 0); + commands[i], NULL, 0, 0); } string_free_split (commands); } |