1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 15:53:26 +01:00

Fixed backspace key bug on xterm when toxic is compiled with widechar.

This commit is contained in:
irungentoo 2013-09-26 07:52:17 -04:00
parent 7de4089695
commit 0c3767762e
2 changed files with 21 additions and 25 deletions

View File

@ -166,7 +166,17 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
int x, y, y2, x2; int x, y, y2, x2;
getyx(self->window, y, x); getyx(self->window, y, x);
getmaxyx(self->window, y2, x2); 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 */ /* Add printable chars to buffer and print on input space */
#if HAVE_WIDECHAR #if HAVE_WIDECHAR
if (iswprint(key)) { if (iswprint(key)) {
@ -179,19 +189,6 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
ctx->line[ctx->pos] = L'\0'; 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 */ /* RETURN key: Execute command or print line */
else if (key == '\n') { else if (key == '\n') {
uint8_t *line = wcs_to_char(ctx->line); uint8_t *line = wcs_to_char(ctx->line);

View File

@ -132,6 +132,17 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
getyx(self->window, y, x); getyx(self->window, y, x);
getmaxyx(self->window, y2, x2); 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 */ /* Add printable chars to buffer and print on input space */
#if HAVE_WIDECHAR #if HAVE_WIDECHAR
if (iswprint(key)) { 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 */ /* RETURN key: Execute command or print line */
else if (key == '\n') { else if (key == '\n') {
uint8_t *line = wcs_to_char(ctx->line); uint8_t *line = wcs_to_char(ctx->line);