aboutsummaryrefslogtreecommitdiff
path: root/cmd-choose-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-02-10 17:32:58 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-02-10 17:32:58 +0000
commit4d382ae8e6c71c5414dc41053223c05400d923f8 (patch)
tree7b2f3526edeec9fb799a1228df00bd3b34439675 /cmd-choose-buffer.c
parent418ba99078a2712ece398e17a5a9bc1f6600126b (diff)
downloadrtmux-4d382ae8e6c71c5414dc41053223c05400d923f8.tar.gz
rtmux-4d382ae8e6c71c5414dc41053223c05400d923f8.tar.bz2
rtmux-4d382ae8e6c71c5414dc41053223c05400d923f8.zip
Miscellaneous tidying of choose API, including:
- rename client and session to start_client and start_session in window_choose_data struct. also add TREE_OTHER define and reorder the struct - rename window_choose_ctx to window_choose_data_run - don't pass a cmd_ctx into window_choose_create (will let it use a different client later). instead take type, session, client - add window_choose_data_free and use it to dispose of wcd rather than each cmd-*.c doing it individually - change so ref counting is done by wcd_add and wcd_free rather than callers. this means 1 ref for each item but what of it :-) - also add a ref to tree_session - not sure if this is needed? - all the callbacks except choose-client and find-window are the same so remove them and add window_choose_default_callback - reorder/rename some other bits and pieces for tidyness
Diffstat (limited to 'cmd-choose-buffer.c')
-rw-r--r--cmd-choose-buffer.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c
index 50505ea1..21f74f1c 100644
--- a/cmd-choose-buffer.c
+++ b/cmd-choose-buffer.c
@@ -29,9 +29,6 @@
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
-void cmd_choose_buffer_callback(struct window_choose_data *);
-void cmd_choose_buffer_free(struct window_choose_data *);
-
const struct cmd_entry cmd_choose_buffer_entry = {
"choose-buffer", NULL,
"F:t:", 0, 1,
@@ -46,6 +43,7 @@ enum cmd_retval
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
+ struct client *c;
struct window_choose_data *cdata;
struct winlink *wl;
struct paste_buffer *pb;
@@ -57,6 +55,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
ctx->error(ctx, "must be run interactively");
return (CMD_RETURN_ERROR);
}
+ c = ctx->curclient;
if ((template = args_get(args, 'F')) == NULL)
template = CHOOSE_BUFFER_TEMPLATE;
@@ -77,9 +76,8 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
idx = 0;
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
- cdata = window_choose_data_create(ctx);
+ cdata = window_choose_data_create(TREE_OTHER, c, c->session);
cdata->idx = idx - 1;
- cdata->client->references++;
cdata->ft_template = xstrdup(template);
format_add(cdata->ft, "line", "%u", idx - 1);
@@ -93,34 +91,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
}
free(action);
- window_choose_ready(wl->window->active,
- 0, cmd_choose_buffer_callback, cmd_choose_buffer_free);
+ window_choose_ready(wl->window->active, 0, NULL, NULL);
return (CMD_RETURN_NORMAL);
}
-
-void
-cmd_choose_buffer_callback(struct window_choose_data *cdata)
-{
- if (cdata == NULL)
- return;
- if (cdata->client->flags & CLIENT_DEAD)
- return;
-
- window_choose_ctx(cdata);
-}
-
-void
-cmd_choose_buffer_free(struct window_choose_data *data)
-{
- struct window_choose_data *cdata = data;
-
- if (cdata == NULL)
- return;
-
- cdata->client->references--;
-
- free(cdata->command);
- free(cdata->ft_template);
- free(cdata);
-}