mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
8f2b5d714a
@ -50,10 +50,12 @@ enum cmd_retval
|
||||
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
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;
|
||||
int flags;
|
||||
struct client *c = item->client, *c_loop;
|
||||
struct client *c = cmdq_get_client(item), *c_loop;
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
struct window_pane *wp;
|
||||
@ -80,11 +82,11 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
type = CMD_FIND_SESSION;
|
||||
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);
|
||||
s = item->target.s;
|
||||
wl = item->target.wl;
|
||||
wp = item->target.wp;
|
||||
s = target.s;
|
||||
wl = target.wl;
|
||||
wp = target.wp;
|
||||
|
||||
if (wl != 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);
|
||||
|
||||
c->session = s;
|
||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||
if (~shared->flags & CMDQ_SHARED_REPEAT)
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
|
@ -49,15 +49,18 @@ static enum cmd_retval
|
||||
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 winlink *wl = item->source.wl;
|
||||
struct session *src_s = item->source.s;
|
||||
struct session *dst_s = item->target.s;
|
||||
struct window_pane *wp = item->source.wp;
|
||||
struct winlink *wl = source->wl;
|
||||
struct session *src_s = source->s;
|
||||
struct session *dst_s = target->s;
|
||||
struct window_pane *wp = source->wp;
|
||||
struct window *w = wl->window;
|
||||
char *name, *cause;
|
||||
int idx = item->target.idx;
|
||||
int idx = target->idx;
|
||||
const char *template;
|
||||
char *cp;
|
||||
|
||||
|
@ -193,8 +193,8 @@ static enum cmd_retval
|
||||
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct client *c = item->client;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct window_pane *wp = cmdq_get_target(item)->wp;
|
||||
char *buf, *cause;
|
||||
const char *bufname;
|
||||
size_t len;
|
||||
|
@ -72,7 +72,8 @@ static enum cmd_retval
|
||||
cmd_choose_tree_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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;
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
@ -57,10 +57,12 @@ static enum cmd_retval
|
||||
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmdq_shared *shared = item->shared;
|
||||
struct client *c = item->client;
|
||||
struct cmdq_shared *shared = cmdq_get_shared(item);
|
||||
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 window_pane *wp = item->target.wp, *swp;
|
||||
struct window_pane *wp = target->wp, *swp;
|
||||
|
||||
if (args_has(args, 'q')) {
|
||||
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'))
|
||||
swp = item->source.wp;
|
||||
swp = source->wp;
|
||||
else
|
||||
swp = wp;
|
||||
if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) {
|
||||
|
@ -57,11 +57,12 @@ const struct cmd_entry cmd_suspend_client_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct client *c, *cloop;
|
||||
struct session *s;
|
||||
enum msgtype msgtype;
|
||||
const char *cmd = args_get(args, 'E');
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *source = cmdq_get_source(item);
|
||||
struct client *c, *cloop;
|
||||
struct session *s;
|
||||
enum msgtype msgtype;
|
||||
const char *cmd = args_get(args, 'E');
|
||||
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
@ -77,7 +78,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
msgtype = MSG_DETACH;
|
||||
|
||||
if (args_has(args, 's')) {
|
||||
s = item->source.s;
|
||||
s = source->s;
|
||||
if (s == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
TAILQ_FOREACH(cloop, &clients, entry) {
|
||||
|
@ -65,9 +65,11 @@ static void
|
||||
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 cmdq_shared *shared = cmdq_get_shared(item);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct session *s = c->session;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window_pane *wp = target->wp;
|
||||
struct style_ranges *ranges;
|
||||
struct style_range *sr;
|
||||
const char *xp, *yp;
|
||||
@ -97,9 +99,9 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
|
||||
*px = wp->xoff - ox;
|
||||
else
|
||||
*px = 0;
|
||||
} else if (strcmp(xp, "M") == 0 && item->shared->mouse.valid) {
|
||||
if (item->shared->mouse.x > w / 2)
|
||||
*px = item->shared->mouse.x - w / 2;
|
||||
} else if (strcmp(xp, "M") == 0 && shared->mouse.valid) {
|
||||
if (shared->mouse.x > w / 2)
|
||||
*px = shared->mouse.x - w / 2;
|
||||
else
|
||||
*px = 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;
|
||||
else
|
||||
*py = 0;
|
||||
} else if (strcmp(yp, "M") == 0 && item->shared->mouse.valid)
|
||||
*py = item->shared->mouse.y + h;
|
||||
} else if (strcmp(yp, "M") == 0 && shared->mouse.valid)
|
||||
*py = shared->mouse.y + h;
|
||||
else if (strcmp(yp, "S") == 0) {
|
||||
if (options_get_number(s->options, "status-position") == 0) {
|
||||
if (lines != 0)
|
||||
@ -172,11 +174,9 @@ static enum cmd_retval
|
||||
cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 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_item menu_item;
|
||||
const char *key;
|
||||
@ -190,16 +190,15 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
||||
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
|
||||
title = xstrdup("");
|
||||
|
||||
menu = menu_create(title);
|
||||
|
||||
for (i = 0; i != args->argc; /* nothing */) {
|
||||
name = args->argv[i++];
|
||||
if (*name == '\0') {
|
||||
menu_add_item(menu, NULL, item, c, fs);
|
||||
menu_add_item(menu, NULL, item, c, target);
|
||||
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.command = args->argv[i++];
|
||||
|
||||
menu_add_item(menu, &menu_item, item, c, fs);
|
||||
menu_add_item(menu, &menu_item, item, c, target);
|
||||
}
|
||||
free(title);
|
||||
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,
|
||||
menu->count + 2);
|
||||
|
||||
if (!item->shared->mouse.valid)
|
||||
if (!shared->mouse.valid)
|
||||
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_WAIT);
|
||||
}
|
||||
@ -240,8 +239,8 @@ static enum cmd_retval
|
||||
cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct client *c;
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
const char *value, *cmd = NULL, **lines = NULL;
|
||||
const char *shellcmd = NULL;
|
||||
char *cwd, *cause;
|
||||
@ -278,7 +277,7 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
if (nlines != 0)
|
||||
w = popup_width(item, nlines, lines, c, fs) + 2;
|
||||
w = popup_width(item, nlines, lines, c, target) + 2;
|
||||
else
|
||||
w = c->tty.sx / 2;
|
||||
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');
|
||||
if (value != NULL)
|
||||
cwd = format_single(item, value, c, fs->s, fs->wl, fs->wp);
|
||||
cwd = format_single_from_target(item, value, c);
|
||||
else
|
||||
cwd = xstrdup(server_client_get_cwd(c, fs->s));
|
||||
cwd = xstrdup(server_client_get_cwd(c, target->s));
|
||||
|
||||
value = args_get(args, 'R');
|
||||
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'))
|
||||
flags |= POPUP_WRITEKEYS;
|
||||
@ -313,7 +312,7 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
else if (args_has(args, 'E'))
|
||||
flags |= POPUP_CLOSEEXIT;
|
||||
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_WAIT);
|
||||
}
|
||||
|
@ -61,10 +61,11 @@ static enum cmd_retval
|
||||
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct client *c, *target_c;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *template;
|
||||
char *msg, *cause;
|
||||
struct format_tree *ft;
|
||||
@ -105,7 +106,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
flags = FORMAT_VERBOSE;
|
||||
else
|
||||
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);
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
|
@ -45,7 +45,8 @@ static enum cmd_retval
|
||||
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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];
|
||||
char *filter, *argv = { NULL };
|
||||
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, 'f', filter);
|
||||
|
||||
window_pane_set_mode(wp, NULL, &window_tree_mode, &item->target,
|
||||
new_args);
|
||||
window_pane_set_mode(wp, NULL, &window_tree_mode, target, new_args);
|
||||
|
||||
args_free(new_args);
|
||||
free(filter);
|
||||
|
11
cmd-find.c
11
cmd-find.c
@ -960,10 +960,11 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
||||
if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) {
|
||||
fs->current = &marked_pane;
|
||||
log_debug("%s: current is marked pane", __func__);
|
||||
} else if (cmd_find_valid_state(&item->shared->current)) {
|
||||
fs->current = &item->shared->current;
|
||||
} else if (cmd_find_valid_state(&cmdq_get_shared(item)->current)) {
|
||||
fs->current = &cmdq_get_shared(item)->current;
|
||||
log_debug("%s: current is from queue", __func__);
|
||||
} else if (cmd_find_from_client(¤t, item->client, flags) == 0) {
|
||||
} else if (cmd_find_from_client(¤t, cmdq_get_client(item),
|
||||
flags) == 0) {
|
||||
fs->current = ¤t;
|
||||
log_debug("%s: current is from client", __func__);
|
||||
} else {
|
||||
@ -980,7 +981,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
||||
|
||||
/* Mouse target is a plain = or {mouse}. */
|
||||
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
|
||||
m = &item->shared->mouse;
|
||||
m = &cmdq_get_shared(item)->mouse;
|
||||
switch (type) {
|
||||
case CMD_FIND_PANE:
|
||||
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
|
||||
@ -1236,7 +1237,7 @@ cmd_find_current_client(struct cmdq_item *item, int quiet)
|
||||
struct cmd_find_state fs;
|
||||
|
||||
if (item != NULL)
|
||||
c = item->client;
|
||||
c = cmdq_get_client(item);
|
||||
if (c != NULL && c->session != NULL)
|
||||
return (c);
|
||||
|
||||
|
@ -63,20 +63,19 @@ static enum cmd_retval
|
||||
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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;
|
||||
char *shellcmd, *cmd;
|
||||
const char *file;
|
||||
struct cmdq_item *new_item;
|
||||
struct cmd_find_state *fs = &item->target;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
struct window_pane *wp = fs->wp;
|
||||
struct session *s = target->s;
|
||||
struct cmd_parse_input pi;
|
||||
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 (*shellcmd != '0' && *shellcmd != '\0')
|
||||
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);
|
||||
pi.item = item;
|
||||
pi.c = c;
|
||||
cmd_find_copy_state(&pi.fs, fs);
|
||||
cmd_find_copy_state(&pi.fs, target);
|
||||
|
||||
pr = cmd_parse_from_string(cmd, &pi);
|
||||
switch (pr->status) {
|
||||
@ -103,7 +102,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
free(pr->error);
|
||||
return (CMD_RETURN_ERROR);
|
||||
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);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
break;
|
||||
@ -121,7 +120,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
memcpy(&cdata->mouse, m, sizeof cdata->mouse);
|
||||
|
||||
if (!args_has(args, 'b'))
|
||||
cdata->client = item->client;
|
||||
cdata->client = cmdq_get_client(item);
|
||||
else
|
||||
cdata->client = c;
|
||||
if (cdata->client != NULL)
|
||||
@ -139,9 +138,10 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cdata->input.c = c;
|
||||
if (cdata->input.c != NULL)
|
||||
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,
|
||||
-1) == NULL) {
|
||||
cmdq_error(item, "failed to run command: %s", shellcmd);
|
||||
|
@ -63,7 +63,10 @@ static enum cmd_retval
|
||||
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 winlink *src_wl, *dst_wl;
|
||||
struct window *src_w, *dst_w;
|
||||
@ -79,15 +82,15 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
else
|
||||
not_same_window = 0;
|
||||
|
||||
dst_s = item->target.s;
|
||||
dst_wl = item->target.wl;
|
||||
dst_wp = item->target.wp;
|
||||
dst_s = target->s;
|
||||
dst_wl = target->wl;
|
||||
dst_wp = target->wp;
|
||||
dst_w = dst_wl->window;
|
||||
dst_idx = dst_wl->idx;
|
||||
server_unzoom_window(dst_w);
|
||||
|
||||
src_wl = item->source.wl;
|
||||
src_wp = item->source.wp;
|
||||
src_wl = source->wl;
|
||||
src_wp = source->wp;
|
||||
src_w = src_wl->window;
|
||||
server_unzoom_window(src_w);
|
||||
|
||||
|
@ -45,8 +45,9 @@ static enum cmd_retval
|
||||
cmd_kill_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *loopwp, *tmpwp, *wp = item->target.wp;
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct winlink *wl = target->wl;
|
||||
struct window_pane *loopwp, *tmpwp, *wp = target->wp;
|
||||
|
||||
if (args_has(args, 'a')) {
|
||||
server_unzoom_window(wl->window);
|
||||
|
@ -45,11 +45,10 @@ const struct cmd_entry cmd_kill_session_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct session *s, *sloop, *stmp;
|
||||
struct winlink *wl;
|
||||
|
||||
s = item->target.s;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct session *s = target->s, *sloop, *stmp;
|
||||
struct winlink *wl;
|
||||
|
||||
if (args_has(args, 'C')) {
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
|
@ -56,9 +56,10 @@ static enum cmd_retval
|
||||
cmd_kill_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 session *s = item->target.s;
|
||||
struct session *s = target->s;
|
||||
|
||||
if (cmd_get_entry(self) == &cmd_unlink_window_entry) {
|
||||
if (!args_has(args, 'k') && !session_is_linked(s, w)) {
|
||||
|
@ -59,7 +59,7 @@ cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
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);
|
||||
|
||||
if (filter != NULL) {
|
||||
|
@ -52,6 +52,7 @@ static enum cmd_retval
|
||||
cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct client *c;
|
||||
struct session *s;
|
||||
struct format_tree *ft;
|
||||
@ -60,7 +61,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
|
||||
char *line;
|
||||
|
||||
if (args_has(args, 't'))
|
||||
s = item->target.s;
|
||||
s = target->s;
|
||||
else
|
||||
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))
|
||||
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_defaults(ft, c, NULL, NULL, NULL);
|
||||
|
||||
|
@ -329,7 +329,7 @@ cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
|
||||
"#{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);
|
||||
|
||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||
|
@ -50,9 +50,10 @@ const struct cmd_entry cmd_list_panes_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_list_panes_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
|
||||
if (args_has(args, 'a'))
|
||||
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;
|
||||
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_defaults(ft, NULL, s, wl, wp);
|
||||
|
||||
|
@ -66,7 +66,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
n = 0;
|
||||
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_defaults(ft, NULL, s, NULL, NULL);
|
||||
|
||||
|
@ -61,12 +61,13 @@ const struct cmd_entry cmd_list_windows_entry = {
|
||||
static enum cmd_retval
|
||||
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'))
|
||||
cmd_list_windows_server(self, item);
|
||||
else
|
||||
cmd_list_windows_session(self, item->target.s, item, 0);
|
||||
cmd_list_windows_session(self, target->s, item, 0);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
@ -107,7 +108,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
|
||||
|
||||
n = 0;
|
||||
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_defaults(ft, NULL, s, wl, NULL);
|
||||
|
||||
|
@ -86,9 +86,6 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_load_buffer_data *cdata;
|
||||
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');
|
||||
char *path;
|
||||
|
||||
@ -99,8 +96,8 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
else
|
||||
cdata->name = NULL;
|
||||
|
||||
path = format_single(item, args->argv[0], c, s, wl, wp);
|
||||
file_read(item->client, path, cmd_load_buffer_done, cdata);
|
||||
path = format_single_from_target(item, args->argv[0], c);
|
||||
file_read(cmdq_get_client(item), path, cmd_load_buffer_done, cdata);
|
||||
free(path);
|
||||
|
||||
return (CMD_RETURN_WAIT);
|
||||
|
@ -64,13 +64,14 @@ const struct cmd_entry cmd_lock_client_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_lock_server_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct client *c;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct client *c;
|
||||
|
||||
if (cmd_get_entry(self) == &cmd_lock_server_entry)
|
||||
server_lock();
|
||||
else if (cmd_get_entry(self) == &cmd_lock_session_entry)
|
||||
server_lock_session(item->target.s);
|
||||
server_lock_session(target->s);
|
||||
else {
|
||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
@ -59,32 +59,34 @@ const struct cmd_entry cmd_link_window_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
const char *tflag = args_get(args, 't');
|
||||
struct session *src;
|
||||
struct session *dst;
|
||||
struct winlink *wl;
|
||||
char *cause;
|
||||
int idx, kflag, dflag, sflag;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *source = cmdq_get_source(item);
|
||||
struct cmd_find_state target;
|
||||
const char *tflag = args_get(args, 't');
|
||||
struct session *src;
|
||||
struct session *dst;
|
||||
struct winlink *wl;
|
||||
char *cause;
|
||||
int idx, kflag, dflag, sflag;
|
||||
|
||||
if (args_has(args, 'r')) {
|
||||
if (cmd_find_target(&item->target, item, tflag,
|
||||
CMD_FIND_SESSION, CMD_FIND_QUIET) != 0)
|
||||
if (cmd_find_target(&target, item, tflag, CMD_FIND_SESSION,
|
||||
CMD_FIND_QUIET) != 0)
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
||||
session_renumber_windows(item->target.s);
|
||||
session_renumber_windows(target.s);
|
||||
recalculate_sizes();
|
||||
server_status_session(item->target.s);
|
||||
server_status_session(target.s);
|
||||
|
||||
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)
|
||||
return (CMD_RETURN_ERROR);
|
||||
src = item->source.s;
|
||||
dst = item->target.s;
|
||||
wl = item->source.wl;
|
||||
idx = item->target.idx;
|
||||
src = source->s;
|
||||
dst = target.s;
|
||||
wl = source->wl;
|
||||
idx = target.idx;
|
||||
|
||||
kflag = args_has(args, 'k');
|
||||
dflag = args_has(args, 'd');
|
||||
@ -95,8 +97,7 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag,
|
||||
&cause) != 0) {
|
||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||
cmdq_error(item, "can't link window: %s", cause);
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
@ -67,7 +67,10 @@ static enum cmd_retval
|
||||
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 environ *env;
|
||||
struct options *oo;
|
||||
@ -106,7 +109,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (newname != NULL)
|
||||
as = session_find(newname);
|
||||
else
|
||||
as = item->target.s;
|
||||
as = target->s;
|
||||
if (as != NULL) {
|
||||
retval = cmd_attach_session(item, as->name,
|
||||
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? */
|
||||
group = args_get(args, 't');
|
||||
if (group != NULL) {
|
||||
groupwith = item->target.s;
|
||||
groupwith = target->s;
|
||||
if (groupwith == NULL) {
|
||||
if (!session_check_name(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.
|
||||
*/
|
||||
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, "
|
||||
"unset $TMUX to force");
|
||||
goto fail;
|
||||
@ -314,7 +317,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
} else if (c->session != NULL)
|
||||
c->last_session = c->session;
|
||||
c->session = s;
|
||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||
if (~shared->flags & CMDQ_SHARED_REPEAT)
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
@ -344,7 +347,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (!detached) {
|
||||
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);
|
||||
|
@ -52,12 +52,14 @@ static enum cmd_retval
|
||||
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
int idx = item->target.idx;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
int idx = target->idx;
|
||||
struct winlink *new_wl;
|
||||
char *cause = NULL, *cp;
|
||||
const char *template, *add;
|
||||
|
@ -47,7 +47,8 @@ static enum cmd_retval
|
||||
cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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;
|
||||
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
||||
size_t seplen, bufsize;
|
||||
|
@ -56,10 +56,11 @@ static enum cmd_retval
|
||||
cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = target->wp;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
char *cmd;
|
||||
int old_fd, pipe_fd[2], null_fd, in, out;
|
||||
struct format_tree *ft;
|
||||
@ -107,7 +108,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
/* 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);
|
||||
cmd = format_expand_time(ft, args->argv[0]);
|
||||
format_free(ft);
|
||||
|
117
cmd-queue.c
117
cmd-queue.c
@ -25,8 +25,41 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/* Global command queue. */
|
||||
static struct cmdq_list global_queue = TAILQ_HEAD_INITIALIZER(global_queue);
|
||||
/* Command queue item type. */
|
||||
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. */
|
||||
static const char *
|
||||
@ -47,9 +80,83 @@ cmdq_name(struct client *c)
|
||||
static struct cmdq_list *
|
||||
cmdq_get(struct client *c)
|
||||
{
|
||||
if (c == NULL)
|
||||
return (&global_queue);
|
||||
return (&c->queue);
|
||||
static struct cmdq_list *global_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. */
|
||||
|
@ -47,11 +47,12 @@ static enum cmd_retval
|
||||
cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 session *s = item->target.s;
|
||||
struct session *s = target->s;
|
||||
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) {
|
||||
free(newname);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
@ -45,13 +45,13 @@ const struct cmd_entry cmd_rename_window_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
char *newname;
|
||||
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 winlink *wl = target->wl;
|
||||
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);
|
||||
options_set_number(wl->window->options, "automatic-rename", 0);
|
||||
|
||||
|
@ -50,12 +50,13 @@ static enum cmd_retval
|
||||
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmdq_shared *shared = item->shared;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct cmdq_shared *shared = cmdq_get_shared(item);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct window_pane *wp = target->wp;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window *w = wl->window;
|
||||
struct client *c = item->client;
|
||||
struct session *s = item->target.s;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct session *s = target->s;
|
||||
const char *errstr;
|
||||
char *cause;
|
||||
u_int adjust;
|
||||
|
@ -47,9 +47,10 @@ static enum cmd_retval
|
||||
cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 session *s = item->target.s;
|
||||
struct session *s = target->s;
|
||||
const char *errstr;
|
||||
char *cause;
|
||||
u_int adjust, sx, sy;
|
||||
|
@ -48,10 +48,11 @@ static enum cmd_retval
|
||||
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct spawn_context sc;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window_pane *wp = target->wp;
|
||||
char *cause = NULL;
|
||||
const char *add;
|
||||
struct args_value *value;
|
||||
|
@ -48,9 +48,10 @@ static enum cmd_retval
|
||||
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct spawn_context sc;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
char *cause = NULL;
|
||||
const char *add;
|
||||
struct args_value *value;
|
||||
|
@ -44,8 +44,10 @@ static enum cmd_retval
|
||||
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct winlink *wl = item->target.wl;
|
||||
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 winlink *wl = target->wl;
|
||||
struct window *w = wl->window;
|
||||
struct window_pane *wp, *wp2;
|
||||
struct layout_cell *lc;
|
||||
|
@ -90,11 +90,11 @@ static enum cmd_retval
|
||||
cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct cmd_run_shell_data *cdata;
|
||||
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 session *s = target->s;
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *delay;
|
||||
double d;
|
||||
struct timeval tv;
|
||||
@ -102,7 +102,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
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)
|
||||
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'))
|
||||
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;
|
||||
if (s != NULL)
|
||||
session_add_ref(s, __func__);
|
||||
@ -197,8 +197,9 @@ cmd_run_shell_callback(struct job *job)
|
||||
free(msg);
|
||||
|
||||
if (item != NULL) {
|
||||
if (item->client != NULL && item->client->session == NULL)
|
||||
item->client->retval = retcode;
|
||||
if (cmdq_get_client(item) != NULL &&
|
||||
cmdq_get_client(item)->session == NULL)
|
||||
cmdq_get_client(item)->retval = retcode;
|
||||
cmdq_continue(item);
|
||||
}
|
||||
}
|
||||
|
@ -74,9 +74,6 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
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;
|
||||
int flags;
|
||||
const char *bufname = args_get(args, 'b'), *bufdata;
|
||||
@ -100,12 +97,12 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (cmd_get_entry(self) == &cmd_show_buffer_entry)
|
||||
path = xstrdup("-");
|
||||
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'))
|
||||
flags = O_APPEND;
|
||||
else
|
||||
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);
|
||||
free(path);
|
||||
|
||||
|
@ -72,9 +72,10 @@ static enum cmd_retval
|
||||
cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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_pane *wp = item->target.wp;
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *layoutname;
|
||||
char *oldlayout;
|
||||
int next, previous, layout;
|
||||
|
@ -85,12 +85,14 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(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 winlink *wl = item->target.wl;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window *w = wl->window;
|
||||
struct session *s = item->target.s;
|
||||
struct window_pane *wp = item->target.wp, *lastwp, *markedwp;
|
||||
struct session *s = target->s;
|
||||
struct window_pane *wp = target->wp, *lastwp, *markedwp;
|
||||
char *pane_title;
|
||||
const char *style;
|
||||
struct style *sy;
|
||||
|
@ -85,9 +85,11 @@ static enum cmd_retval
|
||||
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *current = &item->shared->current;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct session *s = item->target.s;
|
||||
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 winlink *wl = target->wl;
|
||||
struct session *s = target->s;
|
||||
int next, previous, last, activity;
|
||||
|
||||
next = (cmd_get_entry(self) == &cmd_next_window_entry);
|
||||
|
@ -60,6 +60,7 @@ static struct cmdq_item *
|
||||
cmd_send_keys_inject_key(struct client *c, struct cmd_find_state *fs,
|
||||
struct cmdq_item *item, key_code key)
|
||||
{
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
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 (options_get_number(fs->wp->window->options, "xterm-keys"))
|
||||
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 (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);
|
||||
if (bd != NULL) {
|
||||
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);
|
||||
}
|
||||
return (item);
|
||||
@ -132,12 +134,13 @@ static enum cmd_retval
|
||||
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 cmd_find_state *fs = &item->target;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct mouse_event *m = &item->shared->mouse;
|
||||
struct window_pane *wp = target->wp;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
struct mouse_event *m = &shared->mouse;
|
||||
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
|
||||
int i;
|
||||
key_code key;
|
||||
@ -177,7 +180,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cmdq_error(item, "no mouse target");
|
||||
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);
|
||||
}
|
||||
|
||||
@ -186,7 +189,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
key = options_get_number(s->options, "prefix2");
|
||||
else
|
||||
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);
|
||||
}
|
||||
|
||||
@ -196,8 +199,10 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
for (; np != 0; np--) {
|
||||
for (i = 0; i < args->argc; i++)
|
||||
item = cmd_send_keys_inject_string(c, fs, item, args, i);
|
||||
for (i = 0; i < args->argc; i++) {
|
||||
item = cmd_send_keys_inject_string(c, target, item,
|
||||
args, i);
|
||||
}
|
||||
}
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
@ -46,9 +46,10 @@ const struct cmd_entry cmd_set_environment_entry = {
|
||||
static enum cmd_retval
|
||||
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct environ *env;
|
||||
const char *name, *value, *target;
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct environ *env;
|
||||
const char *name, *value, *tflag;
|
||||
|
||||
name = args->argv[0];
|
||||
if (*name == '\0') {
|
||||
@ -68,15 +69,15 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (args_has(args, 'g'))
|
||||
env = global_environ;
|
||||
else {
|
||||
if (item->target.s == NULL) {
|
||||
target = args_get(args, 't');
|
||||
if (target != NULL)
|
||||
cmdq_error(item, "no such session: %s", target);
|
||||
if (target->s == NULL) {
|
||||
tflag = args_get(args, 't');
|
||||
if (tflag != NULL)
|
||||
cmdq_error(item, "no such session: %s", tflag);
|
||||
else
|
||||
cmdq_error(item, "no current session");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
env = item->target.s->environ;
|
||||
env = target->s->environ;
|
||||
}
|
||||
|
||||
if (args_has(args, 'u')) {
|
||||
|
@ -83,10 +83,9 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
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 session *s = fs->s;
|
||||
struct winlink *wl = fs->wl;
|
||||
struct session *s = target->s;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
struct options *oo;
|
||||
@ -100,7 +99,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
/* Expand argument. */
|
||||
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 (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)
|
||||
value = NULL;
|
||||
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
|
||||
value = xstrdup(args->argv[1]);
|
||||
|
||||
/* 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 (args_has(args, 'q'))
|
||||
goto out;
|
||||
|
@ -98,13 +98,14 @@ static enum cmd_retval
|
||||
cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
struct cmd_find_state *target = cmdq_get_target(item);
|
||||
struct environ *env;
|
||||
struct environ_entry *envent;
|
||||
const char *target;
|
||||
const char *tflag;
|
||||
|
||||
if ((target = args_get(args, 't')) != NULL) {
|
||||
if (item->target.s == NULL) {
|
||||
cmdq_error(item, "no such session: %s", target);
|
||||
if ((tflag = args_get(args, 't')) != NULL) {
|
||||
if (target->s == NULL) {
|
||||
cmdq_error(item, "no such session: %s", tflag);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
@ -112,15 +113,15 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (args_has(args, 'g'))
|
||||
env = global_environ;
|
||||
else {
|
||||
if (item->target.s == NULL) {
|
||||
target = args_get(args, 't');
|
||||
if (target != NULL)
|
||||
cmdq_error(item, "no such session: %s", target);
|
||||
if (target->s == NULL) {
|
||||
tflag = args_get(args, 't');
|
||||
if (tflag != NULL)
|
||||
cmdq_error(item, "no such session: %s", tflag);
|
||||
else
|
||||
cmdq_error(item, "no current session");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
env = item->target.s->environ;
|
||||
env = target->s->environ;
|
||||
}
|
||||
|
||||
if (args->argc != 0) {
|
||||
|
@ -77,10 +77,8 @@ static enum cmd_retval
|
||||
cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct options *oo;
|
||||
char *argument, *name = NULL, *cause;
|
||||
int window, idx, ambiguous, parent, scope;
|
||||
@ -89,7 +87,8 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
window = (cmd_get_entry(self) == &cmd_show_window_options_entry);
|
||||
|
||||
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 (args_has(args, 'q'))
|
||||
return (CMD_RETURN_NORMAL);
|
||||
@ -99,7 +98,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
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);
|
||||
if (name == NULL) {
|
||||
@ -111,7 +110,8 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cmdq_error(item, "invalid option: %s", argument);
|
||||
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 (args_has(args, 'q'))
|
||||
goto fail;
|
||||
|
@ -124,7 +124,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = cmd_get_args(self);
|
||||
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;
|
||||
char *pattern, *cwd;
|
||||
const char *path, *error;
|
||||
|
@ -53,12 +53,14 @@ static enum cmd_retval
|
||||
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 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, *new_wp;
|
||||
struct session *s = target->s;
|
||||
struct winlink *wl = target->wl;
|
||||
struct window_pane *wp = target->wp, *new_wp;
|
||||
enum layout_type type;
|
||||
struct layout_cell *lc;
|
||||
struct cmd_find_state fs;
|
||||
|
@ -46,15 +46,17 @@ static enum cmd_retval
|
||||
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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_pane *tmp_wp, *src_wp, *dst_wp;
|
||||
struct layout_cell *src_lc, *dst_lc;
|
||||
u_int sx, sy, xoff, yoff;
|
||||
|
||||
dst_w = item->target.wl->window;
|
||||
dst_wp = item->target.wp;
|
||||
src_w = item->source.wl->window;
|
||||
src_wp = item->source.wp;
|
||||
dst_w = target->wl->window;
|
||||
dst_wp = target->wp;
|
||||
src_w = source->wl->window;
|
||||
src_wp = source->wp;
|
||||
|
||||
if (window_push_zoom(dst_w, args_has(args, 'Z')))
|
||||
server_redraw_window(dst_w);
|
||||
|
@ -46,20 +46,19 @@ static enum cmd_retval
|
||||
cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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 winlink *wl_src, *wl_dst;
|
||||
struct winlink *wl_src = source->wl, *wl_dst = target->wl;
|
||||
struct window *w_src, *w_dst;
|
||||
|
||||
wl_src = item->source.wl;
|
||||
src = item->source.s;
|
||||
sg_src = session_group_contains(src);
|
||||
|
||||
wl_dst = item->target.wl;
|
||||
dst = item->target.s;
|
||||
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) {
|
||||
cmdq_error(item, "can't move window, sessions are grouped");
|
||||
return (CMD_RETURN_ERROR);
|
||||
|
@ -48,6 +48,9 @@ static enum cmd_retval
|
||||
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
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');
|
||||
enum cmd_find_type type;
|
||||
int flags;
|
||||
@ -69,11 +72,11 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
type = CMD_FIND_SESSION;
|
||||
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);
|
||||
s = item->target.s;
|
||||
wl = item->target.wl;
|
||||
wp = item->target.wp;
|
||||
s = target.s;
|
||||
wl = target.wl;
|
||||
wp = target.wp;
|
||||
|
||||
if (args_has(args, 'r'))
|
||||
c->flags ^= CLIENT_READONLY;
|
||||
@ -111,7 +114,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (item->client == NULL)
|
||||
if (cmdq_get_client(item) == NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
if (wl != NULL && wp != NULL) {
|
||||
w = wl->window;
|
||||
@ -124,7 +127,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
if (wl != NULL) {
|
||||
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)
|
||||
c->last_session = c->session;
|
||||
c->session = s;
|
||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||
if (~shared->flags & CMDQ_SHARED_REPEAT)
|
||||
server_client_set_key_table(c, NULL);
|
||||
tty_update_client_offset(c);
|
||||
status_timer_start(c);
|
||||
|
@ -167,7 +167,7 @@ static enum cmd_retval
|
||||
cmd_wait_for_wait(struct cmdq_item *item, const char *name,
|
||||
struct wait_channel *wc)
|
||||
{
|
||||
struct client *c = item->client;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct wait_item *wi;
|
||||
|
||||
if (c == NULL) {
|
||||
@ -198,7 +198,7 @@ cmd_wait_for_lock(struct cmdq_item *item, const char *name,
|
||||
{
|
||||
struct wait_item *wi;
|
||||
|
||||
if (item->client == NULL) {
|
||||
if (cmdq_get_client(item) == NULL) {
|
||||
cmdq_error(item, "not able to lock");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ control_write(struct client *c, const char *fmt, ...)
|
||||
static enum cmd_retval
|
||||
control_error(struct cmdq_item *item, void *data)
|
||||
{
|
||||
struct client *c = item->client;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
char *error = data;
|
||||
|
||||
cmdq_guard(item, "begin", 1);
|
||||
@ -86,7 +86,7 @@ control_callback(__unused struct client *c, __unused const char *path,
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
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);
|
||||
cmd_list_free(pr->cmdlist);
|
||||
break;
|
||||
|
29
format.c
29
format.c
@ -1108,8 +1108,8 @@ format_cb_mouse_line(struct format_tree *ft, struct format_entry *fe)
|
||||
fe->value = s;
|
||||
}
|
||||
|
||||
/* Merge a format tree. */
|
||||
static void
|
||||
/* Merge one format tree into another. */
|
||||
void
|
||||
format_merge(struct format_tree *ft, struct format_tree *from)
|
||||
{
|
||||
struct format_entry *fe;
|
||||
@ -1124,21 +1124,16 @@ format_merge(struct format_tree *ft, struct format_tree *from)
|
||||
static void
|
||||
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 window_pane *wp;
|
||||
u_int x, y;
|
||||
|
||||
if (item->cmd != NULL) {
|
||||
format_add(ft, "command", "%s",
|
||||
cmd_get_entry (item->cmd)->name);
|
||||
}
|
||||
cmdq_merge_formats(item, ft);
|
||||
|
||||
if (item->shared == NULL)
|
||||
if (shared == NULL)
|
||||
return;
|
||||
if (item->shared->formats != NULL)
|
||||
format_merge(ft, item->shared->formats);
|
||||
|
||||
m = &item->shared->mouse;
|
||||
m = &shared->mouse;
|
||||
if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) {
|
||||
format_add(ft, "mouse_pane", "%%%u", wp->id);
|
||||
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;
|
||||
|
||||
if (item != NULL)
|
||||
ft = format_create(item->client, item, FORMAT_NONE, 0);
|
||||
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
|
||||
else
|
||||
ft = format_create(NULL, item, FORMAT_NONE, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
void
|
||||
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
|
||||
|
@ -549,7 +549,7 @@ key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
|
||||
else {
|
||||
new_item = cmdq_get_command(bd->cmdlist, fs, m, 0);
|
||||
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)
|
||||
new_item = cmdq_insert_after(item, new_item);
|
||||
|
2
menu.c
2
menu.c
@ -282,7 +282,7 @@ chosen:
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
if (md->item != NULL)
|
||||
m = &md->item->shared->mouse;
|
||||
m = &cmdq_get_shared(md->item)->mouse;
|
||||
else
|
||||
m = NULL;
|
||||
new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0);
|
||||
|
13
notify.c
13
notify.c
@ -188,17 +188,18 @@ notify_add(const char *name, struct cmd_find_state *fs, struct client *c,
|
||||
void
|
||||
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);
|
||||
|
||||
ne.name = name;
|
||||
cmd_find_copy_state(&ne.fs, &item->target);
|
||||
cmd_find_copy_state(&ne.fs, target);
|
||||
|
||||
ne.client = item->client;
|
||||
ne.session = item->target.s;
|
||||
ne.window = item->target.w;
|
||||
ne.pane = item->target.wp->id;
|
||||
ne.client = cmdq_get_client(item);
|
||||
ne.session = target->s;
|
||||
ne.window = target->w;
|
||||
ne.pane = target->wp->id;
|
||||
|
||||
notify_insert_hook(item, &ne);
|
||||
}
|
||||
|
12
popup.c
12
popup.c
@ -64,7 +64,7 @@ popup_write_screen(struct client *c, struct popup_data *pd)
|
||||
struct format_tree *ft;
|
||||
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))
|
||||
format_defaults(ft, c, pd->fs.s, pd->fs.wl, pd->fs.wp);
|
||||
else
|
||||
@ -152,9 +152,9 @@ popup_free_cb(struct client *c)
|
||||
|
||||
if (item != NULL) {
|
||||
if (pd->ictx != NULL &&
|
||||
item->client != NULL &&
|
||||
item->client->session == NULL)
|
||||
item->client->retval = pd->status;
|
||||
cmdq_get_client(item) != NULL &&
|
||||
cmdq_get_client(item)->session == NULL)
|
||||
cmdq_get_client(item)->retval = pd->status;
|
||||
cmdq_continue(item);
|
||||
}
|
||||
server_client_unref(pd->c);
|
||||
@ -305,7 +305,7 @@ popup_key_cb(struct client *c, struct key_event *event)
|
||||
break;
|
||||
case CMD_PARSE_SUCCESS:
|
||||
if (pd->item != NULL)
|
||||
m = &pd->item->shared->mouse;
|
||||
m = &cmdq_get_shared(pd->item)->mouse;
|
||||
else
|
||||
m = NULL;
|
||||
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;
|
||||
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))
|
||||
format_defaults(ft, c, fs->s, fs->wl, fs->wp);
|
||||
else
|
||||
|
@ -208,7 +208,7 @@ server_client_create(int fd)
|
||||
c->fd = -1;
|
||||
c->cwd = NULL;
|
||||
|
||||
TAILQ_INIT(&c->queue);
|
||||
c->queue = cmdq_new();
|
||||
|
||||
c->tty.fd = -1;
|
||||
c->title = NULL;
|
||||
@ -353,8 +353,7 @@ server_client_free(__unused int fd, __unused short events, void *arg)
|
||||
|
||||
log_debug("free client %p (%d references)", c, c->references);
|
||||
|
||||
if (!TAILQ_EMPTY(&c->queue))
|
||||
fatalx("queue not empty");
|
||||
cmdq_free(c->queue);
|
||||
|
||||
if (c->references == 0) {
|
||||
free((void *)c->name);
|
||||
@ -1080,7 +1079,7 @@ server_client_update_latest(struct client *c)
|
||||
static enum cmd_retval
|
||||
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;
|
||||
key_code key = event->key;
|
||||
struct mouse_event *m = &event->m;
|
||||
@ -1891,7 +1890,7 @@ server_client_dispatch(struct imsg *imsg, void *arg)
|
||||
static enum cmd_retval
|
||||
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)
|
||||
c->flags |= CLIENT_EXIT;
|
||||
|
19
spawn.c
19
spawn.c
@ -54,10 +54,10 @@ spawn_log(const char *from, struct spawn_context *sc)
|
||||
struct session *s = sc->s;
|
||||
struct winlink *wl = sc->wl;
|
||||
struct window_pane *wp0 = sc->wp0;
|
||||
const char *name = cmdq_get_name(sc->item);
|
||||
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)
|
||||
xsnprintf(tmp, sizeof tmp, "wl=%d wp0=%%%u", wl->idx, wp0->id);
|
||||
@ -68,18 +68,14 @@ spawn_log(const char *from, struct spawn_context *sc)
|
||||
else
|
||||
xsnprintf(tmp, sizeof tmp, "wl=none wp0=none");
|
||||
log_debug("%s: s=$%u %s idx=%d", from, s->id, tmp, sc->idx);
|
||||
|
||||
name = sc->name;
|
||||
if (name == NULL)
|
||||
name = "none";
|
||||
log_debug("%s: name=%s", from, name);
|
||||
log_debug("%s: name=%s", from, sc->name == NULL ? "none" : sc->name);
|
||||
}
|
||||
|
||||
struct winlink *
|
||||
spawn_window(struct spawn_context *sc, char **cause)
|
||||
{
|
||||
struct cmdq_item *item = sc->item;
|
||||
struct client *c = item->client;
|
||||
struct client *c = cmdq_get_client(item);
|
||||
struct session *s = sc->s;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
@ -205,7 +201,8 @@ struct window_pane *
|
||||
spawn_pane(struct spawn_context *sc, char **cause)
|
||||
{
|
||||
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 window *w = sc->wl->window;
|
||||
struct window_pane *new_wp;
|
||||
@ -228,9 +225,9 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
||||
* the pane's stored one unless specified.
|
||||
*/
|
||||
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)
|
||||
cwd = xstrdup(server_client_get_cwd(c, item->target.s));
|
||||
cwd = xstrdup(server_client_get_cwd(c, target->s));
|
||||
else
|
||||
cwd = NULL;
|
||||
|
||||
|
51
tmux.h
51
tmux.h
@ -1380,12 +1380,6 @@ struct cmd_parse_input {
|
||||
struct cmd_find_state fs;
|
||||
};
|
||||
|
||||
/* Command queue item type. */
|
||||
enum cmdq_type {
|
||||
CMDQ_COMMAND,
|
||||
CMDQ_CALLBACK,
|
||||
};
|
||||
|
||||
/* Command queue item shared state. */
|
||||
struct cmdq_shared {
|
||||
int references;
|
||||
@ -1400,39 +1394,13 @@ struct cmdq_shared {
|
||||
struct cmd_find_state current;
|
||||
};
|
||||
|
||||
/* Command queue item. */
|
||||
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;
|
||||
/* Command queue flags. */
|
||||
#define CMDQ_FIRED 0x1
|
||||
#define CMDQ_WAITING 0x2
|
||||
#define CMDQ_NOHOOKS 0x4
|
||||
|
||||
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);
|
||||
/* Command queue callback. */
|
||||
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
|
||||
|
||||
/* Command definition flag. */
|
||||
struct cmd_entry_flag {
|
||||
@ -1515,7 +1483,7 @@ typedef void (*overlay_free_cb)(struct client *);
|
||||
struct client {
|
||||
const char *name;
|
||||
struct tmuxpeer *peer;
|
||||
struct cmdq_list queue;
|
||||
struct cmdq_list *queue;
|
||||
|
||||
pid_t pid;
|
||||
int fd;
|
||||
@ -1829,6 +1797,7 @@ int format_true(const char *);
|
||||
struct format_tree *format_create(struct client *, struct cmdq_item *, int,
|
||||
int);
|
||||
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 *,
|
||||
const char *, ...);
|
||||
void format_each(struct format_tree *, void (*)(const char *,
|
||||
@ -1838,6 +1807,8 @@ char *format_expand(struct format_tree *, const char *);
|
||||
char *format_single(struct cmdq_item *, const char *,
|
||||
struct client *, struct session *, struct winlink *,
|
||||
struct window_pane *);
|
||||
char *format_single_from_target(struct cmdq_item *, const char *,
|
||||
struct client *);
|
||||
void format_defaults(struct format_tree *, struct client *,
|
||||
struct session *, struct winlink *, struct window_pane *);
|
||||
void format_defaults_window(struct format_tree *, struct window *);
|
||||
@ -2137,6 +2108,14 @@ struct cmd_parse_result *cmd_parse_from_arguments(int, char **,
|
||||
struct cmd_parse_input *);
|
||||
|
||||
/* 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 mouse_event *, int);
|
||||
#define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
|
||||
|
Loading…
Reference in New Issue
Block a user