]> git.neil.brown.name Git - edlib.git/commitdiff
Stop using pointp in text_reundo and text_replace.
authorNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 04:12:45 +0000 (15:12 +1100)
committerNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 04:12:45 +0000 (15:12 +1100)
use home->data and home->point instead.

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

index 391f48bc8d0ea22df80d63f34fbdc881f99affa3..793208d6fc9cf9accef3c79ff4d1b681ad7e7b55 100644 (file)
@@ -779,12 +779,12 @@ static int text_redo(struct text *t, struct doc_ref *start, struct doc_ref *end)
 
 DEF_CMD(text_reundo)
 {
-       struct point *p = *ci->pointp;
+       struct doc *d = ci->home->data;
+       struct mark *m = &ci->home->point->m;
        bool redo = ci->numeric != 0;
        struct doc_ref start, end;
        int did_do = 2;
        bool first = 1;
-       struct doc *d = p->doc;
        struct text *t = container_of(d, struct text, doc);
 
        while (did_do != 1) {
@@ -802,57 +802,57 @@ DEF_CMD(text_reundo)
 
                if (first) {
                        /* Not nearby, look from the start */
-                       point_reset(p);
+                       mark_reset(d, m);
                        where = 1;
                        first = 0;
                } else
-                       where = text_locate(t, &p->m.ref, &end);
+                       where = text_locate(t, &m->ref, &end);
                if (!where)
                        break;
 
                if (where == 1) {
                        do {
-                               i = text_advance_towards(t, &p->m.ref, &end);
+                               i = text_advance_towards(t, &m->ref, &end);
                                if (i == 0)
                                        break;
-                               while ((m2 = doc_next_mark_all(d, &p->m)) != NULL &&
-                                      m2->ref.c == p->m.ref.c &&
-                                      m2->ref.o <= p->m.ref.o)
-                                       mark_forward_over(&p->m, m2);
+                               while ((m2 = doc_next_mark_all(d, m)) != NULL &&
+                                      m2->ref.c == m->ref.c &&
+                                      m2->ref.o <= m->ref.o)
+                                       mark_forward_over(m, m2);
                        } while (i == 2);
                } else {
                        do {
-                               i = text_retreat_towards(t, &p->m.ref, &end);
+                               i = text_retreat_towards(t, &m->ref, &end);
                                if (i == 0)
                                        break;
-                               while ((m2 = doc_prev_mark_all(d, &p->m)) != NULL &&
-                                      m2->ref.c == p->m.ref.c &&
-                                      m2->ref.o >= p->m.ref.o)
-                                       mark_backward_over(&p->m, m2);
+                               while ((m2 = doc_prev_mark_all(d, m)) != NULL &&
+                                      m2->ref.c == m->ref.c &&
+                                      m2->ref.o >= m->ref.o)
+                                       mark_backward_over(m, m2);
                        } while (i == 2);
                }
 
-               if (!text_ref_same(t, &p->m.ref, &end))
+               if (!text_ref_same(t, &m->ref, &end))
                        /* eek! */
                        break;
                /* point is now at location of undo */
 
-               m2 = &p->m;
+               m2 = m;
                hlist_for_each_entry_continue_reverse(m2, &t->doc.marks, all)
                        if (text_update_prior_after_change(t, &m2->ref,
                                                           &start, &end) == 0)
                                break;
-               m2 = &p->m;
+               m2 = m;
                hlist_for_each_entry_continue(m2, all)
                        if (text_update_following_after_change(t, &m2->ref,
                                                               &start, &end) == 0)
                                break;
 
-               early = doc_prev_mark_all(d, &p->m);
+               early = doc_prev_mark_all(d, m);
                if (early && !text_ref_same(t, &early->ref, &start))
                        early = NULL;
 
-               point_notify_change(p, early);
+               point_notify_change(ci->home->point, early);
 
                text_check_consistent(t);
        }
@@ -1356,12 +1356,12 @@ static void text_check_consistent(struct text *t)
 
 DEF_CMD(text_replace)
 {
-       struct point *pos = *ci->pointp;
+       struct doc *d = ci->home->data;
+       struct text *t = container_of(d, struct text, doc);
+       struct point *pos = ci->home->point;
        struct mark *end = ci->mark;
        char *str = ci->str;
        bool first = ci->numeric;
-       struct doc *d = pos->doc;
-       struct text *t = container_of(d, struct text, doc);
        struct mark *pm = &pos->m;
        struct mark *early = NULL;
 
@@ -1372,10 +1372,10 @@ DEF_CMD(text_replace)
 
                if (!mark_ordered(pm, end)) {
                        myend = mark_dup(pm, 1);
-                       point_to_mark(pos, end);
+                       mark_to_mark(d, pm, end);
                } else
                        myend = mark_dup(end, 1);
-               l = count_bytes(t, &pos->m, myend);
+               l = count_bytes(t, pm, myend);
                mark_free(myend);
                text_del(t, &pm->ref, l, &first);