diff --git a/server-client.c b/server-client.c index ec08ed0e..3c096e12 100644 --- a/server-client.c +++ b/server-client.c @@ -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/tmux.c b/tmux.c index d15b3fe1..add7289e 100644 --- a/tmux.c +++ b/tmux.c @@ -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/tmux.h b/tmux.h index 42badd33..430470d4 100644 --- a/tmux.h +++ b/tmux.h @@ -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/tty-term.c b/tty-term.c index 7add7cab..8a592b31 100644 --- a/tty-term.c +++ b/tty-term.c @@ -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/tty.c b/tty.c index 596779e1..d329e15b 100644 --- a/tty.c +++ b/tty.c @@ -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); }