summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-06-24 16:01:03 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-06-24 16:01:03 +0000
commitd2c7c5ef77bdae3b0f8bb2cc9af2941494d30cb6 (patch)
tree724f5089affbf16f71f6402809bb96c33f7248e3
parentaf4b2babe3246b386ef2f4b5d88db42a4c9bea30 (diff)
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.
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/tty.c25
2 files changed, 21 insertions, 7 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 07d14672bcc..e7f51dcb240 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.7 2009/06/24 05:35:07 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.8 2009/06/24 16:01:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -994,6 +994,7 @@ void tty_putcode1(struct tty *, enum tty_code_code, int);
void tty_putcode2(struct tty *, enum tty_code_code, int, int);
void tty_puts(struct tty *, const char *);
void tty_putc(struct tty *, u_char);
+void tty_pututf8(struct tty *, const struct grid_utf8 *);
void tty_init(struct tty *, char *, char *);
void tty_start_tty(struct tty *);
void tty_stop_tty(struct tty *);
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 8f1bb963b3b..dc1129fd584 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.4 2009/06/03 23:30:40 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.5 2009/06/24 16:01:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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