diff options
73 files changed, 1001 insertions, 971 deletions
@@ -35,7 +35,7 @@ static u_int cfg_ncauses; struct client *cfg_client; static enum cmd_retval -cfg_done(__unused struct cmd_q *cmdq, __unused void *data) +cfg_done(__unused struct cmdq_item *item, __unused void *data) { if (cfg_finished) return (CMD_RETURN_NORMAL); @@ -79,15 +79,15 @@ start_cfg(void) } int -load_cfg(const char *path, struct client *c, struct cmd_q *cmdq, int quiet) +load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet) { - FILE *f; - char delim[3] = { '\\', '\\', '\0' }; - u_int found; - size_t line = 0; - char *buf, *cause1, *p; - struct cmd_list *cmdlist; - struct cmd_q *new_cmdq; + FILE *f; + char delim[3] = { '\\', '\\', '\0' }; + u_int found; + size_t line = 0; + char *buf, *cause1, *p; + struct cmd_list *cmdlist; + struct cmdq_item *new_item; log_debug("loading %s", path); if ((f = fopen(path, "rb")) == NULL) { @@ -123,11 +123,11 @@ load_cfg(const char *path, struct client *c, struct cmd_q *cmdq, int quiet) if (cmdlist == NULL) continue; - new_cmdq = cmdq_get_command(cmdlist, NULL, NULL, 0); - if (cmdq != NULL) - cmdq_insert_after(cmdq, new_cmdq); + new_item = cmdq_get_command(cmdlist, NULL, NULL, 0); + if (item != NULL) + cmdq_insert_after(item, new_item); else - cmdq_append(c, new_cmdq); + cmdq_append(c, new_item); cmd_list_free(cmdlist); found++; @@ -153,12 +153,12 @@ cfg_add_cause(const char *fmt, ...) } void -cfg_print_causes(struct cmd_q *cmdq) +cfg_print_causes(struct cmdq_item *item) { u_int i; for (i = 0; i < cfg_ncauses; i++) { - cmdq_print(cmdq, "%s", cfg_causes[i]); + cmdq_print(item, "%s", cfg_causes[i]); free(cfg_causes[i]); } diff --git a/cmd-attach-session.c b/cmd-attach-session.c index f0e860f9..d999eb76 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -30,7 +30,8 @@ * Attach existing session to the current terminal. */ -static enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_attach_session_exec(struct cmd *, + struct cmdq_item *); const struct cmd_entry cmd_attach_session_entry = { .name = "attach-session", @@ -46,26 +47,26 @@ const struct cmd_entry cmd_attach_session_entry = { }; enum cmd_retval -cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag, - int Eflag) +cmd_attach_session(struct cmdq_item *item, int dflag, int rflag, + const char *cflag, int Eflag) { - struct session *s = cmdq->state.tflag.s; - struct client *c = cmdq->client, *c_loop; - struct winlink *wl = cmdq->state.tflag.wl; - struct window_pane *wp = cmdq->state.tflag.wp; + struct session *s = item->state.tflag.s; + struct client *c = item->client, *c_loop; + struct winlink *wl = item->state.tflag.wl; + struct window_pane *wp = item->state.tflag.wp; const char *update; char *cause, *cwd; struct format_tree *ft; if (RB_EMPTY(&sessions)) { - cmdq_error(cmdq, "no sessions"); + cmdq_error(item, "no sessions"); return (CMD_RETURN_ERROR); } if (c == NULL) return (CMD_RETURN_NORMAL); if (server_client_check_nested(c)) { - cmdq_error(cmdq, "sessions should be nested with care, " + cmdq_error(item, "sessions should be nested with care, " "unset $TMUX to force"); return (CMD_RETURN_ERROR); } @@ -77,7 +78,7 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag, } if (cflag != NULL) { - ft = format_create(cmdq, 0); + ft = format_create(item, 0); format_defaults(ft, c, s, wl, wp); cwd = format_expand(ft, cflag); format_free(ft); @@ -111,7 +112,7 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag, s->curw->flags &= ~WINLINK_ALERTFLAGS; } else { if (server_client_open(c, &cause) != 0) { - cmdq_error(cmdq, "open terminal failed: %s", cause); + cmdq_error(item, "open terminal failed: %s", cause); free(cause); return (CMD_RETURN_ERROR); } @@ -155,10 +156,10 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag, } static enum cmd_retval -cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - return (cmd_attach_session(cmdq, args_has(args, 'd'), + return (cmd_attach_session(item, args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'), args_has(args, 'E'))); } diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 8c1acba9..4650afb1 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -27,10 +27,10 @@ * Bind a key to a command, this recurses through cmd_*. */ -static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *); -static enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *, - key_code); +static enum cmd_retval cmd_bind_key_mode_table(struct cmd *, + struct cmdq_item *, key_code); const struct cmd_entry cmd_bind_key_entry = { .name = "bind-key", @@ -45,7 +45,7 @@ const struct cmd_entry cmd_bind_key_entry = { }; static enum cmd_retval -cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; char *cause; @@ -55,24 +55,24 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq) if (args_has(args, 't')) { if (args->argc != 2 && args->argc != 3) { - cmdq_error(cmdq, "not enough arguments"); + cmdq_error(item, "not enough arguments"); return (CMD_RETURN_ERROR); } } else { if (args->argc < 2) { - cmdq_error(cmdq, "not enough arguments"); + cmdq_error(item, "not enough arguments"); return (CMD_RETURN_ERROR); } } key = key_string_lookup_string(args->argv[0]); if (key == KEYC_NONE || key == KEYC_UNKNOWN) { - cmdq_error(cmdq, "unknown key: %s", args->argv[0]); + cmdq_error(item, "unknown key: %s", args->argv[0]); return (CMD_RETURN_ERROR); } if (args_has(args, 't')) - return (cmd_bind_key_mode_table(self, cmdq, key)); + return (cmd_bind_key_mode_table(self, item, key)); if (args_has(args, 'T')) tablename = args_get(args, 'T'); @@ -84,7 +84,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq) cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0, &cause); if (cmdlist == NULL) { - cmdq_error(cmdq, "%s", cause); + cmdq_error(item, "%s", cause); free(cause); return (CMD_RETURN_ERROR); } @@ -94,7 +94,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq) } static enum cmd_retval -cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) +cmd_bind_key_mode_table(struct cmd *self, struct cmdq_item *item, key_code key) { struct args *args = self->args; const char *tablename; @@ -104,18 +104,18 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { - cmdq_error(cmdq, "unknown key table: %s", tablename); + cmdq_error(item, "unknown key table: %s", tablename); return (CMD_RETURN_ERROR); } cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]); if (cmd == MODEKEY_NONE) { - cmdq_error(cmdq, "unknown command: %s", args->argv[1]); + cmdq_error(item, "unknown command: %s", args->argv[1]); return (CMD_RETURN_ERROR); } if (args->argc != 2) { - cmdq_error(cmdq, "no argument allowed"); + cmdq_error(item, "no argument allowed"); return (CMD_RETURN_ERROR); } diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 75562750..a5d4e148 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -28,7 +28,7 @@ #define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" -static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmdq_item *); const struct cmd_entry cmd_break_pane_entry = { .name = "break-pane", @@ -45,28 +45,28 @@ const struct cmd_entry cmd_break_pane_entry = { }; static enum cmd_retval -cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - struct winlink *wl = cmdq->state.sflag.wl; - struct session *src_s = cmdq->state.sflag.s; - struct session *dst_s = cmdq->state.tflag.s; - struct window_pane *wp = cmdq->state.sflag.wp; + struct winlink *wl = item->state.sflag.wl; + struct session *src_s = item->state.sflag.s; + struct session *dst_s = item->state.tflag.s; + struct window_pane *wp = item->state.sflag.wp; struct window *w = wl->window; char *name; char *cause; - int idx = cmdq->state.tflag.idx; + int idx = item->state.tflag.idx; struct format_tree *ft; const char *template; char *cp; if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) { - cmdq_error(cmdq, "index %d already in use", idx); + cmdq_error(item, "index %d already in use", idx); return (CMD_RETURN_ERROR); } if (window_count_panes(w) == 1) { - cmdq_error(cmdq, "can't break with only one pane"); + cmdq_error(item, "can't break with only one pane"); return (CMD_RETURN_ERROR); } server_unzoom_window(w); @@ -101,11 +101,11 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq) if ((template = args_get(args, 'F')) == NULL) template = BREAK_PANE_TEMPLATE; - ft = format_create(cmdq, 0); - format_defaults(ft, cmdq->state.c, dst_s, wl, wp); + ft = format_create(item, 0); + format_defaults(ft, item->state.c, dst_s, wl, wp); cp = format_expand(ft, template); - cmdq_print(cmdq, "%s", cp); + cmdq_print(item, "%s", cp); free(cp); format_free(ft); diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 6cf885bc..1ed00b9e 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -27,14 +27,13 @@ * Write the entire contents of a pane to a buffer or stdout. */ -static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *); -static char *cmd_capture_pane_append(char *, size_t *, char *, - size_t); -static char *cmd_capture_pane_pending(struct args *, - struct window_pane *, size_t *); -static char *cmd_capture_pane_history(struct args *, struct cmd_q *, - struct window_pane *, size_t *); +static char *cmd_capture_pane_append(char *, size_t *, char *, size_t); +static char *cmd_capture_pane_pending(struct args *, struct window_pane *, + size_t *); +static char *cmd_capture_pane_history(struct args *, struct cmdq_item *, + struct window_pane *, size_t *); const struct cmd_entry cmd_capture_pane_entry = { .name = "capture-pane", @@ -92,7 +91,8 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp, } static char * -cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq, + +cmd_capture_pane_history(struct args *args, struct cmdq_item *item, struct window_pane *wp, size_t *len) { struct grid *gd; @@ -109,7 +109,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq, gd = wp->saved_grid; if (gd == NULL) { if (!args_has(args, 'q')) { - cmdq_error(cmdq, "no alternate screen"); + cmdq_error(item, "no alternate screen"); return (NULL); } return (xstrdup("")); @@ -177,11 +177,11 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq, } static enum cmd_retval -cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct client *c; - struct window_pane *wp = cmdq->state.tflag.wp; + struct window_pane *wp = item->state.tflag.wp; char *buf, *cause; const char *bufname; size_t len; @@ -190,15 +190,15 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) if (args_has(args, 'P')) buf = cmd_capture_pane_pending(args, wp, &len); else - buf = cmd_capture_pane_history(args, cmdq, wp, &len); + buf = cmd_capture_pane_history(args, item, wp, &len); if (buf == NULL) return (CMD_RETURN_ERROR); if (args_has(args, 'p')) { - c = cmdq->client; + c = item->client; if (c == NULL || (c->session != NULL && !(c->flags & CLIENT_CONTROL))) { - cmdq_error(cmdq, "can't write to stdout"); + cmdq_error(item, "can't write to stdout"); free(buf); return (CMD_RETURN_ERROR); } @@ -213,7 +213,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) bufname = args_get(args, 'b'); if (paste_set(buf, len, bufname, &cause) != 0) { - cmdq_error(cmdq, "%s", cause); + cmdq_error(item, "%s", cause); free(cause); free(buf); return (CMD_RETURN_ERROR); diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c index fee4958a..ae619b6c 100644 --- a/cmd-choose-buffer.c +++ b/cmd-choose-buffer.c @@ -30,7 +30,8 @@ #define CHOOSE_BUFFER_TEMPLATE \ "#{buffer_name}: #{buffer_size} bytes: #{buffer_sample}" -static enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_choose_buffer_exec(struct cmd *, + struct cmdq_item *); const struct cmd_entry cmd_choose_buffer_entry = { .name = "choose-buffer", @@ -46,11 +47,11 @@ const struct cmd_entry cmd_choose_buffer_entry = { }; static enum cmd_retval -cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_choose_buffer_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - struct client *c = cmdq->state.c; - struct winlink *wl = cmdq->state.tflag.wl; + struct client *c = item->state.c; + struct winlink *wl = item->state.tflag.wl; struct window_choose_data *cdata; struct paste_buffer *pb; char *action, *action_data; @@ -58,7 +59,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq) u_int idx; if (c == NULL) { - cmdq_error(cmdq, "no client available"); + cmdq_error(item, "no client available"); return (CMD_RETURN_ERROR); } diff --git a/cmd-choose-client.c b/cmd-choose-client.c index 67d184b3..2a64da69 100644 --- a/cmd-choose-client.c +++ b/cmd-choose-client.c @@ -33,7 +33,8 @@ "#{?client_utf8, (utf8),}#{?client_readonly, (ro),} " \ "(last used #{t:client_activity})" -static enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_choose_client_exec(struct cmd *, + struct cmdq_item *); static void cmd_choose_client_callback(struct window_choose_data *); @@ -55,19 +56,19 @@ struct cmd_choose_client_data { }; static enum cmd_retval -cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_choose_client_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - struct client *c = cmdq->state.c; + struct client *c = item->state.c; struct client *c1; struct window_choose_data *cdata; - struct winlink *wl = cmdq->state.tflag.wl; + struct winlink *wl = item->state.tflag.wl; const char *template; char *action; u_int idx, cur; if (c == NULL) { - cmdq_error(cmdq, "no client available"); + cmdq_error(item, "no client available"); return (CMD_RETURN_ERROR); } @@ -86,7 +87,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq) TAILQ_FOREACH(c1, &clients, entry) { if (c1->session == NULL || c1->tty.path == NULL) continue; - if (c1 == cmdq->client) + if (c1 == item->client) cur = idx; cdata = window_choose_data_create(TREE_OTHER, c, c->session); diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index 13bbe2a7..65d55407 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ - |