mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:13:01 +01:00
added command to clear prompt screen
This commit is contained in:
parent
5e905ca12a
commit
508c805983
10
prompt.c
10
prompt.c
@ -251,20 +251,21 @@ static void execute(ToxWindow* self, char* cmd) {
|
|||||||
wprintw(self->window, "Message successfully sent.\n");
|
wprintw(self->window, "Message successfully sent.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (!strncmp(cmd, "clear", strlen("clear"))) {
|
||||||
|
wclear(self->window);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
wprintw(self->window, "Invalid syntax.\n");
|
wprintw(self->window, "Invalid syntax.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prompt_onKey(ToxWindow* self, int key) {
|
static void prompt_onKey(ToxWindow* self, int key) {
|
||||||
|
|
||||||
// PRINTABLE characters: Add to line.
|
// PRINTABLE characters: Add to line.
|
||||||
if(isprint(key)) {
|
if(isprint(key)) {
|
||||||
|
|
||||||
if(prompt_buf_pos == (sizeof(prompt_buf) - 1)) {
|
if(prompt_buf_pos == (sizeof(prompt_buf) - 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_buf[prompt_buf_pos++] = key;
|
prompt_buf[prompt_buf_pos++] = key;
|
||||||
prompt_buf[prompt_buf_pos] = 0;
|
prompt_buf[prompt_buf_pos] = 0;
|
||||||
}
|
}
|
||||||
@ -273,14 +274,12 @@ static void prompt_onKey(ToxWindow* self, int key) {
|
|||||||
else if(key == '\n') {
|
else if(key == '\n') {
|
||||||
wprintw(self->window, "\n");
|
wprintw(self->window, "\n");
|
||||||
execute(self, prompt_buf);
|
execute(self, prompt_buf);
|
||||||
|
|
||||||
prompt_buf_pos = 0;
|
prompt_buf_pos = 0;
|
||||||
prompt_buf[0] = 0;
|
prompt_buf[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BACKSPACE key: Remove one character from line.
|
// BACKSPACE key: Remove one character from line.
|
||||||
else if(key == 0x107 || key == 0x8 || key == 0x7f) {
|
else if(key == 0x107 || key == 0x8 || key == 0x7f) {
|
||||||
|
|
||||||
if(prompt_buf_pos != 0) {
|
if(prompt_buf_pos != 0) {
|
||||||
prompt_buf[--prompt_buf_pos] = 0;
|
prompt_buf[--prompt_buf_pos] = 0;
|
||||||
}
|
}
|
||||||
@ -315,6 +314,7 @@ static void print_usage(ToxWindow* self) {
|
|||||||
wprintw(self->window, " nick <nickname> : Set your nickname\n");
|
wprintw(self->window, " nick <nickname> : Set your nickname\n");
|
||||||
wprintw(self->window, " accept <number> : Accept friend request\n");
|
wprintw(self->window, " accept <number> : Accept friend request\n");
|
||||||
wprintw(self->window, " myid : Print your ID\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, " quit/exit : Exit program\n");
|
||||||
wprintw(self->window, " help : Print this message again\n");
|
wprintw(self->window, " help : Print this message again\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user