diff options
author | Thomas Adam <thomas@xteddy.org> | 2015-12-13 16:01:13 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2015-12-13 16:01:13 +0000 |
commit | ae5ddfdc1ae471f13c6d0e94ff4029d4fb29e1f4 (patch) | |
tree | 72ebffc1c0617c28ddc421f24045f148b7d59e36 /cmd-attach-session.c | |
parent | 92f187d1c2d84322860dc595da604260999a52f0 (diff) | |
parent | ff599f4004aaa6aae325ece5cbc996e2dc6f0b4f (diff) | |
download | rtmux-ae5ddfdc1ae471f13c6d0e94ff4029d4fb29e1f4.tar.gz rtmux-ae5ddfdc1ae471f13c6d0e94ff4029d4fb29e1f4.tar.bz2 rtmux-ae5ddfdc1ae471f13c6d0e94ff4029d4fb29e1f4.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-attach-session.c')
-rw-r--r-- | cmd-attach-session.c | 43 |
1 files changed, 10 insertions, 33 deletions
diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 00ced9df..c29e9d1a 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -36,48 +36,27 @@ const struct cmd_entry cmd_attach_session_entry = { "attach-session", "attach", "c:dErt:", 0, 0, "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE, - CMD_STARTSERVER, + CMD_STARTSERVER|CMD_SESSION_T|CMD_PANE_T|CMD_PREFERUNATTACHED, cmd_attach_session_exec }; enum cmd_retval -cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag, - const char *cflag, int Eflag) +cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag, + int Eflag) { - struct session *s; + struct session *s = cmdq->state.tflag.s; struct client *c = cmdq->client, *c_loop; - struct winlink *wl = NULL; - struct window *w = NULL; - struct window_pane *wp = NULL; + struct winlink *wl = cmdq->state.tflag.wl; + struct window_pane *wp = cmdq->state.tflag.wp; const char *update; - char *cause; + char *cause, *cwd; struct format_tree *ft; - char *cwd; if (RB_EMPTY(&sessions)) { cmdq_error(cmdq, "no sessions"); return (CMD_RETURN_ERROR); } - if (tflag == NULL) { - if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) - return (CMD_RETURN_ERROR); - } else if (tflag[strcspn(tflag, ":.")] != '\0') { - if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL) - return (CMD_RETURN_ERROR); - } else { - if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) - return (CMD_RETURN_ERROR); - w = window_find_by_id_str(tflag); - if (w == NULL) { - wp = window_pane_find_by_id_str(tflag); - if (wp != NULL) - w = wp->window; - } - if (w != NULL) - wl = winlink_find_by_window(&s->windows, w); - } - if (c == NULL) return (CMD_RETURN_NORMAL); if (server_client_check_nested(c)) { @@ -94,8 +73,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag, if (cflag != NULL) { ft = format_create(cmdq, 0); - format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, - NULL, NULL); + format_defaults(ft, c, s, wl, wp); cwd = format_expand(ft, cflag); format_free(ft); @@ -176,7 +154,6 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; - return (cmd_attach_session(cmdq, args_get(args, 't'), - args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'), - args_has(args, 'E'))); + return (cmd_attach_session(cmdq, args_has(args, 'd'), + args_has(args, 'r'), args_get(args, 'c'), args_has(args, 'E'))); } |