aboutsummaryrefslogtreecommitdiff
path: root/cmd-choose-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-choose-list.c')
-rw-r--r--cmd-choose-list.c41
1 files changed, 8 insertions, 33 deletions
diff --git a/cmd-choose-list.c b/cmd-choose-list.c
index 4c32e694..15f87294 100644
--- a/cmd-choose-list.c
+++ b/cmd-choose-list.c
@@ -31,10 +31,7 @@
* Enter choose mode to choose a custom list.
*/
-enum cmd_retval cmd_choose_list_exec(struct cmd *, struct cmd_ctx *);
-
-void cmd_choose_list_callback(struct window_choose_data *);
-void cmd_choose_list_free(struct window_choose_data *);
+enum cmd_retval cmd_choose_list_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_choose_list_entry = {
"choose-list", NULL,
@@ -47,23 +44,24 @@ const struct cmd_entry cmd_choose_list_entry = {
};
enum cmd_retval
-cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
+cmd_choose_list_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
+ struct client *c;
struct winlink *wl;
const char *list1;
char *template, *item, *copy, *list;
u_int idx;
- if (ctx->curclient == NULL) {
- ctx->error(ctx, "must be run interactively");
+ if ((c = cmd_current_client(cmdq)) == NULL) {
+ cmdq_error(cmdq, "no client available");
return (CMD_RETURN_ERROR);
}
if ((list1 = args_get(args, 'l')) == NULL)
return (CMD_RETURN_ERROR);
- if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
+ if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
@@ -80,7 +78,7 @@ cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
{
if (*item == '\0') /* no empty entries */
continue;
- window_choose_add_item(wl->window->active, ctx, wl, item,
+ window_choose_add_item(wl->window->active, c, wl, item,
template, idx);
idx++;
}
@@ -92,32 +90,9 @@ cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
return (CMD_RETURN_ERROR);
}
- window_choose_ready(wl->window->active, 0, cmd_choose_list_callback,
- cmd_choose_list_free);
+ window_choose_ready(wl->window->active, 0, NULL);
free(template);
return (CMD_RETURN_NORMAL);
}
-
-void
-cmd_choose_list_callback(struct window_choose_data *cdata)
-{
- if (cdata == NULL || (cdata->client->flags & CLIENT_DEAD))
- return;
-
- window_choose_ctx(cdata);
-}
-
-void
-cmd_choose_list_free(struct window_choose_data *cdata)
-{
- cdata->session->references--;
- cdata->client->references--;
-
- free(cdata->ft_template);
- free(cdata->command);
- format_free(cdata->ft);
- free(cdata);
-
-}