diff options
author | nicm <nicm> | 2015-09-25 23:30:12 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-09-25 23:30:12 +0000 |
commit | 03d7dba5d86afa797eac49e75d37554590ef66c3 (patch) | |
tree | 201e71d1e57ebe13071f92a8830f616d290a0d95 /tty.c | |
parent | 28f23f18e9d79405a60348c4f7aeded33da9135b (diff) | |
download | rtmux-03d7dba5d86afa797eac49e75d37554590ef66c3.tar.gz rtmux-03d7dba5d86afa797eac49e75d37554590ef66c3.tar.bz2 rtmux-03d7dba5d86afa797eac49e75d37554590ef66c3.zip |
If the terminal has colors=256, only try to use setaf/setab if they
exist, reported by Filipe Brandenburger.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -1648,14 +1648,19 @@ tty_try_256(struct tty *tty, u_char colour, const char *type) char s[32]; /* - * If the terminfo entry has 256 colours, assume that setaf and setab - * work correctly. + * If the terminfo entry has 256 colours and setaf and setab exist, + * assume that they work correctly. */ if (tty->term->flags & TERM_256COLOURS) { - if (*type == '3') + if (*type == '3') { + if (!tty_term_has(tty->term, TTYC_SETAF)) + goto fallback; tty_putcode1(tty, TTYC_SETAF, colour); - else + } else { + if (!tty_term_has(tty->term, TTYC_SETAB)) + goto fallback; tty_putcode1(tty, TTYC_SETAB, colour); + } return (0); } @@ -1663,13 +1668,15 @@ tty_try_256(struct tty *tty, u_char colour, const char *type) * 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); - } + if (tty->term_flags & TERM_256COLOURS) + goto fallback; return (-1); + +fallback: + xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour); + tty_puts(tty, s); + return (0); } void |