mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 15:23:26 +01:00
Fixed backspace key bug on xterm when toxic is compiled with widechar.
This commit is contained in:
parent
7de4089695
commit
0c3767762e
23
src/chat.c
23
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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user