]> git.neil.brown.name Git - edlib.git/commitdiff
Save search string for later re-use.
authorNeilBrown <neil@brown.name>
Wed, 2 Dec 2015 02:23:58 +0000 (13:23 +1100)
committerNeilBrown <neil@brown.name>
Wed, 2 Dec 2015 02:23:58 +0000 (13:23 +1100)
Signed-off-by: NeilBrown <neil@brown.name>
core-editor.c
emacs-search.c
mode-emacs.c

index 6e41595e51923c31bdf336d70616f10b6658c90d..cb88039160f653916ab44368a155bee2e8faf743 100644 (file)
@@ -19,12 +19,20 @@ DEF_CMD(null_display_handle)
        return 0;
 }
 
+DEF_CMD(global_set_attr)
+{
+       attr_set_str(&ci->home->attrs, ci->str, ci->str2, -1);
+       return 1;
+}
+
 struct pane *editor_new(void)
 {
        struct editor *ed = calloc(sizeof(*ed), 1);
 
-       if (!ed_map)
+       if (!ed_map) {
                ed_map = key_alloc();
+               key_add(ed_map, "global-set-attr", &global_set_attr);
+       }
 
        pane_init(&ed->root, NULL, NULL);
        ed->root.handle = &ed_handle.c;
index afd08a1e793584eedec7cafc50783fa80b6059c3..063ecb1408fe6fb83b481b9e2c1cd14bea97d958 100644 (file)
@@ -54,9 +54,20 @@ DEF_CMD(search_forward)
                /* already pushed and didn't find anything new */
                return 1;
        }
+       str = doc_getstr(ci->focus, NULL);
+       if (!*str) {
+               /* re-use old string; Is there any point to this indirection? */
+               char *ss;
+               ss = pane_attr_get(ci->focus, "done-key");
+               if (ss)
+                       ss = pane_attr_get(ci->focus, ss);
+               if (ss) {
+                       doc_replace(esi->search, NULL, ss, &first);
+                       return 1;
+               }
+       }
        s = malloc(sizeof(*s));
        s->m = esi->start;
-       str = doc_getstr(ci->focus, NULL);
        s->len = strlen(str);
        free(str);
        s->next = esi->s;
index 99d27c4024614515d1d648d0ef7386123d4d4cd3..9c092f3c94eec212dcc545505cef5d3214a1e59f 100644 (file)
@@ -541,6 +541,12 @@ DEF_CMD(emacs_search)
 
        m = call_mark("doc:dup-point", ci->home, 0, NULL, MARK_UNGROUPED);
 
+       ci2.key = "global-set-attr";
+       ci2.str = "Search String";
+       ci2.str2 = ci->str;
+       ci2.focus = ci->home;
+       key_handle_focus(&ci2);
+
        memset(&ci2, 0, sizeof(ci2));
        ci2.focus = ci->home;
        ci2.mark = m;