summaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-12-08 07:49:31 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-12-08 07:49:31 +0000
commit6311bd119ed728117fd6f0073792a76c2a6b842b (patch)
tree8eed2eaa1e2161e39d1f983dc38fbeb8813103ee /cmd.c
parent796eb522ac6534510b22c34296cbd172f8fab3ae (diff)
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.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/cmd.c b/cmd.c
index d094427b..5ad87c23 100644
--- a/cmd.c
+++ b/cmd.c
@@ -856,12 +856,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) {
@@ -895,20 +895,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);
@@ -922,6 +929,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;