From f182cea3e447b7cf6279b6970544440be81a64c3 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 10 Dec 2015 18:11:49 +1100 Subject: [PATCH] Use new notifiers to send notification when document changes. Signed-off-by: NeilBrown --- core-doc.c | 6 ++++++ core-mark.c | 1 + core-pane.c | 12 +++++++++++- core.h | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core-doc.c b/core-doc.c index 406131aa..f25e1f48 100644 --- a/core-doc.c +++ b/core-doc.c @@ -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); diff --git a/core-mark.c b/core-mark.c index 488d3b2f..6b5506fc 100644 --- a/core-mark.c +++ b/core-mark.c @@ -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; diff --git a/core-pane.c b/core-pane.c index fddc7086..f7605f94 100644 --- a/core-pane.c +++ b/core-pane.c @@ -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 78a96aa1..fef5cc67 100644 --- 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; -- 2.39.5