summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-04-29 15:59:09 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-04-29 15:59:09 +0000
commitb0d13f99fc745a16e3ec85281d0e281bf678a967 (patch)
tree04300c0a25f6a49342e49cf0045ffb73ab299197 /usr.bin/tmux/tty.c
parentc9d2772cdbdf4c2aa62bd01b5ba555ca0f8c7e80 (diff)
If default-terminal is set to "screen" or "screen-*", emulate screen's
historical (incorrect) behaviour for SGR 3 and send smso (standout). Previously, we would send sitm (italics) if the terminal outside had it and smso otherwise. This was acceptably until recently because xterm's terminfo entry lacked sitm, so most users got smso. People who want italics should set default-terminal to the forthcoming "tmux" entry (and be prepared to deal with it being missing on older hosts). As a side-effect this changes default-terminal to be a server rather than a session option. suggested by and ok naddy
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 3f335ed8985..4b27e41bf74 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.179 2015/04/25 15:57:48 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.180 2015/04/29 15:59:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,6 +34,7 @@
void tty_read_callback(struct bufferevent *, void *);
void tty_error_callback(struct bufferevent *, short, void *);
+void tty_set_italics(struct tty *);
int tty_try_256(struct tty *, u_char, const char *);
void tty_colours(struct tty *, const struct grid_cell *);
@@ -457,6 +458,21 @@ tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
}
void
+tty_set_italics(struct tty *tty)
+{
+ const char *s;
+
+ if (tty_term_has(tty->term, TTYC_SITM)) {
+ s = options_get_string(&global_options, "default-terminal");
+ if (strcmp(s, "screen") != 0 && strncmp(s, "screen-", 7) != 0) {
+ tty_putcode(tty, TTYC_SITM);
+ return;
+ }
+ }
+ tty_putcode(tty, TTYC_SMSO);
+}
+
+void
tty_set_title(struct tty *tty, const char *title)
{
if (!tty_term_has(tty->term, TTYC_TSL) ||
@@ -1396,12 +1412,8 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
tty_putcode(tty, TTYC_BOLD);
if (changed & GRID_ATTR_DIM)
tty_putcode(tty, TTYC_DIM);
- if (changed & GRID_ATTR_ITALICS) {
- if (tty_term_has(tty->term, TTYC_SITM))
- tty_putcode(tty, TTYC_SITM);
- else
- tty_putcode(tty, TTYC_SMSO);
- }
+ if (changed & GRID_ATTR_ITALICS)
+ tty_set_italics(tty);
if (changed & GRID_ATTR_UNDERSCORE)
tty_putcode(tty, TTYC_SMUL);
if (changed & GRID_ATTR_BLINK)