]> git.neil.brown.name Git - edlib.git/commitdiff
lib-aspell: switch to embedded data pattern
authorNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 07:08:44 +0000 (17:08 +1000)
committerNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 07:08:44 +0000 (17:08 +1000)
aspell now embedded data in pane.

Signed-off-by: NeilBrown <neil@brown.name>
lib-aspell.c

index 38b79937e927289a7f4eea84fbbbcebca6e10180..fc564989d980600a45afc6e9468c0b3e763937a5 100644 (file)
@@ -8,14 +8,16 @@
 
 #include <aspell.h>
 #include <wctype.h>
+#define PANE_DATA_TYPE struct aspell_data
 #include "core.h"
 
-static AspellConfig *spell_config;
-
 struct aspell_data {
        AspellSpeller *speller safe;
        bool need_save;
 };
+#include "core-pane.h"
+
+static AspellConfig *spell_config;
 
 static int trim(const char *safe *wordp safe)
 {
@@ -54,11 +56,11 @@ DEF_CMD(aspell_attach_helper)
                LOG("Cannot create speller: %s", aspell_error_message(ret));
                return Efail;
        }
-       alloc(as, pane);
-       as->speller = safe_cast to_aspell_speller(ret);
-       p = pane_register(ci->focus, 0, &aspell_handle.c, as);
+       p = pane_register(ci->focus, 0, &aspell_handle.c);
        if (!p)
                return Efail;
+       as = p->data;
+       as->speller = safe_cast to_aspell_speller(ret);
 
        call("doc:request:aspell:check", p);
        call("doc:request:aspell:suggest", p);
@@ -340,7 +342,6 @@ void edlib_init(struct pane *ed safe)
 
        aspell_map = key_alloc();
        key_add(aspell_map, "Close", &aspell_close);
-       key_add(aspell_map, "Free", &edlib_do_free);
        key_add(aspell_map, "aspell:check", &aspell_check);
        key_add(aspell_map, "aspell:suggest", &aspell_suggest);
        key_add(aspell_map, "aspell:set-dict", &aspell_set_dict);