diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-25 21:11:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-25 21:11:22 +0000 |
commit | 95f341381dcddefb851a3d8a07461a8a37c4df72 (patch) | |
tree | e525bc8c517fb970fd881c18506229e2c1877b5d | |
parent | a9f0985ce71f7768c83b39c36b1ad103dbc112a7 (diff) |
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.
-rw-r--r-- | usr.bin/tmux/server-client.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 10 | ||||
-rw-r--r-- | usr.bin/tmux/tty-term.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 39 |
5 files changed, 32 insertions, 41 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 6c7f9a63531..451b5f81e3d 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.4 2009/10/25 17:51:07 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.5 2009/10/25 21:11:21 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -703,8 +703,6 @@ server_client_msg_identify( c->tty.term_flags |= TERM_256COLOURS; else if (data->flags & IDENTIFY_88COLOURS) c->tty.term_flags |= TERM_88COLOURS; - if (data->flags & IDENTIFY_HASDEFAULTS) - c->tty.term_flags |= TERM_HASDEFAULTS; tty_resize(&c->tty); diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index fe9fc0aad0c..bba33d99dd6 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.51 2009/10/22 10:04:07 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.52 2009/10/25 21:11:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -62,7 +62,7 @@ __dead void usage(void) { fprintf(stderr, - "usage: %s [-28dlquv] [-c shell-command] [-f file] [-L socket-name]\n" + "usage: %s [-28lquv] [-c shell-command] [-f file] [-L socket-name]\n" " [-S socket-path] [command [flags]]\n", __progname); exit(1); @@ -317,9 +317,6 @@ main(int argc, char **argv) xfree(shellcmd); shellcmd = xstrdup(optarg); break; - case 'd': - flags |= IDENTIFY_HASDEFAULTS; - break; case 'f': if (cfg_file != NULL) xfree(cfg_file); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 744b8556d05..0c149af9785 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.146 2009/10/22 19:41:51 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.147 2009/10/25 21:11:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -346,7 +346,6 @@ struct msg_identify_data { #define IDENTIFY_UTF8 0x1 #define IDENTIFY_256COLOURS 0x2 #define IDENTIFY_88COLOURS 0x4 -#define IDENTIFY_HASDEFAULTS 0x8 int flags; }; @@ -908,10 +907,9 @@ struct tty_term { struct tty_code codes[NTTYCODE]; -#define TERM_HASDEFAULTS 0x1 -#define TERM_256COLOURS 0x2 -#define TERM_88COLOURS 0x4 -#define TERM_EARLYWRAP 0x8 +#define TERM_256COLOURS 0x1 +#define TERM_88COLOURS 0x2 +#define TERM_EARLYWRAP 0x4 int flags; SLIST_ENTRY(tty_term) entry; diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c index e3895427918..4a65155c6bf 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.11 2009/10/24 21:18:33 nicm Exp $ */ +/* $OpenBSD: tty-term.c,v 1.12 2009/10/25 21:11:21 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -348,17 +348,6 @@ tty_term_find(char *name, int fd, const char *overrides, char **cause) goto error; } - /* - * Figure out if terminal support default colours. AX is a screen - * extension which indicates this. Also check if op (orig_pair) uses - * the default colours - if it does, this is a good indication the - * terminal supports them. - */ - if (tty_term_flag(term, TTYC_AX)) - term->flags |= TERM_HASDEFAULTS; - if (strcmp(tty_term_string(term, TTYC_OP), "\033[39;49m") == 0) - term->flags |= TERM_HASDEFAULTS; - /* Figure out if we have 256 or 88 colours. */ if (tty_term_number(term, TTYC_COLORS) == 256) term->flags |= TERM_256COLOURS; 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); } |