summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-05-15 16:44:04 +0000
committernicm <nicm@openbsd.org>2017-05-15 16:44:04 +0000
commite5a58dfc590192402cd30048ecb236420c8bd129 (patch)
treed0c4b57cb5a7f661e42169e79ac7a36ccf795a72 /usr.bin/tmux/tty.c
parentPut the closing parenthesis in the right spot and fix std-dev calculation (diff)
downloadwireguard-openbsd-e5a58dfc590192402cd30048ecb236420c8bd129.tar.xz
wireguard-openbsd-e5a58dfc590192402cd30048ecb236420c8bd129.zip
Check the terminfo(5) U8 capability and disable using UTF-8 for ACS if
it is present and zero. This is useful for users with terminals or fonts that do not correctly support UTF-8 line drawing characters. GitHub issue 927, reported by Hiroaki Yamazoe and Akinori Hattori.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 9bd83afbe22..05372230d1b 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.284 2017/05/15 07:54:44 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.285 2017/05/15 16:44:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -71,8 +71,6 @@ static void tty_default_colours(struct grid_cell *,
static void tty_default_attributes(struct tty *, const struct window_pane *,
u_int);
-#define tty_use_acs(tty) \
- (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8))
#define tty_use_margin(tty) \
((tty)->term_type == TTY_VT420)
@@ -278,7 +276,8 @@ tty_open(struct tty *tty, char **cause)
void
tty_start_tty(struct tty *tty)
{
- struct termios tio;
+ struct client *c = tty->client;
+ struct termios tio;
if (tty->fd != -1 && tcgetattr(tty->fd, &tty->tio) == 0) {
setblocking(tty->fd, 0);
@@ -299,10 +298,14 @@ tty_start_tty(struct tty *tty)
tty_putcode(tty, TTYC_SMCUP);
tty_putcode(tty, TTYC_SMKX);
- if (tty_use_acs(tty))
- tty_putcode(tty, TTYC_ENACS);
tty_putcode(tty, TTYC_CLEAR);
+ if (tty_acs_needed(tty)) {
+ log_debug("%s: using capabilities for ACS", c->name);
+ tty_putcode(tty, TTYC_ENACS);
+ } else
+ log_debug("%s: using UTF-8 for ACS", c->name);
+
tty_putcode(tty, TTYC_CNORM);
if (tty_term_has(tty->term, TTYC_KMOUS))
tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
@@ -351,7 +354,7 @@ tty_stop_tty(struct tty *tty)
return;
tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
- if (tty_use_acs(tty))
+ if (tty_acs_needed(tty))
tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX));
@@ -1417,7 +1420,7 @@ tty_reset(struct tty *tty)
struct grid_cell *gc = &tty->cell;
if (!grid_cells_equal(gc, &grid_default_cell)) {
- if ((gc->attr & GRID_ATTR_CHARSET) && tty_use_acs(tty))
+ if ((gc->attr & GRID_ATTR_CHARSET) && tty_acs_needed(tty))
tty_putcode(tty, TTYC_RMACS);
tty_putcode(tty, TTYC_SGR0);
memcpy(gc, &grid_default_cell, sizeof *gc);
@@ -1767,7 +1770,7 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
tty_putcode(tty, TTYC_INVIS);
if (changed & GRID_ATTR_STRIKETHROUGH)
tty_putcode(tty, TTYC_SMXX);
- if ((changed & GRID_ATTR_CHARSET) && tty_use_acs(tty))
+ if ((changed & GRID_ATTR_CHARSET) && tty_acs_needed(tty))
tty_putcode(tty, TTYC_SMACS);
}