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) {
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);
}
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;
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);