]> git.neil.brown.name Git - edlib.git/commitdiff
Change ->reundo from doc_operation to command
authorNeilBrown <neil@brown.name>
Tue, 24 Nov 2015 05:32:33 +0000 (16:32 +1100)
committerNeilBrown <neil@brown.name>
Tue, 24 Nov 2015 05:32:33 +0000 (16:32 +1100)
Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core.h
doc-dir.c
doc-text.c

index 8bcfd5b9feada72b3237704d3a708d612506f787..2503a5b42d39de285e358ccbd9bbbacec71a4a88 100644 (file)
@@ -279,11 +279,6 @@ static void docs_replace(struct point *pos, struct mark *end,
 {
 }
 
-static int docs_reundo(struct point *p, bool redo)
-{
-       return 0;
-}
-
 static wint_t docs_step(struct doc *doc, struct mark *m, bool forward, bool move)
 {
        struct doc *d = m->ref.d, *next;
@@ -372,7 +367,6 @@ static int docs_set_attr(struct point *p, char *attr, char *val)
 
 static struct doc_operations docs_ops = {
        .replace   = docs_replace,
-       .reundo    = docs_reundo,
        .step      = docs_step,
        .same_ref  = docs_sameref,
        .get_attr  = docs_get_attr,
diff --git a/core.h b/core.h
index f1ba2af02d1b344c6cdcde1784dd3eb86fd50da5..f759d1f567bc500dc40d7407111975d7e85b7058 100644 (file)
--- a/core.h
+++ b/core.h
@@ -86,7 +86,6 @@ struct doc {
 struct doc_operations {
        void            (*replace)(struct point *pos, struct mark *end,
                                   char *str, bool *first);
-       int             (*reundo)(struct point *pos, bool undo);
        wint_t          (*step)(struct doc *d, struct mark *m, bool forward, bool move);
        int             (*same_ref)(struct doc *d, struct mark *a, struct mark *b);
        /* get/set attr operate on the attributes of the char immediately
@@ -359,7 +358,11 @@ static inline void doc_replace(struct point *p, struct mark *m,
 }
 static inline int doc_undo(struct point *p, bool redo)
 {
-       return p->doc->ops->reundo(p, redo);
+       struct cmd_info ci = {0};
+       ci.pointp = &p;
+       ci.numeric = redo ? 1 : 0;
+       ci.key = "doc:reundo";
+       return key_lookup(p->doc->map, &ci);
 }
 static inline int doc_load_file(struct doc *d, struct point *p,
                                int fd, char *name)
index 1c876d2d0b4cfd3c24e7db46e70ee5adb97f544c..dc2c683f7739b8c884445ce44f53e46a5582d4b4 100644 (file)
--- a/doc-dir.c
+++ b/doc-dir.c
@@ -264,11 +264,6 @@ DEF_CMD(dir_same_file)
        return 1;
 }
 
-static int dir_reundo(struct point *p, bool redo)
-{
-       return 0;
-}
-
 static wint_t dir_step(struct doc *doc, struct mark *m, bool forward, bool move)
 {
        struct directory *dr = container_of(doc, struct directory, doc);
@@ -491,7 +486,6 @@ DEF_CMD(dir_destroy)
 
 static struct doc_operations dir_ops = {
        .replace   = dir_replace,
-       .reundo    = dir_reundo,
        .step      = dir_step,
        .same_ref  = dir_sameref,
        .get_attr  = dir_get_attr,
index d03b969bee87b881bd09c93bdcf3820bf7c34494..686ac606addea091cf6e6f2c009b81bda3cb0ced 100644 (file)
@@ -773,8 +773,10 @@ static int text_redo(struct text *t, struct doc_ref *start, struct doc_ref *end)
                return 2;
 }
 
-static int text_reundo(struct point *p, bool redo)
+DEF_CMD(text_reundo)
 {
+       struct point *p = *ci->pointp;
+       bool redo = ci->numeric != 0;
        struct doc_ref start, end;
        int did_do = 2;
        bool first = 1;
@@ -1496,7 +1498,6 @@ DEF_CMD(text_destroy)
 
 static struct doc_operations text_ops = {
        .replace   = text_replace,
-       .reundo    = text_reundo,
        .step      = text_step,
        .same_ref  = text_sameref,
        .get_attr  = text_get_attr,
@@ -1626,4 +1627,5 @@ void edlib_init(struct editor *ed)
        key_add(text_map, "doc:destroy", &text_destroy);
        key_add(text_map, "doc:set-ref", &text_set_ref);
        key_add(text_map, "doc:save-file", &text_save_file);
+       key_add(text_map, "doc:reundo", &text_reundo);
 }