diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-12-10 16:52:58 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-12-10 16:52:58 +0000 |
commit | 328861e330f7dac0c4d2c0bdbb58f59d2f5b78aa (patch) | |
tree | 224c70e9f0634300b529f46cab019e886464a684 /cmd.c | |
parent | 39b1cdbdb9766bb2bd4ae04b55b19b1e5e1339b6 (diff) | |
download | rtmux-328861e330f7dac0c4d2c0bdbb58f59d2f5b78aa.tar.gz rtmux-328861e330f7dac0c4d2c0bdbb58f59d2f5b78aa.tar.bz2 rtmux-328861e330f7dac0c4d2c0bdbb58f59d2f5b78aa.zip |
Sync OpenBSD patchset 584:
Permit panes to be referred to as "top", "bottom", "top-left" etc, if the right
pane can be identified.
Diffstat (limited to 'cmd.c')
-rw-r--r-- | cmd.c | 43 |
1 files changed, 28 insertions, 15 deletions
@@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.134 2009-12-04 22:14:47 tcunha Exp $ */ +/* $Id: cmd.c,v 1.135 2009-12-10 16:52:58 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -855,12 +855,12 @@ struct winlink * cmd_find_pane(struct cmd_ctx *ctx, const char *arg, struct session **sp, struct window_pane **wpp) { - struct session *s; - struct winlink *wl; - const char *period; - char *winptr, *paneptr; - const char *errstr; - u_int idx; + struct session *s; + struct winlink *wl; + struct layout_cell *lc; + const char *period, *errstr; + char *winptr, *paneptr; + u_int idx; /* Get the current session. */ if ((s = cmd_current_session(ctx)) == NULL) { @@ -894,20 +894,27 @@ cmd_find_pane(struct cmd_ctx *ctx, *wpp = wl->window->active; else { idx = strtonum(paneptr, 0, INT_MAX, &errstr); - if (errstr != NULL) { - ctx->error(ctx, "pane %s: %s", errstr, paneptr); - goto error; - } + if (errstr != NULL) + goto lookup_string; *wpp = window_pane_at_index(wl->window, idx); - if (*wpp == NULL) { - ctx->error(ctx, "no such pane: %u", idx); - goto error; - } + if (*wpp == NULL) + goto lookup_string; } xfree(winptr); return (wl); +lookup_string: + /* Try pane string description. */ + if ((lc = layout_find_string(s->curw->window, paneptr)) == NULL) { + ctx->error(ctx, "can't find pane: %s", paneptr); + goto error; + } + *wpp = lc->wp; + + xfree(winptr); + return (s->curw); + no_period: /* Try as a pane number alone. */ idx = strtonum(arg, 0, INT_MAX, &errstr); @@ -921,6 +928,12 @@ no_period: return (s->curw); lookup_window: + /* Try pane string description. */ + if ((lc = layout_find_string(s->curw->window, arg)) != NULL) { + *wpp = lc->wp; + return (s->curw); + } + /* Try as a window and use the active pane. */ if ((wl = cmd_find_window(ctx, arg, sp)) != NULL) *wpp = wl->window->active; |