summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/perl
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-06-18 16:47:09 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-06-18 16:47:09 +0200
commit66e8d703bd12c3c5da29c091d14485e260f6ab31 (patch)
tree0b2fa44b1da0c0d5c105c3426c0900ef3d2a4363 /src/plugins/scripts/perl
parent47c9c68b40dfaaf0f61f0d3ee1d37db1934f241a (diff)
downloadweechat-66e8d703bd12c3c5da29c091d14485e260f6ab31.zip
Add new options for completion, optional stop instead of cycling with words found
Diffstat (limited to 'src/plugins/scripts/perl')
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c45
-rw-r--r--src/plugins/scripts/perl/weechat-perl.c8
2 files changed, 45 insertions, 8 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 586f0fbbd..0ae18e0c7 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -2398,9 +2398,9 @@ static XS (XS_weechat_hook_config)
*/
int
-weechat_perl_api_hook_completion_cb (void *data, const char *completion,
+weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
- struct t_weelist *list)
+ struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *perl_argv[4];
@@ -2408,9 +2408,9 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion,
script_callback = (struct t_script_callback *)data;
- perl_argv[0] = (char *)completion;
+ perl_argv[0] = (char *)completion_item;
perl_argv[1] = script_ptr2str (buffer);
- perl_argv[2] = script_ptr2str (list);
+ perl_argv[2] = script_ptr2str (completion);
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
@@ -2469,6 +2469,42 @@ static XS (XS_weechat_hook_completion)
}
/*
+ * weechat::hook_completion_list_add: add a word to list for a completion
+ */
+
+static XS (XS_weechat_hook_completion_list_add)
+{
+ char *completion, *word, *where;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add");
+ PERL_RETURN_ERROR;
+ }
+
+ if (items < 4)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add");
+ PERL_RETURN_ERROR;
+ }
+
+ completion = SvPV (ST (0), PL_na);
+ word = SvPV (ST (1), PL_na);
+ where = SvPV (ST (3), PL_na);
+
+ weechat_hook_completion_list_add (script_str2ptr (completion),
+ word,
+ SvIV (ST (2)), /* nick_completion */
+ where);
+
+ PERL_RETURN_OK;
+}
+
+/*
* weechat_perl_api_hook_modifier_cb: callback for modifier hooked
*/
@@ -3922,6 +3958,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::hook_signal_send", XS_weechat_hook_signal_send, "weechat");
newXS ("weechat::hook_config", XS_weechat_hook_config, "weechat");
newXS ("weechat::hook_completion", XS_weechat_hook_completion, "weechat");
+ newXS ("weechat::hook_completion_list_add", XS_weechat_hook_completion_list_add, "weechat");
newXS ("weechat::hook_modifier", XS_weechat_hook_modifier, "weechat");
newXS ("weechat::hook_modifier_exec", XS_weechat_hook_modifier_exec, "weechat");
newXS ("weechat::unhook", XS_weechat_unhook, "weechat");
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c
index f76cf337e..6f426cd70 100644
--- a/src/plugins/scripts/perl/weechat-perl.c
+++ b/src/plugins/scripts/perl/weechat-perl.c
@@ -554,16 +554,16 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
-weechat_perl_completion_cb (void *data, const char *completion,
+weechat_perl_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
- struct t_weelist *list)
+ struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) data;
- (void) completion;
+ (void) completion_item;
(void) buffer;
- script_completion (weechat_perl_plugin, list, perl_scripts);
+ script_completion (weechat_perl_plugin, completion, perl_scripts);
return WEECHAT_RC_OK;
}