]> git.neil.brown.name Git - edlib.git/commitdiff
Remove all doc:step and doc:step-bytes implementations
authorNeilBrown <neil@brown.name>
Fri, 30 Apr 2021 05:13:02 +0000 (15:13 +1000)
committerNeilBrown <neil@brown.name>
Thu, 6 May 2021 11:22:34 +0000 (21:22 +1000)
Some of the code remains to implement doc:char, but the code is never
registered to support doc:step, and doesn't use DEF_CMD any more.

Signed-off-by: NeilBrown <neil@brown.name>
16 files changed:
DOC/TODO.md
core-log.c
doc-dir.c
doc-docs.c
doc-email.c
doc-multipart.c
doc-text.c
lib-base64.c
lib-charset.c
lib-crop.c
lib-qprint.c
lib-utf8.c
python/lib-compose-email.py
python/module-notmuch.py
render-format.c
render-hex.c

index 3e4d7be5f0c519f662424388f14c5e63981db70f..76b07d937c2b0541df9dda4647d0e5bc6fdac5e5 100644 (file)
@@ -371,6 +371,7 @@ Module features
 
 ### doc-text
 
+- [ ] a single undo should never cross a save point!
 - [ ] use larger buffers for adding text - especially when filling from pipe.
       e.g. new buffer doubles each time??
 - [ ] support disable of undo in text, e.g. for copybuf document.
index 8e68e8d1e44688723412da73758d14690138adbc..9ffa933a1ca03591060e01d63e87780324e4372d 100644 (file)
@@ -235,19 +235,16 @@ DEF_CMD(log_set_ref)
        return 1;
 }
 
-DEF_CMD(log_step)
+static int log_step(struct pane *home safe, struct mark *mark safe, int num, int num2)
 {
-       struct doc *d = ci->home->data;
+       struct doc *d = home->data;
        struct log *log = container_of(d, struct log, doc);
-       struct mark *m = ci->mark;
-       bool forward = ci->num;
-       bool move = ci->num2;
+       struct mark *m = mark;
+       bool forward = num;
+       bool move = num2;
        struct doc_ref ref;
        wint_t ret;
 
-       if (!m)
-               return Enoarg;
-
        ref = m->ref;
        if (forward) {
                if (!ref.b)
@@ -310,7 +307,7 @@ DEF_CMD(log_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&log_step, "", ci->home, forward, m, NULL, 1);
+               ret = log_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -320,7 +317,7 @@ DEF_CMD(log_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&log_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return log_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 DEF_CMD(log_destroy)
@@ -398,7 +395,6 @@ void log_setup(struct pane *ed safe)
        key_add_chain(log_map, doc_default_cmd);
        key_add(log_map, "doc:content", &log_content);
        key_add(log_map, "doc:set-ref", &log_set_ref);
-       key_add(log_map, "doc:step", &log_step);
        key_add(log_map, "doc:char", &log_char);
        key_add(log_map, "doc:destroy", &log_destroy);
        key_add(log_map, "doc:log:append", &log_append);
index 5145fe88d65c29ec95ddaa41cffd4759960d5c4d..67a44dd42c2d1bd32dbf154c502b54031427de8c 100644 (file)
--- a/doc-dir.c
+++ b/doc-dir.c
@@ -380,18 +380,17 @@ DEF_CMD(dir_same_file)
        return 1;
 }
 
-DEF_CMD(dir_step)
+static int dir_step(struct pane *home safe, struct mark *mark safe,
+                   int num, int num2)
 {
-       struct doc *doc = ci->home->data;
-       struct mark *m = ci->mark;
-       bool forward = ci->num;
-       bool move = ci->num2;
+       struct doc *doc = home->data;
+       struct mark *m = mark;
+       bool forward = num;
+       bool move = num2;
        struct directory *dr = container_of(doc, struct directory, doc);
        struct dir_ent *d;
        wint_t ret = '\n';
 
-       if (!m)
-               return Enoarg;
        d = m->ref.d;
        if (forward) {
                if (d == NULL)
@@ -439,7 +438,7 @@ DEF_CMD(dir_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&dir_step, "", ci->home, forward, m, NULL, 1);
+               ret = dir_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -449,7 +448,7 @@ DEF_CMD(dir_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&dir_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return dir_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 DEF_CMD(dir_set_ref)
@@ -939,7 +938,6 @@ void edlib_init(struct pane *ed safe)
        key_add(doc_map, "doc:same-file", &dir_same_file);
        key_add(doc_map, "doc:set-ref", &dir_set_ref);
        key_add(doc_map, "doc:get-attr", &dir_doc_get_attr);
-       key_add(doc_map, "doc:step", &dir_step);
        key_add(doc_map, "doc:char", &dir_char);
        key_add(doc_map, "doc:cmd-f", &dir_do_open);
        key_add(doc_map, "doc:cmd-o", &dir_do_open_other);
index 6d9ec99a1ce325bb418dc75dba5fba5fad305ece..798e5986c63cd83a139d646c1c21c6ab0ab47ade 100644 (file)
@@ -444,19 +444,17 @@ DEF_CMD(doc_revisit)
        return 1;
 }
 
-DEF_CMD(docs_step)
+static int docs_step(struct pane *home safe, struct mark *mark safe,
+                    int num, int num2)
 {
-       struct doc *doc = ci->home->data;
-       struct mark *m = ci->mark;
-       bool forward = ci->num;
-       bool move = ci->num2;
+       struct doc *doc = home->data;
+       struct mark *m = mark;
+       bool forward = num;
+       bool move = num2;
        int ret;
        struct pane *p, *next;
        struct docs *d = container_of(doc, struct docs, doc);
 
-       if (!m)
-               return Enoarg;
-
        p = m->ref.p;
        if (forward) {
                /* report on d */
@@ -509,7 +507,7 @@ DEF_CMD(docs_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&docs_step, "", ci->home, forward, m, NULL, 1);
+               ret = docs_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -519,7 +517,7 @@ DEF_CMD(docs_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&docs_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return docs_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 DEF_CMD(docs_set_ref)
@@ -792,7 +790,6 @@ static void docs_init_map(void)
        key_add_chain(docs_map, doc_default_cmd);
        key_add(docs_map, "doc:set-ref", &docs_set_ref);
        key_add(docs_map, "doc:get-attr", &docs_doc_get_attr);
-       key_add(docs_map, "doc:step", &docs_step);
        key_add(docs_map, "doc:char", &docs_char);
        key_add(docs_map, "doc:destroy", &docs_destroy);
        key_add(docs_map, "doc:cmd-f", &docs_do_open);
index 9222cbefc696b222382041002a5d27e7102f24d2..f7401aabe506d46e0cb4bf4031c2901adf78da7d 100644 (file)
@@ -814,48 +814,47 @@ static int count_buttons(struct pane *p safe, struct mark *m safe)
        return cnt;
 }
 
-DEF_CMD(email_step)
+static int email_step(struct pane *home safe, struct mark *mark safe,
+                     int num, int num2)
 {
-       struct pane *p = ci->home;
+       struct pane *p = home;
        struct email_view *evi = p->data;
        wint_t ret;
        int n = -1;
 
-       if (!ci->mark)
-               return Enoarg;
-       if (ci->num) {
-               ret = home_call(p->parent, "doc:char", ci->focus,
-                               ci->num2 ? 1 : 0,
-                               ci->mark, evi->invis,
-                               ci->num2 ? 0 : 1);
-               n = get_part(p->parent, ci->mark);
-               if (ci->num2 && is_spacer(n)) {
+       if (num) {
+               ret = home_call(p->parent, "doc:char", home,
+                               num2 ? 1 : 0,
+                               mark, evi->invis,
+                               num2 ? 0 : 1);
+               n = get_part(p->parent, mark);
+               if (num2 && is_spacer(n)) {
                        /* Moving in a spacer, If after valid buttons,
                         * move to end
                         */
                        wint_t c;
                        unsigned int buttons;
-                       buttons = count_buttons(p, ci->mark);
-                       while ((c = doc_following(p->parent, ci->mark)) != WEOF
+                       buttons = count_buttons(p, mark);
+                       while ((c = doc_following(p->parent, mark)) != WEOF
                               && iswdigit(c) && (c - '0') >= buttons)
-                                       doc_next(p->parent, ci->mark);
+                                       doc_next(p->parent, mark);
                }
        } else {
-               ret = home_call(p->parent, "doc:char", ci->focus,
-                               ci->num2 ? -1 : 0,
-                               ci->mark, evi->invis,
-                               ci->num2 ? 0 : -1);
-               n = get_part(p->parent, ci->mark);
-               if (is_spacer(n) && ci->num2 &&
+               ret = home_call(p->parent, "doc:char", home,
+                               num2 ? -1 : 0,
+                               mark, evi->invis,
+                               num2 ? 0 : -1);
+               n = get_part(p->parent, mark);
+               if (is_spacer(n) && num2 &&
                    ret != CHAR_RET(WEOF) && iswdigit(ret & 0x1fffff)) {
                        /* Just stepped back over the 9 at the end of a spacer,
                         * Maybe step further if there aren't 10 buttons.
                         */
-                       unsigned int buttons = count_buttons(p, ci->mark);
+                       unsigned int buttons = count_buttons(p, mark);
                        wint_t c = ret & 0x1fffff;
 
                        while (c != WEOF && iswdigit(c) && c - '0' >= buttons)
-                               c = doc_prev(p->parent, ci->mark);
+                               c = doc_prev(p->parent, mark);
                        ret = CHAR_RET(c);
                }
        }
@@ -878,8 +877,7 @@ DEF_CMD(email_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&email_step, "", ci->home,
-                               forward, m, NULL, 1);
+               ret = email_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -889,7 +887,7 @@ DEF_CMD(email_char)
        if (ci->num &&(ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&email_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return email_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 DEF_CMD(email_content)
@@ -1040,7 +1038,6 @@ static void email_init_map(void)
 {
        email_view_map = key_alloc();
        key_add(email_view_map, "Free", &email_view_free);
-       key_add(email_view_map, "doc:step", &email_step);
        key_add(email_view_map, "doc:char", &email_char);
        key_add(email_view_map, "doc:content", &email_content);
        key_add(email_view_map, "doc:set-ref", &email_set_ref);
index 1374927dc97c60b77673a7dd95ffdfebadce2cfa..3960cac7cb4b5c35b53c43dea56005957d8f9e9c 100644 (file)
@@ -269,13 +269,14 @@ DEF_CMD(mp_set_ref)
        return ret;
 }
 
-DEF_CMD(mp_step)
+static int mp_step(struct pane *home safe, struct mark *mark safe,
+                  int num, int num2, const char *str)
 {
-       struct mp_info *mpi = ci->home->data;
+       struct mp_info *mpi = home->data;
        struct mark *m1 = NULL;
-       struct mark *m = ci->mark;
-       const char *vis = ci->str && (int)strlen(ci->str) >= mpi->nparts ?
-               ci->str : NULL;
+       struct mark *m = mark;
+       const char *vis = str && (int)strlen(str) >= mpi->nparts ?
+               str : NULL;
        int n;
        int ret;
 
@@ -284,14 +285,11 @@ DEF_CMD(mp_step)
         * calls the document.  Then make sure the marks are still in
         * order.
         */
-       mp_check_consistent(mpi);
-       if (!m)
-               return Enoarg;
 
        mp_check_consistent(mpi);
 
-       if (ci->num2) {
-               mark_step(m, ci->num);
+       if (num2) {
+               mark_step(m, num);
                pre_move(m);
        }
 
@@ -301,18 +299,18 @@ DEF_CMD(mp_step)
                ret = -1;
        else
                ret = home_call(mpi->parts[m->ref.docnum].pane,
-                               "doc:char", ci->focus,
-                               ci->num2 ? (ci->num ? 1 : -1) : 0,
-                               m1, ci->str,
-                               ci->num2 ? 0 : (ci->num ? 1 : -1),
-                               NULL, ci->str2, 0,0, ci->comm2);
+                               "doc:char", home,
+                               num2 ? (num ? 1 : -1) : 0,
+                               m1, str,
+                               num2 ? 0 : (num ? 1 : -1),
+                               NULL, NULL);
        while (ret == CHAR_RET(WEOF) || ret == -1) {
-               if (!ci->num2 && m == ci->mark) {
-                       /* don't change ci->mark when not moving */
+               if (!num2 && m == mark) {
+                       /* don't change mark when not moving */
                        m = mark_dup(m);
                        pre_move(m);
                }
-               if (ci->num) {
+               if (num) {
                        if (m->ref.docnum >= mpi->nparts)
                                break;
                        n = m->ref.docnum + 1;
@@ -332,19 +330,17 @@ DEF_CMD(mp_step)
                        ret = -1;
                else
                        ret = home_call(mpi->parts[m->ref.docnum].pane,
-                                       "doc:char", ci->focus,
-                                       ci->num2 ? (ci->num ? 1 : -1) : 0,
-                                       m1, ci->str,
-                                       ci->num2 ? 0 : (ci->num ? 1 : -1),
-                                       NULL, ci->str2,
-                                       0,0, ci->comm2);
+                                       "doc:char", home,
+                                       num2 ? (num ? 1 : -1) : 0,
+                                       m1, str,
+                                       num2 ? 0 : (num ? 1 : -1));
        }
-       if (ci->num2) {
-               mp_normalize(mpi, ci->mark, vis);
-               post_move(ci->mark);
+       if (num2) {
+               mp_normalize(mpi, mark, vis);
+               post_move(mark);
        }
 
-       if (m != ci->mark)
+       if (m != mark)
                mark_free(m);
 
        mp_check_consistent(mpi);
@@ -367,7 +363,7 @@ DEF_CMD(mp_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&mp_step, "", ci->home, forward, m, ci->str, 1);
+               ret = mp_step(ci->home, m, forward, 1, ci->str);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -377,7 +373,7 @@ DEF_CMD(mp_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&mp_step, "", ci->home, ci->num2 > 0, m, ci->str, 0);
+       return mp_step(ci->home, m, ci->num2 > 0, 0, ci->str);
 }
 
 DEF_CMD(mp_step_part)
@@ -742,7 +738,6 @@ static void mp_init_map(void)
        mp_map = key_alloc();
        key_add_chain(mp_map, doc_default_cmd);
        key_add(mp_map, "doc:set-ref", &mp_set_ref);
-       key_add(mp_map, "doc:step", &mp_step);
        key_add(mp_map, "doc:char", &mp_char);
        key_add(mp_map, "doc:content", &mp_content);
        key_add(mp_map, "doc:get-attr", &mp_attr);
index 550d66b3db8b1468f17bedbd05b988e3943711e8..fff0dfc84d80f72aa2d0bf189b49050e327d425c 100644 (file)
@@ -1547,20 +1547,18 @@ static wint_t text_prev(struct text *t safe, struct doc_ref *r safe, bool bytes)
        return ret;
 }
 
-DEF_CMD(text_step)
+static int text_step(struct pane *home safe, struct mark *mark safe,
+                    int num, int num2)
 {
-       struct doc *d = ci->home->data;
-       struct mark *m = ci->mark;
-       bool forward = ci->num;
-       bool move = ci->num2;
+       struct doc *d = home->data;
+       struct mark *m = mark;
+       bool forward = num;
+       bool move = num2;
        struct text *t = container_of(d, struct text, doc);
        struct doc_ref r;
        wint_t ret;
 
-       if (!m)
-               return Enoarg;
-
-       ASSERT(m->owner == ci->home);
+       ASSERT(m->owner == home);
 
        r = m->ref;
        if (forward)
@@ -1592,7 +1590,7 @@ DEF_CMD(text_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&text_step, "", ci->home, forward, m, NULL, 1);
+               ret = text_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -1602,15 +1600,16 @@ DEF_CMD(text_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&text_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return text_step(ci->home, m, ci->num2 > 0, 0);
 }
 
-DEF_CMD(text_step_bytes)
+static int text_step_bytes(struct pane *home safe, struct mark *mark safe,
+                          int num, int num2)
 {
-       struct doc *d = ci->home->data;
-       struct mark *m = ci->mark;
-       bool forward = ci->num;
-       bool move = ci->num2;
+       struct doc *d = home->data;
+       struct mark *m = mark;
+       bool forward = num;
+       bool move = num2;
        struct text *t = container_of(d, struct text, doc);
        struct doc_ref r;
        wint_t ret;
@@ -1618,7 +1617,7 @@ DEF_CMD(text_step_bytes)
        if (!m)
                return Enoarg;
 
-       ASSERT(m->owner == ci->home);
+       ASSERT(m->owner == home);
 
        r = m->ref;
        if (forward)
@@ -1650,7 +1649,7 @@ DEF_CMD(text_byte)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&text_step_bytes, "", ci->home, forward, m, NULL, 1);
+               ret = text_step_bytes(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -1660,7 +1659,7 @@ DEF_CMD(text_byte)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&text_step_bytes, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return text_step_bytes(ci->home, m, ci->num2 > 0, 0);
 }
 
 static bool _text_ref_same(struct text *t safe, struct doc_ref *r1 safe,
@@ -2530,9 +2529,7 @@ void edlib_init(struct pane *ed safe)
        key_add(text_map, "doc:set-attr", &text_set_attr);
        key_add(text_map, "doc:get-attr", &text_doc_get_attr);
        key_add(text_map, "doc:replace", &text_replace);
-       key_add(text_map, "doc:step", &text_step);
        key_add(text_map, "doc:char", &text_char);
-       key_add(text_map, "doc:step-bytes", &text_step_bytes);
        key_add(text_map, "doc:byte", &text_byte);
        key_add(text_map, "doc:modified", &text_modified);
        key_add(text_map, "doc:set:readonly", &text_readonly);
index 56371e529a848465dee523fc4e8579bd0f6643bd..e48fe1f3b4a34c10589d9a9d5cfcaa56f556c8df 100644 (file)
@@ -365,9 +365,7 @@ void edlib_init(struct pane *ed safe)
 
        b64_map = key_alloc();
 
-       key_add(b64_map, "doc:step", &base64_step);
        key_add(b64_map, "doc:char", &base64_char);
-       key_add(b64_map, "doc:step-bytes", &base64_step);
        key_add(b64_map, "doc:byte", &base64_char);
        key_add(b64_map, "doc:content", &base64_content);
        key_add(b64_map, "Close", &b64_close);
index 7c9ba9973767f4477e56494e44c23097b88a1ea2..6be7435bc5614fa3d9a61419c62a6c6d03221d8e 100644 (file)
@@ -1316,16 +1316,16 @@ static const wchar_t ISO_8859_15_UNICODE_TABLE[] = {
 static struct map *charset_map safe;
 DEF_LOOKUP_CMD(charset_handle, charset_map);
 
-DEF_CMD(charset_step)
+static int charset_step(struct pane *home safe, struct mark *mark safe,
+                       int num, int num2)
 {
        wint_t ret;
-       wchar_t *tbl = ci->home->data;
+       wchar_t *tbl = home->data;
 
-       ret = home_call(ci->home->parent, "doc:char", ci->focus,
-                       ci->num2 ? (ci->num ? 1 : -1) : 0,
-                       ci->mark, ci->str,
-                       ci->num2 ? 0 : (ci->num ? 1 : -1),
-                       ci->mark2, ci->str2);
+       ret = home_call(home->parent, "doc:char", home,
+                       num2 ? (num ? 1 : -1) : 0,
+                       mark, NULL,
+                       num2 ? 0 : (num ? 1 : -1));
        if (ret <= 0 || ret == CHAR_RET(WEOF))
                return ret;
        return CHAR_RET(tbl[ret & 0xff]);
@@ -1347,7 +1347,7 @@ DEF_CMD(charset_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&charset_step, "", ci->home, forward, m, NULL, 1);
+               ret = charset_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -1357,7 +1357,7 @@ DEF_CMD(charset_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&charset_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return charset_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 struct win1251cb {
@@ -1500,7 +1500,6 @@ void edlib_init(struct pane *ed safe)
 {
        charset_map = key_alloc();
 
-       key_add(charset_map, "doc:step", &charset_step);
        key_add(charset_map, "doc:char", &charset_char);
        key_add(charset_map, "doc:content", &charset_content);
 
index 13ace172b8e3d0dc48788c5519e4a3b938ed58ef..51e702be6d49536a3731ab2deec6d47d65393258 100644 (file)
@@ -75,33 +75,29 @@ DEF_CMD(crop_write)
                         0,0, ci->comm2);
 }
 
-DEF_CMD(crop_step)
+static int crop_step(struct pane *home safe, struct mark *mark safe,
+                    int num, int num2)
 {
-       struct pane *p = ci->home->parent;
-       struct crop_data *cd = ci->home->data;
+       struct pane *p = home->parent;
+       struct crop_data *cd = home->data;
        int ret;
 
-       if (!ci->mark && !ci->mark2)
-               return Enoarg;
-
        /* Always force marks to be in range */
-       crop(ci->mark, cd);
-       crop(ci->mark2, cd);
+       crop(mark, cd);
 
-       ret = home_call(p, "doc:char", ci->focus,
-                       ci->num2 ? (ci->num ? 1 : -1) : 0,
-                       ci->mark, ci->str,
-                       ci->num2 ? 0 : (ci->num ? 1 : -1),
-                       ci->mark2, ci->str2, 0,0, ci->comm2);
-       if (crop(ci->mark, cd) || crop(ci->mark2, cd))
+       ret = home_call(p, "doc:char", home,
+                       num2 ? (num ? 1 : -1) : 0,
+                       mark, NULL,
+                       num2 ? 0 : (num ? 1 : -1));
+       if (crop(mark, cd))
                ret = CHAR_RET(WEOF);
 
-       if (ci->num2 == 0 && ci->mark) {
-               if (ci->num) {
-                       if (mark_same(ci->mark, cd->end))
+       if (num2 == 0) {
+               if (num) {
+                       if (mark_same(mark, cd->end))
                                ret = CHAR_RET(WEOF);
                } else {
-                       if (mark_same(ci->mark, cd->start))
+                       if (mark_same(mark, cd->start))
                                ret = CHAR_RET(WEOF);
                }
        }
@@ -124,7 +120,7 @@ DEF_CMD(crop_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&crop_step, "", ci->home, forward, m, NULL, 1);
+               ret = crop_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -134,7 +130,7 @@ DEF_CMD(crop_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&crop_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return crop_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 DEF_CMD(crop_clip)
@@ -222,7 +218,6 @@ void edlib_init(struct pane *ed safe)
        key_add(crop_map, "Close", &crop_close);
        key_add(crop_map, "Free", &edlib_do_free);
        key_add(crop_map, "doc:write_file", &crop_write);
-       key_add(crop_map, "doc:step", &crop_step);
        key_add(crop_map, "doc:char", &crop_char);
        key_add(crop_map, "doc:content", &crop_content);
        key_add(crop_map, "Notify:clip", &crop_clip);
index 672910a76beae2c7ecd9a1444fc35622d15917a1..eb97a8fc096a09e81f8b9f675d9f4afb638253b3 100644 (file)
@@ -36,13 +36,14 @@ static int hex(wint_t c)
        return -1;
 }
 
-DEF_CMD(qp_step)
+static int qp_step(struct pane *home safe, struct mark *mark safe,
+                  int num, int num2)
 {
-       int forward = ci->num;
-       int move = ci->num2;
-       struct pane *p = ci->home->parent;
+       int forward = num;
+       int move = num2;
+       struct pane *p = home->parent;
        wint_t ch, c2, c3;
-       struct mark *m = ci->mark;
+       struct mark *m = mark;
 
        if (!m)
                return Enoarg;
@@ -54,9 +55,9 @@ retry:
                else
                        ch = doc_following(p, m);
                if (ch != '=' && ch != ' ' && ch != '\t' && ch != '\r') {
-                       if (m != ci->mark) {
+                       if (m != mark) {
                                if (move)
-                                       mark_to_mark(ci->mark, m);
+                                       mark_to_mark(mark, m);
                                mark_free(m);
                        }
                        goto normalize;
@@ -65,15 +66,15 @@ retry:
                        /* assume CR-LF - skip an extra char */
                        if (move)
                                doc_next(p, m);
-                       if (m != ci->mark) {
+                       if (m != mark) {
                                if (move)
-                                       mark_to_mark(ci->mark, m);
+                                       mark_to_mark(mark, m);
                                mark_free(m);
                        }
                        ch = '\n';
                        goto normalize;
                }
-               if (m == ci->mark)
+               if (m == mark)
                        m = mark_dup(m);
                if (!move)
                        doc_next(p, m);
@@ -88,14 +89,14 @@ retry:
                        if (hex(c2) >= 0 && hex(c3) >= 0) {
                                ch = hex(c2)*16 + hex(c3);
                                if (move)
-                                       mark_to_mark(ci->mark, m);
+                                       mark_to_mark(mark, m);
                        }
                        mark_free(m);
                        goto normalize;
                }
                /* Whitespace, ignore if at eol */
                if (move)
-                       mark_to_mark(ci->mark, m);
+                       mark_to_mark(mark, m);
                while ((c2 = doc_next(p, m)) == ' ' || c2 == '\t')
                        ;
                if (c2 == '\r')
@@ -112,11 +113,11 @@ retry:
                if (!move)
                        return CHAR_RET(ch);
        normalize_more:
-               m = ci->mark;
+               m = mark;
                /* If next is "=\n" we need to skip over it. */
                if (doc_following(p, m) != '=')
                        return CHAR_RET(ch);
-               m = mark_dup(ci->mark);
+               m = mark_dup(mark);
                doc_next(p, m);
                while ((c2 = doc_next(p, m)) == ' ' ||
                       c2 == '\t' || c2 == '\r')
@@ -126,7 +127,7 @@ retry:
                        mark_free(m);
                        return CHAR_RET(ch);
                }
-               mark_to_mark(ci->mark, m);
+               mark_to_mark(mark, m);
                mark_free(m);
                goto normalize_more;
        } else {
@@ -135,7 +136,7 @@ retry:
                else
                        ch = doc_prior(p, m);
                if (ch == '\n') {
-                       if (m == ci->mark)
+                       if (m == mark)
                                m = mark_dup(m);
                        if (!move)
                                doc_prev(p, m);
@@ -148,22 +149,22 @@ retry:
                                goto retry;
                        }
                        if (move)
-                               mark_to_mark(ci->mark, m);
+                               mark_to_mark(mark, m);
                        mark_free(m);
                        return CHAR_RET('\n');
                }
                if (hex(ch) < 0) {
-                       if (m != ci->mark) {
+                       if (m != mark) {
                                if (move)
-                                       mark_to_mark(ci->mark, m);
+                                       mark_to_mark(mark, m);
                                mark_free(m);
                        }
                        return CHAR_RET(ch);
                }
-               if (m == ci->mark)
+               if (m == mark)
                        m = mark_dup(m);
                else if (move)
-                       mark_to_mark(ci->mark, m);
+                       mark_to_mark(mark, m);
                if (!move)
                        doc_prev(p, m);
 
@@ -176,7 +177,7 @@ retry:
                                /* =HH */
                                ch = hex(c2)*16 + hex(c3);
                                if (move)
-                                       mark_to_mark(ci->mark, m);
+                                       mark_to_mark(mark, m);
                                mark_free(m);
                                return CHAR_RET(ch);
                        }
@@ -202,7 +203,7 @@ DEF_CMD(qp_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&qp_step, "", ci->home, forward, m, NULL, 1);
+               ret = qp_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -212,7 +213,7 @@ DEF_CMD(qp_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&qp_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return qp_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 struct qpcb {
@@ -362,9 +363,7 @@ void edlib_init(struct pane *ed safe)
 
        qp_map = key_alloc();
 
-       key_add(qp_map, "doc:step", &qp_step);
        key_add(qp_map, "doc:char", &qp_char);
-       key_add(qp_map, "doc:step-bytes", &qp_step);
        key_add(qp_map, "doc:byte", &qp_char);
        key_add(qp_map, "doc:content", &qp_content);
 
index 06678a7084a22c4b90f9f1eee09c4cae7fca3c8b..1a8338a3a26072d504ca1bc2f85e71c4f7750b20 100644 (file)
 static struct map *utf8_map safe;
 DEF_LOOKUP_CMD(utf8_handle, utf8_map);
 
-DEF_CMD(utf8_step)
+static int utf8_step(struct pane *home safe, struct mark *mark safe,
+                    int num, int num2)
 {
-       int dir = ci->num ? 1 : -1;
-       int move = ci->num2;
-       struct pane *p = ci->home->parent;
+       int dir = num ? 1 : -1;
+       int move = num2;
+       struct pane *p = home->parent;
        wint_t ch;
-       struct mark *m = ci->mark;
+       struct mark *m = mark;
        char buf[10];
        const char *b;
        int i;
        wint_t ret;
 
-       if (!m)
-               return Enoarg;
-
        if (move)
                ch = doc_move(p, m, dir);
        else
@@ -80,7 +78,7 @@ DEF_CMD(utf8_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&utf8_step, "", ci->home, forward, m, NULL, 1);
+               ret = utf8_step(ci->home, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -90,7 +88,7 @@ DEF_CMD(utf8_char)
        if (ci->num && (ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&utf8_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return utf8_step(ci->home, m, ci->num2 > 0, 0);
 }
 
 struct utf8cb {
@@ -187,7 +185,6 @@ void edlib_init(struct pane *ed safe)
 
        utf8_map = key_alloc();
 
-       key_add(utf8_map, "doc:step", &utf8_step);
        key_add(utf8_map, "doc:char", &utf8_char);
        key_add(utf8_map, "doc:content", &utf8_content);
 
index 6c857c01a4bee86785e319ebfeb63446737de113..4ab39dfb748ece0e1c2fbf6b986f3993db0b4d35 100644 (file)
@@ -426,7 +426,7 @@ class compose_email(edlib.Pane):
             return edlib.Einval
         ret = edlib.Einval
         while steps and ret != edlib.WEOF and (not end or mark == end):
-            ret = self.handle_doc_step(key, focus, mark, forward, 1)
+            ret = self.handle_doc_step(key, mark, forward, 1)
             steps -= forward * 2 - 1
         if end:
             return 1 + (num - steps if forward else steps - num)
@@ -435,10 +435,9 @@ class compose_email(edlib.Pane):
         if num and (num2 < 0) == (num > 0):
             return ret
         # want the next character
-        return self.handle_doc_step(key, focus, mark, 1 if num2 > 0 else 0, 0)
+        return self.handle_doc_step(key, mark, 1 if num2 > 0 else 0, 0)
 
-    def handle_doc_step(self, key, focus, mark, num, num2, **a):
-        "handle:doc:step"
+    def handle_doc_step(self, key, mark, num, num2):
         # if in a marker, only allow a space and newline to be seen
         if not mark:
             return edlib.Enoarg
@@ -453,23 +452,23 @@ class compose_email(edlib.Pane):
                     return ' '
                 else:
                     # backward
-                    return self.parent.call("doc:char", focus, mark,
+                    return self.parent.call("doc:char", mark,
                                             -1 if num2 else 0, 0 if num2 else -1)
             else:
                 # at end of marker
                 if num > 0:
-                    return self.parent.call("doc:char", focus, mark,
+                    return self.parent.call("doc:char", mark,
                                             1 if num2 else 0, 0 if num2 else 1)
                 else:
-                    return self.parent.call("doc:char", focus, mark,
+                    return self.parent.call("doc:char", mark,
                                             -1 if num2 else 0, 0 if num2 else -1)
         if not m or not m['compose-type']:
             # not in a marker
             if num > 0:
-                return self.parent.call("doc:char", focus, mark,
+                return self.parent.call("doc:char", mark,
                                         1 if num2 else 0, 0 if num2 else 1)
             else:
-                return self.parent.call("doc:char", focus, mark,
+                return self.parent.call("doc:char", mark,
                                         -1 if num2 else 0, 0 if num2 else -1)
 
         # should be just before newline
index 351240697c6d2c6a6343fd6bc50b3cd076235904..b10e1882042625d7a85617857c48e3d67f460116 100644 (file)
@@ -378,8 +378,7 @@ class notmuch_main(edlib.Doc):
         # want the next character
         return self.handle_step(key, mark, 1 if num2 > 0 else 0, 0)
 
-    def handle_step(self, key, mark, num, num2, **a):
-        "handle:doc:step"
+    def handle_step(self, key, mark, num, num2):
         forward = num
         move = num2
         ret = edlib.WEOF
@@ -1191,8 +1190,7 @@ class notmuch_query(edlib.Doc):
         # want the next character
         return self.handle_step(key, mark, 1 if num2 > 0 else 0, 0)
 
-    def handle_step(self, key, mark, num, num2, **a):
-        "handle:doc:step"
+    def handle_step(self, key, mark, num, num2):
         forward = num
         move = num2
         return self.step(mark, forward, move)
@@ -2347,8 +2345,7 @@ class notmuch_query_view(edlib.Pane):
         # want the next character
         return self.handle_step(key, focus, mark, 1 if num2 > 0 else 0, 0)
 
-    def handle_step(self, key, focus, mark, num, num2, **a):
-        "handle:doc:step"
+    def handle_step(self, key, focus, mark, num, num2):
         forward = num
         move = num2
         if self.whole_thread:
index 8faa279ef56fd05b685d70891f404ca89cb44c46..a2e77480eca6ae1641d4b326dd7d2c14431ecb3f 100644 (file)
@@ -493,13 +493,15 @@ static void next_line(struct pane *home safe, struct mark *m safe)
        mark_step(m, 1);
 }
 
-DEF_CMD(format_step)
+static int format_step(struct pane *home safe, struct pane *focus safe,
+                      struct mark *mark safe,
+                      int num, int num2)
 {
-       struct rf_data *rd = ci->home->data;
+       struct rf_data *rd = home->data;
        struct rf_field *rf;
-       struct mark *m = ci->mark;
-       int forward = ci->num;
-       int move = ci->num2;
+       struct mark *m = mark;
+       int forward = num;
+       int move = num2;
        int f, o;
        int margin;
        int fsize;
@@ -507,24 +509,21 @@ DEF_CMD(format_step)
        char *val = NULL;
        int index;
 
-       if (!m)
-               return Enoarg;
-
-       set_format(ci->focus, rd);
+       set_format(focus, rd);
 
        if (!forward) {
-               index = normalize(ci->home, m, -1);
+               index = normalize(home, m, -1);
                if (index < 0) {
-                       if (doc_prior(ci->home->parent, m) == WEOF)
+                       if (doc_prior(home->parent, m) == WEOF)
                                return CHAR_RET(WEOF);
                        if (move)
-                               prev_line(ci->home, m);
+                               prev_line(home, m);
                        return CHAR_RET('\n');
                }
        } else {
                if (m->ref.p == NULL)
                        return CHAR_RET(WEOF);
-               index = normalize(ci->home, m, 0);
+               index = normalize(home, m, 0);
                if (index < 0)
                        /* Should be impossible */
                        return CHAR_RET(WEOF);
@@ -534,18 +533,18 @@ DEF_CMD(format_step)
 
        if (f >= rd->nfields) {
                if (move)
-                       next_line(ci->home, m);
+                       next_line(home, m);
                return CHAR_RET('\n');
        }
        rf = &rd->fields[f];
-       fsize = field_size(ci->home, m, f, &val);
+       fsize = field_size(home, m, f, &val);
        if (val)
                len = strlen(val);
        if (move && forward) {
                mark_step(m, forward);
-               index = normalize(ci->home, m, 1);
+               index = normalize(home, m, 1);
                if (index < 0) {
-                       next_line(ci->home, m);
+                       next_line(home, m);
                        return CHAR_RET('\n');
                }
                m->ref.i = index;
@@ -603,7 +602,7 @@ DEF_CMD(format_char)
                /* Can never cross 'end' */
                return Einval;
        while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
-               ret = comm_call(&format_step, "", ci->home, forward, m, NULL, 1);
+               ret = format_step(ci->home, ci->focus, m, forward, 1);
                steps -= forward*2 - 1;
        }
        if (end)
@@ -613,7 +612,7 @@ DEF_CMD(format_char)
        if (ci->num &&(ci->num2 < 0) == forward)
                return ret;
        /* Want the 'next' char */
-       return comm_call(&format_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+       return format_step(ci->home, ci->focus, m, ci->num2 > 0, 0);
 }
 
 DEF_CMD(format_attr)
@@ -781,7 +780,6 @@ static void render_format_register_map(void)
 
        rf2_map = key_alloc();
 
-       key_add(rf2_map, "doc:step", &format_step);
        key_add(rf2_map, "doc:char", &format_char);
        key_add(rf2_map, "doc:get-attr", &format_attr);
        key_add(rf2_map, "map-attr", &format_map);
index c069ba900d7a9f709625f0fe55b098359d487673..697e592403c3db1373703abb0fe92af74cfbcf03 100644 (file)
@@ -189,22 +189,6 @@ DEF_CMD(render_line_prev)
        return 1;
 }
 
-DEF_CMD(hex_step)
-{
-       struct he_data *he = ci->home->data;
-
-       if (he->bytes)
-               return home_call(ci->home->parent, "doc:step-bytes", ci->focus,
-                                ci->num, ci->mark, ci->str,
-                                ci->num2, ci->mark2, ci->str2);
-       else
-               return home_call(ci->home->parent, "doc:char", ci->focus,
-                                ci->num2 ? (ci->num ? 1 : -1) : 0,
-                                ci->mark, ci->str,
-                                ci->num2 ? 0 : (ci->num ? 1 : -1),
-                                ci->mark2, ci->str2);
-}
-
 DEF_CMD(hex_char)
 {
        struct he_data *he = ci->home->data;
@@ -224,7 +208,6 @@ static void render_hex_register_map(void)
        he_map = key_alloc();
 
        key_add(he_map, "doc:EOL", &render_hex_eol);
-       key_add(he_map, "doc:step", &hex_step);
        key_add(he_map, "doc:char", &hex_char);
 
        key_add(he_map, "doc:render-line-prev", &render_line_prev);