mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 23:16:22 +00:00
Added command autocomplete
This commit is contained in:
21
command.c
21
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;
|
||||
|
||||
Reference in New Issue
Block a user