summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty-term.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-01-28 11:39:52 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-01-28 11:39:52 +0000
commit47da54884439dbbdedc35c0963e885fa497392d2 (patch)
tree8bf3bbd90bdb2d3f8a90a5ddbc074af9465135e1 /usr.bin/tmux/tty-term.c
parentaaf6fd7a800c15fbb06df1b2528c3753883eec5f (diff)
If we can identify the terminal as iTerm2 or as tmux, we can be sure
they support 256 and RGB colours, so set those flags too.
Diffstat (limited to 'usr.bin/tmux/tty-term.c')
-rw-r--r--usr.bin/tmux/tty-term.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c
index 7f3edd3ecd0..8a08f31fdd3 100644
--- a/usr.bin/tmux/tty-term.c
+++ b/usr.bin/tmux/tty-term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-term.c,v 1.70 2020/01/12 21:07:07 nicm Exp $ */
+/* $OpenBSD: tty-term.c,v 1.71 2020/01/28 11:39:51 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -522,11 +522,16 @@ tty_term_find(char *name, int fd, char **cause)
goto error;
}
- /* Figure out if we have 256 colours (or more). */
- if (tty_term_number(term, TTYC_COLORS) >= 256 ||
- tty_term_has(term, TTYC_RGB))
+ /* Set flag if terminal has 256 colours. */
+ if (tty_term_number(term, TTYC_COLORS) >= 256)
term->flags |= TERM_256COLOURS;
+ /* Set flag if terminal has RGB colours. */
+ if ((tty_term_flag(term, TTYC_TC) || tty_term_has(term, TTYC_RGB)) ||
+ (tty_term_has(term, TTYC_SETRGBF) &&
+ tty_term_has(term, TTYC_SETRGBB)))
+ term->flags |= TERM_RGBCOLOURS;
+
/*
* Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1
* rather than $COLUMNS (the cursor can never be beyond $COLUMNS - 1).
@@ -561,22 +566,7 @@ tty_term_find(char *name, int fd, char **cause)
code->type = TTYCODE_STRING;
}
- /*
- * On terminals with RGB colour (Tc or RGB), fill in setrgbf and
- * setrgbb if they are missing.
- */
- if ((tty_term_flag(term, TTYC_TC) || tty_term_flag(term, TTYC_RGB)) &&
- !tty_term_has(term, TTYC_SETRGBF) &&
- !tty_term_has(term, TTYC_SETRGBB)) {
- code = &term->codes[TTYC_SETRGBF];
- code->value.string = xstrdup("\033[38;2;%p1%d;%p2%d;%p3%dm");
- code->type = TTYCODE_STRING;
- code = &term->codes[TTYC_SETRGBB];
- code->value.string = xstrdup("\033[48;2;%p1%d;%p2%d;%p3%dm");
- code->type = TTYCODE_STRING;
- }
-
- /* Log it. */
+ /* Log the capabilities. */
for (i = 0; i < tty_term_ncodes(); i++)
log_debug("%s%s", name, tty_term_describe(term, i));