Reset content when press / and ESC
This commit is contained in:
parent
f8dd9e6ee3
commit
9407946738
1 changed files with 11 additions and 9 deletions
20
src/zen/ui.c
20
src/zen/ui.c
|
@ -533,6 +533,14 @@ void add_username(char *username)
|
||||||
arraylist_add(users, username, randomco, false, false);
|
arraylist_add(users, username, randomco, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset_content()
|
||||||
|
{
|
||||||
|
/* Reset for new input */
|
||||||
|
curs_pos = 0;
|
||||||
|
/* Set content[0] for printing purposes */
|
||||||
|
content[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
void update_panel()
|
void update_panel()
|
||||||
{
|
{
|
||||||
wclear(panel);
|
wclear(panel);
|
||||||
|
@ -692,12 +700,8 @@ void get_panel_content(int ch)
|
||||||
send_message();
|
send_message();
|
||||||
} else if (current_mode == COMMAND) {
|
} else if (current_mode == COMMAND) {
|
||||||
use_command();
|
use_command();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/* Reset for new input */
|
reset_content();
|
||||||
curs_pos = 0;
|
|
||||||
/* Set content[0] for printing purposes */
|
|
||||||
content[0] = '\0';
|
|
||||||
|
|
||||||
} else if (curs_pos < MAX_MESSAGE_LENGTH - 1) {
|
} else if (curs_pos < MAX_MESSAGE_LENGTH - 1) {
|
||||||
/* Append it to the content if it is normal character */
|
/* Append it to the content if it is normal character */
|
||||||
|
@ -786,6 +790,7 @@ void ui(int *fd)
|
||||||
int ch = getch();
|
int ch = getch();
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case ESC:
|
case ESC:
|
||||||
|
reset_content();
|
||||||
current_mode = NORMAL;
|
current_mode = NORMAL;
|
||||||
current_window = USERS_WINDOW;
|
current_window = USERS_WINDOW;
|
||||||
draw_border(users_border, true);
|
draw_border(users_border, true);
|
||||||
|
@ -799,8 +804,6 @@ void ui(int *fd)
|
||||||
case '/':
|
case '/':
|
||||||
if (current_mode == NORMAL) {
|
if (current_mode == NORMAL) {
|
||||||
current_mode = COMMAND;
|
current_mode = COMMAND;
|
||||||
curs_pos = 0;
|
|
||||||
content[0] = '\0';
|
|
||||||
update_panel();
|
update_panel();
|
||||||
} else {
|
} else {
|
||||||
get_panel_content(ch);
|
get_panel_content(ch);
|
||||||
|
@ -843,8 +846,7 @@ void ui(int *fd)
|
||||||
|
|
||||||
case CLEAR_INPUT:
|
case CLEAR_INPUT:
|
||||||
if (current_window == CHAT_WINDOW) {
|
if (current_window == CHAT_WINDOW) {
|
||||||
curs_pos = 0;
|
reset_content();
|
||||||
content[0] = '\0';
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue