mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 03:08:46 +00:00
Sync OpenBSD patchset 446:
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.
This commit is contained in:
parent
c4637da860
commit
41863470ba
@ -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 <nicm@users.sourceforge.net>
|
||||
@ -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);
|
||||
|
||||
|
7
tmux.c
7
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 <nicm@users.sourceforge.net>
|
||||
@ -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);
|
||||
|
10
tmux.h
10
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 <nicm@users.sourceforge.net>
|
||||
@ -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;
|
||||
|
13
tty-term.c
13
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 <nicm@users.sourceforge.net>
|
||||
@ -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;
|
||||
|
39
tty.c
39
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 <nicm@users.sourceforge.net>
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user