diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-21 16:10:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-21 16:10:00 +0000 |
commit | c453333608305c138898896122c071c4a097b7c4 (patch) | |
tree | 01da80a10a789cca0f5cf1d6df418af14131e345 | |
parent | bb2f551d2454279521f9535fe6fc2751e1bf5819 (diff) |
Allow choose commands to be used outside tmux, so long as at least one
client is attached.
-rw-r--r-- | usr.bin/tmux/cmd-choose-buffer.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-choose-client.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-choose-list.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-choose-tree.c | 14 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-find-window.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 25 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 8 | ||||
-rw-r--r-- | usr.bin/tmux/window-choose.c | 11 |
8 files changed, 39 insertions, 49 deletions
diff --git a/usr.bin/tmux/cmd-choose-buffer.c b/usr.bin/tmux/cmd-choose-buffer.c index 75c293d61d1..54236b1f973 100644 --- a/usr.bin/tmux/cmd-choose-buffer.c +++ b/usr.bin/tmux/cmd-choose-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-buffer.c,v 1.12 2013/03/21 16:09:17 nicm Exp $ */ +/* $OpenBSD: cmd-choose-buffer.c,v 1.13 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> @@ -51,11 +51,10 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) const char *template; u_int idx; - if (ctx->curclient == NULL) { - ctx->error(ctx, "must be run interactively"); + if ((c = cmd_current_client(ctx)) == NULL) { + ctx->error(ctx, "no client available"); return (CMD_RETURN_ERROR); } - c = ctx->curclient; if ((template = args_get(args, 'F')) == NULL) template = CHOOSE_BUFFER_TEMPLATE; diff --git a/usr.bin/tmux/cmd-choose-client.c b/usr.bin/tmux/cmd-choose-client.c index 316a03bc7f1..53aaefcad48 100644 --- a/usr.bin/tmux/cmd-choose-client.c +++ b/usr.bin/tmux/cmd-choose-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-client.c,v 1.15 2013/03/21 16:09:17 nicm Exp $ */ +/* $OpenBSD: cmd-choose-client.c,v 1.16 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -57,11 +57,10 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx) char *action; u_int i, idx, cur; - if (ctx->curclient == NULL) { - ctx->error(ctx, "must be run interactively"); + if ((c = cmd_current_client(ctx)) == NULL) { + ctx->error(ctx, "no client available"); return (CMD_RETURN_ERROR); } - c = ctx->curclient; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (CMD_RETURN_ERROR); diff --git a/usr.bin/tmux/cmd-choose-list.c b/usr.bin/tmux/cmd-choose-list.c index 30c40b0aeaa..5b5fa26adf7 100644 --- a/usr.bin/tmux/cmd-choose-list.c +++ b/usr.bin/tmux/cmd-choose-list.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-list.c,v 1.5 2013/03/21 16:09:17 nicm Exp $ */ +/* $Id: cmd-choose-list.c,v 1.6 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> @@ -47,13 +47,14 @@ enum cmd_retval cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx) { 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(ctx)) == NULL) { + ctx->error(ctx, "no client available"); return (CMD_RETURN_ERROR); } @@ -77,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++; } diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c index 8c3210b8304..b23d05c7239 100644 --- a/usr.bin/tmux/cmd-choose-tree.c +++ b/usr.bin/tmux/cmd-choose-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-tree.c,v 1.15 2013/03/21 16:09:17 nicm Exp $ */ +/* $OpenBSD: cmd-choose-tree.c,v 1.16 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> @@ -71,6 +71,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct winlink *wl, *wm; struct session *s, *s2; + struct client *c; struct window_choose_data *wcd = NULL; const char *ses_template, *win_template; char *final_win_action, *cur_win_template; @@ -83,12 +84,13 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) ses_template = win_template = NULL; ses_action = win_action = NULL; - if (ctx->curclient == NULL) { - ctx->error(ctx, "must be run interactively"); + if ((c = cmd_current_client(ctx)) == NULL) { + ctx->error(ctx, "no client available"); return (CMD_RETURN_ERROR); } - s = ctx->curclient->session; + if ((s = c->session) == NULL) + return (CMD_RETURN_ERROR); if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (CMD_RETURN_ERROR); @@ -172,7 +174,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) } wcd = window_choose_add_session(wl->window->active, - ctx, s2, ses_template, (char *)ses_action, idx_ses); + c, s2, ses_template, (char *)ses_action, idx_ses); /* If we're just choosing sessions, skip choosing windows. */ if (sflag && !wflag) { @@ -210,7 +212,7 @@ windows_only: cur_win_template = final_win_template_last; window_choose_add_window(wl->window->active, - ctx, s2, wm, cur_win_template, + c, s2, wm, cur_win_template, final_win_action, (wflag && !sflag) ? win_ses : idx_ses); diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c index b972508b58b..30a0e2322f0 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.22 2013/03/21 16:09:17 nicm Exp $ */ +/* $OpenBSD: cmd-find-window.c,v 1.23 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -139,11 +139,10 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) const char *template; u_int i, match_flags; - if (ctx->curclient == NULL) { - ctx->error(ctx, "must be run interactively"); + if ((c = cmd_current_client(ctx)) == NULL) { + ctx->error(ctx, "no client available"); return (CMD_RETURN_ERROR); } - c = ctx->curclient; s = c->session; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index c6b71430c13..fc1d83f6e9c 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.313 2013/01/17 00:11:22 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.314 2013/03/21 16:09:59 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 17 2013 $ +.Dd $Mdocdate: March 21 2013 $ .Dt TMUX 1 .Os .Sh NAME @@ -1074,8 +1074,7 @@ For the meaning of the flag, see the .Sx FORMATS section. -This command works only from inside -.Nm . +This command works only if at least one client is attached. .It Xo .Ic choose-list .Op Fl l Ar items @@ -1101,8 +1100,7 @@ also accepts format specifiers. For the meaning of this see the .Sx FORMATS section. -This command works only from inside -.Nm . +This command works only if at least one client is attached. .It Xo .Ic choose-session .Op Fl F Ar format @@ -1124,8 +1122,7 @@ For the meaning of the flag, see the .Sx FORMATS section. -This command works only from inside -.Nm . +This command works only if at least one client is attached. .It Xo .Ic choose-tree .Op Fl s @@ -1189,8 +1186,7 @@ and options, see the .Sx FORMATS section. -This command only works from inside -.Nm . +This command works only if at least one client is attached. .It Xo .Ic choose-window .Op Fl F Ar format @@ -1212,8 +1208,7 @@ For the meaning of the flag, see the .Sx FORMATS section. -This command works only from inside -.Nm . +This command works only if at least one client is attached. .It Ic display-panes Op Fl t Ar target-client .D1 (alias: Ic displayp) Display a visible indicator of each pane shown by @@ -1257,8 +1252,7 @@ For the meaning of the flag, see the .Sx FORMATS section. -This command only works from inside -.Nm . +This command works only if at least one client is attached. .It Xo Ic join-pane .Op Fl bdhv .Oo Fl l @@ -3306,8 +3300,7 @@ For the meaning of the flag, see the .Sx FORMATS section. -This command works only from inside -.Nm . +This command works only if at least one client is attached. .It Ic clear-history Op Fl t Ar target-pane .D1 (alias: Ic clearhist ) Remove and free the history for the specified pane. diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 164f0ce6f61..ca0ec7f5e3f 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.376 2013/03/21 16:09:17 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.377 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -2208,13 +2208,13 @@ struct window_choose_data *window_choose_data_create (int, void window_choose_data_free(struct window_choose_data *); void window_choose_data_run(struct window_choose_data *); struct window_choose_data *window_choose_add_window(struct window_pane *, - struct cmd_ctx *, struct session *, struct winlink *, + struct client *, struct session *, struct winlink *, const char *, char *, u_int); struct window_choose_data *window_choose_add_session(struct window_pane *, - struct cmd_ctx *, struct session *, const char *, + struct client *, struct session *, const char *, char *, u_int); struct window_choose_data *window_choose_add_item(struct window_pane *, - struct cmd_ctx *, struct winlink *, const char *, + struct client *, struct winlink *, const char *, char *, u_int); void window_choose_expand_all(struct window_pane *); diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c index 48caec2c794..e802826c291 100644 --- a/usr.bin/tmux/window-choose.c +++ b/usr.bin/tmux/window-choose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-choose.c,v 1.34 2013/03/21 16:09:17 nicm Exp $ */ +/* $OpenBSD: window-choose.c,v 1.35 2013/03/21 16:09:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -863,11 +863,10 @@ window_choose_scroll_down(struct window_pane *wp) } struct window_choose_data * -window_choose_add_session(struct window_pane *wp, struct cmd_ctx *ctx, +window_choose_add_session(struct window_pane *wp, struct client *c, struct session *s, const char *template, char *action, u_int idx) { struct window_choose_data *wcd; - struct client *c = ctx->curclient; wcd = window_choose_data_create(TREE_SESSION, c, c->session); wcd->idx = s->idx; @@ -887,11 +886,10 @@ window_choose_add_session(struct window_pane *wp, struct cmd_ctx *ctx, } struct window_choose_data * -window_choose_add_item(struct window_pane *wp, struct cmd_ctx *ctx, +window_choose_add_item(struct window_pane *wp, struct client *c, struct winlink *wl, const char *template, char *action, u_int idx) { struct window_choose_data *wcd; - struct client *c = ctx->curclient; char *expanded; wcd = window_choose_data_create(TREE_OTHER, c, c->session); @@ -918,12 +916,11 @@ window_choose_add_item(struct window_pane *wp, struct cmd_ctx *ctx, } struct window_choose_data * -window_choose_add_window(struct window_pane *wp, struct cmd_ctx *ctx, +window_choose_add_window(struct window_pane *wp, struct client *c, struct session *s, struct winlink *wl, const char *template, char *action, u_int idx) { struct window_choose_data *wcd; - struct client *c = ctx->curclient; char *expanded; wcd = window_choose_data_create(TREE_WINDOW, c, c->session); |