]> git.neil.brown.name Git - edlib.git/commitdiff
Make it possible to replace current event handler.
authorNeilBrown <neil@brown.name>
Fri, 11 Dec 2015 06:31:41 +0000 (17:31 +1100)
committerNeilBrown <neil@brown.name>
Fri, 11 Dec 2015 06:31:41 +0000 (17:31 +1100)
Setting DAMAGED_EVENTS on the root and then refreshing
should do it.  Untested though.

Signed-off-by: NeilBrown <neil@brown.name>
core-pane.c
core.h
display-ncurses.c
edlib.c
lib-libevent.c

index d0862eff51be8e58ccde6eff11b6324871b55728..708c73dc1b7f1db209f2eaf7d9eb0e2df83550e0 100644 (file)
@@ -127,7 +127,7 @@ static void __pane_refresh(struct cmd_info *ci)
                        ci2.extra |= DAMAGED_CONTENT;
                if (ci2.extra & DAMAGED_CONTENT)
                        ci2.extra |= DAMAGED_CURSOR;
-               damage &= DAMAGED_SIZE;
+               damage &= DAMAGED_SIZE | DAMAGED_EVENTS;
                ci2.comm = p->handle;
                ret = p->handle->func(&ci2);
                if (ret == 0)
diff --git a/core.h b/core.h
index 09577ef0434e3c41577f9f72183b7204999a0502..157411362ab8a70f3b77336b73c3e5b35cdee5f0 100644 (file)
--- a/core.h
+++ b/core.h
@@ -310,6 +310,10 @@ void key_add_range(struct map *map, char *first, char *last,
                   struct command *comm);
 struct command *key_register_prefix(char *name);
 
+/* DAMAGED_SIZE and DAMAGED_EVENTS propagate down.
+ * DAMAGED_CURSOR propagates up.
+ * If any flag is set on children, DAMAGED_CHILD is set.
+ */
 enum {
        DAMAGED_CHILD   = 1,
        DAMAGED_SIZE    = 2, /* these three each impose the next. */
@@ -317,6 +321,7 @@ enum {
        DAMAGED_CURSOR  = 8,
 
        DAMAGED_CLOSED  = 1024,
+       DAMAGED_EVENTS  = 2048, /* event loop changed, resubmit requests */
 };
 
 struct pane *pane_register(struct pane *parent, int z,
index 505a811dde1e7b20f5fd1fad9cf3009bed5f5bb2..d0e95b1a3ecaa6124b39694dfb6f280e849d95cb 100644 (file)
@@ -151,6 +151,12 @@ DEF_CMD(ncurses_handle)
                        int damage = ci->extra;
                        if (damage & DAMAGED_SIZE)
                                getmaxyx(stdscr, p->h, p->w);
+                       if (damage & DAMAGED_EVENTS) {
+                               call_home(p, "event:read", p, 0, NULL,
+                                         &input_handle);
+                               call_home(p, "event:signal", p, SIGWINCH, NULL,
+                                         &handle_winch);
+                       }
                }
                return 2; /* request post-order call */
        }
diff --git a/edlib.c b/edlib.c
index 050166a86ee508a74d408fb4d0e0a95e16c1a955..f8fdcb4fdd8a45bff6f91d8653cd39bc32aa6067 100644 (file)
--- a/edlib.c
+++ b/edlib.c
@@ -93,7 +93,8 @@ int main(int argc, char *argv[])
                key_handle(&ci);
 
                pane_refresh(&ed->root);
-               call3("event:run", vroot, 0, NULL);
+               while (call3("event:run", vroot, 0, NULL) == 1)
+                       ;
        }
        pane_close(&ed->root);
        exit(0);
index c1fac008eb4c62d5442484e3a00444c5f34a46b6..afb1d3306df3dc45d5162ed2469a3093c73b5c83 100644 (file)
@@ -68,6 +68,9 @@ DEF_CMD(libevent_signal)
 DEF_CMD(libevent_run)
 {
        struct event_base *b = base;
+       if (!b)
+               return 0;
+
        event_base_dispatch(b);
        while (!list_empty(&event_list)) {
                struct evt *ev = list_first_entry(&event_list, struct evt, lst);