diff options
author | James Booth <boothj5@gmail.com> | 2012-06-04 23:59:09 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-06-04 23:59:09 +0100 |
commit | 6bb120200efa4a89ddc0506d2eb12a103e4e39a1 (patch) | |
tree | d6944493f17982af85f8fe19b622b1e7e2d68757 /command.c | |
parent | 467b5cce7e6c6e830b0066f78edac699f4364d1f (diff) | |
download | profani-tty-6bb120200efa4a89ddc0506d2eb12a103e4e39a1.tar.gz |
Added command autocomplete
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/command.c b/command.c index f14cffb6..19fd1ab7 100644 --- a/command.c +++ b/command.c @@ -32,6 +32,7 @@ #include "ui.h" #include "util.h" #include "preferences.h" +#include "prof_autocomplete.h" static gboolean _handle_command(const char * const command, const char * const inp); @@ -59,6 +60,8 @@ struct cmd_t { gboolean (*func)(const char * const inp); }; +static PAutocomplete commands_ac; + static struct cmd_t commands[] = { { "/away", _cmd_away }, { "/beep", _cmd_set_beep }, @@ -108,9 +111,27 @@ gboolean process_input(char *inp) void command_init(void) { + commands_ac = p_autocomplete_new(); + + int i; + for (i = 0; i < num_cmds; i++) { + struct cmd_t *pcmd = commands+i; + p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd); + } + history_init(); } +char * cmd_complete(char *inp) +{ + return p_autocomplete_complete(commands_ac, inp); +} + +void reset_command_completer(void) +{ + p_autocomplete_reset(commands_ac); +} + static gboolean _handle_command(const char * const command, const char * const inp) { int i; |