From 7aa177c6687d78b3bc3f1fe1b951145cb2a07635 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 28 Oct 2012 01:47:57 +0100 Subject: Added /who autocomplete --- src/command.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/command.c b/src/command.c index c68ce06b..0fd093bb 100644 --- a/src/command.c +++ b/src/command.c @@ -63,6 +63,8 @@ static gboolean _cmd_set_boolean_preference(const char * const inp, static char *_cmd_complete(char *inp); static void _cmd_reset_command_completer(void); +static char *_cmd_who_complete(char *inp); +static void _cmd_reset_who_completer(void); static char *_cmd_help_complete(char *inp); static void _cmd_help_reset_completer(void); static char *_cmd_notify_complete(char *inp); @@ -394,6 +396,7 @@ static struct cmd_t status_commands[] = }; static PAutocomplete commands_ac; +static PAutocomplete who_ac; static PAutocomplete help_ac; static PAutocomplete notify_ac; @@ -404,12 +407,16 @@ void cmd_init(void) { log_info("Initialising commands"); + commands_ac = p_autocomplete_new(); + who_ac = p_autocomplete_new(); + help_ac = p_autocomplete_new(); p_autocomplete_add(help_ac, strdup("basic")); p_autocomplete_add(help_ac, strdup("status")); p_autocomplete_add(help_ac, strdup("settings")); p_autocomplete_add(help_ac, strdup("navigation")); + notify_ac = p_autocomplete_new(); p_autocomplete_add(notify_ac, strdup("message")); p_autocomplete_add(notify_ac, strdup("typing")); @@ -432,6 +439,7 @@ cmd_init(void) struct cmd_t *pcmd = status_commands+i; p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); + p_autocomplete_add(who_ac, (gchar *)strdup(pcmd->cmd+1)); } history_init(); @@ -441,6 +449,7 @@ void cmd_close(void) { p_autocomplete_clear(commands_ac); + p_autocomplete_clear(who_ac); p_autocomplete_clear(help_ac); p_autocomplete_clear(notify_ac); } @@ -481,6 +490,7 @@ cmd_reset_autocomplete() _cmd_help_reset_completer(); _cmd_notify_reset_completer(); _cmd_reset_command_completer(); + _cmd_reset_who_completer(); } GSList * @@ -569,6 +579,18 @@ _cmd_reset_command_completer(void) p_autocomplete_reset(commands_ac); } +static char * +_cmd_who_complete(char *inp) +{ + return p_autocomplete_complete(who_ac, inp); +} + +static void +_cmd_reset_who_completer(void) +{ + p_autocomplete_reset(who_ac); +} + static char * _cmd_help_complete(char *inp) { @@ -617,6 +639,8 @@ _cmd_complete_parameters(char *input, int *size) prefs_find_login); _parameter_autocomplete(input, size, "/help", _cmd_help_complete); + _parameter_autocomplete(input, size, "/who", + _cmd_who_complete); _notify_autocomplete(input, size); } -- cgit 1.4.1-2-gfad0