Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2020-04-13 10:30:00 +01:00
commit b117c3b812
74 changed files with 538 additions and 326 deletions

View File

@ -215,8 +215,10 @@ args_escape(const char *s)
char *escaped, *result; char *escaped, *result;
int flags; int flags;
if (*s == '\0') if (*s == '\0') {
return (xstrdup(s)); xasprintf(&result, "''");
return (result);
}
if (s[0] != ' ' && if (s[0] != ' ' &&
(strchr(quoted, s[0]) != NULL || s[0] == '~') && (strchr(quoted, s[0]) != NULL || s[0] == '~') &&
s[1] == '\0') { s[1] == '\0') {

2
cfg.c
View File

@ -283,7 +283,7 @@ cfg_show_causes(struct session *s)
wme = TAILQ_FIRST(&wp->modes); wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode != &window_view_mode) if (wme == NULL || wme->mode != &window_view_mode)
window_pane_set_mode(wp, &window_view_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
for (i = 0; i < cfg_ncauses; i++) { for (i = 0; i < cfg_ncauses; i++) {
window_copy_add(wp, "%s", cfg_causes[i]); window_copy_add(wp, "%s", cfg_causes[i]);
free(cfg_causes[i]); free(cfg_causes[i]);

View File

@ -236,7 +236,6 @@ int
client_main(struct event_base *base, int argc, char **argv, int flags) client_main(struct event_base *base, int argc, char **argv, int flags)
{ {
struct cmd_parse_result *pr; struct cmd_parse_result *pr;
struct cmd *cmd;
struct msg_command *data; struct msg_command *data;
int fd, i; int fd, i;
const char *ttynam, *cwd; const char *ttynam, *cwd;
@ -265,10 +264,8 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
*/ */
pr = cmd_parse_from_arguments(argc, argv, NULL); pr = cmd_parse_from_arguments(argc, argv, NULL);
if (pr->status == CMD_PARSE_SUCCESS) { if (pr->status == CMD_PARSE_SUCCESS) {
TAILQ_FOREACH(cmd, &pr->cmdlist->list, qentry) { if (cmd_list_any_have(pr->cmdlist, CMD_STARTSERVER))
if (cmd->entry->flags & CMD_STARTSERVER) flags |= CLIENT_STARTSERVER;
flags |= CLIENT_STARTSERVER;
}
cmd_list_free(pr->cmdlist); cmd_list_free(pr->cmdlist);
} else } else
free(pr->error); free(pr->error);

View File

@ -177,7 +177,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
static enum cmd_retval static enum cmd_retval
cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item) cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
return (cmd_attach_session(item, args_get(args, 't'), return (cmd_attach_session(item, args_get(args, 't'),
args_has(args, 'd'), args_has(args, 'x'), args_has(args, 'r'), args_has(args, 'd'), args_has(args, 'x'), args_has(args, 'r'),

View File

@ -44,7 +44,7 @@ const struct cmd_entry cmd_bind_key_entry = {
static enum cmd_retval static enum cmd_retval
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item) cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
key_code key; key_code key;
const char *tablename, *note; const char *tablename, *note;
struct cmd_parse_result *pr; struct cmd_parse_result *pr;

View File

@ -48,7 +48,7 @@ const struct cmd_entry cmd_break_pane_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmd_find_state *current = &item->shared->current;
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 = item->source.wl;
@ -98,7 +98,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
if (idx == -1) if (idx == -1)
idx = -1 - options_get_number(dst_s->options, "base-index"); idx = -1 - options_get_number(dst_s->options, "base-index");
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */ wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
if (!args_has(self->args, 'd')) { if (!args_has(args, 'd')) {
session_select(dst_s, wl->idx); session_select(dst_s, wl->idx);
cmd_find_from_session(current, dst_s, 0); cmd_find_from_session(current, dst_s, 0);
} }

View File

@ -192,14 +192,14 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c = item->client; struct client *c = item->client;
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
char *buf, *cause; char *buf, *cause;
const char *bufname; const char *bufname;
size_t len; size_t len;
if (self->entry == &cmd_clear_history_entry) { if (cmd_get_entry(self) == &cmd_clear_history_entry) {
window_pane_reset_mode_all(wp); window_pane_reset_mode_all(wp);
grid_clear_history(wp->base.grid); grid_clear_history(wp->base.grid);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@ -71,21 +71,21 @@ const struct cmd_entry cmd_choose_buffer_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
const struct window_mode *mode; const struct window_mode *mode;
if (self->entry == &cmd_choose_buffer_entry) { if (cmd_get_entry(self) == &cmd_choose_buffer_entry) {
if (paste_get_top(NULL) == NULL) if (paste_get_top(NULL) == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
mode = &window_buffer_mode; mode = &window_buffer_mode;
} else if (self->entry == &cmd_choose_client_entry) { } else if (cmd_get_entry(self) == &cmd_choose_client_entry) {
if (server_client_how_many() == 0) if (server_client_how_many() == 0)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
mode = &window_client_mode; mode = &window_client_mode;
} else } else
mode = &window_tree_mode; mode = &window_tree_mode;
window_pane_set_mode(wp, mode, &item->target, args); window_pane_set_mode(wp, NULL, mode, &item->target, args);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -64,7 +64,7 @@ struct cmd_command_prompt_cdata {
static enum cmd_retval static enum cmd_retval
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item) cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
const char *inputs, *prompts; const char *inputs, *prompts;
struct cmd_command_prompt_cdata *cdata; struct cmd_command_prompt_cdata *cdata;
struct client *c; struct client *c;

View File

@ -53,7 +53,7 @@ struct cmd_confirm_before_data {
static enum cmd_retval static enum cmd_retval
cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item) cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct cmd_confirm_before_data *cdata; struct cmd_confirm_before_data *cdata;
struct client *c; struct client *c;
char *cmd, *copy, *new_prompt, *ptr; char *cmd, *copy, *new_prompt, *ptr;

View File

@ -30,9 +30,10 @@ const struct cmd_entry cmd_copy_mode_entry = {
.name = "copy-mode", .name = "copy-mode",
.alias = NULL, .alias = NULL,
.args = { "eHMt:uq", 0, 0 }, .args = { "eHMs:t:uq", 0, 0 },
.usage = "[-eHMuq] " CMD_TARGET_PANE_USAGE, .usage = "[-eHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE,
.source = { 's', CMD_FIND_PANE, 0 },
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
@ -55,11 +56,11 @@ const struct cmd_entry cmd_clock_mode_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = item->shared; struct cmdq_shared *shared = item->shared;
struct client *c = item->client; struct client *c = item->client;
struct session *s; struct session *s;
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->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);
@ -73,16 +74,20 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (self->entry == &cmd_clock_mode_entry) { if (cmd_get_entry(self) == &cmd_clock_mode_entry) {
window_pane_set_mode(wp, &window_clock_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_clock_mode, NULL, NULL);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (!window_pane_set_mode(wp, &window_copy_mode, NULL, args)) { if (args_has(args, 's'))
swp = item->source.wp;
else
swp = wp;
if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) {
if (args_has(args, 'M')) if (args_has(args, 'M'))
window_copy_start_drag(c, &shared->mouse); window_copy_start_drag(c, &shared->mouse);
} }
if (args_has(self->args, 'u')) if (args_has(args, 'u'))
window_copy_pageup(wp, 0); window_copy_pageup(wp, 0);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@ -57,7 +57,7 @@ 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c, *cloop; struct client *c, *cloop;
struct session *s; struct session *s;
enum msgtype msgtype; enum msgtype msgtype;
@ -66,7 +66,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
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);
if (self->entry == &cmd_suspend_client_entry) { if (cmd_get_entry(self) == &cmd_suspend_client_entry) {
server_client_suspend(c); server_client_suspend(c);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -171,7 +171,7 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
struct session *s = item->target.s; struct session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
@ -239,7 +239,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
struct cmd_find_state *fs = &item->target; struct cmd_find_state *fs = &item->target;
const char *value, *cmd = NULL, **lines = NULL; const char *value, *cmd = NULL, **lines = NULL;

View File

@ -60,7 +60,7 @@ cmd_display_message_each(const char *key, const char *value, void *arg)
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c, *target_c; struct client *c, *target_c;
struct session *s = item->target.s; struct session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
@ -101,7 +101,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
target_c = c; target_c = c;
else else
target_c = cmd_find_best_client(s); target_c = cmd_find_best_client(s);
if (args_has(self->args, 'v')) if (args_has(args, 'v'))
flags = FORMAT_VERBOSE; flags = FORMAT_VERBOSE;
else else
flags = 0; flags = 0;
@ -114,7 +114,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
} }
msg = format_expand_time(ft, template); msg = format_expand_time(ft, template);
if (args_has(self->args, 'p')) if (args_has(args, 'p'))
cmdq_print(item, "%s", msg); cmdq_print(item, "%s", msg);
else if (c != NULL) else if (c != NULL)
status_message_set(c, "%s", msg); status_message_set(c, "%s", msg);

View File

@ -239,7 +239,7 @@ cmd_display_panes_key(struct client *c, struct key_event *event)
static enum cmd_retval static enum cmd_retval
cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item) cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
struct session *s; struct session *s;
u_int delay; u_int delay;

View File

@ -44,7 +44,7 @@ const struct cmd_entry cmd_find_window_entry = {
static enum cmd_retval 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 = self->args, *new_args; struct args *args = cmd_get_args(self), *new_args;
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
const char *s = args->argv[0]; const char *s = args->argv[0];
char *filter, *argv = { NULL }; char *filter, *argv = { NULL };
@ -116,7 +116,8 @@ 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, &window_tree_mode, &item->target, new_args); window_pane_set_mode(wp, NULL, &window_tree_mode, &item->target,
new_args);
args_free(new_args); args_free(new_args);
free(filter); free(filter);

View File

@ -62,10 +62,11 @@ struct cmd_if_shell_data {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct mouse_event *m = &item->shared->mouse; struct mouse_event *m = &item->shared->mouse;
struct cmd_if_shell_data *cdata; struct cmd_if_shell_data *cdata;
char *shellcmd, *cmd; char *shellcmd, *cmd;
const char *file;
struct cmdq_item *new_item; struct cmdq_item *new_item;
struct cmd_find_state *fs = &item->target; 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);
@ -88,9 +89,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
memset(&pi, 0, sizeof pi); memset(&pi, 0, sizeof pi);
if (self->file != NULL) cmd_get_source(self, &pi.file, &pi.line);
pi.file = self->file;
pi.line = self->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, fs);
@ -134,10 +133,9 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata->item = NULL; cdata->item = NULL;
memset(&cdata->input, 0, sizeof cdata->input); memset(&cdata->input, 0, sizeof cdata->input);
if (self->file != NULL) cmd_get_source(self, &file, &cdata->input.line);
cdata->input.file = xstrdup(self->file); if (file != NULL)
cdata->input.line = self->line; cdata->input.file = xstrdup(file);
cdata->input.item = cdata->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++;

View File

@ -62,7 +62,7 @@ const struct cmd_entry cmd_move_pane_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmd_find_state *current = &item->shared->current;
struct session *dst_s; struct session *dst_s;
struct winlink *src_wl, *dst_wl; struct winlink *src_wl, *dst_wl;
@ -74,7 +74,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
enum layout_type type; enum layout_type type;
struct layout_cell *lc; struct layout_cell *lc;
if (self->entry == &cmd_join_pane_entry) if (cmd_get_entry(self) == &cmd_join_pane_entry)
not_same_window = 1; not_same_window = 1;
else else
not_same_window = 0; not_same_window = 0;

View File

@ -44,10 +44,11 @@ const struct cmd_entry cmd_kill_pane_entry = {
static enum cmd_retval 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 winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
struct window_pane *loopwp, *tmpwp, *wp = item->target.wp; struct window_pane *loopwp, *tmpwp, *wp = item->target.wp;
if (args_has(self->args, 'a')) { if (args_has(args, 'a')) {
server_unzoom_window(wl->window); server_unzoom_window(wl->window);
TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) { TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, entry, tmpwp) {
if (loopwp == wp) if (loopwp == wp)

View File

@ -54,7 +54,7 @@ const struct cmd_entry cmd_start_server_entry = {
static enum cmd_retval static enum cmd_retval
cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item) cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
{ {
if (self->entry == &cmd_kill_server_entry) if (cmd_get_entry(self) == &cmd_kill_server_entry)
kill(getpid(), SIGTERM); kill(getpid(), SIGTERM);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@ -45,7 +45,7 @@ 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 = self->args; struct args *args = cmd_get_args(self);
struct session *s, *sloop, *stmp; struct session *s, *sloop, *stmp;
struct winlink *wl; struct winlink *wl;

View File

@ -55,13 +55,13 @@ const struct cmd_entry cmd_unlink_window_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl, *wl2, *wl3; struct winlink *wl = item->target.wl, *wl2, *wl3;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = item->target.s; struct session *s = item->target.s;
if (self->entry == &cmd_unlink_window_entry) { if (cmd_get_entry(self) == &cmd_unlink_window_entry) {
if (!args_has(self->args, 'k') && !session_is_linked(s, w)) { if (!args_has(args, 'k') && !session_is_linked(s, w)) {
cmdq_error(item, "window only linked to one session"); cmdq_error(item, "window only linked to one session");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_buffers_entry = {
.name = "list-buffers", .name = "list-buffers",
.alias = "lsb", .alias = "lsb",
.args = { "F:", 0, 0 }, .args = { "F:f:", 0, 0 },
.usage = "[-F format]", .usage = "[-F format] [-f filter]",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_list_buffers_exec .exec = cmd_list_buffers_exec
@ -46,23 +46,33 @@ const struct cmd_entry cmd_list_buffers_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item) cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct paste_buffer *pb; struct paste_buffer *pb;
struct format_tree *ft; struct format_tree *ft;
char *line; const char *template, *filter;
const char *template; char *line, *expanded;
int flag;
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
template = LIST_BUFFERS_TEMPLATE; template = LIST_BUFFERS_TEMPLATE;
filter = args_get(args, 'f');
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(item->client, item, FORMAT_NONE, 0);
format_defaults_paste_buffer(ft, pb); format_defaults_paste_buffer(ft, pb);
line = format_expand(ft, template); if (filter != NULL) {
cmdq_print(item, "%s", line); expanded = format_expand(ft, filter);
free(line); flag = format_true(expanded);
free(expanded);
} else
flag = 1;
if (flag) {
line = format_expand(ft, template);
cmdq_print(item, "%s", line);
free(line);
}
format_free(ft); format_free(ft);
} }

View File

@ -51,7 +51,7 @@ const struct cmd_entry cmd_list_clients_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
struct session *s; struct session *s;
struct format_tree *ft; struct format_tree *ft;

View File

@ -144,7 +144,7 @@ cmd_list_keys_get_prefix(struct args *args, key_code *prefix)
static enum cmd_retval static enum cmd_retval
cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct key_table *table; struct key_table *table;
struct key_binding *bd; struct key_binding *bd;
const char *tablename, *r; const char *tablename, *r;
@ -153,7 +153,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
int repeat, width, tablewidth, keywidth, found = 0; int repeat, width, tablewidth, keywidth, found = 0;
size_t tmpsize, tmpused, cplen; size_t tmpsize, tmpused, cplen;
if (self->entry == &cmd_list_commands_entry) if (cmd_get_entry(self) == &cmd_list_commands_entry)
return (cmd_list_keys_commands(self, item)); return (cmd_list_keys_commands(self, item));
if (args->argc != 0) { if (args->argc != 0) {
@ -313,7 +313,7 @@ out:
static enum cmd_retval static enum cmd_retval
cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item) cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
const struct cmd_entry **entryp; const struct cmd_entry **entryp;
const struct cmd_entry *entry; const struct cmd_entry *entry;
struct format_tree *ft; struct format_tree *ft;

View File

@ -38,8 +38,8 @@ const struct cmd_entry cmd_list_panes_entry = {
.name = "list-panes", .name = "list-panes",
.alias = "lsp", .alias = "lsp",
.args = { "asF:t:", 0, 0 }, .args = { "asF:f:t:", 0, 0 },
.usage = "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE, .usage = "[-as] [-F format] [-f filter] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 }, .target = { 't', CMD_FIND_WINDOW, 0 },
@ -50,7 +50,7 @@ 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 = self->args; struct args *args = cmd_get_args(self);
struct session *s = item->target.s; struct session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
@ -87,12 +87,13 @@ static void
cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl, cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
struct cmdq_item *item, int type) struct cmdq_item *item, int type)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct window_pane *wp; struct window_pane *wp;
u_int n; u_int n;
struct format_tree *ft; struct format_tree *ft;
const char *template; const char *template, *filter;
char *line; char *line, *expanded;
int flag;
template = args_get(args, 'F'); template = args_get(args, 'F');
if (template == NULL) { if (template == NULL) {
@ -120,6 +121,7 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
break; break;
} }
} }
filter = args_get(args, 'f');
n = 0; n = 0;
TAILQ_FOREACH(wp, &wl->window->panes, entry) { TAILQ_FOREACH(wp, &wl->window->panes, entry) {
@ -127,9 +129,17 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
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);
line = format_expand(ft, template); if (filter != NULL) {
cmdq_print(item, "%s", line); expanded = format_expand(ft, filter);
free(line); flag = format_true(expanded);
free(expanded);
} else
flag = 1;
if (flag) {
line = format_expand(ft, template);
cmdq_print(item, "%s", line);
free(line);
}
format_free(ft); format_free(ft);
n++; n++;

View File

@ -42,8 +42,8 @@ const struct cmd_entry cmd_list_sessions_entry = {
.name = "list-sessions", .name = "list-sessions",
.alias = "ls", .alias = "ls",
.args = { "F:", 0, 0 }, .args = { "F:f:", 0, 0 },
.usage = "[-F format]", .usage = "[-F format] [-f filter]",
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_list_sessions_exec .exec = cmd_list_sessions_exec
@ -52,15 +52,17 @@ const struct cmd_entry cmd_list_sessions_entry = {
static enum cmd_retval static enum cmd_retval
cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item) cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct session *s; struct session *s;
u_int n; u_int n;
struct format_tree *ft; struct format_tree *ft;
const char *template; const char *template, *filter;
char *line; char *line, *expanded;
int flag;
if ((template = args_get(args, 'F')) == NULL) if ((template = args_get(args, 'F')) == NULL)
template = LIST_SESSIONS_TEMPLATE; template = LIST_SESSIONS_TEMPLATE;
filter = args_get(args, 'f');
n = 0; n = 0;
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
@ -68,9 +70,17 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
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);
line = format_expand(ft, template); if (filter != NULL) {
cmdq_print(item, "%s", line); expanded = format_expand(ft, filter);
free(line); flag = format_true(expanded);
free(expanded);
} else
flag = 1;
if (flag) {
line = format_expand(ft, template);
cmdq_print(item, "%s", line);
free(line);
}
format_free(ft); format_free(ft);
n++; n++;

View File

@ -49,8 +49,8 @@ const struct cmd_entry cmd_list_windows_entry = {
.name = "list-windows", .name = "list-windows",
.alias = "lsw", .alias = "lsw",
.args = { "F:at:", 0, 0 }, .args = { "F:f:at:", 0, 0 },
.usage = "[-a] [-F format] " CMD_TARGET_SESSION_USAGE, .usage = "[-a] [-F format] [-f filter] " CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_SESSION, 0 },
@ -61,7 +61,7 @@ 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 = self->args; struct args *args = cmd_get_args(self);
if (args_has(args, 'a')) if (args_has(args, 'a'))
cmd_list_windows_server(self, item); cmd_list_windows_server(self, item);
@ -84,12 +84,13 @@ static void
cmd_list_windows_session(struct cmd *self, struct session *s, cmd_list_windows_session(struct cmd *self, struct session *s,
struct cmdq_item *item, int type) struct cmdq_item *item, int type)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct winlink *wl; struct winlink *wl;
u_int n; u_int n;
struct format_tree *ft; struct format_tree *ft;
const char *template; const char *template, *filter;
char *line; char *line, *expanded;
int flag;
template = args_get(args, 'F'); template = args_get(args, 'F');
if (template == NULL) { if (template == NULL) {
@ -102,6 +103,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
break; break;
} }
} }
filter = args_get(args, 'f');
n = 0; n = 0;
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {
@ -109,9 +111,17 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
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);
line = format_expand(ft, template); if (filter != NULL) {
cmdq_print(item, "%s", line); expanded = format_expand(ft, filter);
free(line); flag = format_true(expanded);
free(expanded);
} else
flag = 1;
if (flag) {
line = format_expand(ft, template);
cmdq_print(item, "%s", line);
free(line);
}
format_free(ft); format_free(ft);
n++; n++;

View File

@ -83,7 +83,7 @@ cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
static enum cmd_retval static enum cmd_retval
cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item) cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; 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 session *s = item->target.s;

View File

@ -64,12 +64,12 @@ 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
if (self->entry == &cmd_lock_server_entry) if (cmd_get_entry(self) == &cmd_lock_server_entry)
server_lock(); server_lock();
else if (self->entry == &cmd_lock_session_entry) else if (cmd_get_entry(self) == &cmd_lock_session_entry)
server_lock_session(item->target.s); server_lock_session(item->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)

View File

@ -59,7 +59,7 @@ 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 = self->args; struct args *args = cmd_get_args(self);
const char *tflag = args_get(args, 't'); const char *tflag = args_get(args, 't');
struct session *src; struct session *src;
struct session *dst; struct session *dst;
@ -86,11 +86,11 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
wl = item->source.wl; wl = item->source.wl;
idx = item->target.idx; idx = item->target.idx;
kflag = args_has(self->args, 'k'); kflag = args_has(args, 'k');
dflag = args_has(self->args, 'd'); dflag = args_has(args, 'd');
sflag = args_has(self->args, 's'); sflag = args_has(args, 's');
if (args_has(self->args, 'a')) { if (args_has(args, 'a')) {
if ((idx = winlink_shuffle_up(dst, dst->curw)) == -1) if ((idx = winlink_shuffle_up(dst, dst->curw)) == -1)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@ -101,7 +101,7 @@ cmd_move_window_exec(struct cmd *self, struct cmdq_item *item)
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (self->entry == &cmd_move_window_entry) if (cmd_get_entry(self) == &cmd_move_window_entry)
server_unlink_window(src, wl); server_unlink_window(src, wl);
/* /*

View File

@ -66,7 +66,7 @@ const struct cmd_entry cmd_has_session_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct client *c = item->client; struct client *c = item->client;
struct session *s, *as, *groupwith; struct session *s, *as, *groupwith;
struct environ *env; struct environ *env;
@ -81,7 +81,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
enum cmd_retval retval; enum cmd_retval retval;
struct cmd_find_state fs; struct cmd_find_state fs;
if (self->entry == &cmd_has_session_entry) { if (cmd_get_entry(self) == &cmd_has_session_entry) {
/* /*
* cmd_find_target() will fail if the session cannot be found, * cmd_find_target() will fail if the session cannot be found,
* so always return success here. * so always return success here.

View File

@ -51,7 +51,7 @@ const struct cmd_entry cmd_new_window_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmd_find_state *current = &item->shared->current;
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);

View File

@ -46,7 +46,7 @@ const struct cmd_entry cmd_paste_buffer_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
struct paste_buffer *pb; struct paste_buffer *pb;
const char *sepstr, *bufname, *bufdata, *bufend, *line; const char *sepstr, *bufname, *bufdata, *bufend, *line;

View File

@ -55,7 +55,7 @@ const struct cmd_entry cmd_pipe_pane_entry = {
static enum cmd_retval 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 = self->args; 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 window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
struct session *s = item->target.s; struct session *s = item->target.s;
@ -88,13 +88,13 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
* *
* bind ^p pipep -o 'cat >>~/output' * bind ^p pipep -o 'cat >>~/output'
*/ */
if (args_has(self->args, 'o') && old_fd != -1) if (args_has(args, 'o') && old_fd != -1)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
/* What do we want to do? Neither -I or -O is -O. */ /* What do we want to do? Neither -I or -O is -O. */
if (args_has(self->args, 'I')) { if (args_has(args, 'I')) {
in = 1; in = 1;
out = args_has(self->args, 'O'); out = args_has(args, 'O');
} else { } else {
in = 0; in = 0;
out = 1; out = 1;

View File

@ -209,11 +209,13 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
{ {
struct cmdq_item *item, *first = NULL, *last = NULL; struct cmdq_item *item, *first = NULL, *last = NULL;
struct cmd *cmd; struct cmd *cmd;
const struct cmd_entry *entry;
struct cmdq_shared *shared = NULL; struct cmdq_shared *shared = NULL;
u_int group = 0; u_int group, last_group = 0;
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { cmd = cmd_list_first(cmdlist, &group);
if (cmd->group != group) { while (cmd != NULL) {
if (group != last_group) {
shared = xcalloc(1, sizeof *shared); shared = xcalloc(1, sizeof *shared);
if (current != NULL) if (current != NULL)
cmd_find_copy_state(&shared->current, current); cmd_find_copy_state(&shared->current, current);
@ -221,14 +223,15 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
cmd_find_clear_state(&shared->current, 0); cmd_find_clear_state(&shared->current, 0);
if (m != NULL) if (m != NULL)
memcpy(&shared->mouse, m, sizeof shared->mouse); memcpy(&shared->mouse, m, sizeof shared->mouse);
group = cmd->group; last_group = group;
} }
entry = cmd_get_entry(cmd);
item = xcalloc(1, sizeof *item); item = xcalloc(1, sizeof *item);
xasprintf(&item->name, "[%s/%p]", cmd->entry->name, item); xasprintf(&item->name, "[%s/%p]", entry->name, item);
item->type = CMDQ_COMMAND; item->type = CMDQ_COMMAND;
item->group = cmd->group; item->group = group;
item->flags = flags; item->flags = flags;
item->shared = shared; item->shared = shared;
@ -245,6 +248,8 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
if (last != NULL) if (last != NULL)
last->next = item; last->next = item;
last = item; last = item;
cmd = cmd_list_next(cmd, &group);
} }
return (first); return (first);
} }
@ -261,7 +266,7 @@ cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs,
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
value = args_get(item->cmd->args, flag->flag); value = args_get(cmd_get_args(item->cmd), flag->flag);
if (cmd_find_target(fs, item, value, flag->type, flag->flags) != 0) { if (cmd_find_target(fs, item, value, flag->type, flag->flags) != 0) {
cmd_find_clear_state(fs, 0); cmd_find_clear_state(fs, 0);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
@ -277,7 +282,7 @@ cmdq_fire_command(struct cmdq_item *item)
const char *name = cmdq_name(c); const char *name = cmdq_name(c);
struct cmdq_shared *shared = item->shared; struct cmdq_shared *shared = item->shared;
struct cmd *cmd = item->cmd; struct cmd *cmd = item->cmd;
const struct cmd_entry *entry = cmd->entry; const struct cmd_entry *entry = cmd_get_entry(cmd);
enum cmd_retval retval; enum cmd_retval retval;
struct cmd_find_state *fsp, fs; struct cmd_find_state *fsp, fs;
int flags; int flags;
@ -511,8 +516,10 @@ cmdq_print(struct cmdq_item *item, const char *fmt, ...)
} else { } else {
wp = c->session->curw->window->active; wp = c->session->curw->window->active;
wme = TAILQ_FIRST(&wp->modes); wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode != &window_view_mode) if (wme == NULL || wme->mode != &window_view_mode) {
window_pane_set_mode(wp, &window_view_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_view_mode, NULL,
NULL);
}
window_copy_add(wp, "%s", msg); window_copy_add(wp, "%s", msg);
} }
@ -526,8 +533,9 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
struct client *c = item->client; struct client *c = item->client;
struct cmd *cmd = item->cmd; struct cmd *cmd = item->cmd;
va_list ap; va_list ap;
char *msg; char *msg, *tmp;
char *tmp; const char *file;
u_int line;
va_start(ap, fmt); va_start(ap, fmt);
xvasprintf(&msg, fmt, ap); xvasprintf(&msg, fmt, ap);
@ -535,9 +543,10 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
log_debug("%s: %s", __func__, msg); log_debug("%s: %s", __func__, msg);
if (c == NULL) if (c == NULL) {
cfg_add_cause("%s:%u: %s", cmd->file, cmd->line, msg); cmd_get_source(cmd, &file, &line);
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) { cfg_add_cause("%s:%u: %s", file, line, msg);
} else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
if (~c->flags & CLIENT_UTF8) { if (~c->flags & CLIENT_UTF8) {
tmp = msg; tmp = msg;
msg = utf8_sanitize(tmp); msg = utf8_sanitize(tmp);

View File

@ -45,7 +45,7 @@ const struct cmd_entry cmd_refresh_client_entry = {
static enum cmd_retval static enum cmd_retval
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
struct tty *tty; struct tty *tty;
struct window *w; struct window *w;

View File

@ -46,7 +46,7 @@ const struct cmd_entry cmd_rename_session_entry = {
static enum cmd_retval 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 = self->args; 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 session *s = item->target.s;
char *newname; char *newname;

View File

@ -45,7 +45,7 @@ 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 = self->args; 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 session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;

View File

@ -49,7 +49,7 @@ const struct cmd_entry cmd_resize_pane_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = item->shared; struct cmdq_shared *shared = item->shared;
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;

View File

@ -46,7 +46,7 @@ const struct cmd_entry cmd_resize_window_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
struct window *w = wl->window; struct window *w = wl->window;
struct session *s = item->target.s; struct session *s = item->target.s;

View File

@ -47,7 +47,7 @@ const struct cmd_entry cmd_respawn_pane_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct spawn_context sc; struct spawn_context sc;
struct session *s = item->target.s; struct session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;

View File

@ -47,7 +47,7 @@ const struct cmd_entry cmd_respawn_window_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct spawn_context sc; struct spawn_context sc;
struct session *s = item->target.s; struct session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;

View File

@ -43,6 +43,7 @@ const struct cmd_entry cmd_rotate_window_entry = {
static enum cmd_retval 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 cmd_find_state *current = &item->shared->current; struct cmd_find_state *current = &item->shared->current;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
struct window *w = wl->window; struct window *w = wl->window;
@ -50,9 +51,9 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
struct layout_cell *lc; struct layout_cell *lc;
u_int sx, sy, xoff, yoff; u_int sx, sy, xoff, yoff;
window_push_zoom(w, args_has(self->args, 'Z')); window_push_zoom(w, args_has(args, 'Z'));
if (args_has(self->args, 'D')) { if (args_has(args, 'D')) {
wp = TAILQ_LAST(&w->panes, window_panes); wp = TAILQ_LAST(&w->panes, window_panes);
TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_REMOVE(&w->panes, wp, entry);
TAILQ_INSERT_HEAD(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry);

View File

@ -82,14 +82,14 @@ cmd_run_shell_print(struct job *job, const char *msg)
wme = TAILQ_FIRST(&wp->modes); wme = TAILQ_FIRST(&wp->modes);
if (wme == NULL || wme->mode != &window_view_mode) if (wme == NULL || wme->mode != &window_view_mode)
window_pane_set_mode(wp, &window_view_mode, NULL, NULL); window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
window_copy_add(wp, "%s", msg); window_copy_add(wp, "%s", msg);
} }
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
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 = item->target.s;

View File

@ -72,7 +72,7 @@ cmd_save_buffer_done(__unused struct client *c, const char *path, int error,
static enum cmd_retval static enum cmd_retval
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item) cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; 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 session *s = item->target.s;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
@ -97,11 +97,11 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
} }
bufdata = paste_buffer_data(pb, &bufsize); bufdata = paste_buffer_data(pb, &bufsize);
if (self->entry == &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(item, args->argv[0], c, s, wl, wp);
if (args_has(self->args, 'a')) if (args_has(args, 'a'))
flags = O_APPEND; flags = O_APPEND;
else else
flags = 0; flags = 0;

View File

@ -71,7 +71,7 @@ const struct cmd_entry cmd_previous_layout_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
struct window *w = wl->window; struct window *w = wl->window;
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
@ -81,10 +81,10 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
server_unzoom_window(w); server_unzoom_window(w);
next = self->entry == &cmd_next_layout_entry; next = (cmd_get_entry(self) == &cmd_next_layout_entry);
if (args_has(args, 'n')) if (args_has(args, 'n'))
next = 1; next = 1;
previous = self->entry == &cmd_previous_layout_entry; previous = (cmd_get_entry(self) == &cmd_previous_layout_entry);
if (args_has(args, 'p')) if (args_has(args, 'p'))
previous = 1; previous = 1;

View File

@ -83,7 +83,8 @@ cmd_select_pane_redraw(struct window *w)
static enum cmd_retval static enum cmd_retval
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; 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 cmd_find_state *current = &item->shared->current;
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 = item->target.wl;
@ -95,7 +96,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
struct style *sy; struct style *sy;
struct options_entry *o; struct options_entry *o;
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { if (entry == &cmd_last_pane_entry || args_has(args, 'l')) {
lastwp = w->last; lastwp = w->last;
if (lastwp == NULL && window_count_panes(w) == 2) { if (lastwp == NULL && window_count_panes(w) == 2) {
lastwp = TAILQ_PREV(w->active, window_panes, entry); lastwp = TAILQ_PREV(w->active, window_panes, entry);
@ -106,12 +107,12 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "no last pane"); cmdq_error(item, "no last pane");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (args_has(self->args, 'e')) if (args_has(args, 'e'))
lastwp->flags &= ~PANE_INPUTOFF; lastwp->flags &= ~PANE_INPUTOFF;
else if (args_has(self->args, 'd')) else if (args_has(args, 'd'))
lastwp->flags |= PANE_INPUTOFF; lastwp->flags |= PANE_INPUTOFF;
else { else {
if (window_push_zoom(w, args_has(self->args, 'Z'))) if (window_push_zoom(w, args_has(args, 'Z')))
server_redraw_window(w); server_redraw_window(w);
window_redraw_active_switch(w, lastwp); window_redraw_active_switch(w, lastwp);
if (window_set_active_pane(w, lastwp, 1)) { if (window_set_active_pane(w, lastwp, 1)) {
@ -146,7 +147,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(self->args, 'P') || args_has(self->args, 'g')) { if (args_has(args, 'P') || args_has(args, 'g')) {
if ((style = args_get(args, 'P')) != NULL) { if ((style = args_get(args, 'P')) != NULL) {
o = options_set_style(wp->options, "window-style", 0, o = options_set_style(wp->options, "window-style", 0,
style); style);
@ -158,26 +159,26 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
style); style);
wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED); wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
} }
if (args_has(self->args, 'g')) { if (args_has(args, 'g')) {
sy = options_get_style(wp->options, "window-style"); sy = options_get_style(wp->options, "window-style");
cmdq_print(item, "%s", style_tostring(sy)); cmdq_print(item, "%s", style_tostring(sy));
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(self->args, 'L')) { if (args_has(args, 'L')) {
window_push_zoom(w, 1); window_push_zoom(w, 1);
wp = window_pane_find_left(wp); wp = window_pane_find_left(wp);
window_pop_zoom(w); window_pop_zoom(w);
} else if (args_has(self->args, 'R')) { } else if (args_has(args, 'R')) {
window_push_zoom(w, 1); window_push_zoom(w, 1);
wp = window_pane_find_right(wp); wp = window_pane_find_right(wp);
window_pop_zoom(w); window_pop_zoom(w);
} else if (args_has(self->args, 'U')) { } else if (args_has(args, 'U')) {
window_push_zoom(w, 1); window_push_zoom(w, 1);
wp = window_pane_find_up(wp); wp = window_pane_find_up(wp);
window_pop_zoom(w); window_pop_zoom(w);
} else if (args_has(self->args, 'D')) { } else if (args_has(args, 'D')) {
window_push_zoom(w, 1); window_push_zoom(w, 1);
wp = window_pane_find_down(wp); wp = window_pane_find_down(wp);
window_pop_zoom(w); window_pop_zoom(w);
@ -185,17 +186,17 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
if (wp == NULL) if (wp == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (args_has(self->args, 'e')) { if (args_has(args, 'e')) {
wp->flags &= ~PANE_INPUTOFF; wp->flags &= ~PANE_INPUTOFF;
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(self->args, 'd')) { if (args_has(args, 'd')) {
wp->flags |= PANE_INPUTOFF; wp->flags |= PANE_INPUTOFF;
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (args_has(self->args, 'T')) { if (args_has(args, 'T')) {
pane_title = format_single(item, args_get(self->args, 'T'), pane_title = format_single(item, args_get(args, 'T'),
c, s, wl, wp); c, s, wl, wp);
if (screen_set_title(&wp->base, pane_title)) if (screen_set_title(&wp->base, pane_title))
server_status_window(wp->window); server_status_window(wp->window);
@ -205,7 +206,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
if (wp == w->active) if (wp == w->active)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (window_push_zoom(w, args_has(self->args, 'Z'))) if (window_push_zoom(w, args_has(args, 'Z')))
server_redraw_window(w); server_redraw_window(w);
window_redraw_active_switch(w, wp); window_redraw_active_switch(w, wp);
if (window_set_active_pane(w, wp, 1)) { if (window_set_active_pane(w, wp, 1)) {

View File

@ -84,23 +84,24 @@ const struct cmd_entry cmd_last_window_entry = {
static enum cmd_retval 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 cmd_find_state *current = &item->shared->current; struct cmd_find_state *current = &item->shared->current;
struct winlink *wl = item->target.wl; struct winlink *wl = item->target.wl;
struct session *s = item->target.s; struct session *s = item->target.s;
int next, previous, last, activity; int next, previous, last, activity;
next = self->entry == &cmd_next_window_entry; next = (cmd_get_entry(self) == &cmd_next_window_entry);
if (args_has(self->args, 'n')) if (args_has(args, 'n'))
next = 1; next = 1;
previous = self->entry == &cmd_previous_window_entry; previous = (cmd_get_entry(self) == &cmd_previous_window_entry);
if (args_has(self->args, 'p')) if (args_has(args, 'p'))
previous = 1; previous = 1;
last = self->entry == &cmd_last_window_entry; last = (cmd_get_entry(self) == &cmd_last_window_entry);
if (args_has(self->args, 'l')) if (args_has(args, 'l'))
last = 1; last = 1;
if (next || previous || last) { if (next || previous || last) {
activity = args_has(self->args, 'a'); activity = args_has(args, 'a');
if (next) { if (next) {
if (session_next(s, activity) != 0) { if (session_next(s, activity) != 0) {
cmdq_error(item, "no next window"); cmdq_error(item, "no next window");
@ -125,7 +126,7 @@ cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
* If -T and select-window is invoked on same window as * If -T and select-window is invoked on same window as
* current, switch to previous window. * current, switch to previous window.
*/ */
if (args_has(self->args, 'T') && wl == s->curw) { if (args_has(args, 'T') && wl == s->curw) {
if (session_last(s) != 0) { if (session_last(s) != 0) {
cmdq_error(item, "no last window"); cmdq_error(item, "no last window");
return (-1); return (-1);

View File

@ -131,7 +131,7 @@ cmd_send_keys_inject_string(struct client *c, struct cmd_find_state *fs,
static enum cmd_retval 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 = self->args; 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 cmd_find_state *fs = &item->target; struct cmd_find_state *fs = &item->target;
struct window_pane *wp = item->target.wp; struct window_pane *wp = item->target.wp;
@ -181,7 +181,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
if (self->entry == &cmd_send_prefix_entry) { if (cmd_get_entry(self) == &cmd_send_prefix_entry) {
if (args_has(args, '2')) if (args_has(args, '2'))
key = options_get_number(s->options, "prefix2"); key = options_get_number(s->options, "prefix2");
else else

View File

@ -54,7 +54,7 @@ const struct cmd_entry cmd_delete_buffer_entry = {
static enum cmd_retval static enum cmd_retval
cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item) cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct paste_buffer *pb; struct paste_buffer *pb;
char *bufdata, *cause; char *bufdata, *cause;
const char *bufname, *olddata; const char *bufname, *olddata;
@ -66,7 +66,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
else else
pb = paste_get_name(bufname); pb = paste_get_name(bufname);
if (self->entry == &cmd_delete_buffer_entry) { if (cmd_get_entry(self) == &cmd_delete_buffer_entry) {
if (pb == NULL) if (pb == NULL)
pb = paste_get_top(&bufname); pb = paste_get_top(&bufname);
if (pb == NULL) { if (pb == NULL) {

View File

@ -46,7 +46,7 @@ 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 = self->args; struct args *args = cmd_get_args(self);
struct environ *env; struct environ *env;
const char *name, *value, *target; const char *name, *value, *target;
@ -65,7 +65,7 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
else else
value = args->argv[1]; value = args->argv[1];
if (args_has(self->args, 'g')) if (args_has(args, 'g'))
env = global_environ; env = global_environ;
else { else {
if (item->target.s == NULL) { if (item->target.s == NULL) {
@ -79,13 +79,13 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
env = item->target.s->environ; env = item->target.s->environ;
} }
if (args_has(self->args, 'u')) { if (args_has(args, 'u')) {
if (value != NULL) { if (value != NULL) {
cmdq_error(item, "can't specify a value with -u"); cmdq_error(item, "can't specify a value with -u");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
environ_unset(env, name); environ_unset(env, name);
} else if (args_has(self->args, 'r')) { } else if (args_has(args, 'r')) {
if (value != NULL) { if (value != NULL) {
cmdq_error(item, "can't specify a value with -r"); cmdq_error(item, "can't specify a value with -r");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);

View File

@ -69,10 +69,10 @@ const struct cmd_entry cmd_set_hook_entry = {
.name = "set-hook", .name = "set-hook",
.alias = NULL, .alias = NULL,
.args = { "agRt:u", 1, 2 }, .args = { "agpRt:uw", 1, 2 },
.usage = "[-agRu] " CMD_TARGET_SESSION_USAGE " hook [command]", .usage = "[-agpRuw] " CMD_TARGET_PANE_USAGE " hook [command]",
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_set_option_exec .exec = cmd_set_option_exec
@ -81,7 +81,7 @@ const struct cmd_entry cmd_set_hook_entry = {
static enum cmd_retval static enum cmd_retval
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; 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 *fs = &item->target;
struct client *c, *loop; struct client *c, *loop;
@ -96,14 +96,14 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
int scope; int scope;
struct style *sy; struct style *sy;
window = (self->entry == &cmd_set_window_option_entry); window = (cmd_get_entry(self) == &cmd_set_window_option_entry);
/* 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(item, args->argv[0], c, s, wl, NULL);
/* If set-hook -R, fire the hook straight away. */ /* If set-hook -R, fire the hook straight away. */
if (self->entry == &cmd_set_hook_entry && args_has(args, 'R')) { if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) {
notify_hook(item, argument); notify_hook(item, argument);
free(argument); free(argument);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
@ -288,7 +288,7 @@ cmd_set_option_set(struct cmd *self, struct cmdq_item *item, struct options *oo,
struct options_entry *parent, const char *value) struct options_entry *parent, const char *value)
{ {
const struct options_table_entry *oe; const struct options_table_entry *oe;
struct args *args = self->args; struct args *args = cmd_get_args(self);
int append = args_has(args, 'a'); int append = args_has(args, 'a');
struct options_entry *o; struct options_entry *o;
long long number; long long number;

View File

@ -69,7 +69,7 @@ static void
cmd_show_environment_print(struct cmd *self, struct cmdq_item *item, cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
struct environ_entry *envent) struct environ_entry *envent)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
char *escaped; char *escaped;
if (!args_has(args, 'h') && (envent->flags & ENVIRON_HIDDEN)) if (!args_has(args, 'h') && (envent->flags & ENVIRON_HIDDEN))
@ -77,7 +77,7 @@ cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
if (args_has(args, 'h') && (~envent->flags & ENVIRON_HIDDEN)) if (args_has(args, 'h') && (~envent->flags & ENVIRON_HIDDEN))
return; return;
if (!args_has(self->args, 's')) { if (!args_has(args, 's')) {
if (envent->value != NULL) if (envent->value != NULL)
cmdq_print(item, "%s=%s", envent->name, envent->value); cmdq_print(item, "%s=%s", envent->name, envent->value);
else else
@ -97,7 +97,7 @@ cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct environ *env; struct environ *env;
struct environ_entry *envent; struct environ_entry *envent;
const char *target; const char *target;
@ -109,7 +109,7 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
} }
} }
if (args_has(self->args, 'g')) if (args_has(args, 'g'))
env = global_environ; env = global_environ;
else { else {
if (item->target.s == NULL) { if (item->target.s == NULL) {

View File

@ -68,7 +68,7 @@ cmd_show_messages_terminals(struct cmdq_item *item, int blank)
static enum cmd_retval static enum cmd_retval
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item) cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
struct client *c; struct client *c;
struct message_entry *msg; struct message_entry *msg;
char *tim; char *tim;

View File

@ -64,10 +64,10 @@ const struct cmd_entry cmd_show_hooks_entry = {
.name = "show-hooks", .name = "show-hooks",
.alias = NULL, .alias = NULL,
.args = { "gt:", 0, 1 }, .args = { "gpt:w", 0, 1 },
.usage = "[-g] " CMD_TARGET_SESSION_USAGE, .usage = "[-gpw] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 }, .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
.flags = CMD_AFTERHOOK, .flags = CMD_AFTERHOOK,
.exec = cmd_show_options_exec .exec = cmd_show_options_exec
@ -76,7 +76,7 @@ const struct cmd_entry cmd_show_hooks_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmd_find_state *fs = &item->target; 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 = item->target.s; struct session *s = item->target.s;
@ -86,7 +86,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
int window, idx, ambiguous, parent, scope; int window, idx, ambiguous, parent, scope;
struct options_entry *o; struct options_entry *o;
window = (self->entry == &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, fs, &oo, &cause);
@ -142,6 +142,7 @@ static void
cmd_show_options_print(struct cmd *self, struct cmdq_item *item, cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
struct options_entry *o, int idx, int parent) struct options_entry *o, int idx, int parent)
{ {
struct args *args = cmd_get_args(self);
struct options_array_item *a; struct options_array_item *a;
const char *name = options_name(o); const char *name = options_name(o);
char *value, *tmp = NULL, *escaped; char *value, *tmp = NULL, *escaped;
@ -153,7 +154,7 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
if (options_isarray(o)) { if (options_isarray(o)) {
a = options_array_first(o); a = options_array_first(o);
if (a == NULL) { if (a == NULL) {
if (!args_has(self->args, 'v')) if (!args_has(args, 'v'))
cmdq_print(item, "%s", name); cmdq_print(item, "%s", name);
return; return;
} }
@ -168,7 +169,7 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
} }
value = options_tostring(o, idx, 0); value = options_tostring(o, idx, 0);
if (args_has(self->args, 'v')) if (args_has(args, 'v'))
cmdq_print(item, "%s", value); cmdq_print(item, "%s", value);
else if (options_isstring(o)) { else if (options_isstring(o)) {
escaped = args_escape(value); escaped = args_escape(value);
@ -192,6 +193,7 @@ static enum cmd_retval
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope, cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
struct options *oo) struct options *oo)
{ {
struct args *args = cmd_get_args(self);
const struct options_table_entry *oe; const struct options_table_entry *oe;
struct options_entry *o; struct options_entry *o;
struct options_array_item *a; struct options_array_item *a;
@ -209,16 +211,16 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
if (~oe->scope & scope) if (~oe->scope & scope)
continue; continue;
if ((self->entry != &cmd_show_hooks_entry && if ((cmd_get_entry(self) != &cmd_show_hooks_entry &&
!args_has(self->args, 'H') && !args_has(args, 'H') &&
(oe->flags & OPTIONS_TABLE_IS_HOOK)) || (oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
(self->entry == &cmd_show_hooks_entry && (cmd_get_entry(self) == &cmd_show_hooks_entry &&
(~oe->flags & OPTIONS_TABLE_IS_HOOK))) (~oe->flags & OPTIONS_TABLE_IS_HOOK)))
continue; continue;
o = options_get_only(oo, oe->name); o = options_get_only(oo, oe->name);
if (o == NULL) { if (o == NULL) {
if (!args_has(self->args, 'A')) if (!args_has(args, 'A'))
continue; continue;
o = options_get(oo, oe->name); o = options_get(oo, oe->name);
if (o == NULL) if (o == NULL)
@ -230,7 +232,7 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
if (!options_isarray(o)) if (!options_isarray(o))
cmd_show_options_print(self, item, o, -1, parent); cmd_show_options_print(self, item, o, -1, parent);
else if ((a = options_array_first(o)) == NULL) { else if ((a = options_array_first(o)) == NULL) {
if (!args_has(self->args, 'v')) { if (!args_has(args, 'v')) {
name = options_name(o); name = options_name(o);
if (parent) if (parent)
cmdq_print(item, "%s*", name); cmdq_print(item, "%s*", name);

View File

@ -122,7 +122,7 @@ cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
static enum cmd_retval static enum cmd_retval
cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; 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 = item->client;
enum cmd_retval retval = CMD_RETURN_NORMAL; enum cmd_retval retval = CMD_RETURN_NORMAL;

View File

@ -52,7 +52,7 @@ const struct cmd_entry cmd_split_window_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
struct cmd_find_state *current = &item->shared->current; struct cmd_find_state *current = &item->shared->current;
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);

View File

@ -45,7 +45,7 @@ const struct cmd_entry cmd_swap_pane_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
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;

View File

@ -45,6 +45,7 @@ const struct cmd_entry cmd_swap_window_entry = {
static enum cmd_retval 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 session *src, *dst; struct session *src, *dst;
struct session_group *sg_src, *sg_dst; struct session_group *sg_src, *sg_dst;
struct winlink *wl_src, *wl_dst; struct winlink *wl_src, *wl_dst;
@ -77,7 +78,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item)
wl_src->window = w_dst; wl_src->window = w_dst;
TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry); TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry);
if (args_has(self->args, 'd')) { if (args_has(args, 'd')) {
session_select(dst, wl_dst->idx); session_select(dst, wl_dst->idx);
if (src != dst) if (src != dst)
session_select(src, wl_src->idx); session_select(src, wl_src->idx);

View File

@ -47,7 +47,7 @@ const struct cmd_entry cmd_switch_client_entry = {
static enum cmd_retval 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 = self->args; struct args *args = cmd_get_args(self);
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;
@ -115,7 +115,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (wl != NULL && wp != NULL) { if (wl != NULL && wp != NULL) {
w = wl->window; w = wl->window;
if (window_push_zoom(w, args_has(self->args, 'Z'))) if (window_push_zoom(w, args_has(args, 'Z')))
server_redraw_window(w); server_redraw_window(w);
window_redraw_active_switch(w, wp); window_redraw_active_switch(w, wp);
window_set_active_pane(w, wp, 1); window_set_active_pane(w, wp, 1);

View File

@ -42,7 +42,7 @@ const struct cmd_entry cmd_unbind_key_entry = {
static enum cmd_retval static enum cmd_retval
cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item) cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
key_code key; key_code key;
const char *tablename; const char *tablename;

View File

@ -120,7 +120,7 @@ cmd_wait_for_remove(struct wait_channel *wc)
static enum cmd_retval static enum cmd_retval
cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item) cmd_wait_for_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = self->args; struct args *args = cmd_get_args(self);
const char *name = args->argv[0]; const char *name = args->argv[0];
struct wait_channel *wc, wc0; struct wait_channel *wc, wc0;

127
cmd.c
View File

@ -206,8 +206,27 @@ const struct cmd_entry *cmd_table[] = {
NULL NULL
}; };
/* Instance of a command. */
struct cmd {
const struct cmd_entry *entry;
struct args *args;
u_int group;
char *file;
u_int line;
char *alias;
int argc;
char **argv;
TAILQ_ENTRY(cmd) qentry;
};
TAILQ_HEAD(cmds, cmd);
/* Next group number for new command list. */
static u_int cmd_list_next_group = 1; static u_int cmd_list_next_group = 1;
/* Log an argument vector. */
void printflike(3, 4) void printflike(3, 4)
cmd_log_argv(int argc, char **argv, const char *fmt, ...) cmd_log_argv(int argc, char **argv, const char *fmt, ...)
{ {
@ -224,6 +243,7 @@ cmd_log_argv(int argc, char **argv, const char *fmt, ...)
free(prefix); free(prefix);
} }
/* Prepend to an argument vector. */
void void
cmd_prepend_argv(int *argc, char ***argv, char *arg) cmd_prepend_argv(int *argc, char ***argv, char *arg)
{ {
@ -240,6 +260,7 @@ cmd_prepend_argv(int *argc, char ***argv, char *arg)
(*argc)++; (*argc)++;
} }
/* Append to an argument vector. */
void void
cmd_append_argv(int *argc, char ***argv, char *arg) cmd_append_argv(int *argc, char ***argv, char *arg)
{ {
@ -247,6 +268,7 @@ cmd_append_argv(int *argc, char ***argv, char *arg)
(*argv)[(*argc)++] = xstrdup(arg); (*argv)[(*argc)++] = xstrdup(arg);
} }
/* Pack an argument vector up into a buffer. */
int int
cmd_pack_argv(int argc, char **argv, char *buf, size_t len) cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
{ {
@ -269,6 +291,7 @@ cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
return (0); return (0);
} }
/* Unpack an argument vector from a packed buffer. */
int int
cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv) cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
{ {
@ -297,6 +320,7 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv)
return (0); return (0);
} }
/* Copy an argument vector, ensuring it is terminated by NULL. */
char ** char **
cmd_copy_argv(int argc, char **argv) cmd_copy_argv(int argc, char **argv)
{ {
@ -313,6 +337,7 @@ cmd_copy_argv(int argc, char **argv)
return (new_argv); return (new_argv);
} }
/* Free an argument vector. */
void void
cmd_free_argv(int argc, char **argv) cmd_free_argv(int argc, char **argv)
{ {
@ -325,6 +350,7 @@ cmd_free_argv(int argc, char **argv)
free(argv); free(argv);
} }
/* Convert argument vector to a string. */
char * char *
cmd_stringify_argv(int argc, char **argv) cmd_stringify_argv(int argc, char **argv)
{ {
@ -351,6 +377,31 @@ cmd_stringify_argv(int argc, char **argv)
return (buf); return (buf);
} }
/* Get entry for command. */
const struct cmd_entry *
cmd_get_entry(struct cmd *cmd)
{
return (cmd->entry);
}
/* Get arguments for command. */
struct args *
cmd_get_args(struct cmd *cmd)
{
return (cmd->args);
}
/* Get file and line for command. */
void
cmd_get_source(struct cmd *cmd, const char **file, u_int *line)
{
if (file != NULL)
*file = cmd->file;
if (line != NULL)
*line = cmd->line;
}
/* Look for an alias for a command. */
char * char *
cmd_get_alias(const char *name) cmd_get_alias(const char *name)
{ {
@ -381,6 +432,7 @@ cmd_get_alias(const char *name)
return (NULL); return (NULL);
} }
/* Look up a command entry by name. */
static const struct cmd_entry * static const struct cmd_entry *
cmd_find(const char *name, char **cause) cmd_find(const char *name, char **cause)
{ {
@ -430,6 +482,7 @@ ambiguous:
return (NULL); return (NULL);
} }
/* Parse a single command from an argument vector. */
struct cmd * struct cmd *
cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause) cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause)
{ {
@ -478,6 +531,7 @@ usage:
return (NULL); return (NULL);
} }
/* Free a command. */
void void
cmd_free(struct cmd *cmd) cmd_free(struct cmd *cmd)
{ {
@ -490,6 +544,7 @@ cmd_free(struct cmd *cmd)
free(cmd); free(cmd);
} }
/* Get a command as a string. */
char * char *
cmd_print(struct cmd *cmd) cmd_print(struct cmd *cmd)
{ {
@ -505,6 +560,7 @@ cmd_print(struct cmd *cmd)
return (out); return (out);
} }
/* Create a new command list. */
struct cmd_list * struct cmd_list *
cmd_list_new(void) cmd_list_new(void)
{ {
@ -513,29 +569,33 @@ cmd_list_new(void)
cmdlist = xcalloc(1, sizeof *cmdlist); cmdlist = xcalloc(1, sizeof *cmdlist);
cmdlist->references = 1; cmdlist->references = 1;
cmdlist->group = cmd_list_next_group++; cmdlist->group = cmd_list_next_group++;
TAILQ_INIT(&cmdlist->list); cmdlist->list = xcalloc(1, sizeof *cmdlist->list);
TAILQ_INIT(cmdlist->list);
return (cmdlist); return (cmdlist);
} }
/* Append a command to a command list. */
void void
cmd_list_append(struct cmd_list *cmdlist, struct cmd *cmd) cmd_list_append(struct cmd_list *cmdlist, struct cmd *cmd)
{ {
cmd->group = cmdlist->group; cmd->group = cmdlist->group;
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry); TAILQ_INSERT_TAIL(cmdlist->list, cmd, qentry);
} }
/* Move all commands from one command list to another */
void void
cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from) cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from)
{ {
struct cmd *cmd, *cmd1; struct cmd *cmd, *cmd1;
TAILQ_FOREACH_SAFE(cmd, &from->list, qentry, cmd1) { TAILQ_FOREACH_SAFE(cmd, from->list, qentry, cmd1) {
TAILQ_REMOVE(&from->list, cmd, qentry); TAILQ_REMOVE(from->list, cmd, qentry);
TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry); TAILQ_INSERT_TAIL(cmdlist->list, cmd, qentry);
} }
cmdlist->group = cmd_list_next_group++; cmdlist->group = cmd_list_next_group++;
} }
/* Free a command list. */
void void
cmd_list_free(struct cmd_list *cmdlist) cmd_list_free(struct cmd_list *cmdlist)
{ {
@ -544,14 +604,15 @@ cmd_list_free(struct cmd_list *cmdlist)
if (--cmdlist->references != 0) if (--cmdlist->references != 0)
return; return;
TAILQ_FOREACH_SAFE(cmd, &cmdlist->list, qentry, cmd1) { TAILQ_FOREACH_SAFE(cmd, cmdlist->list, qentry, cmd1) {
TAILQ_REMOVE(&cmdlist->list, cmd, qentry); TAILQ_REMOVE(cmdlist->list, cmd, qentry);
cmd_free(cmd); cmd_free(cmd);
} }
free(cmdlist->list);
free(cmdlist); free(cmdlist);
} }
/* Get a command list as a string. */
char * char *
cmd_list_print(struct cmd_list *cmdlist, int escaped) cmd_list_print(struct cmd_list *cmdlist, int escaped)
{ {
@ -562,7 +623,7 @@ cmd_list_print(struct cmd_list *cmdlist, int escaped)
len = 1; len = 1;
buf = xcalloc(1, len); buf = xcalloc(1, len);
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
this = cmd_print(cmd); this = cmd_print(cmd);
len += strlen(this) + 4; len += strlen(this) + 4;
@ -582,6 +643,54 @@ cmd_list_print(struct cmd_list *cmdlist, int escaped)
return (buf); return (buf);
} }
/* Get first command in list. */
struct cmd *
cmd_list_first(struct cmd_list *cmdlist, u_int *group)
{
struct cmd *cmd;
cmd = TAILQ_FIRST(cmdlist->list);
if (cmd != NULL && group != NULL)
*group = cmd->group;
return (cmd);
}
/* Get next command in list. */
struct cmd *
cmd_list_next(struct cmd *cmd, u_int *group)
{
cmd = TAILQ_NEXT(cmd, qentry);
if (cmd != NULL && group != NULL)
*group = cmd->group;
return (cmd);
}
/* Do all of the commands in this command list have this flag? */
int
cmd_list_all_have(struct cmd_list *cmdlist, int flag)
{
struct cmd *cmd;
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
if (~cmd->entry->flags & flag)
return (0);
}
return (1);
}
/* Do any of the commands in this command list have this flag? */
int
cmd_list_any_have(struct cmd_list *cmdlist, int flag)
{
struct cmd *cmd;
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
if (cmd->entry->flags & flag)
return (1);
}
return (0);
}
/* Adjust current mouse position for a pane. */ /* Adjust current mouse position for a pane. */
int int
cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp, cmd_mouse_at(struct window_pane *wp, struct mouse_event *m, u_int *xp,

View File

@ -804,7 +804,7 @@ format_width(const char *expanded)
if (cp[0] == '#' && cp[1] == '[') { if (cp[0] == '#' && cp[1] == '[') {
end = format_skip(cp + 2, "]"); end = format_skip(cp + 2, "]");
if (end == NULL) if (end == NULL)
return 0; return (0);
cp = end + 1; cp = end + 1;
} else if ((more = utf8_open(&ud, *cp)) == UTF8_MORE) { } else if ((more = utf8_open(&ud, *cp)) == UTF8_MORE) {
while (*++cp != '\0' && more == UTF8_MORE) while (*++cp != '\0' && more == UTF8_MORE)

View File

@ -1128,8 +1128,10 @@ format_create_add_item(struct format_tree *ft, struct cmdq_item *item)
struct window_pane *wp; struct window_pane *wp;
u_int x, y; u_int x, y;
if (item->cmd != NULL) if (item->cmd != NULL) {
format_add(ft, "command", "%s", item->cmd->entry->name); format_add(ft, "command", "%s",
cmd_get_entry (item->cmd)->name);
}
if (item->shared == NULL) if (item->shared == NULL)
return; return;
@ -1617,7 +1619,7 @@ format_build_modifiers(struct format_tree *ft, const char **s, u_int *count)
return (NULL); return (NULL);
} }
*s = cp + 1; *s = cp + 1;
return list; return (list);
} }
/* Match against an fnmatch(3) pattern or regular expression. */ /* Match against an fnmatch(3) pattern or regular expression. */
@ -1909,7 +1911,7 @@ format_replace_expression(struct format_modifier *mexp, struct format_tree *ft,
free(right); free(right);
free(left); free(left);
return value; return (value);
fail: fail:
free(right); free(right);

View File

@ -537,19 +537,13 @@ struct cmdq_item *
key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item, key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
struct client *c, struct mouse_event *m, struct cmd_find_state *fs) struct client *c, struct mouse_event *m, struct cmd_find_state *fs)
{ {
struct cmd *cmd;
struct cmdq_item *new_item; struct cmdq_item *new_item;
int readonly; int readonly;
if (c == NULL || (~c->flags & CLIENT_READONLY)) if (c == NULL || (~c->flags & CLIENT_READONLY))
readonly = 1; readonly = 1;
else { else
readonly = 1; readonly = cmd_list_all_have(bd->cmdlist, CMD_READONLY);
TAILQ_FOREACH(cmd, &bd->cmdlist->list, qentry) {
if (~cmd->entry->flags & CMD_READONLY)
readonly = 0;
}
}
if (!readonly) if (!readonly)
new_item = cmdq_get_callback(key_bindings_read_only, NULL); new_item = cmdq_get_callback(key_bindings_read_only, NULL);
else { else {

View File

@ -75,6 +75,14 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne)
else else
oo = fs.s->options; oo = fs.s->options;
o = options_get(oo, ne->name); o = options_get(oo, ne->name);
if (o == NULL && fs.wp != NULL) {
oo = fs.wp->options;
o = options_get(oo, ne->name);
}
if (o == NULL && fs.wl != NULL) {
oo = fs.wl->window->options;
o = options_get(oo, ne->name);
}
if (o == NULL) if (o == NULL)
return; return;

View File

@ -139,7 +139,7 @@ static const char *options_table_status_format_default[] = {
OPTIONS_TABLE_STATUS_FORMAT1, OPTIONS_TABLE_STATUS_FORMAT2, NULL OPTIONS_TABLE_STATUS_FORMAT1, OPTIONS_TABLE_STATUS_FORMAT2, NULL
}; };
/* Helper for hook options. */ /* Helpers for hook options. */
#define OPTIONS_TABLE_HOOK(hook_name, default_value) \ #define OPTIONS_TABLE_HOOK(hook_name, default_value) \
{ .name = hook_name, \ { .name = hook_name, \
.type = OPTIONS_TABLE_COMMAND, \ .type = OPTIONS_TABLE_COMMAND, \
@ -149,6 +149,24 @@ static const char *options_table_status_format_default[] = {
.separator = "" \ .separator = "" \
} }
#define OPTIONS_TABLE_PANE_HOOK(hook_name, default_value) \
{ .name = hook_name, \
.type = OPTIONS_TABLE_COMMAND, \
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, \
.flags = OPTIONS_TABLE_IS_ARRAY|OPTIONS_TABLE_IS_HOOK, \
.default_str = default_value, \
.separator = "" \
}
#define OPTIONS_TABLE_WINDOW_HOOK(hook_name, default_value) \
{ .name = hook_name, \
.type = OPTIONS_TABLE_COMMAND, \
.scope = OPTIONS_TABLE_WINDOW, \
.flags = OPTIONS_TABLE_IS_ARRAY|OPTIONS_TABLE_IS_HOOK, \
.default_str = default_value, \
.separator = "" \
}
/* Top-level options. */ /* Top-level options. */
const struct options_table_entry options_table[] = { const struct options_table_entry options_table[] = {
/* Server options. */ /* Server options. */
@ -850,21 +868,21 @@ const struct options_table_entry options_table[] = {
OPTIONS_TABLE_HOOK("client-detached", ""), OPTIONS_TABLE_HOOK("client-detached", ""),
OPTIONS_TABLE_HOOK("client-resized", ""), OPTIONS_TABLE_HOOK("client-resized", ""),
OPTIONS_TABLE_HOOK("client-session-changed", ""), OPTIONS_TABLE_HOOK("client-session-changed", ""),
OPTIONS_TABLE_HOOK("pane-died", ""), OPTIONS_TABLE_PANE_HOOK("pane-died", ""),
OPTIONS_TABLE_HOOK("pane-exited", ""), OPTIONS_TABLE_PANE_HOOK("pane-exited", ""),
OPTIONS_TABLE_HOOK("pane-focus-in", ""), OPTIONS_TABLE_PANE_HOOK("pane-focus-in", ""),
OPTIONS_TABLE_HOOK("pane-focus-out", ""), OPTIONS_TABLE_PANE_HOOK("pane-focus-out", ""),
OPTIONS_TABLE_HOOK("pane-mode-changed", ""), OPTIONS_TABLE_PANE_HOOK("pane-mode-changed", ""),
OPTIONS_TABLE_HOOK("pane-set-clipboard", ""), OPTIONS_TABLE_PANE_HOOK("pane-set-clipboard", ""),
OPTIONS_TABLE_HOOK("session-closed", ""), OPTIONS_TABLE_HOOK("session-closed", ""),
OPTIONS_TABLE_HOOK("session-created", ""), OPTIONS_TABLE_HOOK("session-created", ""),
OPTIONS_TABLE_HOOK("session-renamed", ""), OPTIONS_TABLE_HOOK("session-renamed", ""),
OPTIONS_TABLE_HOOK("session-window-changed", ""), OPTIONS_TABLE_HOOK("session-window-changed", ""),
OPTIONS_TABLE_HOOK("window-layout-changed", ""), OPTIONS_TABLE_WINDOW_HOOK("window-layout-changed", ""),
OPTIONS_TABLE_HOOK("window-linked", ""), OPTIONS_TABLE_WINDOW_HOOK("window-linked", ""),
OPTIONS_TABLE_HOOK("window-pane-changed", ""), OPTIONS_TABLE_WINDOW_HOOK("window-pane-changed", ""),
OPTIONS_TABLE_HOOK("window-renamed", ""), OPTIONS_TABLE_WINDOW_HOOK("window-renamed", ""),
OPTIONS_TABLE_HOOK("window-unlinked", ""), OPTIONS_TABLE_WINDOW_HOOK("window-unlinked", ""),
{ .name = NULL } { .name = NULL }
}; };

82
tmux.1
View File

@ -1055,12 +1055,18 @@ List the syntax of
.Ar command .Ar command
or - if omitted - of all commands supported by or - if omitted - of all commands supported by
.Nm . .Nm .
.It Ic list-sessions Op Fl F Ar format .It Xo Ic list-sessions
.Op Fl F Ar format
.Op Fl f Ar filter
.Xc
.D1 (alias: Ic ls ) .D1 (alias: Ic ls )
List all sessions managed by the server. List all sessions managed by the server.
For the meaning of the
.Fl F .Fl F
flag, see the specifies the format of each line and
.Fl f
a filter.
Only sessions for which the filter is true are shown.
See the
.Sx FORMATS .Sx FORMATS
section. section.
.It Ic lock-client Op Fl t Ar target-client .It Ic lock-client Op Fl t Ar target-client
@ -1608,6 +1614,7 @@ command is:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo Ic copy-mode .It Xo Ic copy-mode
.Op Fl eHMqu .Op Fl eHMqu
.Op Fl s Ar src-pane
.Op Fl t Ar target-pane .Op Fl t Ar target-pane
.Xc .Xc
Enter copy mode. Enter copy mode.
@ -1621,6 +1628,11 @@ begins a mouse drag (only valid if bound to a mouse key binding, see
hides the position indicator in the top right. hides the position indicator in the top right.
.Fl q .Fl q
cancels copy mode and any other modes. cancels copy mode and any other modes.
.Fl s
copies from
.Ar src-pane
instead of
.Ar target-pane .
.Pp .Pp
.Fl e .Fl e
specifies that scrolling to the bottom of the history (to the visible screen) specifies that scrolling to the bottom of the history (to the visible screen)
@ -2056,6 +2068,7 @@ is given, the newly linked window is not selected.
.It Xo Ic list-panes .It Xo Ic list-panes
.Op Fl as .Op Fl as
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl t Ar target .Op Fl t Ar target
.Xc .Xc
.D1 (alias: Ic lsp ) .D1 (alias: Ic lsp )
@ -2072,14 +2085,18 @@ is a session (or the current session).
If neither is given, If neither is given,
.Ar target .Ar target
is a window (or the current window). is a window (or the current window).
For the meaning of the
.Fl F .Fl F
flag, see the specifies the format of each line and
.Fl f
a filter.
Only panes for which the filter is true are shown.
See the
.Sx FORMATS .Sx FORMATS
section. section.
.It Xo Ic list-windows .It Xo Ic list-windows
.Op Fl a .Op Fl a
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl t Ar target-session .Op Fl t Ar target-session
.Xc .Xc
.D1 (alias: Ic lsw ) .D1 (alias: Ic lsw )
@ -2088,9 +2105,12 @@ If
is given, list all windows on the server. is given, list all windows on the server.
Otherwise, list windows in the current session or in Otherwise, list windows in the current session or in
.Ar target-session . .Ar target-session .
For the meaning of the
.Fl F .Fl F
flag, see the specifies the format of each line and
.Fl f
a filter.
Only windows for which the filter is true are shown.
See the
.Sx FORMATS .Sx FORMATS
section. section.
.It Xo Ic move-pane .It Xo Ic move-pane
@ -3312,6 +3332,9 @@ with
.Fl np . .Fl np .
.It Ic message-command-style Ar style .It Ic message-command-style Ar style
Set status line message command style. Set status line message command style.
This is used for the command prompt with
.Xr vi 1
keys when in command mode.
For how to specify For how to specify
.Ar style , .Ar style ,
see the see the
@ -3319,6 +3342,7 @@ see the
section. section.
.It Ic message-style Ar style .It Ic message-style Ar style
Set status line message style. Set status line message style.
This is used for messages and for the command prompt.
For how to specify For how to specify
.Ar style , .Ar style ,
see the see the
@ -3873,6 +3897,7 @@ hook and there are a number of hooks not associated with commands.
.Pp .Pp
Hooks are stored as array options, members of the array are executed in Hooks are stored as array options, members of the array are executed in
order when the hook is triggered. order when the hook is triggered.
Like options different hooks may be global or belong to a session, window or pane.
Hooks may be configured with the Hooks may be configured with the
.Ic set-hook .Ic set-hook
or or
@ -3965,8 +3990,8 @@ Run when a window is unlinked from a session.
Hooks are managed with these commands: Hooks are managed with these commands:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo Ic set-hook .It Xo Ic set-hook
.Op Fl agRu .Op Fl agpRuw
.Op Fl t Ar target-session .Op Fl t Ar target-pane
.Ar hook-name .Ar hook-name
.Ar command .Ar command
.Xc .Xc
@ -3978,18 +4003,8 @@ unsets) hook
.Ar hook-name .Ar hook-name
to to
.Ar command . .Ar command .
If The flags are the same as for
.Fl g .Ic set-option .
is given,
.Em hook-name
is added to the global list of hooks, otherwise it is added to the session
hooks (for
.Ar target-session
with
.Fl t ) .
.Fl a
appends to a hook.
Like options, session hooks inherit from the global ones.
.Pp .Pp
With With
.Fl R , .Fl R ,
@ -3997,12 +4012,12 @@ run
.Ar hook-name .Ar hook-name
immediately. immediately.
.It Xo Ic show-hooks .It Xo Ic show-hooks
.Op Fl g .Op Fl gpw
.Op Fl t Ar target-session .Op Fl t Ar target-pane
.Xc .Xc
Shows the global list of hooks with Shows hooks.
.Fl g , The flags are the same as for
otherwise the session hooks. .Ic show-options .
.El .El
.Sh MOUSE SUPPORT .Sh MOUSE SUPPORT
If the If the
@ -5251,12 +5266,16 @@ Delete the buffer named
or the most recently added automatically named buffer if not specified. or the most recently added automatically named buffer if not specified.
.It Xo Ic list-buffers .It Xo Ic list-buffers
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter
.Xc .Xc
.D1 (alias: Ic lsb ) .D1 (alias: Ic lsb )
List the global buffers. List the global buffers.
For the meaning of the
.Fl F .Fl F
flag, see the specifies the format of each line and
.Fl f
a filter.
Only buffers for which the filter is true are shown.
See the
.Sx FORMATS .Sx FORMATS
section. section.
.It Xo Ic load-buffer .It Xo Ic load-buffer
@ -5442,7 +5461,7 @@ The server crashed or otherwise exited without telling the client the reason.
understands some unofficial extensions to understands some unofficial extensions to
.Xr terminfo 5 : .Xr terminfo 5 :
.Bl -tag -width Ds .Bl -tag -width Ds
.It Em Cs , Cr .It Em \&Cs , Cr
Set the cursor colour. Set the cursor colour.
The first takes a single string argument and is used to set the colour; The first takes a single string argument and is used to set the colour;
the second takes no arguments and restores the default cursor colour. the second takes no arguments and restores the default cursor colour.
@ -5506,6 +5525,11 @@ capabilities to the
.Nm .Nm
.Xr terminfo 5 .Xr terminfo 5
entry). entry).
.Pp
This is equivalent to the
.Em RGB
.Xr terminfo 5
capability.
.It Em \&Ms .It Em \&Ms
Store the current buffer in the host terminal's selection (clipboard). Store the current buffer in the host terminal's selection (clipboard).
See the See the

55
tmux.h
View File

@ -41,9 +41,11 @@ extern char **environ;
struct args; struct args;
struct args_value; struct args_value;
struct client; struct client;
struct cmd;
struct cmd_find_state; struct cmd_find_state;
struct cmdq_item; struct cmdq_item;
struct cmdq_list; struct cmdq_list;
struct cmds;
struct environ; struct environ;
struct format_job_tree; struct format_job_tree;
struct format_tree; struct format_tree;
@ -52,8 +54,8 @@ struct job;
struct mode_tree_data; struct mode_tree_data;
struct mouse_event; struct mouse_event;
struct options; struct options;
struct options_entry;
struct options_array_item; struct options_array_item;
struct options_entry;
struct session; struct session;
struct tmuxpeer; struct tmuxpeer;
struct tmuxproc; struct tmuxproc;
@ -845,11 +847,11 @@ struct window_mode {
void (*formats)(struct window_mode_entry *, void (*formats)(struct window_mode_entry *,
struct format_tree *); struct format_tree *);
}; };
#define WINDOW_MODE_TIMEOUT 180
/* Active window mode. */ /* Active window mode. */
struct window_mode_entry { struct window_mode_entry {
struct window_pane *wp; struct window_pane *wp;
struct window_pane *swp;
const struct window_mode *mode; const struct window_mode *mode;
void *data; void *data;
@ -1337,27 +1339,11 @@ struct cmd_find_state {
#define CMD_FIND_EXACT_WINDOW 0x20 #define CMD_FIND_EXACT_WINDOW 0x20
#define CMD_FIND_CANFAIL 0x40 #define CMD_FIND_CANFAIL 0x40
/* Command and list of commands. */ /* List of commands. */
struct cmd {
const struct cmd_entry *entry;
struct args *args;
u_int group;
char *file;
u_int line;
char *alias;
int argc;
char **argv;
TAILQ_ENTRY(cmd) qentry;
};
TAILQ_HEAD(cmds, cmd);
struct cmd_list { struct cmd_list {
int references; int references;
u_int group; u_int group;
struct cmds list; struct cmds *list;
}; };
/* Command return values. */ /* Command return values. */
@ -2104,6 +2090,7 @@ int cmd_find_from_mouse(struct cmd_find_state *,
int cmd_find_from_nothing(struct cmd_find_state *, int); int cmd_find_from_nothing(struct cmd_find_state *, int);
/* cmd.c */ /* cmd.c */
extern const struct cmd_entry *cmd_table[];
void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...); void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
void cmd_prepend_argv(int *, char ***, char *); void cmd_prepend_argv(int *, char ***, char *);
void cmd_append_argv(int *, char ***, char *); void cmd_append_argv(int *, char ***, char *);
@ -2113,16 +2100,27 @@ char **cmd_copy_argv(int, char **);
void cmd_free_argv(int, char **); void cmd_free_argv(int, char **);
char *cmd_stringify_argv(int, char **); char *cmd_stringify_argv(int, char **);
char *cmd_get_alias(const char *); char *cmd_get_alias(const char *);
const struct cmd_entry *cmd_get_entry(struct cmd *);
struct args *cmd_get_args(struct cmd *);
void cmd_get_source(struct cmd *, const char **, u_int *);
struct cmd *cmd_parse(int, char **, const char *, u_int, char **); struct cmd *cmd_parse(int, char **, const char *, u_int, char **);
void cmd_free(struct cmd *); void cmd_free(struct cmd *);
char *cmd_print(struct cmd *); char *cmd_print(struct cmd *);
struct cmd_list *cmd_list_new(void);
void cmd_list_append(struct cmd_list *, struct cmd *);
void cmd_list_move(struct cmd_list *, struct cmd_list *);
void cmd_list_free(struct cmd_list *);
char *cmd_list_print(struct cmd_list *, int);
struct cmd *cmd_list_first(struct cmd_list *, u_int *);
struct cmd *cmd_list_next(struct cmd *, u_int *);
int cmd_list_all_have(struct cmd_list *, int);
int cmd_list_any_have(struct cmd_list *, int);
int cmd_mouse_at(struct window_pane *, struct mouse_event *, int cmd_mouse_at(struct window_pane *, struct mouse_event *,
u_int *, u_int *, int); u_int *, u_int *, int);
struct winlink *cmd_mouse_window(struct mouse_event *, struct session **); struct winlink *cmd_mouse_window(struct mouse_event *, struct session **);
struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **, struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **,
struct winlink **); struct winlink **);
char *cmd_template_replace(const char *, const char *, int); char *cmd_template_replace(const char *, const char *, int);
extern const struct cmd_entry *cmd_table[];
/* cmd-attach-session.c */ /* cmd-attach-session.c */
enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int, enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int,
@ -2138,13 +2136,6 @@ struct cmd_parse_result *cmd_parse_from_buffer(const void *, size_t,
struct cmd_parse_result *cmd_parse_from_arguments(int, char **, struct cmd_parse_result *cmd_parse_from_arguments(int, char **,
struct cmd_parse_input *); struct cmd_parse_input *);
/* cmd-list.c */
struct cmd_list *cmd_list_new(void);
void cmd_list_append(struct cmd_list *, struct cmd *);
void cmd_list_move(struct cmd_list *, struct cmd_list *);
void cmd_list_free(struct cmd_list *);
char *cmd_list_print(struct cmd_list *, int);
/* cmd-queue.c */ /* cmd-queue.c */
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);
@ -2539,8 +2530,8 @@ void window_pane_unset_palette(struct window_pane *, u_int);
void window_pane_reset_palette(struct window_pane *); void window_pane_reset_palette(struct window_pane *);
int window_pane_get_palette(struct window_pane *, int); int window_pane_get_palette(struct window_pane *, int);
int window_pane_set_mode(struct window_pane *, int window_pane_set_mode(struct window_pane *,
const struct window_mode *, struct cmd_find_state *, struct window_pane *, const struct window_mode *,
struct args *); struct cmd_find_state *, struct args *);
void window_pane_reset_mode(struct window_pane *); void window_pane_reset_mode(struct window_pane *);
void window_pane_reset_mode_all(struct window_pane *); void window_pane_reset_mode_all(struct window_pane *);
int window_pane_key(struct window_pane *, struct client *, int window_pane_key(struct window_pane *, struct client *,

View File

@ -130,7 +130,7 @@ static void window_copy_rectangle_toggle(struct window_mode_entry *);
static void window_copy_move_mouse(struct mouse_event *); static void window_copy_move_mouse(struct mouse_event *);
static void window_copy_drag_update(struct client *, struct mouse_event *); static void window_copy_drag_update(struct client *, struct mouse_event *);
static void window_copy_drag_release(struct client *, struct mouse_event *); static void window_copy_drag_release(struct client *, struct mouse_event *);
static struct screen* window_copy_clone_screen(struct screen *src); static struct screen* window_copy_clone_screen(struct screen *, struct screen*);
const struct window_mode window_copy_mode = { const struct window_mode window_copy_mode = {
.name = "copy-mode", .name = "copy-mode",
@ -299,21 +299,29 @@ window_copy_scroll_timer(__unused int fd, __unused short events, void *arg)
} }
static struct screen * static struct screen *
window_copy_clone_screen(struct screen *src) window_copy_clone_screen(struct screen *src, struct screen *hint)
{ {
struct screen *dst; struct screen *dst;
struct screen_write_ctx ctx; struct screen_write_ctx ctx;
u_int dy, sy;
dst = xcalloc(1, sizeof *dst); dst = xcalloc(1, sizeof *dst);
screen_init(dst, screen_size_x(src),
screen_hsize(src) + screen_size_y(src), src->grid->hlimit); sy = screen_hsize(src) + screen_size_y(src);
grid_duplicate_lines(dst->grid, 0, src->grid, 0, if (screen_size_y(hint) > sy)
screen_hsize(src) + screen_size_y(src)); dy = screen_size_y(hint);
dst->grid->sy = screen_size_y(src); else
dst->grid->hsize = screen_hsize(src); dy = sy;
screen_init(dst, screen_size_x(src), dy, src->grid->hlimit);
grid_duplicate_lines(dst->grid, 0, src->grid, 0, sy);
if (screen_size_y(hint) < sy) {
dst->grid->sy = screen_size_y(hint);
dst->grid->hsize = sy - screen_size_y(hint);
}
screen_write_start(&ctx, NULL, dst); screen_write_start(&ctx, NULL, dst);
screen_write_cursormove(&ctx, src->cx, src->cy, 0); screen_write_cursormove(&ctx, 0, dst->grid->sy - 1, 0);
screen_write_stop(&ctx); screen_write_stop(&ctx);
return (dst); return (dst);
@ -361,14 +369,14 @@ static struct screen *
window_copy_init(struct window_mode_entry *wme, window_copy_init(struct window_mode_entry *wme,
__unused struct cmd_find_state *fs, struct args *args) __unused struct cmd_find_state *fs, struct args *args)
{ {
struct window_pane *wp = wme->wp; struct window_pane *wp = wme->swp;
struct window_copy_mode_data *data; struct window_copy_mode_data *data;
struct screen_write_ctx ctx; struct screen_write_ctx ctx;
u_int i; u_int i;
data = window_copy_common_init(wme); data = window_copy_common_init(wme);
data->backing = window_copy_clone_screen(&wp->base); data->backing = window_copy_clone_screen(&wp->base, &data->screen);
data->cx = data->backing->cx; data->cx = data->backing->cx;
data->cy = data->backing->cy; data->cy = data->backing->cy;
@ -2001,7 +2009,7 @@ static enum window_copy_cmd_action
window_copy_cmd_refresh_from_pane(struct window_copy_cmd_state *cs) window_copy_cmd_refresh_from_pane(struct window_copy_cmd_state *cs)
{ {
struct window_mode_entry *wme = cs->wme; struct window_mode_entry *wme = cs->wme;
struct window_pane *wp = wme->wp; struct window_pane *wp = wme->swp;
struct window_copy_mode_data *data = wme->data; struct window_copy_mode_data *data = wme->data;
if (data->viewmode) if (data->viewmode)
@ -2009,7 +2017,7 @@ window_copy_cmd_refresh_from_pane(struct window_copy_cmd_state *cs)
screen_free(data->backing); screen_free(data->backing);
free(data->backing); free(data->backing);
data->backing = window_copy_clone_screen(&wp->base); data->backing = window_copy_clone_screen(&wp->base, &data->screen);
return (WINDOW_COPY_CMD_REDRAW); return (WINDOW_COPY_CMD_REDRAW);
} }
@ -2964,6 +2972,7 @@ window_copy_write_line(struct window_mode_entry *wme,
struct grid_cell gc; struct grid_cell gc;
char hdr[512]; char hdr[512];
size_t size = 0; size_t size = 0;
u_int hsize = screen_hsize(data->backing);
style_apply(&gc, oo, "mode-style"); style_apply(&gc, oo, "mode-style");
gc.flags |= GRID_FLAG_NOPALETTE; gc.flags |= GRID_FLAG_NOPALETTE;
@ -2972,23 +2981,20 @@ window_copy_write_line(struct window_mode_entry *wme,
if (data->searchmark == NULL) { if (data->searchmark == NULL) {
if (data->timeout) { if (data->timeout) {
size = xsnprintf(hdr, sizeof hdr, size = xsnprintf(hdr, sizeof hdr,
"(timed out) [%u/%u]", data->oy, "(timed out) [%u/%u]", data->oy, hsize);
screen_hsize(data->backing));
} else { } else {
size = xsnprintf(hdr, sizeof hdr, size = xsnprintf(hdr, sizeof hdr,
"[%u/%u]", data->oy, "[%u/%u]", data->oy, hsize);
screen_hsize(data->backing));
} }
} else { } else {
if (data->searchthis == -1) { if (data->searchthis == -1) {
size = xsnprintf(hdr, sizeof hdr, size = xsnprintf(hdr, sizeof hdr,
"(%u results) [%d/%u]", data->searchcount, "(%u results) [%d/%u]", data->searchcount,
data->oy, screen_hsize(data->backing)); data->oy, hsize);
} else { } else {
size = xsnprintf(hdr, sizeof hdr, size = xsnprintf(hdr, sizeof hdr,
"(%u/%u results) [%d/%u]", data->searchthis, "(%u/%u results) [%d/%u]", data->searchthis,
data->searchcount, data->oy, data->searchcount, data->oy, hsize);
screen_hsize(data->backing));
} }
} }
if (size > screen_size_x(s)) if (size > screen_size_x(s))
@ -3000,8 +3006,7 @@ window_copy_write_line(struct window_mode_entry *wme,
if (size < screen_size_x(s)) { if (size < screen_size_x(s)) {
screen_write_cursormove(ctx, 0, py, 0); screen_write_cursormove(ctx, 0, py, 0);
screen_write_copy(ctx, data->backing, 0, screen_write_copy(ctx, data->backing, 0, hsize - data->oy + py,
(screen_hsize(data->backing) - data->oy) + py,
screen_size_x(s) - size, 1, data->searchmark, &gc); screen_size_x(s) - size, 1, data->searchmark, &gc);
} }

View File

@ -833,7 +833,7 @@ window_tree_search(__unused void *modedata, void *itemdata, const char *ss)
return (0); return (0);
retval = (strstr(cmd, ss) != NULL); retval = (strstr(cmd, ss) != NULL);
free(cmd); free(cmd);
return retval; return (retval);
} }
return (0); return (0);
} }

View File

@ -1077,8 +1077,9 @@ window_pane_get_palette(struct window_pane *wp, int c)
} }
int int
window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode, window_pane_set_mode(struct window_pane *wp, struct window_pane *swp,
struct cmd_find_state *fs, struct args *args) const struct window_mode *mode, struct cmd_find_state *fs,
struct args *args)
{ {
struct window_mode_entry *wme; struct window_mode_entry *wme;
@ -1095,6 +1096,7 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode,
} else { } else {
wme = xcalloc(1, sizeof *wme); wme = xcalloc(1, sizeof *wme);
wme->wp = wp; wme->wp = wp;
wme->swp = swp;
wme->mode = mode; wme->mode = mode;
wme->prefix = 1; wme->prefix = 1;
TAILQ_INSERT_HEAD(&wp->modes, wme, entry); TAILQ_INSERT_HEAD(&wp->modes, wme, entry);