]> git.neil.brown.name Git - edlib.git/commitdiff
Remove option for doc being stored other than in the pane.
authorNeilBrown <neil@brown.name>
Thu, 14 Sep 2023 07:01:11 +0000 (17:01 +1000)
committerNeilBrown <neil@brown.name>
Fri, 15 Sep 2023 03:38:14 +0000 (13:38 +1000)
Now DOC_DATA_TYPE must be given, and the doc must be in the pane.

Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core.h

index 2e325132eca71bfde8915c09335d306eb16efa46..36ba723e874a0a8ed7f9798e73b1f5c765f80f12 100644 (file)
@@ -33,6 +33,7 @@ struct doc_ref {
 };
 
 #define PANE_DATA_TYPE struct doc_data
+#define DOC_DATA_TYPE struct doc
 #include "core.h"
 #include "misc.h"
 #include "internal.h"
@@ -66,23 +67,20 @@ static void doc_init(struct doc *d safe)
 
 struct pane *do_doc_register(struct pane *parent safe,
                             struct command *handle safe,
-                            struct doc *doc,
                             unsigned short data_size)
 {
        struct pane *p;
 
-       if (doc == NULL && data_size < sizeof(*doc))
+       if (data_size < sizeof(struct doc))
                /* Not enough room for the doc ! */
                return NULL;
 
        /* Documents are always registered against the root */
        parent = pane_root(parent);
-       p = do_pane_register(parent, 0, handle, doc, data_size);
+       p = do_pane_register(parent, 0, handle, NULL, data_size);
        if (!p)
                return p;
-       if (!doc)
-               doc = &p->doc;
-       doc_init(doc);
+       doc_init(&p->doc);
        return p;
 }
 
diff --git a/core.h b/core.h
index 25fcb925344e1c904a8cf690a3dd4cb41c0a27f6..9cfccb97d797c7df0c0022ccfaf9e6ac060f6e1e 100644 (file)
--- a/core.h
+++ b/core.h
@@ -478,15 +478,12 @@ struct pane * do_pane_register(struct pane *parent safe, short z,
 
 void pane_update_handle(struct pane *p safe, struct command *handle safe);
 
+
+#ifdef DOC_DATA_TYPE
 struct pane *do_doc_register(struct pane *parent safe,
                             struct command *handle safe,
-                            struct doc *doc,
                             unsigned short data_size);
-
-#ifdef DOC_DATA_TYPE
-#define doc_register(p,h) do_doc_register(p, h, NULL, sizeof(DOC_DATA_TYPE))
-#else
-#define doc_register(p,h,d) do_doc_register(p,h,&(d)->doc,sizeof((d)[0]))
+#define doc_register(p,h) do_doc_register(p, h, sizeof(DOC_DATA_TYPE))
 #endif
 
 void pane_reparent(struct pane *p safe, struct pane *newparent safe);