1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2015-04-29 18:42:12 +01:00
commit c0cf4843e5
6 changed files with 71 additions and 35 deletions

View File

@ -242,10 +242,13 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs)
struct window_pane *wp; struct window_pane *wp;
/* If this is running in a pane, that's great. */ /* If this is running in a pane, that's great. */
RB_FOREACH(wp, window_pane_tree, &all_window_panes) { if (fs->cmdq->client->tty.path != NULL) {
if (strcmp(wp->tty, fs->cmdq->client->tty.path) == 0) RB_FOREACH(wp, window_pane_tree, &all_window_panes) {
break; if (strcmp(wp->tty, fs->cmdq->client->tty.path) == 0)
} break;
}
} else
wp = NULL;
/* Not running in a pane. We know nothing. Find the best session. */ /* Not running in a pane. We know nothing. Find the best session. */
if (wp == NULL) { if (wp == NULL) {
@ -425,7 +428,20 @@ cmd_find_get_window(struct cmd_find_state *fs, const char *window)
fs->s = fs->current->s; fs->s = fs->current->s;
/* We now only need to find the winlink in this session. */ /* We now only need to find the winlink in this session. */
return (cmd_find_get_window_with_session(fs, window)); if (cmd_find_get_window_with_session(fs, window) == 0)
return (0);
/* Otherwise try as a session itself. */
if (cmd_find_get_session(fs, window) == 0) {
if (~fs->flags & CMD_FIND_WINDOW_INDEX) {
fs->wl = fs->s->curw;
fs->w = fs->wl->window;
fs->idx = fs->wl->idx;
}
return (0);
}
return (-1);
} }
/* /*
@ -591,14 +607,23 @@ cmd_find_get_pane(struct cmd_find_state *fs, const char *pane)
return (cmd_find_best_session_with_window(fs)); return (cmd_find_best_session_with_window(fs));
} }
/* Not a pane id, so use the current session and window. */ /* Not a pane id, so try the current session and window. */
fs->s = fs->current->s; fs->s = fs->current->s;
fs->wl = fs->current->wl; fs->wl = fs->current->wl;
fs->idx = fs->current->idx; fs->idx = fs->current->idx;
fs->w = fs->current->w; fs->w = fs->current->w;
/* We now only need to find the pane in this window. */ /* We now only need to find the pane in this window. */
return (cmd_find_get_pane_with_window(fs, pane)); if (cmd_find_get_pane_with_window(fs, pane) == 0)
return (0);
/* Otherwise try as a window itself (this will also try as session). */
if (cmd_find_get_window(fs, pane) == 0) {
fs->wp = fs->w->active;
return (0);
}
return (-1);
} }
/* /*

View File

@ -100,10 +100,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
wp = window_pane_find_up(wp); wp = window_pane_find_up(wp);
else if (args_has(self->args, 'D')) else if (args_has(self->args, 'D'))
wp = window_pane_find_down(wp); wp = window_pane_find_down(wp);
if (wp == NULL) { if (wp == NULL)
cmdq_error(cmdq, "pane not found"); return (CMD_RETURN_NORMAL);
return (CMD_RETURN_ERROR);
}
if (args_has(self->args, 'e')) { if (args_has(self->args, 'e')) {
wp->flags &= ~PANE_INPUTOFF; wp->flags &= ~PANE_INPUTOFF;

View File

@ -60,6 +60,11 @@ const struct options_table_entry server_options_table[] = {
.default_num = 20 .default_num = 20
}, },
{ .name = "default-terminal",
.type = OPTIONS_TABLE_STRING,
.default_str = "screen"
},
{ .name = "escape-time", { .name = "escape-time",
.type = OPTIONS_TABLE_NUMBER, .type = OPTIONS_TABLE_NUMBER,
.minimum = 0, .minimum = 0,
@ -142,11 +147,6 @@ const struct options_table_entry session_options_table[] = {
.default_str = _PATH_BSHELL .default_str = _PATH_BSHELL
}, },
{ .name = "default-terminal",
.type = OPTIONS_TABLE_STRING,
.default_str = "screen"
},
{ .name = "destroy-unattached", { .name = "destroy-unattached",
.type = OPTIONS_TABLE_FLAG, .type = OPTIONS_TABLE_FLAG,
.default_num = 0 .default_num = 0

View File

@ -36,7 +36,7 @@ server_fill_environ(struct session *s, struct environ *env)
long pid; long pid;
if (s != NULL) { if (s != NULL) {
term = options_get_string(&s->options, "default-terminal"); term = options_get_string(&global_options, "default-terminal");
environ_set(env, "TERM", term); environ_set(env, "TERM", term);
idx = s->id; idx = s->id;

25
tmux.1
View File

@ -2270,6 +2270,19 @@ Available server options are:
Set the number of buffers; as new buffers are added to the top of the stack, Set the number of buffers; as new buffers are added to the top of the stack,
old ones are removed from the bottom if necessary to maintain this maximum old ones are removed from the bottom if necessary to maintain this maximum
length. length.
.It Ic default-terminal Ar terminal
Set the default terminal for new windows created in this session - the
default value of the
.Ev TERM
environment variable.
For
.Nm
to work correctly, this
.Em must
be set to
.Ql screen ,
.Ql tmux
or a derivative of them.
.It Ic escape-time Ar time .It Ic escape-time Ar time
Set the time in milliseconds for which Set the time in milliseconds for which
.Nm .Nm
@ -2409,18 +2422,6 @@ or
This option should be configured when This option should be configured when
.Nm .Nm
is used as a login shell. is used as a login shell.
.It Ic default-terminal Ar terminal
Set the default terminal for new windows created in this session - the
default value of the
.Ev TERM
environment variable.
For
.Nm
to work correctly, this
.Em must
be set to
.Ql screen
or a derivative of it.
.It Xo Ic destroy-unattached .It Xo Ic destroy-unattached
.Op Ic on | off .Op Ic on | off
.Xc .Xc

24
tty.c
View File

@ -34,6 +34,7 @@
void tty_read_callback(struct bufferevent *, void *); void tty_read_callback(struct bufferevent *, void *);
void tty_error_callback(struct bufferevent *, short, void *); void tty_error_callback(struct bufferevent *, short, void *);
void tty_set_italics(struct tty *);
int tty_try_256(struct tty *, u_char, const char *); int tty_try_256(struct tty *, u_char, const char *);
void tty_colours(struct tty *, const struct grid_cell *); void tty_colours(struct tty *, const struct grid_cell *);
@ -456,6 +457,21 @@ tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
tty->cx += width; tty->cx += width;
} }
void
tty_set_italics(struct tty *tty)
{
const char *s;
if (tty_term_has(tty->term, TTYC_SITM)) {
s = options_get_string(&global_options, "default-terminal");
if (strcmp(s, "screen") != 0 && strncmp(s, "screen-", 7) != 0) {
tty_putcode(tty, TTYC_SITM);
return;
}
}
tty_putcode(tty, TTYC_SMSO);
}
void void
tty_set_title(struct tty *tty, const char *title) tty_set_title(struct tty *tty, const char *title)
{ {
@ -1396,12 +1412,8 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
tty_putcode(tty, TTYC_BOLD); tty_putcode(tty, TTYC_BOLD);
if (changed & GRID_ATTR_DIM) if (changed & GRID_ATTR_DIM)
tty_putcode(tty, TTYC_DIM); tty_putcode(tty, TTYC_DIM);
if (changed & GRID_ATTR_ITALICS) { if (changed & GRID_ATTR_ITALICS)
if (tty_term_has(tty->term, TTYC_SITM)) tty_set_italics(tty);
tty_putcode(tty, TTYC_SITM);
else
tty_putcode(tty, TTYC_SMSO);
}
if (changed & GRID_ATTR_UNDERSCORE) if (changed & GRID_ATTR_UNDERSCORE)
tty_putcode(tty, TTYC_SMUL); tty_putcode(tty, TTYC_SMUL);
if (changed & GRID_ATTR_BLINK) if (changed & GRID_ATTR_BLINK)