Handle delete char in command win
This commit is contained in:
19
profanity.c
19
profanity.c
@@ -106,7 +106,7 @@ void event_loop(xmpp_ctx_t *ctx, xmpp_conn_t *conn)
|
|||||||
wtimeout(cmd_win, 0);
|
wtimeout(cmd_win, 0);
|
||||||
|
|
||||||
while(TRUE) {
|
while(TRUE) {
|
||||||
char ch = 0;
|
int ch = ERR;
|
||||||
char command[100];
|
char command[100];
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
@@ -120,11 +120,24 @@ void event_loop(xmpp_ctx_t *ctx, xmpp_conn_t *conn)
|
|||||||
getyx(cmd_win, cmd_y, cmd_x);
|
getyx(cmd_win, cmd_y, cmd_x);
|
||||||
wmove(cmd_win, cmd_y, cmd_x);
|
wmove(cmd_win, cmd_y, cmd_x);
|
||||||
|
|
||||||
// get some more input
|
// echo off, and get some more input
|
||||||
|
noecho();
|
||||||
ch = wgetch(cmd_win);
|
ch = wgetch(cmd_win);
|
||||||
if (ch > 0 && ch != '\n') {
|
|
||||||
|
// if delete pressed, go back and delete it
|
||||||
|
if (ch == 127) {
|
||||||
|
getyx(cmd_win, cmd_y, cmd_x);
|
||||||
|
wmove(cmd_win, cmd_y, cmd_x-1);
|
||||||
|
wdelch(cmd_win);
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
// else if not error or newline, show it and store it
|
||||||
|
else if (ch != ERR && ch != '\n') {
|
||||||
|
waddch(cmd_win, ch);
|
||||||
command[size++] = ch;
|
command[size++] = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo();
|
||||||
}
|
}
|
||||||
|
|
||||||
command[size++] = '\0';
|
command[size++] = '\0';
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ static void create_command_window(void)
|
|||||||
getmaxyx(stdscr, rows, cols);
|
getmaxyx(stdscr, rows, cols);
|
||||||
|
|
||||||
cmd_win = newwin(1, cols, rows-1, 0);
|
cmd_win = newwin(1, cols, rows-1, 0);
|
||||||
|
keypad(cmd_win, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_main_window(void)
|
static void create_main_window(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user