1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-01 13:26: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

@ -17,6 +17,7 @@
uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE] = {0};
uint8_t num_frnd_requests = 0;
extern ToxWindow *prompt;
extern cmd_list[TOT_NUM_COMMANDS][MAX_CMDNAME_SIZE];
/* prevents input string from eating system messages: call this prior to printing a prompt message
TODO: This is only a partial fix */
@ -144,7 +145,14 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
else if (key == KEY_RIGHT) {
if (prt->pos < prt->len)
++prt->pos;
} else
} else if (key == '\t') { /* TAB key: completes command */
if (prt->len > 1 && prt->line[0] == '/')
complete_line(prt->line, &prt->pos, &prt->len, cmd_list, TOT_NUM_COMMANDS,
MAX_CMDNAME_SIZE);
}
else
#if HAVE_WIDECHAR
if (iswprint(key))
#else