1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-30 21:55:24 +00:00

Added /account autocomplete for startscript property

This commit is contained in:
James Booth 2015-11-08 22:31:53 +00:00
parent 60215cdf9d
commit 8230a28445

View File

@ -77,6 +77,8 @@ static gboolean _cmd_execute(ProfWin *window, const char *const command, const c
static char* _cmd_complete_parameters(ProfWin *window, const char *const input);
static char* _script_autocomplete_func(const char *const prefix);
static char* _sub_autocomplete(ProfWin *window, const char *const input);
static char* _notify_autocomplete(ProfWin *window, const char *const input);
static char* _theme_autocomplete(ProfWin *window, const char *const input);
@ -3246,39 +3248,37 @@ _theme_autocomplete(ProfWin *window, const char *const input)
return NULL;
}
static char*
_script_autocomplete_func(const char *const prefix)
{
if (script_show_ac == NULL) {
script_show_ac = autocomplete_new();
GSList *scripts = scripts_list();
GSList *curr = scripts;
while (curr) {
autocomplete_add(script_show_ac, curr->data);
curr = g_slist_next(curr);
}
g_slist_free_full(scripts, g_free);
}
return autocomplete_complete(script_show_ac, prefix, FALSE);
}
static char*
_script_autocomplete(ProfWin *window, const char *const input)
{
char *result = NULL;
if ((strncmp(input, "/script show ", 13) == 0) && (strlen(input) > 13)) {
if (script_show_ac == NULL) {
script_show_ac = autocomplete_new();
GSList *scripts = scripts_list();
GSList *curr = scripts;
while (curr) {
autocomplete_add(script_show_ac, curr->data);
curr = g_slist_next(curr);
}
g_slist_free_full(scripts, g_free);
}
result = autocomplete_param_with_ac(input, "/script show", script_show_ac, TRUE);
result = autocomplete_param_with_func(input, "/script show", _script_autocomplete_func);
if (result) {
return result;
}
}
if ((strncmp(input, "/script run ", 12) == 0) && (strlen(input) > 12)) {
if (script_show_ac == NULL) {
script_show_ac = autocomplete_new();
GSList *scripts = scripts_list();
GSList *curr = scripts;
while (curr) {
autocomplete_add(script_show_ac, curr->data);
curr = g_slist_next(curr);
}
g_slist_free_full(scripts, g_free);
}
result = autocomplete_param_with_ac(input, "/script run", script_show_ac, TRUE);
result = autocomplete_param_with_func(input, "/script run", _script_autocomplete_func);
if (result) {
return result;
}
@ -4019,6 +4019,15 @@ _account_autocomplete(ProfWin *window, const char *const input)
g_strfreev(args);
return found;
}
} else if ((g_strv_length(args) > 3) && (g_strcmp0(args[2], "startscript")) == 0) {
g_string_append(beginning, " ");
g_string_append(beginning, args[2]);
found = autocomplete_param_with_func(input, beginning->str, _script_autocomplete_func);
g_string_free(beginning, TRUE);
if (found) {
g_strfreev(args);
return found;
}
#ifdef HAVE_LIBGPGME
} else if ((g_strv_length(args) > 3) && (g_strcmp0(args[2], "pgpkeyid")) == 0) {
g_string_append(beginning, " ");