summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-find-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-21 16:08:26 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-21 16:08:26 +0000
commit11acb26f8ba0d9cfe239c44002ea5d6c27c39250 (patch)
tree2c3169ec5d71b660a35fd878796d7aa6eaf17726 /usr.bin/tmux/cmd-find-window.c
parentff9aa3a975061758e959ffc2d5802e8608155f69 (diff)
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 - also add a ref to tree_session - 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 'usr.bin/tmux/cmd-find-window.c')
-rw-r--r--usr.bin/tmux/cmd-find-window.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c
index 2c73753cda5..0d47fdc8009 100644
--- a/usr.bin/tmux/cmd-find-window.c
+++ b/usr.bin/tmux/cmd-find-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find-window.c,v 1.20 2012/10/25 11:26:47 nicm Exp $ */
+/* $OpenBSD: cmd-find-window.c,v 1.21 2013/03/21 16:08:24 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,6 @@
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
void cmd_find_window_callback(struct window_choose_data *);
-void cmd_find_window_free(struct window_choose_data *);
/* Flags for determining matching behavior. */
#define CMD_FIND_WINDOW_BY_TITLE 0x1
@@ -131,6 +130,7 @@ enum cmd_retval
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
+ struct client *c;
struct window_choose_data *cdata;
struct session *s;
struct winlink *wl, *wm;
@@ -143,7 +143,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
ctx->error(ctx, "must be run interactively");
return (CMD_RETURN_ERROR);
}
- s = ctx->curclient->session;
+ c = ctx->curclient;
+ s = c->session;
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
@@ -180,9 +181,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
for (i = 0; i < ARRAY_LENGTH(&find_list); i++) {
wm = ARRAY_ITEM(&find_list, i).wl;
- cdata = window_choose_data_create(ctx);
+ cdata = window_choose_data_create(TREE_OTHER, c, c->session);
cdata->idx = wm->idx;
- cdata->client->references++;
cdata->wl = wm;
cdata->ft_template = xstrdup(template);
@@ -198,8 +198,8 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
window_choose_add(wl->window->active, cdata);
}
- window_choose_ready(wl->window->active,
- 0, cmd_find_window_callback, cmd_find_window_free);
+ window_choose_ready(wl->window->active, 0, cmd_find_window_callback,
+ NULL);
out:
ARRAY_FREE(&find_list);
@@ -215,7 +215,7 @@ cmd_find_window_callback(struct window_choose_data *cdata)
if (cdata == NULL)
return;
- s = cdata->session;
+ s = cdata->start_session;
if (!session_alive(s))
return;
@@ -228,16 +228,3 @@ cmd_find_window_callback(struct window_choose_data *cdata)
recalculate_sizes();
}
}
-
-void
-cmd_find_window_free(struct window_choose_data *cdata)
-{
- if (cdata == NULL)
- return;
-
- cdata->session->references--;
-
- free(cdata->ft_template);
- format_free(cdata->ft);
- free(cdata);
-}