]> git.neil.brown.name Git - edlib.git/commitdiff
Unify doc_notify_change and point_notify_change more.
authorNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 07:03:30 +0000 (18:03 +1100)
committerNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 07:03:30 +0000 (18:03 +1100)
In particular: export only one interface.

Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core-mark.c
core.h
doc-dir.c
doc-text.c

index f75aa47112a319dd74ab2bad082f3dc937a8346b..406131aaea4836ca416f1a8069a69ffaf214f4aa 100644 (file)
@@ -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);
                }
 }
 
index 0607696bfda2679c813ebc0b84064053276b8e20..488d3b2f26afc05e858a23e99eca6e1ff81d8261 100644 (file)
@@ -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 87f4cc28443aa436abb7a7d331bd80eb2683e417..78a96aa16c2404c76f00a5647dda6927413dae63 100644 (file)
--- 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);
index a61ce86e387b96bfa19d1fa22ab60cacc24d14e3..622bac941800444b3cfdfa1b6cece4144d75f2e0 100644 (file)
--- 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) {
index 59a1fe3cd0cdf6d01305ecccf42ef2b805295a1c..5b3a1a7c9abd4315fc8543a5e230fe803b311f81 100644 (file)
@@ -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);
 }