]> git.neil.brown.name Git - edlib.git/commitdiff
Use new notifiers to send notification when document changes.
authorNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 07:11:49 +0000 (18:11 +1100)
committerNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 07:14:24 +0000 (18:14 +1100)
Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core-mark.c
core-pane.c
core.h

index 406131aaea4836ca416f1a8069a69ffaf214f4aa..f25e1f48b794e012da5cecb8fdd060b4371a91b9 100644 (file)
@@ -394,6 +394,12 @@ DEF_CMD(doc_handle)
                }
                return 1;
        }
+
+       if (strcmp(ci->key, "Request:Notify:Replace") == 0) {
+               pane_add_notify(ci->focus, dd->doc->home, "Notify:Replace");
+               return 1;
+       }
+
        if (strcmp(ci->key, "Clone") == 0) {
                struct pane *p = doc_attach(ci->focus, dd->doc);
                struct pane *c = pane_child(ci->home);
index 488d3b2f26afc05e858a23e99eca6e1ff81d8261..6b5506fcc3819335b6f04e82d4f1c261ed784a99 100644 (file)
@@ -963,6 +963,7 @@ static void point_notify_change(struct doc *d, struct mark *p, struct mark *m)
        int i;
        struct point_links *lnk = p->mdata;
 
+       pane_notify(d->home, "Notify:Replace", p, m);
        ci.key = "Notify:Replace";
        ci.numeric = 1;
        ci.x = ci.y = -1;
index fddc7086a44036b6b183ce339f8127c286bf6375..f7605f94cbd556369fa35d86478da8d970ca06a6 100644 (file)
@@ -190,12 +190,22 @@ void pane_notify_close(struct pane *p)
                list_del_init(&n->notifier_link);
                if (strcmp(n->notification, "Notify:Close") == 0)
                        comm_call_pane(n->notifiee, n->notification, p,
-                                      0, NULL, NULL, 0);
+                                      0, NULL, NULL, 0, NULL);
                free(n->notification);
                free(n);
        }
 }
 
+void pane_notify(struct pane *p, char *notification, struct mark *m, struct mark *m2)
+{
+       struct notifier *n;
+
+       list_for_each_entry(n, &p->notifiees, notifier_link)
+               if (strcmp(n->notification, notification) == 0)
+                       comm_call_pane(n->notifiee, n->notification, p,
+                                      0, m, NULL, 0, m2);
+}
+
 void pane_close(struct pane *p)
 {
        struct pane *c;
diff --git a/core.h b/core.h
index 78a96aa16c2404c76f00a5647dda6927413dae63..fef5cc67a924a55b5e701990e1bd317f95c07db0 100644 (file)
--- a/core.h
+++ b/core.h
@@ -68,6 +68,7 @@ struct notifier {
        struct list_head        notifier_link, notifiee_link;
 };
 void pane_add_notify(struct pane *target, struct pane *source, char *msg);
+void pane_notify(struct pane *p, char *notification, struct mark *m, struct mark *m2);
 
 /* this is ->data for a document pane.  Only core-doc and
  * individual document handlers can know about this.
@@ -556,7 +557,8 @@ static inline int comm_call(struct command *comm, char *key, struct pane *focus,
 }
 
 static inline int comm_call_pane(struct pane *home, char *key, struct pane *focus,
-                                int numeric, struct mark *m, char *str, int extra)
+                                int numeric, struct mark *m, char *str, int extra,
+                                struct mark *m2)
 {
        struct cmd_info ci = {0};
        struct command *comm = home->handle;