From 0c3767762ec031820a7cf8bc5c2eaa00989ad7d3 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 26 Sep 2013 07:52:17 -0400 Subject: [PATCH] Fixed backspace key bug on xterm when toxic is compiled with widechar. --- src/chat.c | 23 ++++++++++------------- src/groupchat.c | 23 +++++++++++------------ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/chat.c b/src/chat.c index 6291c4f..2678a3d 100644 --- a/src/chat.c +++ b/src/chat.c @@ -166,7 +166,17 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key) int x, y, y2, x2; getyx(self->window, y, x); getmaxyx(self->window, y2, x2); + /* BACKSPACE key: Remove one character from line */ + if (key == 0x107 || key == 0x8 || key == 0x7f) { + if (ctx->pos > 0) { + ctx->line[--ctx->pos] = L'\0'; + if (x == 0) + mvwdelch(self->window, y - 1, x2 - 1); + else + mvwdelch(self->window, y, x - 1); + } + } else /* Add printable chars to buffer and print on input space */ #if HAVE_WIDECHAR if (iswprint(key)) { @@ -179,19 +189,6 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key) ctx->line[ctx->pos] = L'\0'; } } - - /* BACKSPACE key: Remove one character from line */ - else if (key == 0x107 || key == 0x8 || key == 0x7f) { - if (ctx->pos > 0) { - ctx->line[--ctx->pos] = L'\0'; - - if (x == 0) - mvwdelch(self->window, y - 1, x2 - 1); - else - mvwdelch(self->window, y, x - 1); - } - } - /* RETURN key: Execute command or print line */ else if (key == '\n') { uint8_t *line = wcs_to_char(ctx->line); diff --git a/src/groupchat.c b/src/groupchat.c index 986a112..93f8bf3 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -132,6 +132,17 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) getyx(self->window, y, x); getmaxyx(self->window, y2, x2); + /* BACKSPACE key: Remove one character from line */ + if (key == 0x107 || key == 0x8 || key == 0x7f) { + if (ctx->pos > 0) { + ctx->line[--ctx->pos] = L'\0'; + + if (x == 0) + mvwdelch(self->window, y - 1, x2 - 1); + else + mvwdelch(self->window, y, x - 1); + } + } else /* Add printable chars to buffer and print on input space */ #if HAVE_WIDECHAR if (iswprint(key)) { @@ -145,18 +156,6 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) } } - /* BACKSPACE key: Remove one character from line */ - else if (key == 0x107 || key == 0x8 || key == 0x7f) { - if (ctx->pos > 0) { - ctx->line[--ctx->pos] = L'\0'; - - if (x == 0) - mvwdelch(self->window, y - 1, x2 - 1); - else - mvwdelch(self->window, y, x - 1); - } - } - /* RETURN key: Execute command or print line */ else if (key == '\n') { uint8_t *line = wcs_to_char(ctx->line);