From: NeilBrown Date: Thu, 10 Dec 2015 07:03:30 +0000 (+1100) Subject: Unify doc_notify_change and point_notify_change more. X-Git-Tag: lca2016~68 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a4396e2e47633c741682093a3a54c993f1e0fcaf;p=edlib.git Unify doc_notify_change and point_notify_change more. In particular: export only one interface. Signed-off-by: NeilBrown --- diff --git a/core-doc.c b/core-doc.c index f75aa471..406131aa 100644 --- a/core-doc.c +++ b/core-doc.c @@ -902,7 +902,7 @@ static void docs_release(struct doc *d) m = doc_next_mark_all(m)) if (m->ref.p == d->home) { mark_step2(ed->docs, m, 1, 1); - doc_notify_change(ed->docs, m); + doc_notify_change(ed->docs, m, NULL); } } @@ -923,7 +923,7 @@ static void docs_attach(struct doc *d) m = doc_next_mark_all(m)) if (p->siblings.next == &m->ref.p->siblings) { mark_step2(ed->docs, m, 0, 1); - doc_notify_change(ed->docs, m); + doc_notify_change(ed->docs, m, NULL); } } diff --git a/core-mark.c b/core-mark.c index 0607696b..488d3b2f 100644 --- a/core-mark.c +++ b/core-mark.c @@ -952,7 +952,7 @@ struct mark *do_vmark_at_point(struct doc *d, struct mark *pt, int view) return NULL; } -void point_notify_change(struct doc *d, struct mark *p, struct mark *m) +static void point_notify_change(struct doc *d, struct mark *p, struct mark *m) { /* Notify of changes from m (might be NULL) to p. * Notify the last mark which is before p or m, @@ -1011,8 +1011,9 @@ void point_notify_change(struct doc *d, struct mark *p, struct mark *m) /* doc_notify_change is slower than point_notify_change, but only * requires a mark, not a point. + * A second mark should only be given in the first mark is a point */ -void doc_notify_change(struct doc *d, struct mark *m) +void doc_notify_change(struct doc *d, struct mark *m, struct mark *m2) { struct cmd_info ci = {0}; char *done; @@ -1020,9 +1021,10 @@ void doc_notify_change(struct doc *d, struct mark *m) int remaining = d->nviews; if (m->viewnum == MARK_POINT) { - point_notify_change(d, m, NULL); + point_notify_change(d, m, m2); return; } + ASSERT(m2 == NULL); done = alloca(d->nviews); for (i = 0; i < d->nviews; i++) diff --git a/core.h b/core.h index 87f4cc28..78a96aa1 100644 --- a/core.h +++ b/core.h @@ -171,8 +171,7 @@ void mark_reset(struct doc *d, struct mark *m); void __mark_reset(struct doc *d, struct mark *m, int new, int end); void mark_forward_over(struct mark *m, struct mark *m2); void mark_backward_over(struct mark *m, struct mark *mp); -void point_notify_change(struct doc *d, struct mark *p, struct mark *m); -void doc_notify_change(struct doc *d, struct mark *m); +void doc_notify_change(struct doc *d, struct mark *m, struct mark *m2); void doc_check_consistent(struct doc *d); char *doc_attr(struct pane *dp, struct mark *m, bool forward, char *attr); char *doc_getstr(struct pane *from, struct mark *to); diff --git a/doc-dir.c b/doc-dir.c index a61ce86e..622bac94 100644 --- a/doc-dir.c +++ b/doc-dir.c @@ -185,8 +185,8 @@ DEF_CMD(dir_load_file) list_del(&de->lst); free(de); if (m && donotify) { - doc_notify_change(&dr->doc, prev); - doc_notify_change(&dr->doc, m); + doc_notify_change(&dr->doc, prev, NULL); + doc_notify_change(&dr->doc, m, NULL); } } else if (de2 && (de1 == NULL || strcmp(de2->name, de1->name) < 0)) { @@ -197,8 +197,8 @@ DEF_CMD(dir_load_file) else list_add_tail(&de2->lst, &dr->ents); if (m && donotify) { - doc_notify_change(&dr->doc, prev); - doc_notify_change(&dr->doc, m); + doc_notify_change(&dr->doc, prev, NULL); + doc_notify_change(&dr->doc, m, NULL); } } else { /* de1 and de2 are the same. Just step over de1 and @@ -222,7 +222,7 @@ DEF_CMD(dir_load_file) if (!donotify) { m = doc_first_mark_all(&dr->doc); if (m) - doc_notify_change(&dr->doc, m); + doc_notify_change(&dr->doc, m, NULL); } if (name) { diff --git a/doc-text.c b/doc-text.c index 59a1fe3c..5b3a1a7c 100644 --- a/doc-text.c +++ b/doc-text.c @@ -871,7 +871,7 @@ DEF_CMD(text_reundo) if (early && !text_ref_same(t, &early->ref, &start)) early = NULL; - point_notify_change(&t->doc, dd->point, early); + doc_notify_change(&t->doc, dd->point, early); text_check_consistent(t); } @@ -1430,7 +1430,7 @@ DEF_CMD(text_replace) text_check_consistent(t); } - point_notify_change(&t->doc, pm, early); + doc_notify_change(&t->doc, pm, early); return first ? 1 : 2; } @@ -1516,7 +1516,7 @@ DEF_CMD(text_set_attr) c = list_next_entry(c, lst); o = c->start; } - doc_notify_change(&t->doc, ci->mark); + doc_notify_change(&t->doc, ci->mark, NULL); return attr_set_str(&c->attrs, attr, val, o); }