]> git.neil.brown.name Git - edlib.git/commitdiff
Get rid of 'struct point'.
authorNeilBrown <neil@brown.name>
Fri, 27 Nov 2015 00:37:03 +0000 (11:37 +1100)
committerNeilBrown <neil@brown.name>
Fri, 27 Nov 2015 00:37:03 +0000 (11:37 +1100)
Just use 'struct mark' which now as a void* mdata for extension.

Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core-keymap.c
core-mark.c
core-pane.c
core.h
doc-text.c
emacs-search.c

index 2c2b59b5fb2968e060b77123ee5fa118fc723dd3..f9f8ce45deaeb979a9abf1d795fd1c00dbac8b05 100644 (file)
@@ -259,7 +259,7 @@ DEF_CMD(doc_file)
        int rpt = RPT_NUM(ci);
 
        if (ci->mark == NULL)
-               ci->mark = &ci->home->point->m;
+               ci->mark = ci->home->point;
        while (rpt > 0 && ch != WEOF) {
                while ((ch = mark_next(d, ci->mark)) != WEOF)
                        ;
@@ -369,23 +369,21 @@ DEF_CMD(doc_handle)
 
        if (strcmp(ci->key, "Close") == 0) {
                if (ci->home->point)
-                       point_free(ci->home->point);
+                       mark_free(ci->home->point);
                ci->home->point = NULL;
                return 1;
        }
 
        if (strcmp(ci->key, "doc:dup-point") == 0) {
-               struct point *pt = ci->home->point;
+               struct mark *pt = ci->home->point;
                if (ci->mark && ci->mark->viewnum == MARK_POINT)
-                       pt = container_of(ci->mark, struct point, m);
+                       pt = ci->mark;
                ci->mark = NULL;
                if (ci->home->point) {
-                       if (ci->extra == MARK_POINT) {
-                               pt = point_dup(pt);
-                               ci->mark = &pt->m;
-                       }
+                       if (ci->extra == MARK_POINT)
+                               ci->mark = point_dup(pt);
                        else if (ci->extra == MARK_UNGROUPED)
-                               ci->mark = mark_dup(&pt->m, 1);
+                               ci->mark = mark_dup(pt, 1);
                        else
                                ci->mark = do_mark_at_point(d, pt,
                                                            ci->extra);
@@ -696,7 +694,7 @@ DEF_CMD(docs_get_attr)
 DEF_CMD(docs_open)
 {
        struct pane *p = ci->home;
-       struct pane *dp = p->point->m.ref.p;
+       struct pane *dp = p->point->ref.p;
        struct pane *par = p->parent;
        char *renderer = NULL;
 
@@ -842,9 +840,7 @@ int  doc_destroy(struct doc *d)
        free(d->name);
        while (d->marks.first) {
                struct mark *m = hlist_first_entry(&d->marks, struct mark, all);
-               if (m->viewnum == MARK_POINT)
-                       point_free(container_of(m, struct point, m));
-               else if (m->viewnum == MARK_UNGROUPED)
+               if (m->viewnum == MARK_POINT || m->viewnum == MARK_UNGROUPED)
                        mark_free(m);
                else
                        /* vmarks should have gone already */
index 289d93790fe8d90c704c326f2347fe556b995f54..cab542386f8e0e335e54e3485ef9baedcf20496f 100644 (file)
@@ -332,7 +332,7 @@ static int __key_handle_focus(struct cmd_info *ci, int savepoint)
        while (p->focus) {
                p = p->focus;
                if (savepoint && p->point)
-                       ci->mark = &p->point->m;
+                       ci->mark = p->point;
        }
        ci->focus = p;
        ci->comm = NULL;
@@ -373,7 +373,7 @@ static int __key_handle_xy(struct cmd_info *ci, int savepoint)
                y -= chld->y;
                p = chld;
                if (savepoint && p->point)
-                       ci->mark = &p->point->m;
+                       ci->mark = p->point;
        }
        ci->x = x;
        ci->y = y;
index 0286dfa879966ae7a3ead69f68a738fb7a0006f9..18501ea4814b54be1bc3644f78ded2990653b6cb 100644 (file)
@@ -105,22 +105,25 @@ static void mark_delete(struct mark *m)
        attr_free(&m->attrs);
 }
 
-void mark_free(struct mark *m)
+static void point_free(struct mark *p)
 {
-       if (m) {
-               mark_delete(m);
-               free(m);
-       }
+       int i;
+       struct point_links *lnk = p->mdata;
+       for (i = 0; i < lnk->size; i++)
+               tlist_del_init(&lnk->lists[i]);
+       free(lnk);
+       p->mdata = NULL;
 }
 
-void point_free(struct point *p)
+void mark_free(struct mark *m)
 {
-       int i;
-       for (i = 0; i < p->links->size; i++)
-               tlist_del_init(&p->links->lists[i]);
-       mark_delete(&p->m);
-       free(p->links);
-       free(p);
+       if (!m)
+               return;
+       if (m->viewnum == MARK_POINT)
+               point_free(m);
+       ASSERT(m->mdata == NULL);
+       mark_delete(m);
+       free(m);
 }
 
 static void dup_mark(struct mark *orig, struct mark *new)
@@ -132,20 +135,25 @@ static void dup_mark(struct mark *orig, struct mark *new)
        assign_seq(new, orig->seq);
 }
 
-struct mark *do_mark_at_point(struct doc *d, struct point *pt, int view)
+struct mark *do_mark_at_point(struct doc *d, struct mark *pt, int view)
 {
        struct mark *ret;
        int size = sizeof(*ret);
+       struct point_links *lnk;
+
+       if (pt->viewnum != MARK_POINT)
+               return NULL;
+       lnk = pt->mdata;
 
        if (view >= 0)
                size += d->views[view].space;
 
        ret = calloc(size, 1);
 
-       dup_mark(&pt->m, ret);
+       dup_mark(pt, ret);
        ret->viewnum = view;
        if (view >= 0)
-               tlist_add(&ret->view, GRP_MARK, &pt->links->lists[view]);
+               tlist_add(&ret->view, GRP_MARK, &lnk->lists[view]);
        else
                INIT_TLIST_HEAD(&ret->view, GRP_MARK);
        return ret;
@@ -163,38 +171,39 @@ struct mark *mark_at_point(struct pane *p, struct mark *pm, int view)
        return ci.mark;
 }
 
-struct point *point_dup(struct point *p)
+struct mark *point_dup(struct mark *p)
 {
        int i;
-       struct point *ret = malloc(sizeof(*ret));
+       struct point_links *old = p->mdata;
+       struct mark *ret = malloc(sizeof(*ret));
        struct point_links *lnk = malloc(sizeof(*lnk) +
-                                        p->links->size * sizeof(lnk->lists[0]));
+                                        old->size * sizeof(lnk->lists[0]));
 
-       dup_mark(&p->m, &ret->m);
-       ret->m.viewnum = MARK_POINT;
-       ret->links = lnk;
-       lnk->size = p->links->size;
+       dup_mark(p, ret);
+       ret->viewnum = MARK_POINT;
+       ret->mdata = lnk;
+       lnk->size = old->size;
        lnk->pt = ret;
-       tlist_add(&ret->m.view, GRP_MARK, &p->m.view);
+       tlist_add(&ret->view, GRP_MARK, &p->view);
        for (i = 0; i < lnk->size; i++)
-               if (tlist_empty(&p->links->lists[i]))
+               if (tlist_empty(&old->lists[i]))
                        INIT_TLIST_HEAD(&lnk->lists[i], GRP_LIST);
                else
-                       tlist_add(&lnk->lists[i], GRP_LIST, &p->links->lists[i]);
+                       tlist_add(&lnk->lists[i], GRP_LIST, &old->lists[i]);
        return ret;
 }
 
 void points_resize(struct doc *d)
 {
-       struct point *p;
-       tlist_for_each_entry(p, &d->points, m.view) {
+       struct mark *p;
+       tlist_for_each_entry(p, &d->points, view) {
                int i;
-               struct point_links *old = p->links;
+               struct point_links *old = p->mdata;
                struct point_links *new = malloc(sizeof(*new) +
                                                 d->nviews * sizeof(new->lists[0]));
                new->pt = p;
                new->size = d->nviews;
-               p->links = new;
+               p->mdata = new;
                for (i = 0; i < old->size; i++) {
                        tlist_add(&new->lists[i], GRP_LIST, &old->lists[i]);
                        tlist_del(&old->lists[i]);
@@ -207,9 +216,11 @@ void points_resize(struct doc *d)
 
 void points_attach(struct doc *d, int view)
 {
-       struct point *p;
-       tlist_for_each_entry(p, &d->points, m.view)
-               tlist_add_tail(&p->links->lists[view], GRP_LIST, &d->views[view].head);
+       struct mark *p;
+       tlist_for_each_entry(p, &d->points, view) {
+               struct point_links *lnk = p->mdata;
+               tlist_add_tail(&lnk->lists[view], GRP_LIST, &d->views[view].head);
+       }
 }
 
 struct mark *mark_dup(struct mark *m, int notype)
@@ -247,7 +258,6 @@ struct mark *mark_dup(struct mark *m, int notype)
 
 void __mark_reset(struct doc *d, struct mark *m, int new, int end)
 {
-       struct point *p;
        int i;
        struct cmd_info ci = {0};
        int seq = 0;
@@ -295,8 +305,8 @@ void __mark_reset(struct doc *d, struct mark *m, int new, int end)
                tlist_add_tail(&m->view, GRP_MARK, &d->points);
        else
                tlist_add(&m->view, GRP_MARK, &d->points);
-       p = container_of(m, struct point, m);
-       lnk = p->links;
+
+       lnk = m->mdata;;
        for (i = 0; i < lnk->size; i++)
                if (d->views[i].notify) {
                        if (!new)
@@ -310,18 +320,18 @@ void __mark_reset(struct doc *d, struct mark *m, int new, int end)
                        INIT_TLIST_HEAD(&lnk->lists[i], GRP_LIST);
 }
 
-struct point *point_new(struct doc *d)
+struct mark *point_new(struct doc *d)
 {
-       struct point *ret = malloc(sizeof(*ret));
+       struct mark *ret = malloc(sizeof(*ret));
        struct point_links *lnk = malloc(sizeof(*lnk) +
                                         d->nviews * sizeof(lnk->lists[0]));
 
-       ret->m.attrs = NULL;
-       ret->m.viewnum = MARK_POINT;
-       ret->links = lnk;
+       ret->attrs = NULL;
+       ret->viewnum = MARK_POINT;
+       ret->mdata = lnk;
        lnk->size = d->nviews;
        lnk->pt = ret;
-       __mark_reset(d, &ret->m, 1, 0);
+       __mark_reset(d, ret, 1, 0);
        return ret;
 }
 
@@ -432,14 +442,15 @@ static struct mark *prev_mark(struct doc *d, struct mark *m)
        return hlist_prev_entry(m, all);
 }
 
-static void swap_lists(struct point *p1, struct point *p2)
+static void swap_lists(struct mark *p1, struct mark *p2)
 {
        struct point_links *tmp;
-       tmp = p1->links;
-       p1->links = p2->links;
-       p2->links = tmp;
-       p1->links->pt = p1;
-       p2->links->pt = p2;
+       tmp = p1->mdata;
+       p1->mdata = p2->mdata;
+       p2->mdata = tmp;
+       tmp->pt = p2;
+       tmp = p1->mdata;
+       tmp->pt = p1;
 }
 
 void mark_forward_over(struct mark *m, struct mark *m2)
@@ -454,22 +465,20 @@ void mark_forward_over(struct mark *m, struct mark *m2)
        }
        if (m->viewnum == MARK_POINT && m2->viewnum == MARK_POINT) {
                /* moving a point over a point */
-               struct point *p = container_of(m, struct point, m);
-               struct point *p2 = container_of(m2, struct point, m);
-               swap_lists(p, p2);
+               swap_lists(m, m2);
        } else if (m->viewnum == MARK_POINT) {
                /* Moving a point over a mark */
-               struct point *p = container_of(m, struct point, m);
+               struct point_links *lnk = m->mdata;
                if (m2->viewnum >= 0) {
                        tlist_del(&m2->view);
-                       tlist_add_tail(&m2->view, GRP_MARK, &p->links->lists[m2->viewnum]);
+                       tlist_add_tail(&m2->view, GRP_MARK, &lnk->lists[m2->viewnum]);
                }
        } else if (m2->viewnum == MARK_POINT) {
                /* stepping a mark over a point */
-               struct point *p = container_of(m2, struct point, m);
+               struct point_links *lnk = m2->mdata;
                if (m->viewnum >= 0) {
                        tlist_del(&m->view);
-                       tlist_add(&m->view, GRP_MARK, &p->links->lists[m->viewnum]);
+                       tlist_add(&m->view, GRP_MARK, &lnk->lists[m->viewnum]);
                }
        }
        seq = m->seq;
@@ -489,22 +498,20 @@ void mark_backward_over(struct mark *m, struct mark *mp)
        }
        if (m->viewnum == MARK_POINT && mp->viewnum == MARK_POINT) {
                /* moving a point over a point */
-               struct point *p = container_of(m, struct point, m);
-               struct point *pp = container_of(mp, struct point, m);
-               swap_lists(pp, p);
+               swap_lists(m, mp);
        } else if (m->viewnum == MARK_POINT) {
                /* Moving a point over a mark */
-               struct point *p = container_of(m, struct point, m);
+               struct point_links *lnks = m->mdata;
                if (mp->viewnum >= 0) {
                        tlist_del(&mp->view);
-                       tlist_add(&mp->view, GRP_MARK, &p->links->lists[mp->viewnum]);
+                       tlist_add(&mp->view, GRP_MARK, &lnks->lists[mp->viewnum]);
                }
        } else if (mp->viewnum == MARK_POINT) {
                /* Step back over a point */
-               struct point *p = container_of(mp, struct point, m);
+               struct point_links *lnks = mp->mdata;
                if (m->viewnum >= 0) {
                        tlist_del(&m->view);
-                       tlist_add_tail(&m->view, GRP_MARK, &p->links->lists[m->viewnum]);
+                       tlist_add_tail(&m->view, GRP_MARK, &lnks->lists[m->viewnum]);
                }
        }
        seq = m->seq;
@@ -577,15 +584,16 @@ wint_t mark_prev(struct doc *d, struct mark *m)
  * Then update 'all' list, text ref and seq number.
  */
 
-static void point_forward_to_mark(struct point *p, struct mark *m)
+static void point_forward_to_mark(struct mark *p, struct mark *m)
 {
-       struct point *ptmp, *pnear;
+       struct mark *ptmp, *pnear;
        int i;
+       struct point_links *plnk = p->mdata;
 
        pnear = p;
        ptmp = p;
-       tlist_for_each_entry_continue(ptmp, GRP_HEAD, m.view) {
-               if (ptmp->m.seq < m->seq)
+       tlist_for_each_entry_continue(ptmp, GRP_HEAD, view) {
+               if (ptmp->seq < m->seq)
                        pnear = ptmp;
                else
                        break;
@@ -593,16 +601,17 @@ static void point_forward_to_mark(struct point *p, struct mark *m)
        /* pnear is the nearest point to m that is before m. So
         * move p after pnear in the point list. */
        if (p != pnear) {
-               tlist_del(&p->m.view);
-               tlist_add(&p->m.view, GRP_MARK, &pnear->m.view);
+               tlist_del(&p->view);
+               tlist_add(&p->view, GRP_MARK, &pnear->view);
        }
 
        /* Now move 'p' in the various mark lists */
-       for (i = 0; i < p->links->size; i++) {
+       for (i = 0; i < plnk->size; i++) {
                struct mark *mnear = NULL;
                struct tlist_head *tl;
+               struct point_links *pnlnk = pnear->mdata;
 
-               tl = &pnear->links->lists[i];
+               tl = &pnlnk->lists[i];
                if (tlist_empty(tl))
                        continue;
                tlist_for_each_continue(tl,  GRP_HEAD) {
@@ -616,29 +625,30 @@ static void point_forward_to_mark(struct point *p, struct mark *m)
                                break;
                }
                if (mnear) {
-                       tlist_del(&p->links->lists[i]);
-                       tlist_add(&p->links->lists[i], GRP_LIST, &mnear->view);
+                       tlist_del(&plnk->lists[i]);
+                       tlist_add(&plnk->lists[i], GRP_LIST, &mnear->view);
                } else if (p != pnear) {
-                       tlist_del(&p->links->lists[i]);
-                       tlist_add(&p->links->lists[i], GRP_LIST, &pnear->links->lists[i]);
+                       tlist_del(&plnk->lists[i]);
+                       tlist_add(&plnk->lists[i], GRP_LIST, &pnlnk->lists[i]);
                }
        }
        /* finally move in the overall list */
-       hlist_del(&p->m.all);
-       hlist_add_before(&p->m.all, &m->all);
-       p->m.ref = m->ref;
-       assign_seq(&p->m, hlist_prev_entry(&p->m, all)->seq);
+       hlist_del(&p->all);
+       hlist_add_before(&p->all, &m->all);
+       p->ref = m->ref;
+       assign_seq(p, hlist_prev_entry(p, all)->seq);
 }
 
-static void point_backward_to_mark(struct point *p, struct mark *m)
+static void point_backward_to_mark(struct mark *p, struct mark *m)
 {
-       struct point *ptmp, *pnear;
+       struct mark *ptmp, *pnear;
        int i;
+       struct point_links *plnk = p->mdata;
 
        pnear = p;
        ptmp = p;
-       tlist_for_each_entry_continue_reverse(ptmp, GRP_HEAD, m.view) {
-               if (ptmp->m.seq > m->seq)
+       tlist_for_each_entry_continue_reverse(ptmp, GRP_HEAD, view) {
+               if (ptmp->seq > m->seq)
                        pnear = ptmp;
                else
                        break;
@@ -646,16 +656,17 @@ static void point_backward_to_mark(struct point *p, struct mark *m)
        /* pnear is the nearest point to m that is after m. So
         * move p before pnear in the point list */
        if (p != pnear) {
-               tlist_del(&p->m.view);
-               tlist_add_tail(&p->m.view, GRP_MARK, &pnear->m.view);
+               tlist_del(&p->view);
+               tlist_add_tail(&p->view, GRP_MARK, &pnear->view);
        }
 
        /* Now move 'p' in the various mark lists */
-       for (i = 0; i < p->links->size; i++) {
+       for (i = 0; i < plnk->size; i++) {
                struct mark *mnear = NULL;
                struct tlist_head *tl;
+               struct point_links *pnlnk = pnear->mdata;
 
-               tl = &pnear->links->lists[i];
+               tl = &pnlnk->lists[i];
                if (tlist_empty(tl))
                        continue;
                tlist_for_each_continue_reverse(tl, GRP_HEAD) {
@@ -669,36 +680,35 @@ static void point_backward_to_mark(struct point *p, struct mark *m)
                                break;
                }
                if (mnear) {
-                       tlist_del(&p->links->lists[i]);
-                       tlist_add_tail(&p->links->lists[i], GRP_LIST, &mnear->view);
+                       tlist_del(&plnk->lists[i]);
+                       tlist_add_tail(&plnk->lists[i], GRP_LIST, &mnear->view);
                } else if (p != pnear) {
-                       tlist_del(&p->links->lists[i]);
-                       tlist_add_tail(&p->links->lists[i], GRP_LIST, &pnear->links->lists[i]);
+                       tlist_del(&plnk->lists[i]);
+                       tlist_add_tail(&plnk->lists[i], GRP_LIST, &pnlnk->lists[i]);
                }
        }
        /* finally move in the overall list */
-       hlist_del(&p->m.all);
-       hlist_add_after(&m->all, &p->m.all);
-       p->m.ref = m->ref;
-       p->m.rpos = m->rpos;
-       assign_seq(&p->m, m->seq);
+       hlist_del(&p->all);
+       hlist_add_after(&m->all, &p->all);
+       p->ref = m->ref;
+       p->rpos = m->rpos;
+       assign_seq(p, m->seq);
 }
 
-void point_to_mark(struct point *p, struct mark *m)
+void point_to_mark(struct mark *p, struct mark *m)
 {
-       if (p->m.seq < m->seq)
+       if (p->seq < m->seq)
                point_forward_to_mark(p, m);
-       else if (p->m.seq > m->seq)
+       else if (p->seq > m->seq)
                point_backward_to_mark(p, m);
-       p->m.rpos = m->rpos;
+       p->rpos = m->rpos;
 }
 
 void mark_to_mark(struct mark *m, struct mark *target)
 {
 
        if (m->viewnum == MARK_POINT) {
-               point_to_mark(container_of(m, struct point, m),
-                             target);
+               point_to_mark(m, target);
                return;
        }
        while (mark_ordered(m, target)) {
@@ -882,23 +892,24 @@ struct mark *vmark_matching(struct pane *p, struct mark *m)
        return NULL;
 }
 
-struct mark *do_vmark_at_point(struct doc *d, struct point *pt, int view)
+struct mark *do_vmark_at_point(struct doc *d, struct mark *pt, int view)
 {
        struct tlist_head *tl;
        struct mark *m;
+       struct point_links *lnk = pt->mdata;
 
-       tl = &pt->links->lists[view];
+       tl = &lnk->lists[view];
        m = __vmark_prev(tl);
-       if (m && mark_same(d, m, &pt->m))
+       if (m && mark_same(d, m, pt))
                return m;
-       tl = &pt->links->lists[view];
+       tl = &lnk->lists[view];
        m = __vmark_next(tl);
-       if (m && mark_same(d, m, &pt->m))
+       if (m && mark_same(d, m, pt))
                return m;
        return NULL;
 }
 
-void point_notify_change(struct doc *d, struct point *p, struct mark *m)
+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,
@@ -907,14 +918,15 @@ void point_notify_change(struct doc *d, struct point *p, struct mark *m)
         */
        struct cmd_info ci = {0};
        int i;
+       struct point_links *lnk = p->mdata;
 
        ci.key = "Notify:Replace";
        ci.numeric = 1;
        ci.x = ci.y = -1;
        if (!m)
-               m = &p->m;
-       for (i = 0; i < p->links->size; i++) {
-               struct tlist_head *tl = &p->links->lists[i];
+               m = p;
+       for (i = 0; i < lnk->size; i++) {
+               struct tlist_head *tl = &lnk->lists[i];
                struct command *c = d->views[i].notify;
 
                if (!c)
@@ -940,11 +952,11 @@ void point_notify_change(struct doc *d, struct point *p, struct mark *m)
                }
 
                /* Now any relevant marks after point but at the same ref */
-               tl = &p->links->lists[i];
+               tl = &lnk->lists[i];
                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, &p->m))
+                               if (mark_same(d, ci.mark, p))
                                        c->func(&ci);
                                else
                                        break;
@@ -965,7 +977,7 @@ void doc_notify_change(struct doc *d, struct mark *m)
        int remaining = d->nviews;
 
        if (m->viewnum == MARK_POINT) {
-               point_notify_change(d, container_of(m, struct point, m), NULL);
+               point_notify_change(d, m, NULL);
                return;
        }
 
@@ -978,9 +990,9 @@ void doc_notify_change(struct doc *d, struct mark *m)
        while (remaining) {
                if (m->viewnum == MARK_POINT) {
                        /* This is a point so we can notify all remaining easily. */
-                       struct point *p = container_of(m, struct point, m);
-                       for (i = 0; i < p->links->size; i++) {
-                               struct tlist_head *tl = &p->links->lists[i];
+                       struct point_links *lnk = m->mdata;
+                       for (i = 0; i < lnk->size; i++) {
+                               struct tlist_head *tl = &lnk->lists[i];
                                struct command *c = d->views[i].notify;
                                if (done[i])
                                        continue;
@@ -1051,7 +1063,6 @@ void doc_check_consistent(struct doc *d)
                        if (!tlist_empty(&d->views[i].head)) abort();
                } else {
                        struct tlist_head *tl;
-                       struct point *p;
                        struct point_links *pl;
                        seq = 0;
                        tlist_for_each(tl, &d->views[i].head) {
@@ -1062,8 +1073,7 @@ void doc_check_consistent(struct doc *d)
                                        break;
                                case GRP_LIST:
                                        pl = container_of(tl, struct point_links, lists[i]);
-                                       p = pl->pt;
-                                       m = &p->m;
+                                       m = pl->pt;
                                        break;
                                default: abort();
                                }
index c18f1776e07c2b6af34b29dd019350275531dc21..7f3173586cc808371a1ad61d5f0e30f039ea2249 100644 (file)
@@ -108,7 +108,7 @@ static void __pane_refresh(struct cmd_info *ci)
                p->focus = list_first_entry_or_null(
                        &p->children, struct pane, siblings);
        if (p->point)
-               ci2.mark = &p->point->m;
+               ci2.mark = p->point;
 
        damage |= p->damaged;
        if (!damage)
@@ -240,7 +240,7 @@ void pane_subsume(struct pane *p, struct pane *parent)
         */
        void *data;
        struct command *handle;
-       struct point *point;
+       struct mark *point;
        struct pane *c;
 
        list_del_init(&p->siblings);
diff --git a/core.h b/core.h
index d6655a1e2065409630d4ff5d5d5e3ac4aa2e512f..dd79540a8d7c1debf3bb0f31ff1ddfbdc1b87767 100644 (file)
--- a/core.h
+++ b/core.h
@@ -22,7 +22,6 @@ typedef _Bool bool;
 
 struct doc;
 struct mark;
-struct point;
 struct attrset;
 struct display;
 struct pane;
@@ -57,7 +56,7 @@ struct pane {
 
        struct command          *handle;
        void                    *data;
-       struct point            *point;
+       struct mark             *point;
        struct attrset          *attrs;
 };
 
@@ -132,17 +131,17 @@ struct mark {
                                         * a document object (which displays as more than
                                         * a char
                                         */
+       void                    *mdata;
 };
 
-struct point {
-       struct mark             m;
-       struct point_links {
-               int                     size;
-               struct point            *pt;
-               struct tlist_head       lists[];
-       } *links;
+/* A point uses this for the mdata */
+struct point_links {
+       int                     size;
+       struct mark             *pt;
+       struct tlist_head       lists[];
 };
 
+
 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);
@@ -153,37 +152,36 @@ struct mark *doc_prev_mark_all_safe(struct doc *d, struct mark *m);
 struct mark *doc_first_mark(struct doc *d, int viewnum);
 struct mark *doc_next_mark(struct mark *m);
 struct mark *doc_prev_mark(struct mark *m);
-void point_reset(struct point *p);
+void point_reset(struct mark *p);
 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 point *p, struct mark *m);
+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_check_consistent(struct doc *d);
-void point_to_mark(struct point *p, struct mark *m);
+void point_to_mark(struct mark *p, struct mark *m);
 void mark_to_mark(struct mark *m, struct mark *target);
 int mark_same(struct doc *d, struct mark *m1, struct mark *m2);
 int mark_same2(struct doc *d, struct mark *m1, struct mark *m2, struct cmd_info *ci);
 int mark_same_pane(struct pane *p, struct mark *m1, struct mark *m2,
                   struct cmd_info *ci);
-struct point *point_new(struct doc *d);
-struct point *point_dup(struct point *p);
+struct mark *point_new(struct doc *d);
+struct mark *point_dup(struct mark *p);
 wint_t mark_step(struct doc *d, struct mark *m, int forward, int move, struct cmd_info *ci);
 wint_t mark_step2(struct doc *d, struct mark *m, int forward, int move);
 wint_t mark_next(struct doc *d, struct mark *m);
 wint_t mark_prev(struct doc *d, struct mark *m);
 struct mark *mark_at_point(struct pane *p, struct mark *pm, int view);
-struct mark *do_mark_at_point(struct doc *d, struct point *pt, int view);
+struct mark *do_mark_at_point(struct doc *d, struct mark *pt, int view);
 void points_resize(struct doc *d);
 void points_attach(struct doc *d, int view);
-void point_free(struct point *p);
 struct mark *vmark_next(struct mark *m);
 struct mark *vmark_prev(struct mark *m);
 struct mark *do_vmark_first(struct doc *d, int view);
 struct mark *do_vmark_last(struct doc *d, int view);
 struct mark *vmark_matching(struct pane *p, struct mark *m);
-struct mark *do_vmark_at_point(struct doc *d, struct point *pt, int view);
+struct mark *do_vmark_at_point(struct doc *d, struct mark *pt, int view);
 struct mark *vmark_first(struct pane *p, int view);
 struct mark *vmark_last(struct pane *p, int view);
 struct mark *vmark_at_point(struct pane *p, int view);
@@ -401,14 +399,14 @@ static inline char *doc_attr(struct pane *dp, struct mark *m, bool forward, char
        return ci.str2;
 }
 
-static inline int doc_set_attr(struct pane *p, struct point *pt,
+static inline int doc_set_attr(struct pane *p, struct mark *pt,
                               char *attr, char *val)
 {
        struct cmd_info ci = {0};
 
        ci.key = "doc:set-attr";
        ci.focus = p;
-       ci.mark = &pt->m;
+       ci.mark = pt;
        ci.str = attr;
        ci.str2 = val;
        return key_handle_focus(&ci);
index b344110f6de0314ac920a6c607b96c80abcbe88c..6dddf39defe1bcf113a811afdb649f2b33fc3a69 100644 (file)
@@ -780,7 +780,7 @@ static int text_redo(struct text *t, struct doc_ref *start, struct doc_ref *end)
 DEF_CMD(text_reundo)
 {
        struct doc *d = ci->home->data;
-       struct mark *m = &ci->home->point->m;
+       struct mark *m = ci->home->point;
        bool redo = ci->numeric != 0;
        struct doc_ref start, end;
        int did_do = 2;
@@ -1358,11 +1358,10 @@ DEF_CMD(text_replace)
 {
        struct doc *d = ci->home->data;
        struct text *t = container_of(d, struct text, doc);
-       struct point *pos = ci->home->point;
+       struct mark *pm = ci->home->point;
        struct mark *end = ci->mark;
        char *str = ci->str;
        bool first = ci->numeric;
-       struct mark *pm = &pos->m;
        struct mark *early = NULL;
 
        /* First delete, then insert */
@@ -1409,7 +1408,7 @@ DEF_CMD(text_replace)
                text_check_consistent(t);
 
        }
-       point_notify_change(d, pos, early);
+       point_notify_change(d, pm, early);
        ci->numeric = first;
        return 1;
 }
index 9c8c330b68aa37cba2f3d0003ed3de0158e3630a..238f00bb3f859236b3e180b381f1509ef1f5000a 100644 (file)
@@ -29,7 +29,7 @@ struct es_info {
                unsigned int len; /* current length of match string */
        } *s;
        struct mark *start; /* where searching starts */
-       struct point *end; /* where last success ended */
+       struct mark *end; /* where last success ended */
        struct pane *target, *search;
        struct command watch;
        short matched;
@@ -51,7 +51,7 @@ DEF_CMD(search_forward)
        if (!d)
                return -1;
 
-       if (esi->s && mark_same(d, esi->s->m, &esi->end->m)) {
+       if (esi->s && mark_same(d, esi->s->m, esi->end)) {
                /* already pushed and didn't find anything new */
                return 1;
        }
@@ -63,7 +63,7 @@ DEF_CMD(search_forward)
        s->next = esi->s;
        esi->s = s;
        if (esi->matched)
-               esi->start = mark_dup(&esi->end->m, 1);
+               esi->start = mark_dup(esi->end, 1);
        else {
                esi->start = mark_dup(s->m, 1);
                mark_reset(d, esi->start);
@@ -111,7 +111,7 @@ DEF_CMD(search_add)
        do {
                /* TEMP HACK - please fix */
                doc_set_attr(esi->target, esi->end, "highlight", NULL);
-               wch = mark_next(d, &esi->end->m);
+               wch = mark_next(d, esi->end);
                if (wch == WEOF)
                        return 1;
                if (wch == '\n') {
@@ -119,7 +119,7 @@ DEF_CMD(search_add)
                        /* Sending this will cause a call-back to
                         * close everything down.
                         */
-                       mark_prev(d, &esi->end->m);
+                       mark_prev(d, esi->end);
                        return 1;
                }
                /* FIXME utf-8! and quote regexp chars */
@@ -147,7 +147,7 @@ DEF_CMD(search_close)
        doc_del_view(ci->focus, &esi->watch);
        /* TEMP HACK - please fix */
        doc_set_attr(esi->target, esi->end, "highlight", NULL);
-       point_free(esi->end);
+       mark_free(esi->end);
        esi->end = NULL;
        mark_free(esi->start);
        while (esi->s) {
@@ -196,7 +196,7 @@ REDEF_CMD(search_again)
                doc_set_attr(esi->target, esi->end, "highlight","fg:red,inverse");
                ci2.key = "Move-View-Pos";
                ci2.focus = esi->target;
-               ci2.mark = &esi->end->m;
+               ci2.mark = esi->end;
                key_handle_focus(&ci2);
                esi->matched = 1;
                pfx = "Search: ";
@@ -253,7 +253,7 @@ DEF_CMD(emacs_search)
                free(esi);
                return -1;
        }
-       esi->end = container_of(ci2.mark, struct point, m);
+       esi->end = ci2.mark;
 
        esi->start = mark_dup(ci2.mark, 1);
        esi->s = NULL;