mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 12:26:40 +02:00
script: add completion with languages and extensions, support search by language/extension in /script search
This commit is contained in:
@@ -366,7 +366,7 @@ script_command_init ()
|
||||
" /script reload urlserver\n"
|
||||
" /script upgrade"),
|
||||
"list -o|-i"
|
||||
" || search %(script_tags)"
|
||||
" || search %(script_tags)|%(script_languages)|%(script_extensions)"
|
||||
" || show %(script_scripts)"
|
||||
" || load %(script_files)|%*"
|
||||
" || unload %(python_script)|%(perl_script)|%(ruby_script)|"
|
||||
|
||||
@@ -29,6 +29,58 @@
|
||||
#include "script-repo.h"
|
||||
|
||||
|
||||
/*
|
||||
* Adds script languages (python, perl, ruby, ...) to completion list.
|
||||
*/
|
||||
|
||||
int
|
||||
script_completion_languages_cb (void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion,
|
||||
script_language[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds script extensions (py, pl, rb, ...) to completion list.
|
||||
*/
|
||||
|
||||
int
|
||||
script_completion_extensions_cb (void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion,
|
||||
script_extension[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds scripts to completion list.
|
||||
*/
|
||||
@@ -215,6 +267,12 @@ script_completion_tags_cb (void *data, const char *completion_item,
|
||||
void
|
||||
script_completion_init ()
|
||||
{
|
||||
weechat_hook_completion ("script_languages",
|
||||
N_("list of script languages"),
|
||||
&script_completion_languages_cb, NULL);
|
||||
weechat_hook_completion ("script_extensions",
|
||||
N_("list of script extensions"),
|
||||
&script_completion_extensions_cb, NULL);
|
||||
weechat_hook_completion ("script_scripts",
|
||||
N_("list of scripts in repository"),
|
||||
&script_completion_scripts_cb, NULL);
|
||||
|
||||
@@ -948,13 +948,33 @@ script_repo_match_filter (struct t_script_repo *script)
|
||||
if (!has_tag)
|
||||
{
|
||||
match = 0;
|
||||
|
||||
if (script->name_with_extension
|
||||
&& weechat_strcasestr (script->name_with_extension, words[i]))
|
||||
&& weechat_strcasestr (script->name_with_extension,
|
||||
words[i]))
|
||||
{
|
||||
match = 1;
|
||||
}
|
||||
|
||||
if (!match
|
||||
&& (weechat_strcasecmp (script_language[script->language],
|
||||
words[i]) == 0))
|
||||
{
|
||||
match = 1;
|
||||
}
|
||||
|
||||
if (!match
|
||||
&& (weechat_strcasecmp (script_extension[script->language],
|
||||
words[i]) == 0))
|
||||
{
|
||||
match = 1;
|
||||
}
|
||||
|
||||
if (!match && script->description
|
||||
&& weechat_strcasestr (script->description, words[i]))
|
||||
{
|
||||
match = 1;
|
||||
}
|
||||
|
||||
if (!match)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user