From: NeilBrown Date: Mon, 23 Nov 2015 05:38:59 +0000 (+1100) Subject: pane_attach: always return the top-level attached pane. X-Git-Tag: lca2016~288 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=240dcf88e3e370580c63787dd8bf801bc20a90a1;p=edlib.git pane_attach: always return the top-level attached pane. It is fairly easy to find the leaf with pane_final_child(). It is harder to find the top. So return that. Signed-off-by: NeilBrown --- diff --git a/lib-popup.c b/lib-popup.c index b4a8b73c..714b6d68 100644 --- a/lib-popup.c +++ b/lib-popup.c @@ -178,7 +178,7 @@ DEF_CMD(popup_attach) ci2.str2 = "Abort"; key_handle_focus(&ci2); - ci->focus = p; + ci->focus = ppi->popup; return 1; } diff --git a/lib-view.c b/lib-view.c index c032e451..a088fd08 100644 --- a/lib-view.c +++ b/lib-view.c @@ -156,7 +156,7 @@ DEF_CMD(view_handle) p2 = do_view_attach(parent, pt, vd->border); c = pane_child(pane_child(p)); if (c) - return pane_clone(c, p2); + return pane_clone(c, pane_final_child(p2)); return 1; } if (strcmp(ci->key, "Refresh") == 0) @@ -257,7 +257,8 @@ static struct pane *do_view_attach(struct pane *par, struct point *pt, int borde vd->pane = p; pane_check_size(p); - return view_reattach(p, pt); + view_reattach(p, pt); + return p; } DEF_CMD(view_attach) diff --git a/mode-emacs.c b/mode-emacs.c index 7e07fcc7..6c88175c 100644 --- a/mode-emacs.c +++ b/mode-emacs.c @@ -281,7 +281,9 @@ DEF_CMD(emacs_findfile) if (!p) return 0; - ptp = pane_point(p); + ptp = pane_point(pane_final_child(p)); + /* Want to work with the document pane */ + p = container_of(ptp, struct pane, point); d = (*ptp)->doc; if (strncmp(ci->key, "emCX4-", 6) == 0) { attr_set_str(&p->attrs, "prefix", @@ -343,7 +345,9 @@ DEF_CMD(emacs_finddoc) p = pane_attach(ci->focus, "popup", NULL, "D2"); if (!p) return 0; - ptp = pane_point(p); + ptp = pane_point(pane_final_child(p)); + /* Want to work with the document pane */ + p = container_of(ptp, struct pane, point); d = (*ptp)->doc; if (strncmp(ci->key, "emCX4-", 6) == 0) { attr_set_str(&p->attrs, "prefix", @@ -456,9 +460,11 @@ DEF_CMD(emacs_search) struct point **ptp; if (!p) return 0; + ptp = pane_point(pane_final_child(p)); + /* Want to work with the document pane */ + p = container_of(ptp, struct pane, point); attr_set_str(&p->attrs, "prefix", "Search: ", -1); attr_set_str(&p->attrs, "done-key", "Search String", -1); - ptp = pane_point(p); doc_set_name((*ptp)->doc, "Search"); p = pane_final_child(p); pane_attach(p, "emacs-search", NULL, NULL);