version 1.72, 2017/04/22 08:56:24 |
version 1.73, 2017/04/22 10:22:39 |
|
|
.args = { "c:dErt:", 0, 0 }, |
.args = { "c:dErt:", 0, 0 }, |
.usage = "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE, |
.usage = "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE, |
|
|
.tflag = CMD_SESSION_WITHPANE, |
/* -t is special */ |
|
|
.flags = CMD_STARTSERVER, |
.flags = CMD_STARTSERVER, |
.exec = cmd_attach_session_exec |
.exec = cmd_attach_session_exec |
}; |
}; |
|
|
enum cmd_retval |
enum cmd_retval |
cmd_attach_session(struct cmdq_item *item, int dflag, int rflag, |
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, |
const char *cflag, int Eflag) |
int rflag, const char *cflag, int Eflag) |
{ |
{ |
struct cmd_find_state *current = &item->shared->current; |
struct cmd_find_state *current = &item->shared->current; |
struct session *s = item->state.tflag.s; |
enum cmd_find_type type; |
|
int flags; |
struct client *c = item->client, *c_loop; |
struct client *c = item->client, *c_loop; |
struct winlink *wl = item->state.tflag.wl; |
struct session *s; |
struct window_pane *wp = item->state.tflag.wp; |
struct winlink *wl; |
|
struct window_pane *wp; |
char *cause; |
char *cause; |
|
|
if (RB_EMPTY(&sessions)) { |
if (RB_EMPTY(&sessions)) { |
|
|
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
|
if (tflag != NULL && tflag[strcspn(tflag, ":.")] != '\0') { |
|
type = CMD_FIND_PANE; |
|
flags = 0; |
|
} else { |
|
type = CMD_FIND_SESSION; |
|
flags = CMD_FIND_PREFER_UNATTACHED; |
|
} |
|
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0) |
|
return (CMD_RETURN_ERROR); |
|
s = item->target.s; |
|
wl = item->target.wl; |
|
wp = item->target.wp; |
|
|
if (wl != NULL) { |
if (wl != NULL) { |
if (wp != NULL) |
if (wp != NULL) |
window_set_active_pane(wp->window, wp); |
window_set_active_pane(wp->window, wp); |
|
|
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
|
|
return (cmd_attach_session(item, args_has(args, 'd'), |
return (cmd_attach_session(item, args_get(args, 't'), |
args_has(args, 'r'), args_get(args, 'c'), args_has(args, 'E'))); |
args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'), |
|
args_has(args, 'E'))); |
} |
} |