From: NeilBrown Date: Wed, 9 Dec 2015 23:45:17 +0000 (+1100) Subject: Use a call-back to return pane from "display-ncurses". X-Git-Tag: lca2016~93 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a44d1e76332f2fd42ed11be504f3829955b23515;p=edlib.git Use a call-back to return pane from "display-ncurses". Signed-off-by: NeilBrown --- diff --git a/display-ncurses.c b/display-ncurses.c index f694e974..39fb2f2f 100644 --- a/display-ncurses.c +++ b/display-ncurses.c @@ -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 6882ba96..877ee226 100644 --- 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);