diff options
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | src/plugins/script/script-action.c | 72 | ||||
-rw-r--r-- | src/plugins/script/script-action.h | 7 | ||||
-rw-r--r-- | src/plugins/script/script-command.c | 16 |
4 files changed, 58 insertions, 38 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 41c7f6ba3..b2a33ffcc 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -29,6 +29,7 @@ Bug fixes:: * core: fix cursor position after `/plugin list -i` or `/plugin list -il` * irc: fix display of country code in message 344 received as whois geo info (issue #1736) * script: fix cursor position after `/script list -i` or `/script list -il` + * script: fix buffer used by command `/script list -i|-il|-o|-ol` Tests:: diff --git a/src/plugins/script/script-action.c b/src/plugins/script/script-action.c index 36220be91..0249823d3 100644 --- a/src/plugins/script/script-action.c +++ b/src/plugins/script/script-action.c @@ -100,15 +100,19 @@ script_action_run_list () */ void -script_action_run_list_input (int send_to_buffer, int translated) +script_action_run_list_input (struct t_gui_buffer *buffer, + int send_to_buffer, int translated) { int i, length; - char hdata_name[128], **buf, str_pos[16]; + char hdata_name[128], **output, str_pos[16]; struct t_hdata *hdata; void *ptr_script; - buf = weechat_string_dyn_alloc (256); - if (!buf) + if (!buffer) + return; + + output = weechat_string_dyn_alloc (256); + if (!output) return; for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++) @@ -119,27 +123,27 @@ script_action_run_list_input (int send_to_buffer, int translated) ptr_script = weechat_hdata_get_list (hdata, "scripts"); while (ptr_script) { - if (*buf[0]) + if (*output[0]) { - weechat_string_dyn_concat (buf, ", ", -1); + weechat_string_dyn_concat (output, ", ", -1); } else { weechat_string_dyn_concat ( - buf, + output, (translated) ? _("Scripts loaded:") : "Scripts loaded:", -1); - weechat_string_dyn_concat (buf, " ", -1); + weechat_string_dyn_concat (output, " ", -1); } - weechat_string_dyn_concat (buf, + weechat_string_dyn_concat (output, weechat_hdata_string (hdata, ptr_script, "name"), -1); - weechat_string_dyn_concat (buf, ".", -1); - weechat_string_dyn_concat (buf, script_extension[i], -1); - weechat_string_dyn_concat (buf, " ", -1); - weechat_string_dyn_concat (buf, + weechat_string_dyn_concat (output, ".", -1); + weechat_string_dyn_concat (output, script_extension[i], -1); + weechat_string_dyn_concat (output, " ", -1); + weechat_string_dyn_concat (output, weechat_hdata_string (hdata, ptr_script, "version"), @@ -148,27 +152,27 @@ script_action_run_list_input (int send_to_buffer, int translated) } } - if (!*buf[0]) + if (!*output[0]) { weechat_string_dyn_concat ( - buf, + output, (translated) ? _("No scripts loaded") : "No scripts loaded", -1); } if (send_to_buffer) { - weechat_command (weechat_current_buffer (), *buf); + weechat_command (buffer, *output); } else { - weechat_buffer_set (weechat_current_buffer (), "input", *buf); - length = weechat_utf8_strlen (*buf); + weechat_buffer_set (buffer, "input", *output); + length = weechat_utf8_strlen (*output); snprintf (str_pos, sizeof (str_pos), "%d", length); - weechat_buffer_set (weechat_current_buffer (), "input_pos", str_pos); + weechat_buffer_set (buffer, "input_pos", str_pos); } - weechat_string_dyn_free (buf, 1); + weechat_string_dyn_free (output, 1); } /* @@ -1200,7 +1204,7 @@ script_action_run_showdiff () */ void -script_action_add (const char *action) +script_action_add (struct t_gui_buffer *buffer, const char *action) { if (!action) return; @@ -1215,6 +1219,9 @@ script_action_add (const char *action) if (*script_actions[0]) weechat_string_dyn_concat (script_actions, "\n", -1); + weechat_string_dyn_concat ( + script_actions, weechat_buffer_get_string (buffer, "full_name"), -1); + weechat_string_dyn_concat (script_actions, "\r", -1); weechat_string_dyn_concat (script_actions, action, -1); } @@ -1243,6 +1250,7 @@ script_action_run_all () char **actions, **argv, **argv_eol, *ptr_action; int num_actions, argc, i, j, quiet, script_found; struct t_script_repo *ptr_script; + struct t_gui_buffer *ptr_buffer; if (!script_actions || !script_actions[0]) return 0; @@ -1259,7 +1267,14 @@ script_action_run_all () for (i = 0; i < num_actions; i++) { quiet = 0; - ptr_action = actions[i]; + ptr_action = strchr (actions[i], '\r'); + if (!ptr_action) + continue; + ptr_action[0] = '\0'; + ptr_action++; + ptr_buffer = weechat_buffer_search ("==", actions[i]); + if (!ptr_buffer) + ptr_buffer = weechat_current_buffer (); if (ptr_action[0] == '-') { /* @@ -1318,13 +1333,13 @@ script_action_run_all () if (argc > 1) { if (weechat_strcmp (argv[1], "-i") == 0) - script_action_run_list_input (0, 0); + script_action_run_list_input (ptr_buffer, 0, 0); else if (weechat_strcmp (argv[1], "-il") == 0) - script_action_run_list_input (0, 1); + script_action_run_list_input (ptr_buffer, 0, 1); else if (weechat_strcmp (argv[1], "-o") == 0) - script_action_run_list_input (1, 0); + script_action_run_list_input (ptr_buffer, 1, 0); else if (weechat_strcmp (argv[1], "-ol") == 0) - script_action_run_list_input (1, 1); + script_action_run_list_input (ptr_buffer, 1, 1); else script_action_run_list (); } @@ -1527,7 +1542,8 @@ script_action_run_all () */ void -script_action_schedule (const char *action, +script_action_schedule (struct t_gui_buffer *buffer, + const char *action, int need_repository, int error_repository, int quiet) { @@ -1535,7 +1551,7 @@ script_action_schedule (const char *action, if (!weechat_mkdir_home ("${weechat_cache_dir}/" SCRIPT_PLUGIN_NAME, 0755)) return; - script_action_add (action); + script_action_add (buffer, action); if (need_repository) { diff --git a/src/plugins/script/script-action.h b/src/plugins/script/script-action.h index 7ef091421..96afc288b 100644 --- a/src/plugins/script/script-action.h +++ b/src/plugins/script/script-action.h @@ -23,8 +23,11 @@ extern char **script_actions; extern int script_action_run_all (); -extern void script_action_schedule (const char *action, int need_repository, - int error_repository, int quiet); +extern void script_action_schedule (struct t_gui_buffer *buffer, + const char *action, + int need_repository, + int error_repository, + int quiet); extern void script_action_end (); #endif /* WEECHAT_PLUGIN_SCRIPT_ACTION_H */ diff --git a/src/plugins/script/script-command.c b/src/plugins/script/script-command.c index 98aad22f4..7dca16dfb 100644 --- a/src/plugins/script/script-command.c +++ b/src/plugins/script/script-command.c @@ -72,7 +72,7 @@ script_command_action (struct t_gui_buffer *buffer, (quiet) ? "-q " : "", action, ptr_script->name_with_extension); - script_action_schedule (str_action, need_repository, + script_action_schedule (buffer, str_action, need_repository, error_repository, quiet); } } @@ -83,7 +83,7 @@ script_command_action (struct t_gui_buffer *buffer, (quiet) ? "-q " : "", action, arguments); - script_action_schedule (str_action, need_repository, + script_action_schedule (buffer, str_action, need_repository, error_repository, quiet); } } @@ -98,7 +98,7 @@ script_command_action (struct t_gui_buffer *buffer, snprintf (str_action, sizeof (str_action), "-q %s", action); - script_action_schedule (str_action, need_repository, + script_action_schedule (buffer, str_action, need_repository, error_repository, 1); } else @@ -113,7 +113,7 @@ script_command_action (struct t_gui_buffer *buffer, "-q %s %s", action, ptr_script->name_with_extension); - script_action_schedule (str_action, need_repository, + script_action_schedule (buffer, str_action, need_repository, error_repository, 1); } } @@ -140,7 +140,7 @@ script_command_script (const void *pointer, void *data, if (argc == 1) { - script_action_schedule ("buffer", 1, 1, 0); + script_action_schedule (buffer, "buffer", 1, 1, 0); return WEECHAT_RC_OK; } @@ -164,13 +164,13 @@ script_command_script (const void *pointer, void *data, script_repo_filter_scripts ((argc > 2) ? argv_eol[2] : NULL); else script_repo_set_filter ((argc > 2) ? argv_eol[2] : NULL); - script_action_schedule ("buffer", 1, 1, 0); + script_action_schedule (buffer, "buffer", 1, 1, 0); return WEECHAT_RC_OK; } if (weechat_strcmp (argv[1], "list") == 0) { - script_action_schedule (argv_eol[1], 1, 0, 0); + script_action_schedule (buffer, argv_eol[1], 1, 0, 0); return WEECHAT_RC_OK; } @@ -206,7 +206,7 @@ script_command_script (const void *pointer, void *data, if (weechat_strcmp (argv[1], "upgrade") == 0) { - script_action_schedule ("upgrade", 1, 1, 0); + script_action_schedule (buffer, "upgrade", 1, 1, 0); return WEECHAT_RC_OK; } |