]> git.neil.brown.name Git - edlib.git/commitdiff
Remove mark_of_point
authorNeilBrown <neil@brown.name>
Tue, 24 Nov 2015 00:22:45 +0000 (11:22 +1100)
committerNeilBrown <neil@brown.name>
Tue, 24 Nov 2015 00:28:23 +0000 (11:28 +1100)
it is a hang over from when I though 'point' might be a private
data structure.

Signed-off-by: NeilBrown <neil@brown.name>
13 files changed:
core-mark.c
core.h
doc-text.c
emacs-search.c
lib-line-count.c
lib-view.c
mode-emacs.c
render-complete.c
render-dir.c
render-format.c
render-hex.c
render-lines.c
render-text.c

index a7c5275968083b9ce0445d497bf9ffaae13ec47d..4b1f8aee3c65a60c44bf525d3eced45d27b551eb 100644 (file)
@@ -323,11 +323,6 @@ struct doc_ref point_ref(struct point *p)
        return p->m.ref;
 }
 
-struct mark *mark_of_point(struct point *p)
-{
-       return &p->m;
-}
-
 struct mark *doc_first_mark(struct doc *d, int view)
 {
        struct tlist_head *tl;
@@ -778,11 +773,11 @@ struct mark *vmark_at_point(struct point *pt, int view)
 
        tl = &pt->lists[view];
        m = __vmark_prev(tl);
-       if (m && mark_same(pt->doc, m, mark_of_point(pt)))
+       if (m && mark_same(pt->doc, m, &pt->m))
                return m;
        tl = &pt->lists[view];
        m = __vmark_next(tl);
-       if (m && mark_same(pt->doc, m, mark_of_point(pt)))
+       if (m && mark_same(pt->doc, m, &pt->m))
                return m;
        return NULL;
 }
@@ -803,7 +798,7 @@ void point_notify_change(struct point *p, struct mark *m)
        ci.x = ci.y = -1;
        ci.pointp = p->owner;
        if (!m)
-               m = mark_of_point(p);
+               m = &p->m;
        for (i = 0; i < p->size; i++) {
                struct tlist_head *tl = &p->lists[i];
                struct command *c = d->views[i].notify;
@@ -835,7 +830,7 @@ void point_notify_change(struct point *p, struct mark *m)
                while (TLIST_TYPE(tl) != GRP_HEAD) {
                        if (TLIST_TYPE(tl) == GRP_MARK) {
                                ci.mark = tlist_entry(tl, struct mark, view);
-                               if (mark_same(d, ci.mark, mark_of_point(p)))
+                               if (mark_same(d, ci.mark, &p->m))
                                        c->func(&ci);
                                else
                                        break;
diff --git a/core.h b/core.h
index 02f27c5711ca6ecf9525c2229bbd3c0403cd5eff..faa89b8b74f58e0c9551b03864fae25178a2035f 100644 (file)
--- a/core.h
+++ b/core.h
@@ -151,7 +151,6 @@ struct point {
        struct tlist_head       lists[];
 };
 
-struct mark *mark_of_point(struct point *p);
 struct mark *mark_dup(struct mark *m, int notype);
 void mark_free(struct mark *m);
 struct mark *doc_new_mark(struct doc *d, int view);
index 2785744b987980316564d65ebaf2063f795b5c91..c70efc8ab1d850cefad01b427f516bf40ec0d314 100644 (file)
@@ -729,49 +729,49 @@ static int text_reundo(struct point *p, bool redo)
                        where = 1;
                        first = 0;
                } else
-                       where = text_locate(t, &mark_of_point(p)->ref, &end);
+                       where = text_locate(t, &p->m.ref, &end);
                if (!where)
                        break;
 
                if (where == 1) {
                        do {
-                               i = text_advance_towards(t, &mark_of_point(p)->ref, &end);
+                               i = text_advance_towards(t, &p->m.ref, &end);
                                if (i == 0)
                                        break;
-                               while ((m = doc_next_mark_all(d, mark_of_point(p))) != NULL &&
-                                      m->ref.c == mark_of_point(p)->ref.c &&
-                                      m->ref.o < mark_of_point(p)->ref.o)
-                                       mark_forward_over(mark_of_point(p), m);
+                               while ((m = doc_next_mark_all(d, &p->m)) != NULL &&
+                                      m->ref.c == p->m.ref.c &&
+                                      m->ref.o < p->m.ref.o)
+                                       mark_forward_over(&p->m, m);
                        } while (i == 2);
                } else {
                        do {
-                               i = text_retreat_towards(t, &mark_of_point(p)->ref, &end);
+                               i = text_retreat_towards(t, &p->m.ref, &end);
                                if (i == 0)
                                        break;
-                               while ((m = doc_prev_mark_all(d, mark_of_point(p))) != NULL &&
-                                      m->ref.c == mark_of_point(p)->ref.c &&
-                                      m->ref.o > mark_of_point(p)->ref.o)
-                                       mark_backward_over(mark_of_point(p), m);
+                               while ((m = doc_prev_mark_all(d, &p->m)) != NULL &&
+                                      m->ref.c == p->m.ref.c &&
+                                      m->ref.o > p->m.ref.o)
+                                       mark_backward_over(&p->m, m);
                        } while (i == 2);
                }
 
-               if (!text_ref_same(t, &mark_of_point(p)->ref, &end))
+               if (!text_ref_same(t, &p->m.ref, &end))
                        /* eek! */
                        break;
                /* point is now at location of undo */
 
-               m = mark_of_point(p);
+               m = &p->m;
                hlist_for_each_entry_continue_reverse(m, &t->doc.marks, all)
                        if (text_update_prior_after_change(t, &m->ref,
                                                           &start, &end) == 0)
                                break;
-               m = mark_of_point(p);
+               m = &p->m;
                hlist_for_each_entry_continue(m, all)
                        if (text_update_following_after_change(t, &m->ref,
                                                               &start, &end) == 0)
                                break;
 
-               early = doc_prev_mark_all(d, mark_of_point(p));
+               early = doc_prev_mark_all(d, &p->m);
                if (early && !text_ref_same(t, &early->ref, &start))
                        early = NULL;
 
@@ -1256,7 +1256,7 @@ static void text_replace(struct point *pos, struct mark *end,
 {
        struct doc *d = pos->doc;
        struct text *t = container_of(d, struct text, doc);
-       struct mark *pm = mark_of_point(pos);
+       struct mark *pm = &pos->m;
        struct mark *early = NULL;
 
        /* First delete, then insert */
@@ -1269,7 +1269,7 @@ static void text_replace(struct point *pos, struct mark *end,
                        point_to_mark(pos, end);
                } else
                        myend = mark_dup(end, 1);
-               l = count_bytes(t, mark_of_point(pos), myend);
+               l = count_bytes(t, &pos->m, myend);
                mark_free(myend);
                text_del(t, &pm->ref, l, first);
 
@@ -1493,7 +1493,7 @@ DEF_CMD(render_line)
                int offset = m->ref.o;
                if (o >= 0 && b.len >= o)
                        break;
-               if (o == -1 && mark_same(d, m, mark_of_point(*ptp)))
+               if (o == -1 && mark_same(d, m, &(*ptp)->m))
                        break;
                ch = mark_next(d, m);
                if (ch == WEOF)
index 6cc9c47e1f013e5a266ee07dfa8a282267367418..2057018f36c0394897f2ecbaaeb2c99094547083 100644 (file)
@@ -46,7 +46,7 @@ DEF_CMD(search_forward)
        struct stk *s;
        char *str;
 
-       if (esi->s && mark_same(d, esi->s->m, mark_of_point(esi->end))) {
+       if (esi->s && mark_same(d, esi->s->m, &esi->end->m)) {
                /* already pushed and didn't find anything new */
                return 1;
        }
@@ -58,7 +58,7 @@ DEF_CMD(search_forward)
        s->next = esi->s;
        esi->s = s;
        if (esi->matched)
-               esi->start = mark_dup(mark_of_point(esi->end), 1);
+               esi->start = mark_dup(&esi->end->m, 1);
        else {
                esi->start = mark_dup(s->m, 1);
                mark_reset(d, esi->start);
@@ -100,7 +100,7 @@ DEF_CMD(search_add)
        do {
                /* TEMP HACK - please fix */
                d->ops->set_attr(esi->end, "highlight", NULL);
-               wch = mark_next(d, mark_of_point(esi->end));
+               wch = mark_next(d, &esi->end->m);
                if (wch == WEOF)
                        return 1;
                if (wch == '\n') {
@@ -108,7 +108,7 @@ DEF_CMD(search_add)
                        /* Sending this will cause a call-back to
                         * close everything down.
                         */
-                       mark_prev(d, mark_of_point(esi->end));
+                       mark_prev(d, &esi->end->m);
                        return 1;
                }
                /* FIXME utf-8! and quote regexp chars */
@@ -241,7 +241,7 @@ DEF_CMD(emacs_search)
        }
        esi->target = ci2.focus;
        point_dup(esi->target->point, &esi->end);
-       esi->start = mark_dup(mark_of_point(esi->end), 1);
+       esi->start = mark_dup(&esi->end->m, 1);
        esi->s = NULL;
        esi->matched = 0;
        esi->search = ci->focus;
index ac8d06e4db67dd4e82840599452e3c4eb0b560c4..496d0bb0202c56a27d731cc5b9839363e22d2399 100644 (file)
@@ -224,7 +224,7 @@ DEF_CMD(count_lines)
 
        /* FIXME optimise this away most of the time */
        count_calculate(d, NULL, NULL);
-       count_calculate(d, NULL, mark_of_point(pt));
+       count_calculate(d, NULL, &pt->m);
        if (ci->mark)
                count_calculate(d, NULL, ci->mark);
        return 1;
index a088fd08ec2d8f7772746b03d1e97e4a628ace3e..6d3b5995b25b29860011533c026c1b253ce5ea88 100644 (file)
@@ -66,7 +66,7 @@ static int view_refresh(struct cmd_info *ci)
                        ci2.pointp = ci->pointp;
                        key_lookup(pt->doc->ed->commands, &ci2);
 
-                       ln = attr_find_int(*mark_attr(mark_of_point(pt)), "lines");
+                       ln = attr_find_int(*mark_attr(&pt->m), "lines");
                        l = attr_find_int(pt->doc->attrs, "lines");
                        w = attr_find_int(pt->doc->attrs, "words");
                        c = attr_find_int(pt->doc->attrs, "chars");
@@ -417,7 +417,7 @@ DEF_CMD(view_file)
        int rpt = RPT_NUM(ci);
 
        if (ci->mark == NULL)
-               ci->mark = mark_of_point(pt);
+               ci->mark = &pt->m;
        while (rpt > 0 && ch != WEOF) {
                while ((ch = mark_next(pt->doc, ci->mark)) != WEOF)
                        ;
@@ -478,7 +478,7 @@ DEF_CMD(view_click)
        ci2.focus = p;
        ci2.key = "Move-View-Small";
        ci2.numeric = RPT_NUM(ci);
-       ci2.mark = mark_of_point(*ci->pointp);
+       ci2.mark = &(*ci->pointp)->m;
        ci2.pointp = ci->pointp;
 
        if (ci->hy == mid-1) {
index 1de03492980a152e89af13240c3d561d29cb5e16..560e54210909354b4d18cfa3c4011431a82978e9 100644 (file)
@@ -82,7 +82,7 @@ REDEF_CMD(emacs_move)
        ci2.focus = ci->focus;
        ci2.key = mv->type;
        ci2.numeric = mv->direction * RPT_NUM(ci);
-       ci2.mark = mark_of_point(pt);
+       ci2.mark = &pt->m;
        ci2.pointp = ci->pointp;
        ret = key_handle_focus(&ci2);
 
@@ -191,7 +191,7 @@ DEF_CMD(emacs_insert)
        ci2.key = "Replace";
        ci2.numeric = 1;
        ci2.extra = ci->extra;
-       ci2.mark = mark_of_point(*ci->pointp);
+       ci2.mark = &(*ci->pointp)->m;
        strncpy(str,ci->key+4, sizeof(str));
        str[4] = 0;
        ci2.str = str;
@@ -223,7 +223,7 @@ DEF_CMD(emacs_insert_other)
        ci2.key = "Replace";
        ci2.numeric = 1;
        ci2.extra = ci->extra;
-       ci2.mark = mark_of_point(*ci->pointp);
+       ci2.mark = &(*ci->pointp)->m;
        for (i = 0; other_inserts[i].key; i++)
                if (strcmp(other_inserts[i].key, ci->key) == 0)
                        break;
@@ -396,7 +396,7 @@ DEF_CMD(emacs_file_complete)
                struct cmd_info ci3 = {0};
                ci3.key = "Replace";
                ci3.pointp = ci->pointp;
-               ci3.mark = mark_of_point(*ci->pointp);
+               ci3.mark = &(*ci->pointp)->m;
                ci3.numeric = 1;
                ci3.focus = ci->focus;
                ci3.str = c;
@@ -509,7 +509,7 @@ DEF_CMD(emacs_doc_complete)
                struct cmd_info ci3 = {0};
                ci3.key = "Replace";
                ci3.pointp = ci->pointp;
-               ci3.mark = mark_of_point(*ci->pointp);
+               ci3.mark = &(*ci->pointp)->m;
                ci3.numeric = 1;
                ci3.focus = ci->focus;
                ci3.str = c;
@@ -602,7 +602,7 @@ DEF_CMD(emacs_search)
        if (!ci->str || !ci->str[0])
                return -1;
        ci2.pointp = pane_point(ci->focus);
-       ci2.mark = mark_dup(mark_of_point(*ci2.pointp), 1);
+       ci2.mark = mark_dup(&(*ci2.pointp)->m, 1);
        ci2.str = ci->str;
        ci2.key = "text-search";
        if (!key_lookup(pane2ed(ci->focus)->commands, &ci2))
index 91ec6ec805fd48057bbd8ed9ce8cd4cc22b91779..a755e1b25be29c7def82d85e42790f3ee00092b3 100644 (file)
@@ -259,7 +259,7 @@ DEF_CMD(complete_return)
        ci2.key = "render-line";
        ci2.focus = ci->home;
        ci2.home = ci->home;
-       ci2.mark = mark_of_point(*ci->pointp);
+       ci2.mark = &(*ci->pointp)->m;
        ci2.pointp = ci->pointp;
        ci2.numeric = NO_NUMERIC;
        render_complete_line_func(&ci2);
index c508f27b54c67bef9e8cf9a281905b4450fc7c5c..7f18565e6da2dac2d7634c1fe966b8e139d136a4 100644 (file)
@@ -77,7 +77,7 @@ static struct mark *render(struct point **ptp, struct pane *p)
 
                mark_free(last_vis);
                last_vis = mark_dup(m, 0);
-               if (mark_same(d, m, mark_of_point(*ptp))) {
+               if (mark_same(d, m, &(*ptp)->m)) {
                        p->cx = x;
                        p->cy = y;
                }
@@ -106,7 +106,7 @@ static struct mark *render(struct point **ptp, struct pane *p)
                                if (dd->home_field < 0)
                                        dd->home_field = home;
                        }
-                       if (p->cy == y && mark_of_point(*ptp)->rpos == field - dd->home_field)
+                       if (p->cy == y && (*ptp)->m.rpos == field - dd->home_field)
                                p->cx = x;
                        b = buf;
                        while (*n == '-' || *n == '_' || isalnum(*n)) {
@@ -170,7 +170,7 @@ static struct mark *render(struct point **ptp, struct pane *p)
                x = 0;
        }
        mark_free(m);
-       if (mark_ordered(mark_of_point(*ptp), dd->top) && !mark_same(d, mark_of_point(*ptp), dd->top))
+       if (mark_ordered(&(*ptp)->m, dd->top) && !mark_same(d, &(*ptp)->m, dd->top))
                p->cx = p->cy = -1;
        return last_vis;
 }
index 2f3a9e696f00f9acd5cec8eacf72e8c1b8751a40..677d5ad249c374416d5970f0f0d1c6962ff0848e 100644 (file)
@@ -35,7 +35,7 @@ DEF_CMD(render_line)
        int field = 0;
 
        if (RPT_NUM(ci) < 0 &&
-           !mark_same(d, mark_of_point(*ci->pointp), m))
+           !mark_same(d, &(*ci->pointp)->m, m))
                ci->numeric = NO_NUMERIC;
        ch = doc_following(d, m);
        if (ch == WEOF) {
@@ -49,7 +49,7 @@ DEF_CMD(render_line)
        n = body;
        m->rpos = field - rf->home_field;
        if (RPT_NUM(ci) < 0 &&
-           mark_of_point(*ci->pointp)->rpos == m->rpos)
+           (*ci->pointp)->m.rpos == m->rpos)
                goto endwhile;
        if (ci->numeric != NO_NUMERIC && ci->numeric >= 0 &&
            ret.len >= ci->numeric)
@@ -73,7 +73,7 @@ DEF_CMD(render_line)
                    ret.len >= ci->numeric)
                        break;
                if (RPT_NUM(ci) < 0 &&
-                   mark_of_point(*ci->pointp)->rpos == m->rpos)
+                   (*ci->pointp)->m.rpos == m->rpos)
                        break;
                n += 1;
                if (*n == '+') {
@@ -135,7 +135,7 @@ endwhile:
                rf->home_field = home;
                m->rpos = field + 1 - rf->home_field;
                if (RPT_NUM(ci) < 0 &&
-                   mark_of_point(*ci->pointp)->rpos == m->rpos)
+                   (*ci->pointp)->m.rpos == m->rpos)
                        ;
                else if (ci->numeric >= 0 && ci->numeric != NO_NUMERIC)
                        ;
index 742482e523c4ba22e164c459334f644384e17f7a..7d0a1e814a3017954a258c8b7c99fbfaa8f5ca33 100644 (file)
@@ -147,7 +147,7 @@ DEF_CMD(render_line)
                struct mark *m2 = ci->mark;
 
                if (ci->numeric == -1 &&
-                   mark_same(d, m2, mark_of_point(*ptp)))
+                   mark_same(d, m2, &(*ptp)->m))
                        goto done;
                if (ci->numeric >= 0 && ci->numeric != NO_NUMERIC &&
                    ci->numeric <= ret.len)
index 1989e92ed92060f92d2ddbae2c239115a5d828dc..30a91043bc0d5d1a88070b924591fcf0eeab3058 100644 (file)
@@ -530,8 +530,8 @@ restart:
                }
                m2 = container_of(vmark_next(&m->m), struct rl_mark, m);
                if (p->cx <= 0 &&
-                   mark_ordered_or_same(d, &m->m, mark_of_point(*ptp)) &&
-                   (!m2 || mark_ordered_or_same(d, mark_of_point(*ptp), &m2->m))) {
+                   mark_ordered_or_same(d, &m->m, &(*ptp)->m) &&
+                   (!m2 || mark_ordered_or_same(d, &(*ptp)->m, &m2->m))) {
                        int len = call_render_line_to_point(p, ptp,
                                                            m);
                        rl->cursor_line = y;
@@ -783,8 +783,8 @@ DEF_CMD(render_lines_move_pos)
        top = vmark_first(d, rl->typenum);
        bot = vmark_last(d, rl->typenum);
        if (top && bot &&
-           mark_ordered(top, mark_of_point(pt)) &&
-           mark_ordered(mark_of_point(pt), bot))
+           mark_ordered(top, &pt->m) &&
+           mark_ordered(&pt->m, bot))
                /* pos already displayed */
                return 1;
        find_lines(ci->pointp, ci->home);
@@ -825,7 +825,7 @@ DEF_CMD(render_lines_move_line)
                ci2.numeric -= 1;
        else
                ci2.numeric += 1;
-       ci2.mark = mark_of_point(*ptp);
+       ci2.mark = &(*ptp)->m;
        ci2.pointp = ci->pointp;
        if (!key_handle_focus(&ci2))
                return -1;
index 92d9aaeb59bb33e705143803d28cfa31fc44ff73..4e5d82fc29f91da554855b8a9b6fbea586e83ec7 100644 (file)
@@ -136,7 +136,7 @@ static struct mark *render(struct point **ptp, struct pane *p)
        while (y < p->h) {
                mark_free(last_vis);
                last_vis = mark_dup(m, 0);
-               if (mark_same(d, m, mark_of_point(*ptp))) {
+               if (mark_same(d, m, &(*ptp)->m)) {
                        p->cx = x;
                        p->cy = y;
                }
@@ -144,11 +144,11 @@ static struct mark *render(struct point **ptp, struct pane *p)
                        break;
        }
        mark_free(m);
-       if (mark_ordered(mark_of_point(*ptp), rd->top))
+       if (mark_ordered(&(*ptp)->m, rd->top))
                /* point is before mark, cannot possibly see cursor */
                p->cx = p->cy = -1;
-       while (mark_ordered(last_vis, mark_of_point(*ptp)) &&
-              mark_same(d, last_vis, mark_of_point(*ptp)))
+       while (mark_ordered(last_vis, &(*ptp)->m) &&
+              mark_same(d, last_vis, &(*ptp)->m))
                /* point is at end of visible region - need to include it */
                mark_forward_over(last_vis, doc_next_mark_all(d, last_vis));
 
@@ -380,8 +380,8 @@ DEF_CMD(render_text_move_pos)
        rt->ignore_point = 1;
        if (rt->top &&
            rt->bot &&
-           mark_ordered(rt->top, mark_of_point(pt)) &&
-           mark_ordered(mark_of_point(pt), rt->bot))
+           mark_ordered(rt->top, &pt->m) &&
+           mark_ordered(&pt->m, rt->bot))
                /* pos already displayed */
                return 1;
        top = find_top(ci->pointp, ci->home, rt->top, rt->bot);
@@ -440,7 +440,7 @@ DEF_CMD(render_text_move_line)
        ci2.numeric = RPT_NUM(ci);
        if (ci2.numeric < 0)
                ci2.numeric -= 1;
-       m = mark_of_point(pt);
+       m = &pt->m;
        ci2.mark = m;
        ci2.pointp = ci->pointp;
        ret = key_handle_focus(&ci2);