1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 01:56:44 +02:00

implement tab completion for commands

This commit is contained in:
Jfreegman
2013-12-08 18:14:57 -05:00
parent 9c2551b3b9
commit 674aa682e7
8 changed files with 69 additions and 10 deletions

View File

@ -15,8 +15,6 @@ struct cmd_func {
void (*func)(WINDOW *w, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
};
#define GLOBAL_NUM_COMMANDS 13
static struct cmd_func global_commands[] = {
{ "/accept", cmd_accept },
{ "/add", cmd_add },
@ -33,8 +31,6 @@ static struct cmd_func global_commands[] = {
{ "/status", cmd_status },
};
#define CHAT_NUM_COMMANDS 5
static struct cmd_func chat_commands[] = {
{ "/help", cmd_chat_help },
{ "/invite", cmd_groupinvite },
@ -43,6 +39,28 @@ static struct cmd_func chat_commands[] = {
{ "/sendfile", cmd_sendfile },
};
/* Array of all command names; used for tab completion. */
const uint8_t cmd_list[TOT_NUM_COMMANDS][MAX_CMDNAME_SIZE] = {
{ "/accept" },
{ "/add" },
{ "/clear" },
{ "/connect" },
{ "/exit" },
{ "/groupchat" },
{ "/help" },
{ "/invite" },
{ "/join" },
{ "/myid" },
{ "/nick" },
{ "/note" },
{ "/q" },
{ "/quit" },
{ "/savefile" },
{ "/sendfile" },
{ "/status" },
};
/* Parses input command and puts args into arg array.
Returns number of arguments on success, -1 on failure. */
static int parse_command(WINDOW *w, char *cmd, char (*args)[MAX_STR_SIZE])