Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its

use more clearly defined and preparation for some future work).
pull/2172/head
nicm 2020-04-13 10:59:58 +00:00
parent c20eb0c0ae
commit 04cdd03525
62 changed files with 470 additions and 336 deletions

View File

@ -50,10 +50,12 @@ enum cmd_retval
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
int xflag, int rflag, const char *cflag, int Eflag) int xflag, int rflag, const char *cflag, int Eflag)
{ {
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state target;
enum cmd_find_type type; enum cmd_find_type type;
int flags; int flags;
struct client *c = item->client, *c_loop; struct client *c = cmdq_get_client(item), *c_loop;
struct session *s; struct session *s;
struct winlink *wl; struct winlink *wl;
struct window_pane *wp; struct window_pane *wp;
@ -80,11 +82,11 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
type = CMD_FIND_SESSION; type = CMD_FIND_SESSION;
flags = CMD_FIND_PREFER_UNATTACHED; flags = CMD_FIND_PREFER_UNATTACHED;
} }
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0) if (cmd_find_target(&target, item, tflag, type, flags) != 0)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
s = item->target.s; s = target.s;
wl = item->target.wl; wl = target.wl;
wp = item->target.wp; wp = target.wp;
if (wl != NULL) { if (wl != NULL) {
if (wp != NULL) if (wp != NULL)
@ -118,7 +120,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
environ_update(s->options, c->environ, s->environ); environ_update(s->options, c->environ, s->environ);
c->session = s; c->session = s;
if (~item->shared->flags & CMDQ_SHARED_REPEAT) if (~shared->flags & CMDQ_SHARED_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c); tty_update_client_offset(c);
status_timer_start(c); status_timer_start(c);

View File

@ -49,15 +49,18 @@ static enum cmd_retval
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct cmd_find_state *source = cmdq_get_source(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct winlink *wl = item->source.wl; struct winlink *wl = source->wl;
struct session *src_s = item->source.s; struct session *src_s = source->s;
struct session *dst_s = item->target.s; struct session *dst_s = target->s;
struct window_pane *wp = item->source.wp; struct window_pane *wp = source->wp;
struct window *w = wl->window; struct window *w = wl->window;
char *name, *cause; char *name, *cause;
int idx = item->target.idx; int idx = target->idx;
const char *template; const char *template;
char *cp; char *cp;

View File

@ -193,8 +193,8 @@ static enum cmd_retval
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *c = item->client; struct client *c = cmdq_get_client(item);
struct window_pane *wp = item->target.wp; struct window_pane *wp = cmdq_get_target(item)->wp;
char *buf, *cause; char *buf, *cause;
const char *bufname; const char *bufname;
size_t len; size_t len;

View File

@ -72,7 +72,8 @@ static enum cmd_retval
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item) cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct window_pane *wp = item->target.wp; struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp;
const struct window_mode *mode; const struct window_mode *mode;
if (cmd_get_entry(self) == &cmd_choose_buffer_entry) { if (cmd_get_entry(self) == &cmd_choose_buffer_entry) {
@ -86,6 +87,6 @@ cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
} else } else
mode = &window_tree_mode; mode = &window_tree_mode;
window_pane_set_mode(wp, NULL, mode, &item->target, args); window_pane_set_mode(wp, NULL, mode, target, args);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -57,10 +57,12 @@ static enum cmd_retval
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = item->shared; struct cmdq_shared *shared = cmdq_get_shared(item);
struct client *c = item->client; struct cmd_find_state *source = cmdq_get_source(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmdq_get_client(item);
struct session *s; struct session *s;
struct window_pane *wp = item->target.wp, *swp; struct window_pane *wp = target->wp, *swp;
if (args_has(args, 'q')) { if (args_has(args, 'q')) {
window_pane_reset_mode_all(wp); window_pane_reset_mode_all(wp);
@ -80,7 +82,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
} }
if (args_has(args, 's')) if (args_has(args, 's'))
swp = item->source.wp; swp = source->wp;
else else
swp = wp; swp = wp;
if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) { if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) {

View File

@ -57,11 +57,12 @@ const struct cmd_entry cmd_suspend_client_entry = {
static enum cmd_retval static enum cmd_retval
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item) cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *c, *cloop; struct cmd_find_state *source = cmdq_get_source(item);
struct session *s; struct client *c, *cloop;
enum msgtype msgtype; struct session *s;
const char *cmd = args_get(args, 'E'); enum msgtype msgtype;
const char *cmd = args_get(args, 'E');
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL) if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@ -77,7 +78,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
msgtype = MSG_DETACH; msgtype = MSG_DETACH;
if (args_has(args, 's')) { if (args_has(args, 's')) {
s = item->source.s; s = source->s;
if (s == NULL) if (s == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
TAILQ_FOREACH(cloop, &clients, entry) { TAILQ_FOREACH(cloop, &clients, entry) {

View File

@ -65,9 +65,11 @@ static void
cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
struct args *args, u_int *px, u_int *py, u_int w, u_int h) struct args *args, u_int *px, u_int *py, u_int w, u_int h)
{ {
struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = c->session; struct session *s = c->session;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
struct window_pane *wp = item->target.wp; struct window_pane *wp = target->wp;
struct style_ranges *ranges; struct style_ranges *ranges;
struct style_range *sr; struct style_range *sr;
const char *xp, *yp; const char *xp, *yp;
@ -97,9 +99,9 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
*px = wp->xoff - ox; *px = wp->xoff - ox;
else else
*px = 0; *px = 0;
} else if (strcmp(xp, "M") == 0 && item->shared->mouse.valid) { } else if (strcmp(xp, "M") == 0 && shared->mouse.valid) {
if (item->shared->mouse.x > w / 2) if (shared->mouse.x > w / 2)
*px = item->shared->mouse.x - w / 2; *px = shared->mouse.x - w / 2;
else else
*px = 0; *px = 0;
} else if (strcmp(xp, "W") == 0) { } else if (strcmp(xp, "W") == 0) {
@ -131,8 +133,8 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
*py = wp->yoff + wp->sy - oy; *py = wp->yoff + wp->sy - oy;
else else
*py = 0; *py = 0;
} else if (strcmp(yp, "M") == 0 && item->shared->mouse.valid) } else if (strcmp(yp, "M") == 0 && shared->mouse.valid)
*py = item->shared->mouse.y + h; *py = shared->mouse.y + h;
else if (strcmp(yp, "S") == 0) { else if (strcmp(yp, "S") == 0) {
if (options_get_number(s->options, "status-position") == 0) { if (options_get_number(s->options, "status-position") == 0) {
if (lines != 0) if (lines != 0)
@ -172,11 +174,9 @@ static enum cmd_retval
cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c; struct client *c;
struct session *s = item->target.s;
struct winlink *wl = item->target.wl;
struct window_pane *wp = item->target.wp;
struct cmd_find_state *fs = &item->target;
struct menu *menu = NULL; struct menu *menu = NULL;
struct menu_item menu_item; struct menu_item menu_item;
const char *key; const char *key;
@ -190,16 +190,15 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (args_has(args, 'T')) if (args_has(args, 'T'))
title = format_single(item, args_get(args, 'T'), c, s, wl, wp); title = format_single_from_target(item, args_get(args, 'T'), c);
else else
title = xstrdup(""); title = xstrdup("");
menu = menu_create(title); menu = menu_create(title);
for (i = 0; i != args->argc; /* nothing */) { for (i = 0; i != args->argc; /* nothing */) {
name = args->argv[i++]; name = args->argv[i++];
if (*name == '\0') { if (*name == '\0') {
menu_add_item(menu, NULL, item, c, fs); menu_add_item(menu, NULL, item, c, target);
continue; continue;
} }
@ -215,7 +214,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
menu_item.key = key_string_lookup_string(key); menu_item.key = key_string_lookup_string(key);
menu_item.command = args->argv[i++]; menu_item.command = args->argv[i++];
menu_add_item(menu, &menu_item, item, c, fs); menu_add_item(menu, &menu_item, item, c, target);
} }
free(title); free(title);
if (menu == NULL) { if (menu == NULL) {
@ -229,9 +228,9 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4, cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4,
menu->count + 2); menu->count + 2);
if (!item->shared->mouse.valid) if (!shared->mouse.valid)
flags |= MENU_NOMOUSE; flags |= MENU_NOMOUSE;
if (menu_display(menu, flags, item, px, py, c, fs, NULL, NULL) != 0) if (menu_display(menu, flags, item, px, py, c, target, NULL, NULL) != 0)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }
@ -240,8 +239,8 @@ static enum cmd_retval
cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item) cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c; struct client *c;
struct cmd_find_state *fs = &item->target;
const char *value, *cmd = NULL, **lines = NULL; const char *value, *cmd = NULL, **lines = NULL;
const char *shellcmd = NULL; const char *shellcmd = NULL;
char *cwd, *cause; char *cwd, *cause;
@ -278,7 +277,7 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
} }
if (nlines != 0) if (nlines != 0)
w = popup_width(item, nlines, lines, c, fs) + 2; w = popup_width(item, nlines, lines, c, target) + 2;
else else
w = c->tty.sx / 2; w = c->tty.sx / 2;
if (args_has(args, 'w')) { if (args_has(args, 'w')) {
@ -298,13 +297,13 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
value = args_get(args, 'd'); value = args_get(args, 'd');
if (value != NULL) if (value != NULL)
cwd = format_single(item, value, c, fs->s, fs->wl, fs->wp); cwd = format_single_from_target(item, value, c);
else else
cwd = xstrdup(server_client_get_cwd(c, fs->s)); cwd = xstrdup(server_client_get_cwd(c, target->s));
value = args_get(args, 'R'); value = args_get(args, 'R');
if (value != NULL) if (value != NULL)
shellcmd = format_single(item, value, c, fs->s, fs->wl, fs->wp); shellcmd = format_single_from_target(item, value, c);
if (args_has(args, 'K')) if (args_has(args, 'K'))
flags |= POPUP_WRITEKEYS; flags |= POPUP_WRITEKEYS;
@ -313,7 +312,7 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
else if (args_has(args, 'E')) else if (args_has(args, 'E'))
flags |= POPUP_CLOSEEXIT; flags |= POPUP_CLOSEEXIT;
if (popup_display(flags, item, px, py, w, h, nlines, lines, shellcmd, if (popup_display(flags, item, px, py, w, h, nlines, lines, shellcmd,
cmd, cwd, c, fs) != 0) cmd, cwd, c, target) != 0)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);
} }

View File

@ -61,10 +61,11 @@ static enum cmd_retval
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c, *target_c; struct client *c, *target_c;
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
struct window_pane *wp = item->target.wp; struct window_pane *wp = target->wp;
const char *template; const char *template;
char *msg, *cause; char *msg, *cause;
struct format_tree *ft; struct format_tree *ft;
@ -105,7 +106,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
flags = FORMAT_VERBOSE; flags = FORMAT_VERBOSE;
else else
flags = 0; flags = 0;
ft = format_create(item->client, item, FORMAT_NONE, flags); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, flags);
format_defaults(ft, target_c, s, wl, wp); format_defaults(ft, target_c, s, wl, wp);
if (args_has(args, 'a')) { if (args_has(args, 'a')) {

View File

@ -45,7 +45,8 @@ static enum cmd_retval
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self), *new_args; struct args *args = cmd_get_args(self), *new_args;
struct window_pane *wp = item->target.wp; struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp;
const char *s = args->argv[0]; const char *s = args->argv[0];
char *filter, *argv = { NULL }; char *filter, *argv = { NULL };
int C, N, T; int C, N, T;
@ -116,8 +117,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
args_set(new_args, 'Z', NULL); args_set(new_args, 'Z', NULL);
args_set(new_args, 'f', filter); args_set(new_args, 'f', filter);
window_pane_set_mode(wp, NULL, &window_tree_mode, &item->target, window_pane_set_mode(wp, NULL, &window_tree_mode, target, new_args);
new_args);
args_free(new_args); args_free(new_args);
free(filter); free(filter);

View File

@ -961,10 +961,11 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) { if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) {
fs->current = &marked_pane; fs->current = &marked_pane;
log_debug("%s: current is marked pane", __func__); log_debug("%s: current is marked pane", __func__);
} else if (cmd_find_valid_state(&item->shared->current)) { } else if (cmd_find_valid_state(&cmdq_get_shared(item)->current)) {
fs->current = &item->shared->current; fs->current = &cmdq_get_shared(item)->current;
log_debug("%s: current is from queue", __func__); log_debug("%s: current is from queue", __func__);
} else if (cmd_find_from_client(&current, item->client, flags) == 0) { } else if (cmd_find_from_client(&current, cmdq_get_client(item),
flags) == 0) {
fs->current = &current; fs->current = &current;
log_debug("%s: current is from client", __func__); log_debug("%s: current is from client", __func__);
} else { } else {
@ -981,7 +982,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
/* Mouse target is a plain = or {mouse}. */ /* Mouse target is a plain = or {mouse}. */
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) { if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
m = &item->shared->mouse; m = &cmdq_get_shared(item)->mouse;
switch (type) { switch (type) {
case CMD_FIND_PANE: case CMD_FIND_PANE:
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl); fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
@ -1237,7 +1238,7 @@ cmd_find_current_client(struct cmdq_item *item, int quiet)
struct cmd_find_state fs; struct cmd_find_state fs;
if (item != NULL) if (item != NULL)
c = item->client; c = cmdq_get_client(item);
if (c != NULL && c->session != NULL) if (c != NULL && c->session != NULL)
return (c); return (c);

View File

@ -63,20 +63,19 @@ static enum cmd_retval
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct mouse_event *m = &item->shared->mouse; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct mouse_event *m = &shared->mouse;
struct cmd_if_shell_data *cdata; struct cmd_if_shell_data *cdata;
char *shellcmd, *cmd; char *shellcmd, *cmd;
const char *file; const char *file;
struct cmdq_item *new_item; struct cmdq_item *new_item;
struct cmd_find_state *fs = &item->target;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = fs->s; struct session *s = target->s;
struct winlink *wl = fs->wl;
struct window_pane *wp = fs->wp;
struct cmd_parse_input pi; struct cmd_parse_input pi;
struct cmd_parse_result *pr; struct cmd_parse_result *pr;
shellcmd = format_single(item, args->argv[0], c, s, wl, wp); shellcmd = format_single_from_target(item, args->argv[0], c);
if (args_has(args, 'F')) { if (args_has(args, 'F')) {
if (*shellcmd != '0' && *shellcmd != '\0') if (*shellcmd != '0' && *shellcmd != '\0')
cmd = args->argv[1]; cmd = args->argv[1];
@ -92,7 +91,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
cmd_get_source(self, &pi.file, &pi.line); cmd_get_source(self, &pi.file, &pi.line);
pi.item = item; pi.item = item;
pi.c = c; pi.c = c;
cmd_find_copy_state(&pi.fs, fs); cmd_find_copy_state(&pi.fs, target);
pr = cmd_parse_from_string(cmd, &pi); pr = cmd_parse_from_string(cmd, &pi);
switch (pr->status) { switch (pr->status) {
@ -103,7 +102,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
free(pr->error); free(pr->error);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
new_item = cmdq_get_command(pr->cmdlist, fs, m, 0); new_item = cmdq_get_command(pr->cmdlist, target, m, 0);
cmdq_insert_after(item, new_item); cmdq_insert_after(item, new_item);
cmd_list_free(pr->cmdlist); cmd_list_free(pr->cmdlist);
break; break;
@ -121,7 +120,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
memcpy(&cdata->mouse, m, sizeof cdata->mouse); memcpy(&cdata->mouse, m, sizeof cdata->mouse);
if (!args_has(args, 'b')) if (!args_has(args, 'b'))
cdata->client = item->client; cdata->client = cmdq_get_client(item);
else else
cdata->client = c; cdata->client = c;
if (cdata->client != NULL) if (cdata->client != NULL)
@ -139,9 +138,10 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata->input.c = c; cdata->input.c = c;
if (cdata->input.c != NULL) if (cdata->input.c != NULL)
cdata->input.c->references++; cdata->input.c->references++;
cmd_find_copy_state(&cdata->input.fs, fs); cmd_find_copy_state(&cdata->input.fs, target);
if (job_run(shellcmd, s, server_client_get_cwd(item->client, s), NULL, if (job_run(shellcmd, s,
server_client_get_cwd(cmdq_get_client(item), s), NULL,
cmd_if_shell_callback, cmd_if_shell_free, cdata, 0, -1, cmd_if_shell_callback, cmd_if_shell_free, cdata, 0, -1,
-1) == NULL) { -1) == NULL) {
cmdq_error(item, "failed to run command: %s", shellcmd); cmdq_error(item, "failed to run command: %s", shellcmd);

View File

@ -64,7 +64,10 @@ static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct cmd_find_state *source = cmdq_get_source(item);
struct session *dst_s; struct session *dst_s;
struct winlink *src_wl, *dst_wl; struct winlink *src_wl, *dst_wl;
struct window *src_w, *dst_w; struct window *src_w, *dst_w;
@ -80,15 +83,15 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
else else
not_same_window = 0; not_same_window = 0;
dst_s = item->target.s; dst_s = target->s;
dst_wl = item->target.wl; dst_wl = target->wl;
dst_wp = item->target.wp; dst_wp = target->wp;
dst_w = dst_wl->window; dst_w = dst_wl->window;
dst_idx = dst_wl->idx; dst_idx = dst_wl->idx;
server_unzoom_window(dst_w); server_unzoom_window(dst_w);
src_wl = item->source.wl; src_wl = source->wl;
src_wp = item->source.wp; src_wp = source->wp;
src_w = src_wl->window; src_w = src_wl->window;
server_unzoom_window(src_w); server_unzoom_window(src_w);

View File

@ -45,8 +45,9 @@ static enum cmd_retval
cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl; struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *loopwp, *tmpwp, *wp = item->target.wp; struct winlink *wl = target->wl;
struct window_pane *loopwp, *tmpwp, *wp = target->wp;
if (args_has(args, 'a')) { if (args_has(args, 'a')) {
server_unzoom_window(wl->window); server_unzoom_window(wl->window);

View File

@ -45,11 +45,10 @@ const struct cmd_entry cmd_kill_session_entry = {
static enum cmd_retval static enum cmd_retval
cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item) cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct session *s, *sloop, *stmp; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl; struct session *s = target->s, *sloop, *stmp;
struct winlink *wl;
s = item->target.s;
if (args_has(args, 'C')) { if (args_has(args, 'C')) {
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {

View File

@ -56,9 +56,10 @@ static enum cmd_retval
cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item) cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl, *wl2, *wl3; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl, *wl2, *wl3;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = item->target.s; struct session *s = target->s;
if (cmd_get_entry(self) == &cmd_unlink_window_entry) { if (cmd_get_entry(self) == &cmd_unlink_window_entry) {
if (!args_has(args, 'k') && !session_is_linked(s, w)) { if (!args_has(args, 'k') && !session_is_linked(s, w)) {

View File

@ -59,7 +59,7 @@ cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
pb = NULL; pb = NULL;
while ((pb = paste_walk(pb)) != NULL) { while ((pb = paste_walk(pb)) != NULL) {
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults_paste_buffer(ft, pb); format_defaults_paste_buffer(ft, pb);
if (filter != NULL) { if (filter != NULL) {

View File

@ -52,6 +52,7 @@ static enum cmd_retval
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item) cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c; struct client *c;
struct session *s; struct session *s;
struct format_tree *ft; struct format_tree *ft;
@ -60,7 +61,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
char *line; char *line;
if (args_has(args, 't')) if (args_has(args, 't'))
s = item->target.s; s = target->s;
else else
s = NULL; s = NULL;
@ -72,7 +73,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
if (c->session == NULL || (s != NULL && s != c->session)) if (c->session == NULL || (s != NULL && s != c->session))
continue; continue;
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", idx); format_add(ft, "line", "%u", idx);
format_defaults(ft, c, NULL, NULL, NULL); format_defaults(ft, c, NULL, NULL, NULL);

View File

@ -329,7 +329,7 @@ cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
"#{command_list_usage}"; "#{command_list_usage}";
} }
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, NULL, NULL, NULL, NULL); format_defaults(ft, NULL, NULL, NULL, NULL);
for (entryp = cmd_table; *entryp != NULL; entryp++) { for (entryp = cmd_table; *entryp != NULL; entryp++) {

View File

@ -50,9 +50,10 @@ const struct cmd_entry cmd_list_panes_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item) cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct session *s = item->target.s; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = item->target.wl; struct session *s = target->s;
struct winlink *wl = target->wl;
if (args_has(args, 'a')) if (args_has(args, 'a'))
cmd_list_panes_server(self, item); cmd_list_panes_server(self, item);
@ -125,7 +126,7 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
n = 0; n = 0;
TAILQ_FOREACH(wp, &wl->window->panes, entry) { TAILQ_FOREACH(wp, &wl->window->panes, entry) {
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n); format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, wp); format_defaults(ft, NULL, s, wl, wp);

View File

@ -66,7 +66,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
n = 0; n = 0;
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n); format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, NULL, NULL); format_defaults(ft, NULL, s, NULL, NULL);

View File

@ -61,12 +61,13 @@ const struct cmd_entry cmd_list_windows_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item) cmd_list_windows_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
if (args_has(args, 'a')) if (args_has(args, 'a'))
cmd_list_windows_server(self, item); cmd_list_windows_server(self, item);
else else
cmd_list_windows_session(self, item->target.s, item, 0); cmd_list_windows_session(self, target->s, item, 0);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@ -107,7 +108,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
n = 0; n = 0;
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n); format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, NULL); format_defaults(ft, NULL, s, wl, NULL);

View File

@ -86,9 +86,6 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_load_buffer_data *cdata; struct cmd_load_buffer_data *cdata;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s;
struct winlink *wl = item->target.wl;
struct window_pane *wp = item->target.wp;
const char *bufname = args_get(args, 'b'); const char *bufname = args_get(args, 'b');
char *path; char *path;
@ -99,8 +96,8 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
else else
cdata->name = NULL; cdata->name = NULL;
path = format_single(item, args->argv[0], c, s, wl, wp); path = format_single_from_target(item, args->argv[0], c);
file_read(item->client, path, cmd_load_buffer_done, cdata); file_read(cmdq_get_client(item), path, cmd_load_buffer_done, cdata);
free(path); free(path);
return (CMD_RETURN_WAIT); return (CMD_RETURN_WAIT);

View File

@ -64,13 +64,14 @@ const struct cmd_entry cmd_lock_client_entry = {
static enum cmd_retval static enum cmd_retval
cmd_lock_server_exec(struct cmd *self, struct cmdq_item *item) cmd_lock_server_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *c; struct cmd_find_state *target = cmdq_get_target(item);
struct client *c;
if (cmd_get_entry(self) == &cmd_lock_server_entry) if (cmd_get_entry(self) == &cmd_lock_server_entry)
server_lock(); server_lock();
else if (cmd_get_entry(self) == &cmd_lock_session_entry) else if (cmd_get_entry(self) == &cmd_lock_session_entry)
server_lock_session(item->target.s); server_lock_session(target->s);
else { else {
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL) if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);

View File

@ -59,32 +59,34 @@ const struct cmd_entry cmd_link_window_entry = {
static enum cmd_retval static enum cmd_retval
cmd_move_window_exec(struct cmd *self, struct cmdq_item *item) cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
const char *tflag = args_get(args, 't'); struct cmd_find_state *source = cmdq_get_source(item);
struct session *src; struct cmd_find_state target;
struct session *dst; const char *tflag = args_get(args, 't');
struct winlink *wl; struct session *src;
char *cause; struct session *dst;
int idx, kflag, dflag, sflag; struct winlink *wl;
char *cause;
int idx, kflag, dflag, sflag;
if (args_has(args, 'r')) { if (args_has(args, 'r')) {
if (cmd_find_target(&item->target, item, tflag, if (cmd_find_target(&target, item, tflag, CMD_FIND_SESSION,
CMD_FIND_SESSION, CMD_FIND_QUIET) != 0) CMD_FIND_QUIET) != 0)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
session_renumber_windows(item->target.s); session_renumber_windows(target.s);
recalculate_sizes(); recalculate_sizes();
server_status_session(item->target.s); server_status_session(target.s);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (cmd_find_target(&item->target, item, tflag, CMD_FIND_WINDOW, if (cmd_find_target(&target, item, tflag, CMD_FIND_WINDOW,
CMD_FIND_WINDOW_INDEX) != 0) CMD_FIND_WINDOW_INDEX) != 0)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
src = item->source.s; src = source->s;
dst = item->target.s; dst = target.s;
wl = item->source.wl; wl = source->wl;
idx = item->target.idx; idx = target.idx;
kflag = args_has(args, 'k'); kflag = args_has(args, 'k');
dflag = args_has(args, 'd'); dflag = args_has(args, 'd');
@ -95,8 +97,7 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (server_link_window(src, wl, dst, idx, kflag, !dflag, if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
&cause) != 0) {
cmdq_error(item, "can't link window: %s", cause); cmdq_error(item, "can't link window: %s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);

View File

@ -67,7 +67,10 @@ static enum cmd_retval
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *c = item->client; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmdq_get_client(item);
struct session *s, *as, *groupwith; struct session *s, *as, *groupwith;
struct environ *env; struct environ *env;
struct options *oo; struct options *oo;
@ -106,7 +109,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
if (newname != NULL) if (newname != NULL)
as = session_find(newname); as = session_find(newname);
else else
as = item->target.s; as = target->s;
if (as != NULL) { if (as != NULL) {
retval = cmd_attach_session(item, as->name, retval = cmd_attach_session(item, as->name,
args_has(args, 'D'), args_has(args, 'X'), 0, NULL, args_has(args, 'D'), args_has(args, 'X'), 0, NULL,
@ -123,7 +126,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
/* Is this going to be part of a session group? */ /* Is this going to be part of a session group? */
group = args_get(args, 't'); group = args_get(args, 't');
if (group != NULL) { if (group != NULL) {
groupwith = item->target.s; groupwith = target->s;
if (groupwith == NULL) { if (groupwith == NULL) {
if (!session_check_name(group)) { if (!session_check_name(group)) {
cmdq_error(item, "bad group name: %s", group); cmdq_error(item, "bad group name: %s", group);
@ -172,7 +175,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
* over. * over.
*/ */
if (!detached && !already_attached && c->tty.fd != -1) { if (!detached && !already_attached && c->tty.fd != -1) {
if (server_client_check_nested(item->client)) { if (server_client_check_nested(cmdq_get_client(item))) {
cmdq_error(item, "sessions should be nested with care, " cmdq_error(item, "sessions should be nested with care, "
"unset $TMUX to force"); "unset $TMUX to force");
goto fail; goto fail;
@ -314,7 +317,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
} else if (c->session != NULL) } else if (c->session != NULL)
c->last_session = c->session; c->last_session = c->session;
c->session = s; c->session = s;
if (~item->shared->flags & CMDQ_SHARED_REPEAT) if (~shared->flags & CMDQ_SHARED_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c); tty_update_client_offset(c);
status_timer_start(c); status_timer_start(c);
@ -344,7 +347,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
if (!detached) { if (!detached) {
c->flags |= CLIENT_ATTACHED; c->flags |= CLIENT_ATTACHED;
cmd_find_from_session(&item->shared->current, s, 0); cmd_find_from_session(current, s, 0);
} }
cmd_find_from_session(&fs, s, 0); cmd_find_from_session(&fs, s, 0);

View File

@ -52,12 +52,14 @@ static enum cmd_retval
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item) cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
int idx = item->target.idx; int idx = target->idx;
struct winlink *new_wl; struct winlink *new_wl;
char *cause = NULL, *cp; char *cause = NULL, *cp;
const char *template, *add; const char *template, *add;

View File

@ -48,7 +48,8 @@ static enum cmd_retval
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item) cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct window_pane *wp = item->target.wp; struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp;
struct paste_buffer *pb; struct paste_buffer *pb;
const char *sepstr, *bufname, *bufdata, *bufend, *line; const char *sepstr, *bufname, *bufdata, *bufend, *line;
size_t seplen, bufsize; size_t seplen, bufsize;

View File

@ -57,10 +57,11 @@ static enum cmd_retval
cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct window_pane *wp = item->target.wp; struct window_pane *wp = target->wp;
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
char *cmd; char *cmd;
int old_fd, pipe_fd[2], null_fd, in, out; int old_fd, pipe_fd[2], null_fd, in, out;
struct format_tree *ft; struct format_tree *ft;
@ -108,7 +109,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
/* Expand the command. */ /* Expand the command. */
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp); format_defaults(ft, c, s, wl, wp);
cmd = format_expand_time(ft, args->argv[0]); cmd = format_expand_time(ft, args->argv[0]);
format_free(ft); format_free(ft);

View File

@ -25,8 +25,41 @@
#include "tmux.h" #include "tmux.h"
/* Global command queue. */ /* Command queue item type. */
static struct cmdq_list global_queue = TAILQ_HEAD_INITIALIZER(global_queue); enum cmdq_type {
CMDQ_COMMAND,
CMDQ_CALLBACK,
};
/* Command queue item. */
struct cmdq_item {
char *name;
struct cmdq_list *queue;
struct cmdq_item *next;
struct client *client;
enum cmdq_type type;
u_int group;
u_int number;
time_t time;
int flags;
struct cmdq_shared *shared;
struct cmd_find_state source;
struct cmd_find_state target;
struct cmd_list *cmdlist;
struct cmd *cmd;
cmdq_cb cb;
void *data;
TAILQ_ENTRY(cmdq_item) entry;
};
TAILQ_HEAD(cmdq_list, cmdq_item);
/* Get command queue name. */ /* Get command queue name. */
static const char * static const char *
@ -47,9 +80,83 @@ cmdq_name(struct client *c)
static struct cmdq_list * static struct cmdq_list *
cmdq_get(struct client *c) cmdq_get(struct client *c)
{ {
if (c == NULL) static struct cmdq_list *global_queue;
return (&global_queue);
return (&c->queue); if (c == NULL) {
if (global_queue == NULL)
global_queue = cmdq_new();
return (global_queue);
}
return (c->queue);
}
/* Create a queue. */
struct cmdq_list *
cmdq_new(void)
{
struct cmdq_list *queue;
queue = xcalloc (1, sizeof *queue);
TAILQ_INIT (queue);
return (queue);
}
/* Free a queue. */
void
cmdq_free(struct cmdq_list *queue)
{
if (!TAILQ_EMPTY(queue))
fatalx("queue not empty");
free(queue);
}
/* Get item name. */
const char *
cmdq_get_name(struct cmdq_item *item)
{
return (item->name);
}
/* Get item client. */
struct client *
cmdq_get_client(struct cmdq_item *item)
{
return (item->client);
}
/* Get item target. */
struct cmd_find_state *
cmdq_get_target(struct cmdq_item *item)
{
return (&item->target);
}
/* Get item source. */
struct cmd_find_state *
cmdq_get_source(struct cmdq_item *item)
{
return (&item->source);
}
/* Get item shared. */
struct cmdq_shared *
cmdq_get_shared(struct cmdq_item *item)
{
return (item->shared);
}
/* Merge formats from item. */
void
cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft)
{
const struct cmd_entry *entry;
if (item->cmd != NULL) {
entry = cmd_get_entry (item->cmd);
format_add(ft, "command", "%s", entry->name);
}
if (item->shared->formats != NULL)
format_merge(ft, item->shared->formats);
} }
/* Append an item. */ /* Append an item. */

View File

@ -47,11 +47,12 @@ static enum cmd_retval
cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item) cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s; struct session *s = target->s;
char *newname; char *newname;
newname = format_single(item, args->argv[0], c, s, NULL, NULL); newname = format_single_from_target(item, args->argv[0], c);
if (strcmp(newname, s->name) == 0) { if (strcmp(newname, s->name) == 0) {
free(newname); free(newname);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@ -45,13 +45,13 @@ const struct cmd_entry cmd_rename_window_entry = {
static enum cmd_retval static enum cmd_retval
cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item) cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *c = cmd_find_client(item, NULL, 1); struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = item->target.s; struct client *c = cmd_find_client(item, NULL, 1);
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
char *newname; char *newname;
newname = format_single(item, args->argv[0], c, s, wl, NULL); newname = format_single_from_target(item, args->argv[0], c);
window_set_name(wl->window, newname); window_set_name(wl->window, newname);
options_set_number(wl->window->options, "automatic-rename", 0); options_set_number(wl->window->options, "automatic-rename", 0);

View File

@ -50,12 +50,13 @@ static enum cmd_retval
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = item->shared; struct cmdq_shared *shared = cmdq_get_shared(item);
struct window_pane *wp = item->target.wp; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = item->target.wl; struct window_pane *wp = target->wp;
struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct client *c = item->client; struct client *c = cmdq_get_client(item);
struct session *s = item->target.s; struct session *s = target->s;
const char *errstr; const char *errstr;
char *cause; char *cause;
u_int adjust; u_int adjust;

View File

@ -47,9 +47,10 @@ static enum cmd_retval
cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item) cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = item->target.s; struct session *s = target->s;
const char *errstr; const char *errstr;
char *cause; char *cause;
u_int adjust, sx, sy; u_int adjust, sx, sy;

View File

@ -48,10 +48,11 @@ static enum cmd_retval
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc;
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
struct window_pane *wp = item->target.wp; struct window_pane *wp = target->wp;
char *cause = NULL; char *cause = NULL;
const char *add; const char *add;
struct args_value *value; struct args_value *value;

View File

@ -48,9 +48,10 @@ static enum cmd_retval
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item) cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc;
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
char *cause = NULL; char *cause = NULL;
const char *add; const char *add;
struct args_value *value; struct args_value *value;

View File

@ -44,8 +44,10 @@ static enum cmd_retval
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item) cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct winlink *wl = item->target.wl; struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct window_pane *wp, *wp2; struct window_pane *wp, *wp2;
struct layout_cell *lc; struct layout_cell *lc;

View File

@ -90,11 +90,11 @@ static enum cmd_retval
cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item) cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct cmd_run_shell_data *cdata; struct cmd_run_shell_data *cdata;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct window_pane *wp = target->wp;
struct window_pane *wp = item->target.wp;
const char *delay; const char *delay;
double d; double d;
struct timeval tv; struct timeval tv;
@ -102,7 +102,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
if (args->argc != 0) if (args->argc != 0)
cdata->cmd = format_single(item, args->argv[0], c, s, wl, wp); cdata->cmd = format_single_from_target(item, args->argv[0], c);
if (args_has(args, 't') && wp != NULL) if (args_has(args, 't') && wp != NULL)
cdata->wp_id = wp->id; cdata->wp_id = wp->id;
@ -112,7 +112,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
if (!args_has(args, 'b')) if (!args_has(args, 'b'))
cdata->item = item; cdata->item = item;
cdata->cwd = xstrdup(server_client_get_cwd(item->client, s)); cdata->cwd = xstrdup(server_client_get_cwd(cmdq_get_client(item), s));
cdata->s = s; cdata->s = s;
if (s != NULL) if (s != NULL)
session_add_ref(s, __func__); session_add_ref(s, __func__);
@ -197,8 +197,9 @@ cmd_run_shell_callback(struct job *job)
free(msg); free(msg);
if (item != NULL) { if (item != NULL) {
if (item->client != NULL && item->client->session == NULL) if (cmdq_get_client(item) != NULL &&
item->client->retval = retcode; cmdq_get_client(item)->session == NULL)
cmdq_get_client(item)->retval = retcode;
cmdq_continue(item); cmdq_continue(item);
} }
} }

View File

@ -75,9 +75,6 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s;
struct winlink *wl = item->target.wl;
struct window_pane *wp = item->target.wp;
struct paste_buffer *pb; struct paste_buffer *pb;
int flags; int flags;
const char *bufname = args_get(args, 'b'), *bufdata; const char *bufname = args_get(args, 'b'), *bufdata;
@ -101,12 +98,12 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
if (cmd_get_entry(self) == &cmd_show_buffer_entry) if (cmd_get_entry(self) == &cmd_show_buffer_entry)
path = xstrdup("-"); path = xstrdup("-");
else else
path = format_single(item, args->argv[0], c, s, wl, wp); path = format_single_from_target(item, args->argv[0], c);
if (args_has(args, 'a')) if (args_has(args, 'a'))
flags = O_APPEND; flags = O_APPEND;
else else
flags = 0; flags = 0;
file_write(item->client, path, flags, bufdata, bufsize, file_write(cmdq_get_client(item), path, flags, bufdata, bufsize,
cmd_save_buffer_done, item); cmd_save_buffer_done, item);
free(path); free(path);

View File

@ -72,9 +72,10 @@ static enum cmd_retval
cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item) cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct window_pane *wp = item->target.wp; struct window_pane *wp = target->wp;
const char *layoutname; const char *layoutname;
char *oldlayout; char *oldlayout;
int next, previous, layout; int next, previous, layout;

View File

@ -85,12 +85,14 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
const struct cmd_entry *entry = cmd_get_entry(self); const struct cmd_entry *entry = cmd_get_entry(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = item->target.s; struct session *s = target->s;
struct window_pane *wp = item->target.wp, *lastwp, *markedwp; struct window_pane *wp = target->wp, *lastwp, *markedwp;
char *pane_title; char *pane_title;
const char *style; const char *style;
struct style *sy; struct style *sy;

View File

@ -85,9 +85,11 @@ static enum cmd_retval
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item) cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct winlink *wl = item->target.wl; struct cmd_find_state *current = &shared->current;
struct session *s = item->target.s; struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl;
struct session *s = target->s;
int next, previous, last, activity; int next, previous, last, activity;
next = (cmd_get_entry(self) == &cmd_next_window_entry); next = (cmd_get_entry(self) == &cmd_next_window_entry);

View File

@ -60,6 +60,7 @@ static struct cmdq_item *
cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs, cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
struct cmdq_item *item, key_code key) struct cmdq_item *item, key_code key)
{ {
struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = fs->s; struct session *s = fs->s;
struct winlink *wl = fs->wl; struct winlink *wl = fs->wl;
struct window_pane *wp = fs->wp; struct window_pane *wp = fs->wp;
@ -71,7 +72,8 @@ cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
if (wme == NULL || wme->mode->key_table == NULL) { if (wme == NULL || wme->mode->key_table == NULL) {
if (options_get_number(fs->wp->window->options, "xterm-keys")) if (options_get_number(fs->wp->window->options, "xterm-keys"))
key |= KEYC_XTERM; key |= KEYC_XTERM;
if (window_pane_key(wp, item->client, s, wl, key, NULL) != 0) if (window_pane_key(wp, cmdq_get_client(item), s, wl, key,
NULL) != 0)
return (NULL); return (NULL);
return (item); return (item);
} }
@ -80,7 +82,7 @@ cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
bd = key_bindings_get(table, key & ~KEYC_XTERM); bd = key_bindings_get(table, key & ~KEYC_XTERM);
if (bd != NULL) { if (bd != NULL) {
table->references++; table->references++;
item = key_bindings_dispatch(bd, item, c, NULL, &item->target); item = key_bindings_dispatch(bd, item, c, NULL, target);
key_bindings_unref_table(table); key_bindings_unref_table(table);
} }
return (item); return (item);
@ -132,12 +134,13 @@ static enum cmd_retval
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item) cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct cmd_find_state *fs = &item->target; struct window_pane *wp = target->wp;
struct window_pane *wp = item->target.wp; struct session *s = target->s;
struct session *s = item->target.s; struct winlink *wl = target->wl;
struct winlink *wl = item->target.wl; struct mouse_event *m = &shared->mouse;
struct mouse_event *m = &item->shared->mouse;
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
int i; int i;
key_code key; key_code key;
@ -177,7 +180,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "no mouse target"); cmdq_error(item, "no mouse target");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
window_pane_key(wp, item->client, s, wl, m->key, m); window_pane_key(wp, cmdq_get_client(item), s, wl, m->key, m);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@ -186,7 +189,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
key = options_get_number(s->options, "prefix2"); key = options_get_number(s->options, "prefix2");
else else
key = options_get_number(s->options, "prefix"); key = options_get_number(s->options, "prefix");
cmd_send_keys_inject_key(c, fs, item, key); cmd_send_keys_inject_key(c, target, item, key);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
@ -196,8 +199,10 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
} }
for (; np != 0; np--) { for (; np != 0; np--) {
for (i = 0; i < args->argc; i++) for (i = 0; i < args->argc; i++) {
item = cmd_send_keys_inject_string(c, fs, item, args, i); item = cmd_send_keys_inject_string(c, target, item,
args, i);
}
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@ -46,9 +46,10 @@ const struct cmd_entry cmd_set_environment_entry = {
static enum cmd_retval static enum cmd_retval
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item) cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct environ *env; struct cmd_find_state *target = cmdq_get_target(item);
const char *name, *value, *target; struct environ *env;
const char *name, *value, *tflag;
name = args->argv[0]; name = args->argv[0];
if (*name == '\0') { if (*name == '\0') {
@ -68,15 +69,15 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'g')) if (args_has(args, 'g'))
env = global_environ; env = global_environ;
else { else {
if (item->target.s == NULL) { if (target->s == NULL) {
target = args_get(args, 't'); tflag = args_get(args, 't');
if (target != NULL) if (tflag != NULL)
cmdq_error(item, "no such session: %s", target); cmdq_error(item, "no such session: %s", tflag);
else else
cmdq_error(item, "no current session"); cmdq_error(item, "no current session");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
env = item->target.s->environ; env = target->s->environ;
} }
if (args_has(args, 'u')) { if (args_has(args, 'u')) {

View File

@ -83,10 +83,9 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
int append = args_has(args, 'a'); int append = args_has(args, 'a');
struct cmd_find_state *fs = &item->target; struct cmd_find_state *target = cmdq_get_target(item);
struct client *c, *loop; struct client *c, *loop;
struct session *s = fs->s; struct session *s = target->s;
struct winlink *wl = fs->wl;
struct window *w; struct window *w;
struct window_pane *wp; struct window_pane *wp;
struct options *oo; struct options *oo;
@ -100,7 +99,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
/* Expand argument. */ /* Expand argument. */
c = cmd_find_client(item, NULL, 1); c = cmd_find_client(item, NULL, 1);
argument = format_single(item, args->argv[0], c, s, wl, NULL); argument = format_single_from_target(item, args->argv[0], c);
/* If set-hook -R, fire the hook straight away. */ /* If set-hook -R, fire the hook straight away. */
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) { if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) {
@ -123,12 +122,13 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
if (args->argc < 2) if (args->argc < 2)
value = NULL; value = NULL;
else if (args_has(args, 'F')) else if (args_has(args, 'F'))
value = format_single(item, args->argv[1], c, s, wl, NULL); value = format_single_from_target(item, args->argv[1], c);
else else
value = xstrdup(args->argv[1]); value = xstrdup(args->argv[1]);
/* Get the scope and table for the option .*/ /* Get the scope and table for the option .*/
scope = options_scope_from_name(args, window, name, fs, &oo, &cause); scope = options_scope_from_name(args, window, name, target, &oo,
&cause);
if (scope == OPTIONS_TABLE_NONE) { if (scope == OPTIONS_TABLE_NONE) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
goto out; goto out;

View File

@ -98,13 +98,14 @@ static enum cmd_retval
cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item) cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct environ *env; struct environ *env;
struct environ_entry *envent; struct environ_entry *envent;
const char *target; const char *tflag;
if ((target = args_get(args, 't')) != NULL) { if ((tflag = args_get(args, 't')) != NULL) {
if (item->target.s == NULL) { if (target->s == NULL) {
cmdq_error(item, "no such session: %s", target); cmdq_error(item, "no such session: %s", tflag);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
} }
@ -112,15 +113,15 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'g')) if (args_has(args, 'g'))
env = global_environ; env = global_environ;
else { else {
if (item->target.s == NULL) { if (target->s == NULL) {
target = args_get(args, 't'); tflag = args_get(args, 't');
if (target != NULL) if (tflag != NULL)
cmdq_error(item, "no such session: %s", target); cmdq_error(item, "no such session: %s", tflag);
else else
cmdq_error(item, "no current session"); cmdq_error(item, "no current session");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
env = item->target.s->environ; env = target->s->environ;
} }
if (args->argc != 0) { if (args->argc != 0) {

View File

@ -78,10 +78,8 @@ static enum cmd_retval
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item) cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *fs = &item->target; struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s;
struct winlink *wl = item->target.wl;
struct options *oo; struct options *oo;
char *argument, *name = NULL, *cause; char *argument, *name = NULL, *cause;
int window, idx, ambiguous, parent, scope; int window, idx, ambiguous, parent, scope;
@ -90,7 +88,8 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
window = (cmd_get_entry(self) == &cmd_show_window_options_entry); window = (cmd_get_entry(self) == &cmd_show_window_options_entry);
if (args->argc == 0) { if (args->argc == 0) {
scope = options_scope_from_flags(args, window, fs, &oo, &cause); scope = options_scope_from_flags(args, window, target, &oo,
&cause);
if (scope == OPTIONS_TABLE_NONE) { if (scope == OPTIONS_TABLE_NONE) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
@ -100,7 +99,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
} }
return (cmd_show_options_all(self, item, scope, oo)); return (cmd_show_options_all(self, item, scope, oo));
} }
argument = format_single(item, args->argv[0], c, s, wl, NULL); argument = format_single_from_target(item, args->argv[0], c);
name = options_match(argument, &idx, &ambiguous); name = options_match(argument, &idx, &ambiguous);
if (name == NULL) { if (name == NULL) {
@ -112,7 +111,8 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "invalid option: %s", argument); cmdq_error(item, "invalid option: %s", argument);
goto fail; goto fail;
} }
scope = options_scope_from_name(args, window, name, fs, &oo, &cause); scope = options_scope_from_name(args, window, name, target, &oo,
&cause);
if (scope == OPTIONS_TABLE_NONE) { if (scope == OPTIONS_TABLE_NONE) {
if (args_has(args, 'q')) if (args_has(args, 'q'))
goto fail; goto fail;

View File

@ -125,7 +125,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_source_file_data *cdata; struct cmd_source_file_data *cdata;
struct client *c = item->client; struct client *c = cmdq_get_client(item);
enum cmd_retval retval = CMD_RETURN_NORMAL; enum cmd_retval retval = CMD_RETURN_NORMAL;
char *pattern, *cwd; char *pattern, *cwd;
const char *path, *error; const char *path, *error;

View File

@ -54,12 +54,14 @@ static enum cmd_retval
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = item->target.s; struct session *s = target->s;
struct winlink *wl = item->target.wl; struct winlink *wl = target->wl;
struct window_pane *wp = item->target.wp, *new_wp; struct window_pane *wp = target->wp, *new_wp;
enum layout_type type; enum layout_type type;
struct layout_cell *lc; struct layout_cell *lc;
struct cmd_find_state fs; struct cmd_find_state fs;

View File

@ -46,15 +46,17 @@ static enum cmd_retval
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmd_find_state *source = cmdq_get_source(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct window *src_w, *dst_w; struct window *src_w, *dst_w;
struct window_pane *tmp_wp, *src_wp, *dst_wp; struct window_pane *tmp_wp, *src_wp, *dst_wp;
struct layout_cell *src_lc, *dst_lc; struct layout_cell *src_lc, *dst_lc;
u_int sx, sy, xoff, yoff; u_int sx, sy, xoff, yoff;
dst_w = item->target.wl->window; dst_w = target->wl->window;
dst_wp = item->target.wp; dst_wp = target->wp;
src_w = item->source.wl->window; src_w = source->wl->window;
src_wp = item->source.wp; src_wp = source->wp;
if (window_push_zoom(dst_w, args_has(args, 'Z'))) if (window_push_zoom(dst_w, args_has(args, 'Z')))
server_redraw_window(dst_w); server_redraw_window(dst_w);

View File

@ -46,20 +46,19 @@ static enum cmd_retval
cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item) cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct session *src, *dst; struct cmd_find_state *source = cmdq_get_source(item);
struct cmd_find_state *target = cmdq_get_target(item);
struct session *src = source->s, *dst = target->s;
struct session_group *sg_src, *sg_dst; struct session_group *sg_src, *sg_dst;
struct winlink *wl_src, *wl_dst; struct winlink *wl_src = source->wl, *wl_dst = target->wl;
struct window *w_src, *w_dst; struct window *w_src, *w_dst;
wl_src = item->source.wl;
src = item->source.s;
sg_src = session_group_contains(src); sg_src = session_group_contains(src);
wl_dst = item->target.wl;
dst = item->target.s;
sg_dst = session_group_contains(dst); sg_dst = session_group_contains(dst);
if (src != dst && sg_src != NULL && sg_dst != NULL && if (src != dst &&
sg_src != NULL &&
sg_dst != NULL &&
sg_src == sg_dst) { sg_src == sg_dst) {
cmdq_error(item, "can't move window, sessions are grouped"); cmdq_error(item, "can't move window, sessions are grouped");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);

View File

@ -48,6 +48,9 @@ static enum cmd_retval
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item) cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item);
struct cmd_find_state *current = &shared->current;
struct cmd_find_state target;
const char *tflag = args_get(args, 't'); const char *tflag = args_get(args, 't');
enum cmd_find_type type; enum cmd_find_type type;
int flags; int flags;
@ -69,11 +72,11 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
type = CMD_FIND_SESSION; type = CMD_FIND_SESSION;
flags = CMD_FIND_PREFER_UNATTACHED; flags = CMD_FIND_PREFER_UNATTACHED;
} }
if (cmd_find_target(&item->target, item, tflag, type, flags) != 0) if (cmd_find_target(&target, item, tflag, type, flags) != 0)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
s = item->target.s; s = target.s;
wl = item->target.wl; wl = target.wl;
wp = item->target.wp; wp = target.wp;
if (args_has(args, 'r')) if (args_has(args, 'r'))
c->flags ^= CLIENT_READONLY; c->flags ^= CLIENT_READONLY;
@ -111,7 +114,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
} else { } else {
if (item->client == NULL) if (cmdq_get_client(item) == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (wl != NULL && wp != NULL) { if (wl != NULL && wp != NULL) {
w = wl->window; w = wl->window;
@ -124,7 +127,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
} }
if (wl != NULL) { if (wl != NULL) {
session_set_current(s, wl); session_set_current(s, wl);
cmd_find_from_session(&item->shared->current, s, 0); cmd_find_from_session(current, s, 0);
} }
} }
@ -134,7 +137,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
if (c->session != NULL && c->session != s) if (c->session != NULL && c->session != s)
c->last_session = c->session; c->last_session = c->session;
c->session = s; c->session = s;
if (~item->shared->flags & CMDQ_SHARED_REPEAT) if (~shared->flags & CMDQ_SHARED_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c); tty_update_client_offset(c);
status_timer_start(c); status_timer_start(c);

View File

@ -167,7 +167,7 @@ static enum cmd_retval
cmd_wait_for_wait(struct cmdq_item *item, const char *name, cmd_wait_for_wait(struct cmdq_item *item, const char *name,
struct wait_channel *wc) struct wait_channel *wc)
{ {
struct client *c = item->client; struct client *c = cmdq_get_client(item);
struct wait_item *wi; struct wait_item *wi;
if (c == NULL) { if (c == NULL) {
@ -198,7 +198,7 @@ cmd_wait_for_lock(struct cmdq_item *item, const char *name,
{ {
struct wait_item *wi; struct wait_item *wi;
if (item->client == NULL) { if (cmdq_get_client(item) == NULL) {
cmdq_error(item, "not able to lock"); cmdq_error(item, "not able to lock");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@ -42,7 +42,7 @@ control_write(struct client *c, const char *fmt, ...)
static enum cmd_retval static enum cmd_retval
control_error(struct cmdq_item *item, void *data) control_error(struct cmdq_item *item, void *data)
{ {
struct client *c = item->client; struct client *c = cmdq_get_client(item);
char *error = data; char *error = data;
cmdq_guard(item, "begin", 1); cmdq_guard(item, "begin", 1);
@ -86,7 +86,7 @@ control_callback(__unused struct client *c, __unused const char *path,
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0); item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
item->shared->flags |= CMDQ_SHARED_CONTROL; cmdq_get_shared(item)->flags |= CMDQ_SHARED_CONTROL;
cmdq_append(c, item); cmdq_append(c, item);
cmd_list_free(pr->cmdlist); cmd_list_free(pr->cmdlist);
break; break;

View File

@ -1108,8 +1108,8 @@ format_cb_mouse_line(struct format_tree *ft, struct format_entry *fe)
fe->value = s; fe->value = s;
} }
/* Merge a format tree. */ /* Merge one format tree into another. */
static void void
format_merge(struct format_tree *ft, struct format_tree *from) format_merge(struct format_tree *ft, struct format_tree *from)
{ {
struct format_entry *fe; struct format_entry *fe;
@ -1124,21 +1124,16 @@ format_merge(struct format_tree *ft, struct format_tree *from)
static void static void
format_create_add_item(struct format_tree *ft, struct cmdq_item *item) format_create_add_item(struct format_tree *ft, struct cmdq_item *item)
{ {
struct cmdq_shared *shared = cmdq_get_shared(item);
struct mouse_event *m; struct mouse_event *m;
struct window_pane *wp; struct window_pane *wp;
u_int x, y; u_int x, y;
if (item->cmd != NULL) { cmdq_merge_formats(item, ft);
format_add(ft, "command", "%s",
cmd_get_entry (item->cmd)->name);
}
if (item->shared == NULL) if (shared == NULL)
return; return;
if (item->shared->formats != NULL) m = &shared->mouse;
format_merge(ft, item->shared->formats);
m = &item->shared->mouse;
if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) { if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) {
format_add(ft, "mouse_pane", "%%%u", wp->id); format_add(ft, "mouse_pane", "%%%u", wp->id);
if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) { if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) {
@ -2425,7 +2420,7 @@ format_single(struct cmdq_item *item, const char *fmt, struct client *c,
char *expanded; char *expanded;
if (item != NULL) if (item != NULL)
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
else else
ft = format_create(NULL, item, FORMAT_NONE, 0); ft = format_create(NULL, item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp); format_defaults(ft, c, s, wl, wp);
@ -2435,6 +2430,16 @@ format_single(struct cmdq_item *item, const char *fmt, struct client *c,
return (expanded); return (expanded);
} }
/* Expand a single string using target. */
char *
format_single_from_target(struct cmdq_item *item, const char *fmt,
struct client *c)
{
struct cmd_find_state *target = cmdq_get_target(item);
return (format_single(item, fmt, c, target->s, target->wl, target->wp));
}
/* Set defaults for any of arguments that are not NULL. */ /* Set defaults for any of arguments that are not NULL. */
void void
format_defaults(struct format_tree *ft, struct client *c, struct session *s, format_defaults(struct format_tree *ft, struct client *c, struct session *s,

View File

@ -549,7 +549,7 @@ key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
else { else {
new_item = cmdq_get_command(bd->cmdlist, fs, m, 0); new_item = cmdq_get_command(bd->cmdlist, fs, m, 0);
if (bd->flags & KEY_BINDING_REPEAT) if (bd->flags & KEY_BINDING_REPEAT)
new_item->shared->flags |= CMDQ_SHARED_REPEAT; cmdq_get_shared(new_item)->flags |= CMDQ_SHARED_REPEAT;
} }
if (item != NULL) if (item != NULL)
new_item = cmdq_insert_after(item, new_item); new_item = cmdq_insert_after(item, new_item);

2
menu.c
View File

@ -282,7 +282,7 @@ chosen:
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
if (md->item != NULL) if (md->item != NULL)
m = &md->item->shared->mouse; m = &cmdq_get_shared(md->item)->mouse;
else else
m = NULL; m = NULL;
new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0); new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0);

View File

@ -189,17 +189,18 @@ notify_add(const char *name, struct cmd_find_state *fs, struct client *c,
void void
notify_hook(struct cmdq_item *item, const char *name) notify_hook(struct cmdq_item *item, const char *name)
{ {
struct notify_entry ne; struct cmd_find_state *target = cmdq_get_target(item);
struct notify_entry ne;
memset(&ne, 0, sizeof ne); memset(&ne, 0, sizeof ne);
ne.name = name; ne.name = name;
cmd_find_copy_state(&ne.fs, &item->target); cmd_find_copy_state(&ne.fs, target);
ne.client = item->client; ne.client = cmdq_get_client(item);
ne.session = item->target.s; ne.session = target->s;
ne.window = item->target.w; ne.window = target->w;
ne.pane = item->target.wp->id; ne.pane = target->wp->id;
notify_insert_hook(item, &ne); notify_insert_hook(item, &ne);
} }

12
popup.c
View File

@ -64,7 +64,7 @@ popup_write_screen(struct client *c, struct popup_data *pd)
struct format_tree *ft; struct format_tree *ft;
u_int i, y; u_int i, y;
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(c, item, FORMAT_NONE, 0);
if (cmd_find_valid_state(&pd->fs)) if (cmd_find_valid_state(&pd->fs))
format_defaults(ft, c, pd->fs.s, pd->fs.wl, pd->fs.wp); format_defaults(ft, c, pd->fs.s, pd->fs.wl, pd->fs.wp);
else else
@ -152,9 +152,9 @@ popup_free_cb(struct client *c)
if (item != NULL) { if (item != NULL) {
if (pd->ictx != NULL && if (pd->ictx != NULL &&
item->client != NULL && cmdq_get_client(item) != NULL &&
item->client->session == NULL) cmdq_get_client(item)->session == NULL)
item->client->retval = pd->status; cmdq_get_client(item)->retval = pd->status;
cmdq_continue(item); cmdq_continue(item);
} }
server_client_unref(pd->c); server_client_unref(pd->c);
@ -305,7 +305,7 @@ popup_key_cb(struct client *c, struct key_event *event)
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
if (pd->item != NULL) if (pd->item != NULL)
m = &pd->item->shared->mouse; m = &cmdq_get_shared(pd->item)->mouse;
else else
m = NULL; m = NULL;
new_item = cmdq_get_command(pr->cmdlist, fs, m, 0); new_item = cmdq_get_command(pr->cmdlist, fs, m, 0);
@ -382,7 +382,7 @@ popup_width(struct cmdq_item *item, u_int nlines, const char **lines,
struct format_tree *ft; struct format_tree *ft;
u_int i, width = 0, tmpwidth; u_int i, width = 0, tmpwidth;
ft = format_create(item->client, item, FORMAT_NONE, 0); ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
if (fs != NULL && cmd_find_valid_state(fs)) if (fs != NULL && cmd_find_valid_state(fs))
format_defaults(ft, c, fs->s, fs->wl, fs->wp); format_defaults(ft, c, fs->s, fs->wl, fs->wp);
else else

View File

@ -210,7 +210,7 @@ server_client_create(int fd)
c->fd = -1; c->fd = -1;
c->cwd = NULL; c->cwd = NULL;
TAILQ_INIT(&c->queue); c->queue = cmdq_new();
c->tty.fd = -1; c->tty.fd = -1;
c->title = NULL; c->title = NULL;
@ -355,8 +355,7 @@ server_client_free(__unused int fd, __unused short events, void *arg)
log_debug("free client %p (%d references)", c, c->references); log_debug("free client %p (%d references)", c, c->references);
if (!TAILQ_EMPTY(&c->queue)) cmdq_free(c->queue);
fatalx("queue not empty");
if (c->references == 0) { if (c->references == 0) {
free((void *)c->name); free((void *)c->name);
@ -1082,7 +1081,7 @@ server_client_update_latest(struct client *c)
static enum cmd_retval static enum cmd_retval
server_client_key_callback(struct cmdq_item *item, void *data) server_client_key_callback(struct cmdq_item *item, void *data)
{ {
struct client *c = item->client; struct client *c = cmdq_get_client(item);
struct key_event *event = data; struct key_event *event = data;
key_code key = event->key; key_code key = event->key;
struct mouse_event *m = &event->m; struct mouse_event *m = &event->m;
@ -1893,7 +1892,7 @@ server_client_dispatch(struct imsg *imsg, void *arg)
static enum cmd_retval static enum cmd_retval
server_client_command_done(struct cmdq_item *item, __unused void *data) server_client_command_done(struct cmdq_item *item, __unused void *data)
{ {
struct client *c = item->client; struct client *c = cmdq_get_client(item);
if (~c->flags & CLIENT_ATTACHED) if (~c->flags & CLIENT_ATTACHED)
c->flags |= CLIENT_EXIT; c->flags |= CLIENT_EXIT;

19
spawn.c
View File

@ -56,10 +56,10 @@ spawn_log(const char *from, struct spawn_context *sc)
struct session *s = sc->s; struct session *s = sc->s;
struct winlink *wl = sc->wl; struct winlink *wl = sc->wl;
struct window_pane *wp0 = sc->wp0; struct window_pane *wp0 = sc->wp0;
const char *name = cmdq_get_name(sc->item);
char tmp[128]; char tmp[128];
const char *name;
log_debug("%s: %s, flags=%#x", from, sc->item->name, sc->flags); log_debug("%s: %s, flags=%#x", from, name, sc->flags);
if (wl != NULL && wp0 != NULL) if (wl != NULL && wp0 != NULL)
xsnprintf(tmp, sizeof tmp, "wl=%d wp0=%%%u", wl->idx, wp0->id); xsnprintf(tmp, sizeof tmp, "wl=%d wp0=%%%u", wl->idx, wp0->id);
@ -70,18 +70,14 @@ spawn_log(const char *from, struct spawn_context *sc)
else else
xsnprintf(tmp, sizeof tmp, "wl=none wp0=none"); xsnprintf(tmp, sizeof tmp, "wl=none wp0=none");
log_debug("%s: s=$%u %s idx=%d", from, s->id, tmp, sc->idx); log_debug("%s: s=$%u %s idx=%d", from, s->id, tmp, sc->idx);
log_debug("%s: name=%s", from, sc->name == NULL ? "none" : sc->name);
name = sc->name;
if (name == NULL)
name = "none";
log_debug("%s: name=%s", from, name);
} }
struct winlink * struct winlink *
spawn_window(struct spawn_context *sc, char **cause) spawn_window(struct spawn_context *sc, char **cause)
{ {
struct cmdq_item *item = sc->item; struct cmdq_item *item = sc->item;
struct client *c = item->client; struct client *c = cmdq_get_client(item);
struct session *s = sc->s; struct session *s = sc->s;
struct window *w; struct window *w;
struct window_pane *wp; struct window_pane *wp;
@ -207,7 +203,8 @@ struct window_pane *
spawn_pane(struct spawn_context *sc, char **cause) spawn_pane(struct spawn_context *sc, char **cause)
{ {
struct cmdq_item *item = sc->item; struct cmdq_item *item = sc->item;
struct client *c = item->client; struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmdq_get_client(item);
struct session *s = sc->s; struct session *s = sc->s;
struct window *w = sc->wl->window; struct window *w = sc->wl->window;
struct window_pane *new_wp; struct window_pane *new_wp;
@ -230,9 +227,9 @@ spawn_pane(struct spawn_context *sc, char **cause)
* the pane's stored one unless specified. * the pane's stored one unless specified.
*/ */
if (sc->cwd != NULL) if (sc->cwd != NULL)
cwd = format_single(item, sc->cwd, c, item->target.s, NULL, NULL); cwd = format_single(item, sc->cwd, c, target->s, NULL, NULL);
else if (~sc->flags & SPAWN_RESPAWN) else if (~sc->flags & SPAWN_RESPAWN)
cwd = xstrdup(server_client_get_cwd(c, item->target.s)); cwd = xstrdup(server_client_get_cwd(c, target->s));
else else
cwd = NULL; cwd = NULL;

51
tmux.h
View File

@ -1378,12 +1378,6 @@ struct cmd_parse_input {
struct cmd_find_state fs; struct cmd_find_state fs;
}; };
/* Command queue item type. */
enum cmdq_type {
CMDQ_COMMAND,
CMDQ_CALLBACK,
};
/* Command queue item shared state. */ /* Command queue item shared state. */
struct cmdq_shared { struct cmdq_shared {
int references; int references;
@ -1398,39 +1392,13 @@ struct cmdq_shared {
struct cmd_find_state current; struct cmd_find_state current;
}; };
/* Command queue item. */ /* Command queue flags. */
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
struct cmdq_item {
char *name;
struct cmdq_list *queue;
struct cmdq_item *next;
struct client *client;
enum cmdq_type type;
u_int group;
u_int number;
time_t time;
int flags;
#define CMDQ_FIRED 0x1 #define CMDQ_FIRED 0x1
#define CMDQ_WAITING 0x2 #define CMDQ_WAITING 0x2
#define CMDQ_NOHOOKS 0x4 #define CMDQ_NOHOOKS 0x4
struct cmdq_shared *shared; /* Command queue callback. */
struct cmd_find_state source; typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
struct cmd_find_state target;
struct cmd_list *cmdlist;
struct cmd *cmd;
cmdq_cb cb;
void *data;
TAILQ_ENTRY(cmdq_item) entry;
};
TAILQ_HEAD(cmdq_list, cmdq_item);
/* Command definition flag. */ /* Command definition flag. */
struct cmd_entry_flag { struct cmd_entry_flag {
@ -1513,7 +1481,7 @@ typedef void (*overlay_free_cb)(struct client *);
struct client { struct client {
const char *name; const char *name;
struct tmuxpeer *peer; struct tmuxpeer *peer;
struct cmdq_list queue; struct cmdq_list *queue;
pid_t pid; pid_t pid;
int fd; int fd;
@ -1827,6 +1795,7 @@ int format_true(const char *);
struct format_tree *format_create(struct client *, struct cmdq_item *, int, struct format_tree *format_create(struct client *, struct cmdq_item *, int,
int); int);
void format_free(struct format_tree *); void format_free(struct format_tree *);
void format_merge(struct format_tree *, struct format_tree *);
void printflike(3, 4) format_add(struct format_tree *, const char *, void printflike(3, 4) format_add(struct format_tree *, const char *,
const char *, ...); const char *, ...);
void format_each(struct format_tree *, void (*)(const char *, void format_each(struct format_tree *, void (*)(const char *,
@ -1836,6 +1805,8 @@ char *format_expand(struct format_tree *, const char *);
char *format_single(struct cmdq_item *, const char *, char *format_single(struct cmdq_item *, const char *,
struct client *, struct session *, struct winlink *, struct client *, struct session *, struct winlink *,
struct window_pane *); struct window_pane *);
char *format_single_from_target(struct cmdq_item *, const char *,
struct client *);
void format_defaults(struct format_tree *, struct client *, void format_defaults(struct format_tree *, struct client *,
struct session *, struct winlink *, struct window_pane *); struct session *, struct winlink *, struct window_pane *);
void format_defaults_window(struct format_tree *, struct window *); void format_defaults_window(struct format_tree *, struct window *);
@ -2135,6 +2106,14 @@ struct cmd_parse_result *cmd_parse_from_arguments(int, char **,
struct cmd_parse_input *); struct cmd_parse_input *);
/* cmd-queue.c */ /* cmd-queue.c */
struct cmdq_list *cmdq_new(void);
void cmdq_free(struct cmdq_list *);
const char *cmdq_get_name(struct cmdq_item *);
struct client *cmdq_get_client(struct cmdq_item *);
struct cmd_find_state *cmdq_get_target(struct cmdq_item *);
struct cmd_find_state *cmdq_get_source(struct cmdq_item *);
struct cmdq_shared *cmdq_get_shared(struct cmdq_item *);
void cmdq_merge_formats(struct cmdq_item *, struct format_tree *);
struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *,
struct mouse_event *, int); struct mouse_event *, int);
#define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)

View File

@ -1536,7 +1536,7 @@ int
window_pane_start_input(struct window_pane *wp, struct cmdq_item *item, window_pane_start_input(struct window_pane *wp, struct cmdq_item *item,
char **cause) char **cause)
{ {
struct client *c = item->client; struct client *c = cmdq_get_client(item);
struct window_pane_input_data *cdata; struct window_pane_input_data *cdata;
if (~wp->flags & PANE_EMPTY) { if (~wp->flags & PANE_EMPTY) {