summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-10-25 21:11:21 +0000
committernicm <nicm@openbsd.org>2009-10-25 21:11:21 +0000
commit04924df597e93aa6f9f08a588d1cff7dabdc8ef8 (patch)
tree2d66ee15999bfeec76ac7b9f7e836347f79bfce2 /usr.bin/tmux/tty.c
parenttag should also be copied from listener to message when the message is (diff)
downloadwireguard-openbsd-04924df597e93aa6f9f08a588d1cff7dabdc8ef8.tar.xz
wireguard-openbsd-04924df597e93aa6f9f08a588d1cff7dabdc8ef8.zip
Remove the -d flag to tmux and just use op/AX to detect default colours.
Irritatingly, although op can be used to tell if a terminal supports default colours, it can't be used to set them because in some terminfo descriptions it resets attributes as a side-effect (acts as sgr0) and in others it doesn't, so it is not possible to determine reliably what the terminal state will be afterwards. So if AX is missing and op is present, tmux just sends sgr0. Anyone using -d for a terminal who finds they actually needed it can replace it using terminal-overrides, but please let me know as it is probably an omission from terminfo.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index ab0b7d9a2d9..7eaca87bb7c 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.58 2009/10/21 19:27:09 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.59 2009/10/25 21:11:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1236,13 +1236,21 @@ tty_attributes_fg(struct tty *tty, const struct grid_cell *gc)
tty_reset(tty);
}
- if (fg == 8 &&
- !(tty->term->flags & TERM_HASDEFAULTS) &&
- !(tty->term_flags & TERM_HASDEFAULTS))
- fg = 7;
- if (fg == 8)
- tty_puts(tty, "\033[39m");
- else
+ if (fg == 8) {
+ if (tty_term_has(tty->term, TTYC_AX)) {
+ /* AX is an extension that means \033[39m works. */
+ tty_puts(tty, "\033[39m");
+ } else if (tty_term_has(tty->term, TTYC_OP)) {
+ /*
+ * op can be used to look for default colours but there
+ * is no point in using it - with some terminals it
+ * does SGR0 and others not, so SGR0 is needed anyway
+ * to put the terminal into a known state.
+ */
+ tty_reset(tty);
+ } else
+ tty_putcode1(tty, TTYC_SETAF, 7);
+ } else
tty_putcode1(tty, TTYC_SETAF, fg);
}
@@ -1262,12 +1270,13 @@ tty_attributes_bg(struct tty *tty, const struct grid_cell *gc)
bg &= 7;
}
- if (bg == 8 &&
- !(tty->term->flags & TERM_HASDEFAULTS) &&
- !(tty->term_flags & TERM_HASDEFAULTS))
- bg = 0;
- if (bg == 8)
- tty_puts(tty, "\033[49m");
- else
+ if (bg == 8) {
+ if (tty_term_has(tty->term, TTYC_AX)) {
+ tty_puts(tty, "\033[49m");
+ } else if (tty_term_has(tty->term, TTYC_OP))
+ tty_reset(tty);
+ else
+ tty_putcode1(tty, TTYC_SETAB, 0);
+ } else
tty_putcode1(tty, TTYC_SETAB, bg);
}