mirror of
https://github.com/tmux/tmux.git
synced 2024-11-18 10:28:54 +00:00
Sync OpenBSD patchset 1111:
Add a helper function to open the terminal for attach-/new-session.
This commit is contained in:
parent
2f0db58777
commit
1340c012b0
@ -43,7 +43,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
const char *update;
|
const char *update;
|
||||||
char *overrides, *cause;
|
char *cause;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
@ -79,15 +79,8 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
} else {
|
} else {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (server_client_open(ctx->cmdclient, s, &cause) != 0) {
|
||||||
ctx->error(ctx, "not a terminal");
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
overrides =
|
|
||||||
options_get_string(&s->options, "terminal-overrides");
|
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
|
||||||
ctx->error(ctx, "terminal open failed: %s", cause);
|
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
const char *newname, *target, *update, *cwd, *errstr;
|
const char *newname, *target, *update, *cwd, *errstr;
|
||||||
char *overrides, *cmd, *cause;
|
char *cmd, *cause;
|
||||||
int detached, idx;
|
int detached, idx;
|
||||||
u_int sx, sy, i;
|
u_int sx, sy, i;
|
||||||
|
|
||||||
@ -128,14 +128,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
/* Open the terminal if necessary. */
|
/* Open the terminal if necessary. */
|
||||||
if (!detached && ctx->cmdclient != NULL) {
|
if (!detached && ctx->cmdclient != NULL) {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) {
|
||||||
ctx->error(ctx, "not a terminal");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
overrides =
|
|
||||||
options_get_string(&global_s_options, "terminal-overrides");
|
|
||||||
if (tty_open(&ctx->cmdclient->tty, overrides, &cause) != 0) {
|
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -104,6 +104,25 @@ server_client_create(int fd)
|
|||||||
log_debug("new client %d", fd);
|
log_debug("new client %d", fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Open client terminal if needed. */
|
||||||
|
int
|
||||||
|
server_client_open(struct client *c, struct session *s, char **cause)
|
||||||
|
{
|
||||||
|
struct options *oo = s != NULL ? &s->options : &global_s_options;
|
||||||
|
char *overrides;
|
||||||
|
|
||||||
|
if (!(c->flags & CLIENT_TERMINAL)) {
|
||||||
|
*cause = xstrdup ("not a terminal");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
overrides = options_get_string(oo, "terminal-overrides");
|
||||||
|
if (tty_open(&c->tty, overrides, cause) != 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Lost a client. */
|
/* Lost a client. */
|
||||||
void
|
void
|
||||||
server_client_lost(struct client *c)
|
server_client_lost(struct client *c)
|
||||||
|
1
tmux.h
1
tmux.h
@ -1719,6 +1719,7 @@ void server_add_accept(int);
|
|||||||
|
|
||||||
/* server-client.c */
|
/* server-client.c */
|
||||||
void server_client_create(int);
|
void server_client_create(int);
|
||||||
|
int server_client_open(struct client *, struct session *, char **);
|
||||||
void server_client_lost(struct client *);
|
void server_client_lost(struct client *);
|
||||||
void server_client_callback(int, short, void *);
|
void server_client_callback(int, short, void *);
|
||||||
void server_client_status_timer(void);
|
void server_client_status_timer(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user