]> git.neil.brown.name Git - edlib.git/commitdiff
Introduce pane_final_child()
authorNeilBrown <neil@brown.name>
Mon, 23 Nov 2015 04:28:27 +0000 (15:28 +1100)
committerNeilBrown <neil@brown.name>
Mon, 23 Nov 2015 04:28:27 +0000 (15:28 +1100)
We open-code this a few places and will need it more soon.

It is paritcularly useful after attaching a pane which might attach a
collection.

Signed-off-by: NeilBrown <neil@brown.name>
core-pane.c
core.h
emacs-search.c
lib-keymap.c
mode-emacs.c

index 0a80fea27098f21579b91fe9763f2f3bdd4666a9..d823e456c51480c67401dbad7996125dda9fe3d9 100644 (file)
@@ -494,3 +494,12 @@ char *pane_attr_get(struct pane *p, char *key)
        /* FIXME do I want editor-wide attributes too? */
        return NULL;
 }
+
+struct pane *pane_final_child(struct pane *p)
+{
+       struct pane *c;
+
+       while ((c = pane_child(p)) != NULL)
+               p = c;
+       return p;
+}
diff --git a/core.h b/core.h
index e539fde077d6aae74d3c891e894fa072103b009b..0779425790c11488fcc00891d4c68884570e969c 100644 (file)
--- a/core.h
+++ b/core.h
@@ -337,6 +337,7 @@ static inline struct pane *pane_child(struct pane *p)
                        return c;
        return NULL;
 }
+struct pane *pane_final_child(struct pane *p);
 
 /* Inlines */
 
index c52d15c1c44346e9a0b2d7fbc0ccc6e3b8fa814a..6cc9c47e1f013e5a266ee07dfa8a282267367418 100644 (file)
@@ -249,8 +249,7 @@ DEF_CMD(emacs_search)
        ptp = pane_point(ci->focus);
        doc_add_view((*ptp)->doc, &esi->watch);
 
-       while (pane_child(ci->focus))
-               ci->focus = pane_child(ci->focus);
+       ci->focus = pane_final_child(ci->focus);
        p = pane_register(ci->focus, 0, &search_handle, esi, NULL);
        ci->focus = p;
        return 1;
index 6aafce223ddb3b97477ec740cf9123e0bb2d9b67..7d996b8467b675fdd3587b32668b0d8bab396d41 100644 (file)
@@ -130,8 +130,7 @@ DEF_CMD(keymap_attach)
        kd->cmdcount = 0;
        kd->global = ci->comm ? 1 : 0;
        p = ci->focus;
-       while (pane_child(p))
-               p = pane_child(p);
+       p = pane_final_child(p);
        p = pane_register(p, 0, &keymap_handle, kd, NULL);
        pane_check_size(p);
        ci->focus = p;
index fd700f7ff1d3cdb3b6f2b9201bc85c45a5963abb..57b719da3b9f3904c750112167155b23820ab08c 100644 (file)
@@ -460,8 +460,7 @@ DEF_CMD(emacs_search)
                attr_set_str(&p->attrs, "done-key", "Search String", -1);
                ptp = pane_point(p);
                doc_set_name((*ptp)->doc, "Search");
-               while (pane_child(p))
-                       p = pane_child(p);
+               p = pane_final_child(p);
                pane_attach(p, "emacs-search", NULL, NULL);
                return 1;
        }