From 1701ed7023b36f98e77a57e59eb65c08f09a5001 Mon Sep 17 00:00:00 2001 From: Nominate Date: Tue, 6 Aug 2013 08:10:05 +0100 Subject: [PATCH] Stops line-spamming and clears before printing help This addresses one issue in #340 perfectly and slightly improves the other. --- prompt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/prompt.c b/prompt.c index 16750c5..c832db3 100644 --- a/prompt.c +++ b/prompt.c @@ -159,10 +159,11 @@ static void execute(ToxWindow* self, char* cmd) { } } else if(!strcmp(cmd, "clear")) { - wclear(self->window); + wclear(self->window); } else if(!strcmp(cmd, "help")) { - print_usage(self); + wclear(self->window); + print_usage(self); } else if(!strncmp(cmd, "status ", strlen("status "))) { char* msg; @@ -265,8 +266,8 @@ static void execute(ToxWindow* self, char* cmd) { 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; + if(prompt_buf_pos == (COLS - 3)) { + return; } prompt_buf[prompt_buf_pos++] = key; prompt_buf[prompt_buf_pos] = 0;