diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tty-acs.c | 39 | ||||
-rw-r--r-- | usr.bin/tmux/tty-term.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 21 |
4 files changed, 49 insertions, 18 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 07949f0a460..f683295895d 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.768 2017/05/15 07:54:44 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.769 2017/05/15 16:44:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -401,6 +401,7 @@ enum tty_code_code { TTYC_SS, /* set cursor style, Ss */ TTYC_TC, /* 24-bit "true" colour, Tc */ TTYC_TSL, /* to_status_line, tsl */ + TTYC_U8, TTYC_VPA, /* row_address, cv */ TTYC_XENL, /* eat_newline_glitch, xn */ TTYC_XT, /* xterm(1)-compatible title, XT */ @@ -1701,6 +1702,7 @@ int tty_term_flag(struct tty_term *, enum tty_code_code); const char *tty_term_describe(struct tty_term *, enum tty_code_code); /* tty-acs.c */ +int tty_acs_needed(struct tty *); const char *tty_acs_get(struct tty *, u_char); /* tty-keys.c */ diff --git a/usr.bin/tmux/tty-acs.c b/usr.bin/tmux/tty-acs.c index 2cbc9d4ebd9..a8d118fb93a 100644 --- a/usr.bin/tmux/tty-acs.c +++ b/usr.bin/tmux/tty-acs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-acs.c,v 1.5 2016/10/03 22:52:11 nicm Exp $ */ +/* $OpenBSD: tty-acs.c,v 1.6 2017/05/15 16:44:04 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -74,23 +74,48 @@ tty_acs_cmp(const void *key, const void *value) return (ch - entry->key); } +/* Should this terminal use ACS instead of UTF-8 line drawing? */ +int +tty_acs_needed(struct tty *tty) +{ + if (tty == NULL) + return (0); + + /* + * If the U8 flag is present, it marks whether a terminal supports + * UTF-8 and ACS together. + * + * If it is present and zero, we force ACS - this gives users a way to + * turn off UTF-8 line drawing. + * + * If it is nonzero, we can fall through to the default and use UTF-8 + * line drawing on UTF-8 terminals. + */ + if (tty_term_has(tty->term, TTYC_U8) && + tty_term_number(tty->term, TTYC_U8) == 0) + return (1); + + if (tty->flags & TTY_UTF8) + return (0); + return (1); +} + /* Retrieve ACS to output as a string. */ const char * tty_acs_get(struct tty *tty, u_char ch) { - struct tty_acs_entry *entry; + struct tty_acs_entry *entry; - /* If not a UTF-8 terminal, use the ACS set. */ - if (tty != NULL && !(tty->flags & TTY_UTF8)) { + /* Use the ACS set instead of UTF-8 if needed. */ + if (tty_acs_needed(tty)) { if (tty->term->acs[ch][0] == '\0') return (NULL); return (&tty->term->acs[ch][0]); } /* Otherwise look up the UTF-8 translation. */ - entry = bsearch(&ch, - tty_acs_table, nitems(tty_acs_table), sizeof tty_acs_table[0], - tty_acs_cmp); + entry = bsearch(&ch, tty_acs_table, nitems(tty_acs_table), + sizeof tty_acs_table[0], tty_acs_cmp); if (entry == NULL) return (NULL); return (entry->string); diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c index da7d589ac10..4918afd5f45 100644 --- a/usr.bin/tmux/tty-term.c +++ b/usr.bin/tmux/tty-term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-term.c,v 1.53 2017/03/22 07:16:54 nicm Exp $ */ +/* $OpenBSD: tty-term.c,v 1.54 2017/05/15 16:44:04 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -254,6 +254,7 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_TC] = { TTYCODE_FLAG, "Tc" }, [TTYC_TSL] = { TTYCODE_STRING, "tsl" }, [TTYC_VPA] = { TTYCODE_STRING, "vpa" }, + [TTYC_U8] = { TTYCODE_NUMBER, "U8" }, [TTYC_XENL] = { TTYCODE_FLAG, "xenl" }, [TTYC_XT] = { TTYCODE_FLAG, "XT" }, }; 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); } |