]> git.neil.brown.name Git - edlib.git/commitdiff
Allow marks in a view to have extra space allocated.
authorNeilBrown <neil@brown.name>
Mon, 16 Nov 2015 02:04:48 +0000 (13:04 +1100)
committerNeilBrown <neil@brown.name>
Mon, 16 Nov 2015 02:06:18 +0000 (13:06 +1100)
Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core-mark.c
core.h

index 4997c010bf9e646ad6fee74931cbfb661e14ee35..ed2a670ce192ae4128d6a606f9a9e1bcd1278383 100644 (file)
@@ -58,6 +58,7 @@ int doc_add_view(struct doc *d, struct command *c)
                points_resize(d);
        }
        points_attach(d, ret);
+       d->views[ret].space = 0;
        d->views[ret].notify = c;
        return ret;
 }
index f2907f71b36dc86e2fed65df73b54d5f1e36acb2..3af820d31b7f96793e81345672ae7674e6f1f179 100644 (file)
@@ -132,7 +132,13 @@ static void dup_mark(struct mark *orig, struct mark *new)
 
 struct mark *mark_at_point(struct point *p, int view)
 {
-       struct mark *ret = malloc(sizeof(*ret));
+       struct mark *ret;
+       int size = sizeof(*ret);
+
+       if (view >= 0)
+               size += p->doc->views[view].space;
+
+       ret = calloc(size, 1);
 
        dup_mark(&p->m, ret);
        ret->viewnum = view;
@@ -204,7 +210,22 @@ void points_attach(struct doc *d, int view)
 
 struct mark *mark_dup(struct mark *m, int notype)
 {
-       struct mark *ret = malloc(sizeof(*ret));
+       struct mark *ret;
+       int size = sizeof(*ret);
+
+       if (!notype) {
+               struct tlist_head *tl;
+               struct docview *dv;
+               if (m->viewnum == MARK_POINT)
+                       return NULL;
+               tl = &m->view;
+               while (TLIST_TYPE(tl) != GRP_HEAD)
+                       tl = TLIST_PTR(tl->next);
+               dv = container_of(tl, struct docview, head);
+               size += dv->space;
+       }
+
+       ret = calloc(size, 1);
        dup_mark(m, ret);
        if (notype) {
                ret->viewnum = MARK_UNGROUPED;
diff --git a/core.h b/core.h
index 98986b7450638bb409ee2e181b776f7aec6b3509..52d4d77b1654aeb883ef7988129a4b3be2a5cfc7 100644 (file)
--- a/core.h
+++ b/core.h
@@ -69,6 +69,7 @@ struct doc {
        struct docview {
                struct tlist_head head;
                struct command    *notify;
+               int             space;  /* extra space to allocate after a mark */
        } *views;
        struct attrset          *attrs;
        int                     nviews;