mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-23 13:46:22 +00:00
Merge pull request #1374 from profanity-im/revampUrlopen
Rework /url and /executable for filetypes
This commit is contained in:
@@ -124,7 +124,7 @@ static char* _avatar_autocomplete(ProfWin *window, const char *const input, gboo
|
||||
static char* _correction_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _correct_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _software_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _urlopen_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _url_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _executable_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
|
||||
static char* _script_autocomplete_func(const char *const prefix, gboolean previous, void *context);
|
||||
@@ -263,6 +263,7 @@ static Autocomplete logging_group_ac;
|
||||
static Autocomplete color_ac;
|
||||
static Autocomplete correction_ac;
|
||||
static Autocomplete avatar_ac;
|
||||
static Autocomplete url_ac;
|
||||
static Autocomplete executable_ac;
|
||||
|
||||
/*!
|
||||
@@ -1041,9 +1042,14 @@ cmd_ac_init(void)
|
||||
autocomplete_add(avatar_ac, "get");
|
||||
autocomplete_add(avatar_ac, "open");
|
||||
|
||||
url_ac = autocomplete_new();
|
||||
autocomplete_add(url_ac, "open");
|
||||
autocomplete_add(url_ac, "save");
|
||||
|
||||
executable_ac = autocomplete_new();
|
||||
autocomplete_add(executable_ac, "avatar");
|
||||
autocomplete_add(executable_ac, "urlopen");
|
||||
autocomplete_add(executable_ac, "urlsave");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1362,6 +1368,7 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(color_ac);
|
||||
autocomplete_reset(correction_ac);
|
||||
autocomplete_reset(avatar_ac);
|
||||
autocomplete_reset(url_ac);
|
||||
autocomplete_reset(executable_ac);
|
||||
|
||||
autocomplete_reset(script_ac);
|
||||
@@ -1523,6 +1530,7 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(color_ac);
|
||||
autocomplete_free(correction_ac);
|
||||
autocomplete_free(avatar_ac);
|
||||
autocomplete_free(url_ac);
|
||||
autocomplete_free(executable_ac);
|
||||
}
|
||||
|
||||
@@ -1784,7 +1792,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
|
||||
g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/software", _software_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/urlopen", _urlopen_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/url", _url_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete);
|
||||
|
||||
int len = strlen(input);
|
||||
@@ -4133,14 +4141,24 @@ _software_autocomplete(ProfWin *window, const char *const input, gboolean previo
|
||||
}
|
||||
|
||||
static char*
|
||||
_urlopen_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
_url_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/url", url_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (window->type == WIN_CHAT ||
|
||||
window->type == WIN_MUC ||
|
||||
window->type == WIN_PRIVATE) {
|
||||
result = autocomplete_param_with_func(input, "/urlopen", wins_get_url, previous, window);
|
||||
result = autocomplete_param_with_func(input, "/url open", wins_get_url, previous, window);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/url save", wins_get_url, previous, window);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user