1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Handle delete char in command win

This commit is contained in:
James Booth 2012-02-06 22:04:30 +00:00
parent 1729059307
commit b2173522cd
2 changed files with 17 additions and 3 deletions

@ -106,7 +106,7 @@ void event_loop(xmpp_ctx_t *ctx, xmpp_conn_t *conn)
wtimeout(cmd_win, 0);
while(TRUE) {
char ch = 0;
int ch = ERR;
char command[100];
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);
wmove(cmd_win, cmd_y, cmd_x);
// get some more input
// echo off, and get some more input
noecho();
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;
}
echo();
}
command[size++] = '\0';

@ -69,6 +69,7 @@ static void create_command_window(void)
getmaxyx(stdscr, rows, cols);
cmd_win = newwin(1, cols, rows-1, 0);
keypad(cmd_win, TRUE);
}
static void create_main_window(void)