if (term_detached) return;
if (vcmove) term_move_real();
- term_printed_text(1);
+
+ /* With UTF-8, move cursor only if this char is either single-byte
+ (8. bit on) or beginning of multibyte (7+8 bits on) */
+ if (term_type != TERM_TYPE_UTF8 ||
+ (chr & 0x80) == 0 || (chr & 0x40) == 0) {
+ term_printed_text(1);
+ }
+
if (vcy != term_height || vcx != 0)
putc(chr, window->term->out);
}
static void term_addch_utf8(TERM_WINDOW *window, unichar chr)
{
- unsigned char buf[10];
+ char buf[10];
int i, len;
len = utf16_char_to_utf8(chr, buf);
if (i >= term_inbuf_pos)
term_inbuf_pos = 0;
- else {
+ else if (i > 0) {
memmove(term_inbuf+i, term_inbuf, term_inbuf_pos-i);
- term_inbuf_pos = i;
+ term_inbuf_pos -= i;
}
}