version 1.74, 2016/10/16 17:55:14 |
version 1.75, 2016/10/16 19:04:05 |
|
|
|
|
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" |
#define SPLIT_WINDOW_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" |
|
|
static enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *); |
static enum cmd_retval cmd_split_window_exec(struct cmd *, |
|
struct cmdq_item *); |
|
|
const struct cmd_entry cmd_split_window_entry = { |
const struct cmd_entry cmd_split_window_entry = { |
.name = "split-window", |
.name = "split-window", |
|
|
}; |
}; |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct session *s = cmdq->state.tflag.s; |
struct session *s = item->state.tflag.s; |
struct winlink *wl = cmdq->state.tflag.wl; |
struct winlink *wl = item->state.tflag.wl; |
struct window *w = wl->window; |
struct window *w = wl->window; |
struct window_pane *wp = cmdq->state.tflag.wp, *new_wp = NULL; |
struct window_pane *wp = item->state.tflag.wp, *new_wp = NULL; |
struct environ *env; |
struct environ *env; |
const char *cmd, *path, *shell, *template, *cwd, *to_free; |
const char *cmd, *path, *shell, *template, *cwd, *to_free; |
char **argv, *cause, *new_cause, *cp; |
char **argv, *cause, *new_cause, *cp; |
|
|
|
|
to_free = NULL; |
to_free = NULL; |
if (args_has(args, 'c')) { |
if (args_has(args, 'c')) { |
ft = format_create(cmdq, 0); |
ft = format_create(item, 0); |
format_defaults(ft, cmdq->state.c, s, NULL, NULL); |
format_defaults(ft, item->state.c, s, NULL, NULL); |
to_free = cwd = format_expand(ft, args_get(args, 'c')); |
to_free = cwd = format_expand(ft, args_get(args, 'c')); |
format_free(ft); |
format_free(ft); |
} else if (cmdq->client != NULL && cmdq->client->session == NULL) |
} else if (item->client != NULL && item->client->session == NULL) |
cwd = cmdq->client->cwd; |
cwd = item->client->cwd; |
else |
else |
cwd = s->cwd; |
cwd = s->cwd; |
|
|
|
|
layout_assign_pane(lc, new_wp); |
layout_assign_pane(lc, new_wp); |
|
|
path = NULL; |
path = NULL; |
if (cmdq->client != NULL && cmdq->client->session == NULL) |
if (item->client != NULL && item->client->session == NULL) |
envent = environ_find(cmdq->client->environ, "PATH"); |
envent = environ_find(item->client->environ, "PATH"); |
else |
else |
envent = environ_find(s->environ, "PATH"); |
envent = environ_find(s->environ, "PATH"); |
if (envent != NULL) |
if (envent != NULL) |
|
|
if ((template = args_get(args, 'F')) == NULL) |
if ((template = args_get(args, 'F')) == NULL) |
template = SPLIT_WINDOW_TEMPLATE; |
template = SPLIT_WINDOW_TEMPLATE; |
|
|
ft = format_create(cmdq, 0); |
ft = format_create(item, 0); |
format_defaults(ft, cmdq->state.c, s, wl, new_wp); |
format_defaults(ft, item->state.c, s, wl, new_wp); |
|
|
cp = format_expand(ft, template); |
cp = format_expand(ft, template); |
cmdq_print(cmdq, "%s", cp); |
cmdq_print(item, "%s", cp); |
free(cp); |
free(cp); |
|
|
format_free(ft); |
format_free(ft); |
|
|
fs.w = w; |
fs.w = w; |
fs.wp = new_wp; |
fs.wp = new_wp; |
cmd_find_log_state(__func__, &fs); |
cmd_find_log_state(__func__, &fs); |
hooks_insert(s->hooks, cmdq, &fs, "after-split-window"); |
hooks_insert(s->hooks, item, &fs, "after-split-window"); |
|
|
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
|
|
|
|
layout_close_pane(new_wp); |
layout_close_pane(new_wp); |
window_remove_pane(w, new_wp); |
window_remove_pane(w, new_wp); |
} |
} |
cmdq_error(cmdq, "create pane failed: %s", cause); |
cmdq_error(item, "create pane failed: %s", cause); |
free(cause); |
free(cause); |
|
|
if (to_free != NULL) |
if (to_free != NULL) |