From c13de2d2859f09a4b8f0f88d122e9fbd2ecc6b80 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Sat, 3 Aug 2013 17:13:44 -0400 Subject: added command to clear prompt screen --- testing/toxic/prompt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'testing') diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 1db60883..a47238af 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -251,20 +251,21 @@ static void execute(ToxWindow* self, char* cmd) { wprintw(self->window, "Message successfully sent.\n"); } } + + else if (!strncmp(cmd, "clear", strlen("clear"))) { + wclear(self->window); + } else { wprintw(self->window, "Invalid syntax.\n"); } } static void prompt_onKey(ToxWindow* self, int key) { - // PRINTABLE characters: Add to line. if(isprint(key)) { - if(prompt_buf_pos == (sizeof(prompt_buf) - 1)) { return; } - prompt_buf[prompt_buf_pos++] = key; prompt_buf[prompt_buf_pos] = 0; } @@ -273,14 +274,12 @@ static void prompt_onKey(ToxWindow* self, int key) { else if(key == '\n') { wprintw(self->window, "\n"); execute(self, prompt_buf); - prompt_buf_pos = 0; prompt_buf[0] = 0; } // BACKSPACE key: Remove one character from line. else if(key == 0x107 || key == 0x8 || key == 0x7f) { - if(prompt_buf_pos != 0) { prompt_buf[--prompt_buf_pos] = 0; } @@ -315,6 +314,7 @@ static void print_usage(ToxWindow* self) { wprintw(self->window, " nick : Set your nickname\n"); wprintw(self->window, " accept : Accept friend request\n"); wprintw(self->window, " myid : Print your ID\n"); + wprintw(self->window, " clear : Clear the screen\n"); wprintw(self->window, " quit/exit : Exit program\n"); wprintw(self->window, " help : Print this message again\n"); -- cgit v1.2.3