From: NeilBrown Date: Mon, 25 Jan 2016 02:49:54 +0000 (+1100) Subject: doc: remove dependence on view notifier. X-Git-Tag: lca2016~10 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=ec9673a784e6d473ca46297afe16c61263cffd9a;p=edlib.git doc: remove dependence on view notifier. A view can now have no notifier, and everything should work as expected. Signed-off-by: NeilBrown --- diff --git a/core-doc.c b/core-doc.c index 3f0558e1..ff068f74 100644 --- a/core-doc.c +++ b/core-doc.c @@ -41,7 +41,7 @@ static int do_doc_add_view(struct doc *d, struct command *c) int i; for (ret = 0; ret < d->nviews; ret++) - if (d->views[ret].notify == NULL) + if (d->views[ret].state == 0) break; if (ret == d->nviews) { /* Resize the view list */ @@ -469,8 +469,6 @@ DEF_CMD(doc_handle) NULL, dd->doc->name, 0); if (strcmp(ci->key, "doc:add-view") == 0) { - if (!ci->comm2) - return -1; return 1 + do_doc_add_view(dd->doc, ci->comm2); } @@ -975,7 +973,7 @@ static int do_doc_destroy(struct doc *d) d->deleting = 0; for (i = 0; i < d->nviews; i++) - if (d->views[i].notify) + if (d->views[i].state) /* still in use */ return -1; if (d == d->ed->docs) diff --git a/core-editor.c b/core-editor.c index 6b91d0e2..cf6d13c8 100644 --- a/core-editor.c +++ b/core-editor.c @@ -86,7 +86,7 @@ struct pane *editor_choose_doc(struct editor *ed) continue; last = d; for (i = 0; i < d->nviews; i++) - if (d->views[i].notify == NULL) + if (d->views[i].state == 0) break; if (i == d->nviews) { choice = d; diff --git a/core-mark.c b/core-mark.c index d78a5fe8..5475fd8c 100644 --- a/core-mark.c +++ b/core-mark.c @@ -297,7 +297,7 @@ void __mark_reset(struct doc *d, struct mark *m, int new, int end) lnk = m->mdata;; for (i = 0; i < lnk->size; i++) - if (d->views[i].notify) { + if (d->views[i].state) { if (!new) tlist_del(&lnk->lists[i]); if (end) @@ -374,7 +374,7 @@ struct mark *doc_new_mark(struct doc *d, int view) { struct mark *ret; - if (view == MARK_POINT || view >= d->nviews || d->views[view].notify == NULL) + if (view == MARK_POINT || view >= d->nviews || d->views[view].state != 1) return NULL; ret = calloc(sizeof(*ret), 1); ret->viewnum = view; @@ -1007,7 +1007,7 @@ static void point_notify_change(struct doc *d, struct mark *p, struct mark *m) struct tlist_head *tl = &lnk->lists[i]; struct command *c = d->views[i].notify; - if (!c) + if (!c || d->views[i].state == 0) continue; ci.comm = c; while (TLIST_TYPE(tl) == GRP_LIST) @@ -1080,7 +1080,7 @@ void doc_notify_change(struct doc *d, struct mark *m, struct mark *m2) continue; done[i] = 1; remaining -= 1; - if (!c) + if (!c || d->views[i].state == 0) continue; while (TLIST_TYPE(tl) == GRP_LIST) tl = TLIST_PTR(tl->prev); @@ -1099,7 +1099,7 @@ void doc_notify_change(struct doc *d, struct mark *m, struct mark *m2) struct command *c = d->views[m->viewnum].notify; done[m->viewnum] = 1; remaining -= 1; - if (c) { + if (c && d->views[m->viewnum].state) { ci.mark = m; ci.comm = c; c->func(&ci); @@ -1111,7 +1111,7 @@ void doc_notify_change(struct doc *d, struct mark *m, struct mark *m2) struct command *c = d->views[i].notify; if (done[i]) continue; - if (!c) + if (!c || d->views[i].state == 0) continue; ci.mark = NULL; ci.comm = c; @@ -1141,7 +1141,7 @@ void doc_check_consistent(struct doc *d) seq = m->seq + 1; } for (i = 0; i < d->nviews; i++) - if (d->views[i].notify == NULL) { + if (d->views[i].state == 0) { if (!tlist_empty(&d->views[i].head)) abort(); } else { struct tlist_head *tl; diff --git a/core.h b/core.h index 562717ce..21989138 100644 --- a/core.h +++ b/core.h @@ -96,7 +96,7 @@ struct doc { struct docview { struct tlist_head head; struct command *notify; - short state; /* 0 = unused, 1 = active, 2 = being deleted */ + short state; /* 0 = unused, 1 = active, 2 = being deleted */ } *views; struct attrset *attrs; int nviews;