]> git.neil.brown.name Git - edlib.git/commitdiff
Use new notifications to support search_again
authorNeilBrown <neil@brown.name>
Fri, 11 Dec 2015 00:39:06 +0000 (11:39 +1100)
committerNeilBrown <neil@brown.name>
Fri, 11 Dec 2015 00:39:06 +0000 (11:39 +1100)
That than the old doc notifer.

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

diff --git a/core.h b/core.h
index fef5cc67a924a55b5e701990e1bd317f95c07db0..1b32603093b081c771dd08f11d9f8f151d3b94d9 100644 (file)
--- a/core.h
+++ b/core.h
@@ -486,6 +486,19 @@ static inline int call3(char *key, struct pane *focus, int numeric, struct mark
        return key_handle_focus(&ci);
 }
 
+static inline int call_home(struct pane *home, char *key, struct pane *focus,
+                           int numeric, struct mark *m)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.home = home;
+       ci.numeric = numeric;
+       ci.mark = m;
+       return key_handle_focus(&ci);
+}
+
 static inline int call5(char *key, struct pane *focus, int numeric, struct mark *m,
                         char *str, int extra)
 {
index 59fe0efef953cf30fdb6d8ad6a5dc3d2d9029813..b13603384bab9e6b0cb8893efd3ebb15238baa8a 100644 (file)
@@ -39,8 +39,6 @@ struct es_info {
 
 static struct map *es_map;
 
-DEF_CMD(search_again);
-
 DEF_CMD(search_forward)
 {
        struct es_info *esi = ci->home->data;
@@ -166,10 +164,10 @@ DEF_CMD(search_close)
        return 1;
 }
 
-REDEF_CMD(search_again)
+DEF_CMD(search_again)
 {
        /* document has changed, retry search */
-       struct es_info *esi = container_of(ci->comm, struct es_info, watch);
+       struct es_info *esi = ci->home->data;
        struct cmd_info ci2 = {0};
        struct pane *p;
        char *a, *pfx;
@@ -177,12 +175,6 @@ REDEF_CMD(search_again)
        struct mark *m;
        char *str;
 
-       if (strcmp(ci->key, "Release") == 0) {
-               /* No marks to remove */
-               doc_del_view(ci->home, ci->comm);
-               return 0;
-       }
-
        /* TEMP HACK - please fix */
        doc_set_attr(esi->target, esi->end, "highlight", NULL);
        ci2.focus = esi->target;
@@ -243,6 +235,7 @@ static void emacs_search_init_map(void)
        key_add(es_map, "C-Chr-R", &search_backward);
        key_add(es_map, "Close", &search_close);
        key_add(es_map, "popup:Return", &search_done);
+       key_add(es_map, "Notify:Replace", &search_again);
 }
 
 DEF_LOOKUP_CMD(search_handle, es_map);
@@ -272,13 +265,13 @@ DEF_CMD(emacs_search)
        esi->matched = 0;
        esi->wrapped = 0;
        esi->search = ci->focus;
-       esi->watch = search_again;
-       doc_add_view(ci->focus, &esi->watch, 0);
 
        p = pane_final_child(ci->focus);
        p = pane_register(p, 0, &search_handle.c, esi, NULL);
-       if (p)
+       if (p) {
+               call3("Request:Notify:Replace", p, 0, NULL);
                comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0);
+       }
        return 1;
 }