Add commands to tab complete

master
Curtis McEnroe 2018-08-08 21:48:30 -04:00
parent 09fe40abd9
commit c024147504
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 11 additions and 2 deletions

3
chat.c
View File

@ -75,8 +75,9 @@ int main(int argc, char *argv[]) {
if (!chat.nick) chat.nick = prompt("Name: "); if (!chat.nick) chat.nick = prompt("Name: ");
chat.user = strdup(chat.nick); chat.user = strdup(chat.nick);
signal(SIGINT, sigint); inputTab();
signal(SIGINT, sigint);
uiInit(); uiInit();
uiLog(L"Traveling..."); uiLog(L"Traveling...");
uiDraw(); uiDraw();

2
chat.h
View File

@ -73,6 +73,8 @@ const wchar_t *editTail(void);
bool edit(bool meta, bool ctrl, wchar_t ch); bool edit(bool meta, bool ctrl, wchar_t ch);
void handle(char *line); void handle(char *line);
void inputTab(void);
void input(char *line); void input(char *line);
void tabTouch(const char *word); void tabTouch(const char *word);

2
edit.c
View File

@ -126,7 +126,7 @@ static void complete(void) {
free(wcs); free(wcs);
size_t pos = line.tab - line.buf; size_t pos = line.tab - line.buf;
if (!pos) { if (!pos && line.tab[0] != L'/') {
insert(L':'); insert(L':');
} else if (pos >= 2) { } else if (pos >= 2) {
if (line.buf[pos - 2] == L':' || line.buf[pos - 2] == L',') { if (line.buf[pos - 2] == L':' || line.buf[pos - 2] == L',') {

View File

@ -99,3 +99,9 @@ void input(char *input) {
} }
uiFmt("%s isn't a recognized command", command); uiFmt("%s isn't a recognized command", command);
} }
void inputTab(void) {
for (size_t i = 0; i < COMMANDS_LEN; ++i) {
tabTouch(COMMANDS[i].command);
}
}