aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2014-02-17 18:09:25 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2014-02-17 18:09:25 +0000
commitd325104d10b699e8c85cddd7ee9b7d2273c8cf40 (patch)
treeed3512ff09e388cb3f91c82ea5bad6a13d745a09 /tty.c
parent3aadc9d665fd3ec52181c5e1d8bd2d6481a97fef (diff)
parentb3de4a3dec85bc84bb83da6b46e2a8e2a634ace3 (diff)
downloadrtmux-d325104d10b699e8c85cddd7ee9b7d2273c8cf40.tar.gz
rtmux-d325104d10b699e8c85cddd7ee9b7d2273c8cf40.tar.bz2
rtmux-d325104d10b699e8c85cddd7ee9b7d2273c8cf40.zip
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/tty.c b/tty.c
index 675af024..eb2511c9 100644
--- a/tty.c
+++ b/tty.c
@@ -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