diff options
author | James Booth <boothj5@gmail.com> | 2013-12-10 22:11:48 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-12-10 22:11:48 +0000 |
commit | 2fe258ad1bba79606289e49d3a16983d2a32db2e (patch) | |
tree | 42a13086299d701bfc5da1986782bfc843f6ff1e /src/command | |
parent | e27061b131d9ec9e37690e4759d7264d0393a547 (diff) | |
download | profani-tty-2fe258ad1bba79606289e49d3a16983d2a32db2e.tar.gz |
Implemented autocomplete for /account command <setting> parameter
fixes #260
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c index 43acbd09..a213d141 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -895,6 +895,8 @@ static Autocomplete titlebar_ac; static Autocomplete theme_ac; static Autocomplete theme_load_ac; static Autocomplete account_ac; +static Autocomplete account_set_ac; +static Autocomplete account_clear_ac; static Autocomplete disco_ac; static Autocomplete close_ac; static Autocomplete wins_ac; @@ -1000,6 +1002,23 @@ cmd_init(void) autocomplete_add(account_ac, "set"); autocomplete_add(account_ac, "clear"); + account_set_ac = autocomplete_new(); + autocomplete_add(account_set_ac, "jid"); + autocomplete_add(account_set_ac, "server"); + autocomplete_add(account_set_ac, "status"); + autocomplete_add(account_set_ac, "online"); + autocomplete_add(account_set_ac, "chat"); + autocomplete_add(account_set_ac, "away"); + autocomplete_add(account_set_ac, "xa"); + autocomplete_add(account_set_ac, "dnd"); + autocomplete_add(account_set_ac, "resource"); + autocomplete_add(account_set_ac, "password"); + autocomplete_add(account_set_ac, "muc"); + autocomplete_add(account_set_ac, "nick"); + + account_clear_ac = autocomplete_new(); + autocomplete_add(account_clear_ac, "password"); + close_ac = autocomplete_new(); autocomplete_add(close_ac, "read"); autocomplete_add(close_ac, "all"); @@ -1058,6 +1077,8 @@ cmd_close(void) autocomplete_free(theme_load_ac); } autocomplete_free(account_ac); + autocomplete_free(account_set_ac); + autocomplete_free(account_clear_ac); autocomplete_free(disco_ac); autocomplete_free(close_ac); autocomplete_free(wins_ac); @@ -1129,6 +1150,8 @@ cmd_reset_autocomplete() theme_load_ac = NULL; } autocomplete_reset(account_ac); + autocomplete_reset(account_set_ac); + autocomplete_reset(account_clear_ac); autocomplete_reset(disco_ac); autocomplete_reset(close_ac); autocomplete_reset(wins_ac); @@ -3908,6 +3931,32 @@ static char * _account_autocomplete(char *input, int *size) { char *result = NULL; + + input[*size] = '\0'; + gchar **args = parse_args(input, 3, 3); + + if ((strncmp(input, "/account set", 12) == 0) && (args != NULL)) { + GString *beginning = g_string_new("/account set "); + g_string_append(beginning, args[1]); + result = autocomplete_param_with_ac(input, size, beginning->str, account_set_ac); + g_string_free(beginning, TRUE); + if (result != NULL) { + return result; + } + } + + if ((strncmp(input, "/account clear", 14) == 0) && (args != NULL)) { + GString *beginning = g_string_new("/account clear "); + g_string_append(beginning, args[1]); + result = autocomplete_param_with_ac(input, size, beginning->str, account_clear_ac); + g_string_free(beginning, TRUE); + if (result != NULL) { + return result; + } + } + + g_strfreev(args); + int i = 0; gchar *account_choice[] = { "/account set", "/account show", "/account enable", "/account disable", "/account rename", "/account clear" }; |