diff options
author | Thomas Adam <thomas@xteddy.org> | 2014-02-16 23:02:07 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2014-02-16 23:02:07 +0000 |
commit | b3de4a3dec85bc84bb83da6b46e2a8e2a634ace3 (patch) | |
tree | 8704cc16b1ed5380bcd7c678351d85adfd5907c8 /tty.c | |
parent | 8edbbb98656a76f0a25b5243b526709a67ae3531 (diff) | |
parent | 81db6bab91309e7cb42628048408c10504522a48 (diff) | |
download | rtmux-b3de4a3dec85bc84bb83da6b46e2a8e2a634ace3.tar.gz rtmux-b3de4a3dec85bc84bb83da6b46e2a8e2a634ace3.tar.bz2 rtmux-b3de4a3dec85bc84bb83da6b46e2a8e2a634ace3.zip |
Merge branch 'obsd-master'
Conflicts:
tmux.1
tmux.c
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -1581,13 +1581,29 @@ tty_try_256(struct tty *tty, u_char colour, const char *type) { char s[32]; - if (!(tty->term->flags & TERM_256COLOURS) && - !(tty->term_flags & TERM_256COLOURS)) - return (-1); + /* + * If the terminfo entry has 256 colours, assume that setaf and setab + * work correctly. + */ + if (tty->term->flags & TERM_256COLOURS) { + if (*type == '3') + tty_putcode1(tty, TTYC_SETAF, colour); + else + tty_putcode1(tty, TTYC_SETAB, colour); + return (0); + } - xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour); - tty_puts(tty, s); - return (0); + /* + * If the user has specified -2 to the client, setaf and setab may not + * work, so send the usual sequence. + */ + if (tty->term_flags & TERM_256COLOURS) { + xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour); + tty_puts(tty, s); + return (0); + } + + return (-1); } void |