diff --git a/server-client.c b/server-client.c index 62645ac6..e89a8ba8 100644 --- a/server-client.c +++ b/server-client.c @@ -1,4 +1,4 @@ -/* $Id: server-client.c,v 1.5 2009-10-28 22:46:15 tcunha Exp $ */ +/* $Id: server-client.c,v 1.6 2009-10-28 22:48:35 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -702,8 +702,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 c1450645..801c1cac 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.180 2009-10-23 17:40:23 tcunha Exp $ */ +/* $Id: tmux.c,v 1.181 2009-10-28 22:48:35 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -71,7 +71,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); @@ -326,9 +326,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 a39001cb..6da8d90d 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.484 2009-10-23 17:49:47 tcunha Exp $ */ +/* $Id: tmux.h,v 1.485 2009-10-28 22:48:35 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -344,7 +344,6 @@ struct msg_identify_data { #define IDENTIFY_UTF8 0x1 #define IDENTIFY_256COLOURS 0x2 #define IDENTIFY_88COLOURS 0x4 -#define IDENTIFY_HASDEFAULTS 0x8 int flags; }; @@ -906,10 +905,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 46e8c462..17107c16 100644 --- a/tty-term.c +++ b/tty-term.c @@ -1,4 +1,4 @@ -/* $Id: tty-term.c,v 1.33 2009-10-25 10:42:08 tcunha Exp $ */ +/* $Id: tty-term.c,v 1.34 2009-10-28 22:48:35 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -347,17 +347,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 b51b4543..4d5d36b7 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.162 2009-10-23 17:28:29 tcunha Exp $ */ +/* $Id: tty.c,v 1.163 2009-10-28 22:48:35 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1241,13 +1241,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); } @@ -1267,12 +1275,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); }