From: NeilBrown Date: Thu, 14 Sep 2023 10:19:23 +0000 (+1000) Subject: Introduce PANE_DATA_PTR_TYPE_3 for emacs-search. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=c7196d90c907c3795e054b72cd2466d047f27cdc;p=edlib.git Introduce PANE_DATA_PTR_TYPE_3 for emacs-search. Emacs-search has 2 pane types, one is a ptr type. Signed-off-by: NeilBrown --- diff --git a/core-pane.h b/core-pane.h index c466f5ac..373bad44 100644 --- a/core-pane.h +++ b/core-pane.h @@ -42,6 +42,12 @@ struct pane { #endif #ifdef PANE_DATA_PTR_TYPE_2 PANE_DATA_PTR_TYPE_2 data2 safe; +#endif +#ifdef PANE_DATA_TYPE_3 + PANE_DATA_TYPE_3 data3[1]; +#endif +#ifdef PANE_DATA_PTR_TYPE_3 + PANE_DATA_PTR_TYPE_3 data3 safe; #endif void *_data safe; }; diff --git a/core.h b/core.h index 3a8b5835..9a18a7e6 100644 --- a/core.h +++ b/core.h @@ -488,6 +488,18 @@ static inline struct pane *pane_register_2(struct pane *parent safe, short z, } #endif +#ifdef PANE_DATA_TYPE_3 +#define pane_register_3(p,z,h) do_pane_register(p,z,h,NULL, sizeof(PANE_DATA_TYPE_3)) +#endif +#ifdef PANE_DATA_PTR_TYPE_3 +static inline struct pane *pane_register_3(struct pane *parent safe, short z, + struct command *handle safe, + PANE_DATA_PTR_TYPE_3 data) +{ + return do_pane_register(parent, z, handle, (void*)data, sizeof(data)); +} +#endif + void pane_update_handle(struct pane *p safe, struct command *handle safe); diff --git a/emacs-search.c b/emacs-search.c index 22b5b2ba..83a660a4 100644 --- a/emacs-search.c +++ b/emacs-search.c @@ -26,6 +26,7 @@ #include #define PANE_DATA_TYPE struct es_info #define PANE_DATA_TYPE_2 struct highlight_info +#define PANE_DATA_PTR_TYPE_3 struct pane * #include "core.h" #include "rexel.h" @@ -477,7 +478,7 @@ DEF_CMD(search_replace) attr_set_str(&p->attrs, "status-line", " Replacement "); call("doc:set-name", p, 0, NULL, "Replacement"); - p = pane_register(p, 0, &replace_handle.c, ci->focus); + p = pane_register_3(p, 0, &replace_handle.c, ci->focus); if (!p) return Efail; p = call_ret(pane, "attach-history", p, 0, NULL, "*Replace History*"); @@ -563,7 +564,7 @@ DEF_CMD(do_replace) DEF_CMD(replace_request_next) { - struct pane *sp = ci->home->_data; + struct pane *sp = ci->home->data3; char *new; new = call_ret(str, "doc:get-str", ci->focus); @@ -578,7 +579,7 @@ DEF_CMD(replace_request_next) DEF_CMD(replace_request) { - struct pane *sp = ci->home->_data; + struct pane *sp = ci->home->data3; char *new; new = call_ret(str, "doc:get-str", ci->focus); @@ -590,7 +591,7 @@ DEF_CMD(replace_request) DEF_CMD(replace_all) { - struct pane *sp = ci->home->_data; + struct pane *sp = ci->home->data3; char *new; int replaced = 0; @@ -609,7 +610,7 @@ DEF_CMD(replace_all) DEF_CMD(replace_to_search) { - struct pane *sp = ci->home->_data; + struct pane *sp = ci->home->data3; pane_take_focus(sp); return 1; @@ -617,7 +618,7 @@ DEF_CMD(replace_to_search) DEF_CMD(replace_forward) { - struct pane *sp = ci->home->_data; + struct pane *sp = ci->home->data3; call(ci->key, sp); @@ -631,14 +632,14 @@ DEF_CMD(replace_undo) DEF_CMD(replace_escape) { - struct pane *sp = ci->home->_data; + struct pane *sp = ci->home->data3; return call("search:done", sp); } DEF_CMD(replace_prev) { - struct pane *home = ci->home->_data; + struct pane *home = ci->home->data3; struct es_info *esi = home->data; if (esi->target) @@ -648,7 +649,7 @@ DEF_CMD(replace_prev) DEF_CMD(replace_next) { - struct pane *home = ci->home->_data; + struct pane *home = ci->home->data3; struct es_info *esi = home->data; if (esi->target)