Change terminal-overrides to a server option (now that we have them), it

doesn't make much sense as a session option.
This commit is contained in:
nicm 2014-02-23 00:53:06 +00:00
parent 315d45a0eb
commit f1828921df
8 changed files with 58 additions and 59 deletions

View File

@ -132,7 +132,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
server_redraw_client(cmdq->client);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
} else {
if (server_client_open(cmdq->client, s, &cause) != 0) {
if (server_client_open(cmdq->client, &cause) != 0) {
cmdq_error(cmdq, "open terminal failed: %s", cause);
free(cause);
return (CMD_RETURN_ERROR);

View File

@ -145,7 +145,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
/* Open the terminal if necessary. */
if (!detached && !already_attached) {
if (server_client_open(c, NULL, &cause) != 0) {
if (server_client_open(c, &cause) != 0) {
cmdq_error(cmdq, "open terminal failed: %s", cause);
free(cause);
goto error;

View File

@ -91,6 +91,14 @@ const struct options_table_entry server_options_table[] = {
.default_num = 1
},
{ .name = "terminal-overrides",
.type = OPTIONS_TABLE_STRING,
.default_str = "*256col*:colors=256"
",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
":Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT"
},
{ .name = NULL }
};
@ -466,14 +474,6 @@ const struct options_table_entry session_options_table[] = {
.default_num = 0 /* overridden in main() */
},
{ .name = "terminal-overrides",
.type = OPTIONS_TABLE_STRING,
.default_str = "*256col*:colors=256"
",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
":Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT"
},
{ .name = "update-environment",
.type = OPTIONS_TABLE_STRING,
.default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "

View File

@ -114,11 +114,8 @@ server_client_create(int fd)
/* Open client terminal if needed. */
int
server_client_open(struct client *c, struct session *s, char **cause)
server_client_open(struct client *c, char **cause)
{
struct options *oo = s != NULL ? &s->options : &global_s_options;
char *overrides;
if (c->flags & CLIENT_CONTROL)
return (0);
@ -127,8 +124,7 @@ server_client_open(struct client *c, struct session *s, char **cause)
return (-1);
}
overrides = options_get_string(oo, "terminal-overrides");
if (tty_open(&c->tty, overrides, cause) != 0)
if (tty_open(&c->tty, cause) != 0)
return (-1);
return (0);

72
tmux.1
View File

@ -2161,6 +2161,42 @@ disallowedWindowOps: 20,21,SetXprop
Or changing this property from the
.Xr xterm 1
interactive menu when required.
.It Ic terminal-overrides Ar string
Contains a list of entries which override terminal descriptions read using
.Xr terminfo 5 .
.Ar string
is a comma-separated list of items each a colon-separated string made up of a
terminal type pattern (matched using
.Xr fnmatch 3 )
and a set of
.Em name=value
entries.
.Pp
For example, to set the
.Ql clear
.Xr terminfo 5
entry to
.Ql \ee[H\ee[2J
for all terminal types and the
.Ql dch1
entry to
.Ql \ee[P
for the
.Ql rxvt
terminal type, the option could be set to the string:
.Bd -literal -offset indent
"*:clear=\ee[H\ee[2J,rxvt:dch1=\ee[P"
.Ed
.Pp
The terminal entry value is passed through
.Xr strunvis 3
before interpretation.
The default value forcibly corrects the
.Ql colors
entry for terminals which support 256 colours:
.Bd -literal -offset indent
"*256col*:colors=256,xterm*:XT"
.Ed
.El
.Pp
Available session options are:
@ -2605,42 +2641,6 @@ and
.Ic status-right
strings as UTF-8; notably, this is important for wide characters.
This option defaults to off.
.It Ic terminal-overrides Ar string
Contains a list of entries which override terminal descriptions read using
.Xr terminfo 5 .
.Ar string
is a comma-separated list of items each a colon-separated string made up of a
terminal type pattern (matched using
.Xr fnmatch 3 )
and a set of
.Em name=value
entries.
.Pp
For example, to set the
.Ql clear
.Xr terminfo 5
entry to
.Ql \ee[H\ee[2J
for all terminal types and the
.Ql dch1
entry to
.Ql \ee[P
for the
.Ql rxvt
terminal type, the option could be set to the string:
.Bd -literal -offset indent
"*:clear=\ee[H\ee[2J,rxvt:dch1=\ee[P"
.Ed
.Pp
The terminal entry value is passed through
.Xr strunvis 3
before interpretation.
The default value forcibly corrects the
.Ql colors
entry for terminals which support 256 colours:
.Bd -literal -offset indent
"*256col*:colors=256,xterm*:XT"
.Ed
.It Ic update-environment Ar variables
Set a space-separated string containing a list of environment variables to be
copied into the session environment when a new session is created or an

6
tmux.h
View File

@ -1650,7 +1650,7 @@ void tty_set_title(struct tty *, const char *);
void tty_update_mode(struct tty *, int, struct screen *);
void tty_force_cursor_colour(struct tty *, const char *);
void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
int tty_open(struct tty *, const char *, char **);
int tty_open(struct tty *, char **);
void tty_close(struct tty *);
void tty_free(struct tty *);
void tty_write(
@ -1679,7 +1679,7 @@ void tty_bell(struct tty *);
/* tty-term.c */
extern struct tty_terms tty_terms;
extern const struct tty_term_code_entry tty_term_codes[NTTYCODE];
struct tty_term *tty_term_find(char *, int, const char *, char **);
struct tty_term *tty_term_find(char *, int, char **);
void tty_term_free(struct tty_term *);
int tty_term_has(struct tty_term *, enum tty_code_code);
const char *tty_term_string(struct tty_term *, enum tty_code_code);
@ -1893,7 +1893,7 @@ void server_add_accept(int);
/* server-client.c */
void server_client_handle_key(struct client *, int);
void server_client_create(int);
int server_client_open(struct client *, struct session *, char **);
int server_client_open(struct client *, char **);
void server_client_lost(struct client *);
void server_client_callback(int, short, void *);
void server_client_status_timer(void);

View File

@ -305,7 +305,7 @@ tty_term_override(struct tty_term *term, const char *overrides)
}
struct tty_term *
tty_term_find(char *name, int fd, const char *overrides, char **cause)
tty_term_find(char *name, int fd, char **cause)
{
struct tty_term *term;
const struct tty_term_code_entry *ent;
@ -383,7 +383,10 @@ tty_term_find(char *name, int fd, const char *overrides, char **cause)
break;
}
}
tty_term_override(term, overrides);
/* Apply terminal overrides. */
s = options_get_string(&global_options, "terminal-overrides");
tty_term_override(term, s);
/* Delete curses data. */
del_curterm(cur_term);

4
tty.c
View File

@ -128,7 +128,7 @@ tty_set_size(struct tty *tty, u_int sx, u_int sy) {
}
int
tty_open(struct tty *tty, const char *overrides, char **cause)
tty_open(struct tty *tty, char **cause)
{
char out[64];
int fd;
@ -141,7 +141,7 @@ tty_open(struct tty *tty, const char *overrides, char **cause)
tty->log_fd = fd;
}
tty->term = tty_term_find(tty->termname, tty->fd, overrides, cause);
tty->term = tty_term_find(tty->termname, tty->fd, cause);
if (tty->term == NULL) {
tty_close(tty);
return (-1);