]> git.neil.brown.name Git - edlib.git/commitdiff
Use a call-back to return pane from "display-ncurses".
authorNeilBrown <neil@brown.name>
Wed, 9 Dec 2015 23:45:17 +0000 (10:45 +1100)
committerNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 02:54:09 +0000 (13:54 +1100)
Signed-off-by: NeilBrown <neil@brown.name>
display-ncurses.c
edlib.c

index f694e974ee7eaef13ea2a99416501d67e39e98fe..39fb2f2f8962f8494395578df1348f5ce02827e7 100644 (file)
@@ -393,8 +393,10 @@ static void input_handle(int fd, short ev, void *P)
 DEF_CMD(display_ncurses)
 {
        struct pane *p = ncurses_init(pane2ed(ci->home));
-       ci->focus = p;
-       return 1;
+       if (p)
+               return comm_call(ci->comm2, "callback:display", p, 0, NULL,
+                                NULL, 0);
+       return -1;
 }
 
 void edlib_init(struct editor *ed)
diff --git a/edlib.c b/edlib.c
index 6882ba9687473b3cd17fa1913f2925204ceb8151..877ee22636c0c18eb01bcd5b308327ba85ad9242 100644 (file)
--- a/edlib.c
+++ b/edlib.c
@@ -43,12 +43,20 @@ char WelcomeText[] =
        "Mouse clicks move the cursor, and clicking on the scroll bar scrolls\n"
        ;
 
+DEF_CMD(take_pane)
+{
+       struct call_return *cr = container_of(ci->comm, struct call_return, c);
+       cr->p = ci->focus;
+       return 1;
+}
+
 int main(int argc, char *argv[])
 {
        struct event_base *base;
        struct pane *root, *global;
        struct pane *b, *p= NULL;
        struct cmd_info ci = {0};
+       struct call_return cr;
        struct editor *ed;
        struct pane *vroot = editor_new();
 
@@ -64,9 +72,12 @@ int main(int argc, char *argv[])
        editor_load_module(ed, "display-ncurses");
        ci.home = ci.focus = vroot;
        ci.key = "display-ncurses";
+       cr.c = take_pane;
+       cr.p = NULL;
+       ci.comm2 = &cr.c;
        if (!key_lookup(ed->commands, &ci))
                exit(1);
-       root = ci.focus;
+       root = cr.p;
        global = pane_attach(root, "messageline", NULL, NULL);
        global = pane_attach(global, "global-keymap", NULL, NULL);