summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-03-26 19:07:34 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-03-26 19:07:34 +0000
commitf036d809c4df98804cafaccf1fbafa35b8ed114d (patch)
treef7e9970e7b8e32630a08a2173f51d624c25a2c5e
parent5d08167414c948b98a0d5b72a5f51d8ab03dfb30 (diff)
Fix to properly wrap wide characters, from Micah Cowan.
-rw-r--r--usr.bin/tmux/screen-write.c12
-rw-r--r--usr.bin/tmux/tty.c16
2 files changed, 19 insertions, 9 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index da088d3c5fe..db6de008f4a 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.47 2011/03/07 23:46:27 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.48 2011/03/26 19:07:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1012,8 +1012,10 @@ screen_write_cell(struct screen_write_ctx *ctx,
* If this is a wide character and there is no room on the screen, for
* the entire character, don't print it.
*/
- if (width > 1 && (width > screen_size_x(s) ||
- (s->cx != screen_size_x(s) && s->cx > screen_size_x(s) - width)))
+ if (!(s->mode & MODE_WRAP)
+ && (width > 1 && (width > screen_size_x(s) ||
+ (s->cx != screen_size_x(s)
+ && s->cx > screen_size_x(s) - width))))
return;
/*
@@ -1045,8 +1047,8 @@ screen_write_cell(struct screen_write_ctx *ctx,
}
/* Sanity checks. */
- if (((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - 1)
- || s->cy > screen_size_y(s) - 1)
+ if (((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width)
+ || s->cy > screen_size_y(s) - width)
return;
/* Handle overwriting of UTF-8 characters. */
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 1d5ad909a91..f8edbe3cbc9 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.101 2011/03/08 19:23:49 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.102 2011/03/26 19:07:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -892,11 +892,19 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen;
u_int cx;
+ u_int width;
+ const struct grid_cell *gc = ctx->cell;
+ const struct grid_utf8 *gu = ctx->utf8;
+
+ if (gc->flags & GRID_FLAG_UTF8)
+ width = gu->width;
+ else
+ width = 1;
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
/* Is the cursor in the very last position? */
- if (ctx->ocx > wp->sx - ctx->last_width) {
+ if (ctx->ocx > wp->sx - width) {
if (wp->xoff != 0 || wp->sx != tty->sx) {
/*
* The pane doesn't fill the entire line, the linefeed
@@ -906,10 +914,10 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
} else if (tty->cx < tty->sx) {
/*
* The cursor isn't in the last position already, so
- * move as far left as possinble and redraw the last
+ * move as far left as possible and redraw the last
* cell to move into the last position.
*/
- cx = screen_size_x(s) - ctx->last_width;
+ cx = screen_size_x(s) - width;
tty_cursor_pane(tty, ctx, cx, ctx->ocy);
tty_cell(tty, &ctx->last_cell, &ctx->last_utf8);
}