From: nicm Date: Fri, 16 Dec 2022 08:19:58 +0000 (+0000) Subject: Make U+FE0F VARIATION SELECTOR-16 change the width from 1 to 2. GitHub X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=485d86f6e4540aab098d7bc39e631e734a081088;p=openbsd Make U+FE0F VARIATION SELECTOR-16 change the width from 1 to 2. GitHub issue 3409. --- diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 3e8eeafd16e..99da665cdcc 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.211 2022/10/25 17:53:31 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.212 2022/12/16 08:19:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1820,7 +1820,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) struct grid_cell tmp_gc, now_gc; struct tty_ctx ttyctx; u_int sx = screen_size_x(s), sy = screen_size_y(s); - u_int width = gc->data.width, xx, last, cx, cy; + u_int width = gc->data.width, xx, last, cy; int selected, skip = 1; /* Ignore padding cells. */ @@ -1853,12 +1853,12 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) ctx->flags &= ~SCREEN_WRITE_ZWJ; screen_write_collect_flush(ctx, 0, __func__); if ((gc = screen_write_combine(ctx, ud, &xx)) != NULL) { - cx = s->cx; cy = s->cy; + cy = s->cy; screen_write_set_cursor(ctx, xx, s->cy); screen_write_initctx(ctx, &ttyctx, 0); ttyctx.cell = gc; tty_write(tty_cmd_cell, &ttyctx); - s->cx = cx; s->cy = cy; + s->cx = xx + 1 + gc->data.width; s->cy = cy; } return; } @@ -2016,6 +2016,14 @@ screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud, memcpy(gc.data.data + gc.data.size, ud->data, ud->size); gc.data.size += ud->size; + /* If this is U+FE0F VARIATION SELECTOR-16, force the width to 2. */ + if (gc.data.width == 1 && + ud->size == 3 && + memcmp(ud->data, "\357\270\217", 3) == 0) { + grid_view_set_padding(gd, (*xx) + 1, s->cy); + gc.data.width = 2; + } + /* Set the new cell. */ grid_view_set_cell(gd, *xx, s->cy, &gc); diff --git a/usr.bin/tmux/utf8.c b/usr.bin/tmux/utf8.c index 81932ee1ba5..f54fad040d3 100644 --- a/usr.bin/tmux/utf8.c +++ b/usr.bin/tmux/utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utf8.c,v 1.58 2021/06/10 07:56:47 nicm Exp $ */ +/* $OpenBSD: utf8.c,v 1.59 2022/12/16 08:19:58 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -227,12 +227,11 @@ utf8_width(struct utf8_data *ud, int *width) return (UTF8_ERROR); } *width = wcwidth(wc); - if (*width < 0 || *width > 0xff) { - log_debug("UTF-8 %.*s, wcwidth() %d", (int)ud->size, ud->data, - *width); - return (UTF8_ERROR); - } - return (UTF8_DONE); + log_debug("UTF-8 %.*s %#x, wcwidth() %d", (int)ud->size, ud->data, + (u_int)wc, *width); + if (*width >= 0 && *width <= 0xff) + return (UTF8_DONE); + return (UTF8_ERROR); } /*