diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-06-24 16:01:02 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-06-24 16:01:02 +0000 |
commit | 2de599ac0ec0634282a52711378258e25839bc7f (patch) | |
tree | 801da081ece4aed7ebb958c794de17f63328cd1e /tty.c | |
parent | 7b4077ef8710aead343ea306d598f457652ba5c0 (diff) | |
download | rtmux-2de599ac0ec0634282a52711378258e25839bc7f.tar.gz rtmux-2de599ac0ec0634282a52711378258e25839bc7f.tar.bz2 rtmux-2de599ac0ec0634282a52711378258e25839bc7f.zip |
Trying to predict the cursor position for UTF-8 output in the same way as for
normal eight-bit output is wrong, separate it into a different function. Fixes
spacing when mixing UTF-8 with some escape sequences, notably the way w3m does
it.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -409,6 +409,23 @@ tty_putc(struct tty *tty, u_char ch) } void +tty_pututf8(struct tty *tty, const struct grid_utf8 *gu) +{ + u_int i, width; + + for (i = 0; i < UTF8_SIZE; i++) { + if (gu->data[i] == 0xff) + break; + buffer_write8(tty->out, gu->data[i]); + if (tty->log_fd != -1) + write(tty->log_fd, &gu->data[i], 1); + } + + width = utf8_width(gu->data); + tty->cx += width; +} + +void tty_set_title(struct tty *tty, const char *title) { if (strstr(tty->termname, "xterm") == NULL && @@ -912,11 +929,7 @@ tty_cell( } /* Otherwise, write UTF-8. */ - for (i = 0; i < UTF8_SIZE; i++) { - if (gu->data[i] == 0xff) - break; - tty_putc(tty, gu->data[i]); - } + tty_pututf8(tty, gu); } void |