]> git.neil.brown.name Git - edlib.git/commitdiff
Change render_attach to return that attached pane.
authorNeilBrown <neil@brown.name>
Mon, 23 Nov 2015 05:48:50 +0000 (16:48 +1100)
committerNeilBrown <neil@brown.name>
Mon, 23 Nov 2015 05:48:50 +0000 (16:48 +1100)
this may not be necessary, but it seems useful and is consistent
with pane_attach().

Signed-off-by: NeilBrown <neil@brown.name>
core-pane.c
core.h
render-dir.c
render-format.c
render-hex.c
render-lines.c
render-text.c

index f02c38e768c8c51b45a9a2bf5bc726f840e672ff..30098db6353c34cf2100c85d4efa2a84bd23a466 100644 (file)
@@ -365,7 +365,7 @@ struct pane *pane_with_cursor(struct pane *p, int *oxp, int *oyp)
        return ret;
 }
 
-int render_attach(char *name, struct pane *parent)
+struct pane *render_attach(char *name, struct pane *parent)
 {
        char buf[100];
        struct cmd_info ci = {0};
@@ -376,7 +376,7 @@ int render_attach(char *name, struct pane *parent)
        parent = pane_final_child(parent);
        ptp = pane_point(parent);
        if (!ptp)
-               return 0;
+               return NULL;
        if (!name)
                name = (*ptp)->doc->default_render;
 
@@ -386,11 +386,14 @@ int render_attach(char *name, struct pane *parent)
        ci.pointp = ptp;
        ret = key_lookup(pane2ed(parent)->commands, &ci);
        if (ret)
-               return ret;
+               return ci.focus;
        sprintf(buf, "render-%s", name);
        editor_load_module(pane2ed(parent), buf);
        sprintf(buf, "render-%s-attach", name);
-       return key_lookup(pane2ed(parent)->commands, &ci);
+       ret = key_lookup(pane2ed(parent)->commands, &ci);
+       if (ret)
+               return ci.focus;
+       return NULL;
 }
 
 
diff --git a/core.h b/core.h
index ee53a9498d9b610e04e7b1d57fdee93e28a0b0c8..02f27c5711ca6ecf9525c2229bbd3c0403cd5eff 100644 (file)
--- a/core.h
+++ b/core.h
@@ -115,7 +115,7 @@ struct doc *doc_find(struct editor *ed, char *name);
 void doc_promote(struct doc *d);
 int  doc_destroy(struct doc *d);
 
-int render_attach(char *name, struct pane *parent);
+struct pane *render_attach(char *name, struct pane *parent);
 
 /* Points and Marks */
 
index 5b18c205fd5b78f3f1fb638ff7ac182a8963c14d..c508f27b54c67bef9e8cf9a281905b4450fc7c5c 100644 (file)
@@ -27,7 +27,7 @@ struct dir_data {
 };
 
 static struct map *dr_map;
-static void do_render_dir_attach(struct pane *parent, struct point **ptp);
+static struct pane *do_render_dir_attach(struct pane *parent, struct point **ptp);
 
 static int put_str(struct pane *p, char *buf, char *attrs, int x, int y)
 {
@@ -467,7 +467,7 @@ static void render_dir_register_map(void)
        key_add(dr_map, "Chr-g", &render_dir_reload);
 }
 
-static void do_render_dir_attach(struct pane *parent, struct point **ptp)
+static struct pane *do_render_dir_attach(struct pane *parent, struct point **ptp)
 {
        struct dir_data *dd = malloc(sizeof(*dd));
        struct pane *p;
@@ -475,7 +475,7 @@ static void do_render_dir_attach(struct pane *parent, struct point **ptp)
        if (!ptp)
                ptp = pane_point(parent);
        if (!ptp)
-               return;
+               return NULL;
        dd->top = NULL;
        dd->bot = NULL;
        dd->ignore_point = 0;
@@ -488,11 +488,12 @@ static void do_render_dir_attach(struct pane *parent, struct point **ptp)
 
        if (!dr_map)
                render_dir_register_map();
+       return p;
 }
 
 DEF_CMD(render_dir_attach)
 {
-       do_render_dir_attach(ci->focus, ci->pointp);
+       ci->focus = do_render_dir_attach(ci->focus, ci->pointp);
        return 1;
 }
 
index 9269ef9c95aa5a65c37672fbc931016832abaad0..fec36731c082c1eb762468a81aebabdcaef8d994 100644 (file)
@@ -177,7 +177,7 @@ DEF_CMD(format_clone)
        render_format_attach_func(ci);
        c = pane_child(ci->home);
        if (c)
-               return pane_clone(c, pane_child(ci->focus));
+               return pane_clone(c, ci->focus);
        return 1;
 }
 
@@ -281,6 +281,7 @@ REDEF_CMD(render_format_attach)
 
        if (!rf_map)
                render_format_register_map();
+       ci->focus = p;
        return 1;
 }
 
index e679896f845d34bdcab91dde70e2d332efc1be7f..742482e523c4ba22e164c459334f644384e17f7a 100644 (file)
@@ -26,7 +26,7 @@ struct he_data {
 };
 
 static struct map *he_map;
-static void do_render_hex_attach(struct pane *parent, struct point **ptp);
+static struct pane *do_render_hex_attach(struct pane *parent, struct point **ptp);
 
 DEF_CMD(render_hex_handle)
 {
@@ -221,7 +221,7 @@ static void render_hex_register_map(void)
        key_add(he_map, "render-line", &render_line);
 }
 
-static void do_render_hex_attach(struct pane *parent, struct point **ptp)
+static struct pane *do_render_hex_attach(struct pane *parent, struct point **ptp)
 {
        struct he_data *he = malloc(sizeof(*he));
        struct pane *p;
@@ -229,7 +229,7 @@ static void do_render_hex_attach(struct pane *parent, struct point **ptp)
        if (!ptp)
                ptp = pane_point(parent);
        if (!ptp)
-               return;
+               return NULL;
 
        he->type = render_hex_notify;
        he->typenum = doc_add_view((*ptp)->doc, &he->type);
@@ -241,11 +241,12 @@ static void do_render_hex_attach(struct pane *parent, struct point **ptp)
 
        if (!he_map)
                render_hex_register_map();
+       return p;
 }
 
 DEF_CMD(render_hex_attach)
 {
-       do_render_hex_attach(ci->focus, ci->pointp);
+       ci->focus = do_render_hex_attach(ci->focus, ci->pointp);
        return 1;
 }
 
index 8d29015737f50e6a6ea96b88019950dd29a297ad..908a0fa73297676986c11f8e0e094b41de3cc31e 100644 (file)
@@ -959,6 +959,7 @@ REDEF_CMD(render_lines_attach)
 
        if (!rl_map)
                render_lines_register_map();
+       ci->focus = rl->pane;
        return 1;
 }
 
index 218d38a34138519e3f8b354c72e730a94fe101d0..92d9aaeb59bb33e705143803d28cfa31fc44ff73 100644 (file)
@@ -32,7 +32,7 @@ struct rt_data {
 };
 
 static struct map *rt_map;
-static void do_render_text_attach(struct pane *p, struct point **pt);
+static struct pane *do_render_text_attach(struct pane *p, struct point **pt);
 
 static int rt_fore(struct doc *d, struct pane *p, struct mark *m, int *x, int *y, int draw)
 {
@@ -481,7 +481,7 @@ static void render_text_register_map(void)
        key_add(rt_map, "Replace", &render_text_follow_point);
 }
 
-static void do_render_text_attach(struct pane *parent, struct point **ptp)
+static struct pane *do_render_text_attach(struct pane *parent, struct point **ptp)
 {
        struct rt_data *rt = malloc(sizeof(*rt));
        struct pane *p;
@@ -489,7 +489,7 @@ static void do_render_text_attach(struct pane *parent, struct point **ptp)
        if (!ptp)
                ptp = pane_point(parent);
        if (!ptp)
-               return;
+               return NULL;
        rt->top = NULL;
        rt->bot = NULL;
        rt->ignore_point = 0;
@@ -501,11 +501,12 @@ static void do_render_text_attach(struct pane *parent, struct point **ptp)
 
        if (!rt_map)
                render_text_register_map();
+       return p;
 }
 
 DEF_CMD(render_text_attach)
 {
-       do_render_text_attach(ci->focus, ci->pointp);
+       ci->focus = do_render_text_attach(ci->focus, ci->pointp);
        return 1;
 }