aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-06-05 10:53:05 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-06-05 10:53:05 +0000
commit2b60c648c4e0202ca2743fe958e0eabfc0479f55 (patch)
treed100a1acc4a275a6290eb01a50268eef7bf0b4a4 /window.c
parentf537870909c024ff5aaa7b9d15f3af469811ab3c (diff)
downloadrtmux-2b60c648c4e0202ca2743fe958e0eabfc0479f55.tar.gz
rtmux-2b60c648c4e0202ca2743fe958e0eabfc0479f55.tar.bz2
rtmux-2b60c648c4e0202ca2743fe958e0eabfc0479f55.zip
Get rid of the layout string code which tries to walk through the layout
hierarchy and instead just look at what panes are actually in the window.
Diffstat (limited to 'window.c')
-rw-r--r--window.c58
1 files changed, 51 insertions, 7 deletions
diff --git a/window.c b/window.c
index d5f56898..ab3177e6 100644
--- a/window.c
+++ b/window.c
@@ -356,21 +356,65 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
}
}
-void
-window_set_active_at(struct window *w, u_int x, u_int y)
+struct window_pane *
+window_get_active_at(struct window *w, u_int x, u_int y)
{
struct window_pane *wp;
TAILQ_FOREACH(wp, &w->panes, entry) {
- if (wp == w->active || !window_pane_visible(wp))
+ if (!window_pane_visible(wp))
continue;
- if (x < wp->xoff || x >= wp->xoff + wp->sx)
+ if (x < wp->xoff || x > wp->xoff + wp->sx)
continue;
- if (y < wp->yoff || y >= wp->yoff + wp->sy)
+ if (y < wp->yoff || y > wp->yoff + wp->sy)
continue;
- window_set_active_pane(w, wp);
- break;
+ return (wp);
}
+ return (NULL);
+}
+
+void
+window_set_active_at(struct window *w, u_int x, u_int y)
+{
+ struct window_pane *wp;
+
+ wp = window_get_active_at(w, x, y);
+ if (wp != NULL && wp != w->active)
+ window_set_active_pane(w, wp);
+}
+
+struct window_pane *
+window_find_string(struct window *w, const char *s)
+{
+ u_int x, y;
+
+ x = w->sx / 2;
+ y = w->sy / 2;
+
+ if (strcasecmp(s, "top") == 0)
+ y = 0;
+ else if (strcasecmp(s, "bottom") == 0)
+ y = w->sy - 1;
+ else if (strcasecmp(s, "left") == 0)
+ x = 0;
+ else if (strcasecmp(s, "right") == 0)
+ x = w->sx - 1;
+ else if (strcasecmp(s, "top-left") == 0) {
+ x = 0;
+ y = 0;
+ } else if (strcasecmp(s, "top-right") == 0) {
+ x = w->sx - 1;
+ y = 0;
+ } else if (strcasecmp(s, "bottom-left") == 0) {
+ x = 0;
+ y = w->sy - 1;
+ } else if (strcasecmp(s, "bottom-right") == 0) {
+ x = w->sx - 1;
+ y = w->sy - 1;
+ } else
+ return (NULL);
+
+ return (window_get_active_at(w, x, y));
}
struct window_pane *