]> git.neil.brown.name Git - edlib.git/commitdiff
discard commcache.
authorNeilBrown <neil@brown.name>
Fri, 28 Jul 2023 05:59:24 +0000 (15:59 +1000)
committerNeilBrown <neil@brown.name>
Fri, 28 Jul 2023 05:59:24 +0000 (15:59 +1000)
The idea here was to accelerate repeated calls to the one request, so we
didn't need to repeat the search up the pane tree, or for the comm in
the keymap.
However I since decided that it is generally best to avoid repeated
calls like this, and mostly we do.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
core-doc.c
core-pane.c
core-pane.h
core.h
doc-docs.c

index ddb8283860781e6426c58957644196e53f8ebccb..c6a189019a32353dcfcff660529de1ea8103fd60 100644 (file)
@@ -91,7 +91,7 @@ Requirements for a v1.0 release
 Core features
 -------------
 
-- [ ] Discard ccache ??
+- [X] Discard ccache ??
 - [ ] Ensure all panes that should use "Free" properly, and find some
       what to encourage its use.
 - [ ] Add optional unit-test interface for modules.  This should be
@@ -187,6 +187,21 @@ Core features
 Module features
 ---------------
 
+### render-stack
+
+   My idea is to have a generic rendering pane which draws row or column
+   of other panes.  Maybe a doc-list describes those panes with attrs
+   identifying the doc, the pos in the doc, the view.
+   Marks only identify the panes, not anything in the pane. (maybe).
+   I want to use this for:
+        - menu bar - as stack of menu triggers
+        - presenter thumbnails
+        - image thumbnails
+
+   However this *could* be render-lines which stacks lib-renderline
+   panes all on the same document.  This wouldn't use an attribute to
+   identify the location in the doc, so I'm not 100% sure of this
+
 ### lib-askpass
 
 - [ ] have askpass tell shellmode (and others) about the SSH_ASKPASS*
index a4c178a9327abfa6675118ae804d950f827fd11f..7030511df1b4142286a3e11bef1ef8eb1dd9c6a3 100644 (file)
@@ -863,7 +863,6 @@ DEF_CMD(doc_default_content)
         * accurate mark.
         */
        struct mark *m = ci->mark;
-       struct commcache dchar = CCINIT;
        int nxt;
        char *cmd = "doc:char";
 
@@ -873,11 +872,11 @@ DEF_CMD(doc_default_content)
        if (strcmp(ci->key, "doc:content-bytes") == 0)
                cmd = "doc:byte";
 
-       nxt = ccall(&dchar, cmd, ci->home, 1, m);
+       nxt = call(cmd, ci->home, 1, m);
        while (nxt > 0 && nxt != CHAR_RET(WEOF) &&
               (!ci->mark2 || mark_ordered_or_same(m, ci->mark2)) &&
               comm_call(ci->comm2, "consume", ci->home, (nxt & 0x1FFFF), m) > 0)
-               nxt = ccall(&dchar, cmd, ci->home, 1, m);
+               nxt = call(cmd, ci->home, 1, m);
 
        mark_free(m);
        return nxt < 0 ? nxt : 1;
index a76fbe4cdefca1789939b1534bfdbc052b1b5477..0ff75cf63d7829f95e6c08fa305547f210c2e1f9 100644 (file)
@@ -922,14 +922,13 @@ struct pane *do_call_pane(enum target_type type, struct pane *home,
                          const char *key safe, struct pane *focus safe,
                          int num,  struct mark *m,  const char *str,
                          int num2, struct mark *m2, const char *str2,
-                         int x, int y, struct command *comm2b,
-                         struct commcache *ccache)
+                         int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_simple;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        if (cr.ret < 0)
                return NULL;
        return cr.p;
@@ -940,14 +939,13 @@ struct mark *do_call_mark(enum target_type type, struct pane *home,
                          const char *key safe, struct pane *focus safe,
                          int num,  struct mark *m,  const char *str,
                          int num2, struct mark *m2, const char *str2,
-                         int x, int y, struct command *comm2b,
-                         struct commcache *ccache)
+                         int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_simple;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        if (cr.ret < 0)
                return NULL;
        return cr.m;
@@ -958,14 +956,13 @@ struct mark *do_call_mark2(enum target_type type, struct pane *home,
                           const char *key safe, struct pane *focus safe,
                           int num,  struct mark *m,  const char *str,
                           int num2, struct mark *m2, const char *str2,
-                          int x, int y, struct command *comm2b,
-                          struct commcache *ccache)
+                          int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_simple;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        if (cr.ret < 0)
                return NULL;
        return cr.m2;
@@ -976,14 +973,13 @@ struct command *do_call_comm(enum target_type type, struct pane *home,
                             const char *key safe, struct pane *focus safe,
                             int num,  struct mark *m,  const char *str,
                             int num2, struct mark *m2, const char *str2,
-                            int x, int y, struct command *comm2b,
-                            struct commcache *ccache)
+                            int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_comm;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        if (cr.ret < 0)
                return NULL;
        return cr.comm;
@@ -994,14 +990,13 @@ char *do_call_strsave(enum target_type type, struct pane *home,
                      const char *key safe, struct pane *focus safe,
                      int num,  struct mark *m,  const char *str,
                      int num2, struct mark *m2, const char *str2,
-                     int x, int y, struct command *comm2b,
-                     struct commcache *ccache)
+                     int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_simple;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        return cr.s;
 }
 
@@ -1010,14 +1005,13 @@ struct call_return do_call_all(enum target_type type, struct pane *home,
                               const char *key safe, struct pane *focus safe,
                               int num,  struct mark *m,  const char *str,
                               int num2, struct mark *m2, const char *str2,
-                              int x, int y, struct command *comm2b,
-                              struct commcache *ccache)
+                              int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_simple;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        return cr;
 }
 
@@ -1026,14 +1020,13 @@ char *do_call_str(enum target_type type, struct pane *home,
                  const char *key safe, struct pane *focus safe,
                  int num,  struct mark *m,  const char *str,
                  int num2, struct mark *m2, const char *str2,
-                 int x, int y, struct command *comm2b,
-                 struct commcache *ccache)
+                 int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_str;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        if (cr.ret < 0) {
                free(cr.s);
                return NULL;
@@ -1046,14 +1039,13 @@ struct call_return do_call_bytes(enum target_type type, struct pane *home,
                                 const char *key safe, struct pane *focus safe,
                                 int num,  struct mark *m,  const char *str,
                                 int num2, struct mark *m2, const char *str2,
-                                int x, int y, struct command *comm2b,
-                                struct commcache *ccache)
+                                int x, int y, struct command *comm2b)
 {
        struct call_return cr = {};
 
        cr.c = take_bytes;
        cr.ret = do_call_val(type, home, comm2a, key, focus, num, m, str,
-                            num2, m2, str2, x, y, &cr.c, ccache);
+                            num2, m2, str2, x, y, &cr.c);
        if (cr.ret < 0) {
                free(cr.s);
                cr.s = NULL;
index 24ce3ec6f0e3d42d25b1e83fd06b8fd3d9dd4455..60a3e58edf8392a0680d3e9a0fa48a22b049e530 100644 (file)
@@ -97,8 +97,7 @@ static inline int do_call_val(enum target_type type, struct pane *home,
                              const char *key safe, struct pane *focus safe,
                              int num,  struct mark *m,  const char *str,
                              int num2, struct mark *m2, const char *str2,
-                             int x, int y, struct command *comm2b,
-                             struct commcache *ccache)
+                             int x, int y, struct command *comm2b)
 {
        struct cmd_info ci = {.key = key, .focus = focus, .home = focus,
                              .num = num, .mark = m, .str = str,
@@ -120,12 +119,6 @@ static inline int do_call_val(enum target_type type, struct pane *home,
                        ci.home = home;
                /* fall-through */
        case TYPE_focus:
-               if (ccache) {
-                       if ((void*)ccache->home)
-                               ci.home = ccache->home;
-                       if ((void*)ccache->comm)
-                               ci.comm = ccache->comm;
-               }
                ret = key_handle(&ci);
                break;
        case TYPE_pane:
@@ -146,12 +139,7 @@ static inline int do_call_val(enum target_type type, struct pane *home,
                ci.comm = comm2a;
                ci.comm2 = comm2b;
                ret = ci.comm->func(&ci);
-               ccache = NULL;
                break;
        }
-       if (ccache) {
-               ccache->comm = ci.comm;
-               ccache->home = ci.home;
-       }
        return ret;
 }
diff --git a/core.h b/core.h
index baab64ecaf2da9ed73eba1b67a1a6cdbb03f3283..bd5aa6e9893bb97c0327e8f2e43eaa6e711006f8 100644 (file)
--- a/core.h
+++ b/core.h
@@ -387,12 +387,6 @@ struct cmd_info {
        unsigned int *hash;
 };
 
-struct commcache {
-       struct pane     *home safe;
-       struct command  *comm safe;
-};
-#define CCINIT {safe_cast 0, safe_cast 0}
-
 #define        NO_NUMERIC      (INT_MAX/2)
 #define        RPT_NUM(ci)     ((ci)->num == NO_NUMERIC ? 1 :          \
                         (ci)->num == NO_NUMERIC + 1 ? 4 :      \
@@ -629,57 +623,49 @@ struct pane *do_call_pane(enum target_type type, struct pane *home,
                          const char *key safe, struct pane *focus safe,
                          int num,  struct mark *m,  const char *str,
                          int num2, struct mark *m2, const char *str2,
-                         int x, int y, struct command *comm2b,
-                         struct commcache *cache);
+                         int x, int y, struct command *comm2b);
 struct mark *do_call_mark(enum target_type type, struct pane *home,
                          struct command *comm2a,
                          const char *key safe, struct pane *focus safe,
                          int num,  struct mark *m,  const char *str,
                          int num2, struct mark *m2, const char *str2,
-                         int x, int y, struct command *comm2b,
-                         struct commcache *cache);
+                         int x, int y, struct command *comm2b);
 struct mark *do_call_mark2(enum target_type type, struct pane *home,
                           struct command *comm2a,
                           const char *key safe, struct pane *focus safe,
                           int num,  struct mark *m,  const char *str,
                           int num2, struct mark *m2, const char *str2,
-                          int x, int y, struct command *comm2b,
-                          struct commcache *cache);
+                          int x, int y, struct command *comm2b);
 struct command *do_call_comm(enum target_type type, struct pane *home,
                             struct command *comm2a,
                             const char *key safe, struct pane *focus safe,
                             int num,  struct mark *m,  const char *str,
                             int num2, struct mark *m2, const char *str2,
-                            int x, int y, struct command *comm2b,
-                            struct commcache *cache);
+                            int x, int y, struct command *comm2b);
 struct call_return do_call_all(enum target_type type, struct pane *home,
                               struct command *comm2a,
                               const char *key safe, struct pane *focus safe,
                               int num,  struct mark *m,  const char *str,
                               int num2, struct mark *m2, const char *str2,
-                              int x, int y, struct command *comm2b,
-                              struct commcache *cache);
+                              int x, int y, struct command *comm2b);
 char *do_call_str(enum target_type type, struct pane *home,
                  struct command *comm2a,
                  const char *key safe, struct pane *focus safe,
                  int num,  struct mark *m,  const char *str,
                  int num2, struct mark *m2, const char *str2,
-                 int x, int y, struct command *comm2b,
-                 struct commcache *cache);
+                 int x, int y, struct command *comm2b);
 struct call_return do_call_bytes(enum target_type type, struct pane *home,
                                 struct command *comm2a,
                                 const char *key safe, struct pane *focus safe,
                                 int num,  struct mark *m,  const char *str,
                                 int num2, struct mark *m2, const char *str2,
-                                int x, int y, struct command *comm2b,
-                                struct commcache *cache);
+                                int x, int y, struct command *comm2b);
 char *do_call_strsave(enum target_type type, struct pane *home,
                      struct command *comm2a,
                      const char *key safe, struct pane *focus safe,
                      int num,  struct mark *m,  const char *str,
                      int num2, struct mark *m2, const char *str2,
-                     int x, int y, struct command *comm2b,
-                     struct commcache *cache);
+                     int x, int y, struct command *comm2b);
 
 #define T_focus(_p, _c) _p
 #define T_home(_p, _c) _p
@@ -692,64 +678,35 @@ char *do_call_strsave(enum target_type type, struct pane *home,
 #define CALL15(ret, t_type, target, key, comm2a, focus, num, mark, str,        \
               num2, mark2, str2, x, y, comm2) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2,target), \
-                     key, focus, num, mark, str, num2, mark2, str2, x, y, comm2, NULL)
+                     key, focus, num, mark, str, num2, mark2, str2, x, y, comm2)
 #define CALL14(ret, t_type, target, key, comm2a, focus, num, mark, str, num2, mark2, str2, x, y) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, mark2, str2, x, y, NULL, NULL)
+                     key, focus, num, mark, str, num2, mark2, str2, x, y, NULL)
 #define CALL12(ret, t_type, target, key, comm2a, focus, num, mark, str, num2, mark2, str2) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, mark2, str2, 0, 0, NULL, NULL)
+                     key, focus, num, mark, str, num2, mark2, str2, 0, 0, NULL)
 #define CALL11(ret, t_type, target, key, comm2a, focus, num, mark, str, num2, mark2) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, mark2, NULL, 0, 0, NULL, NULL)
+                     key, focus, num, mark, str, num2, mark2, NULL, 0, 0, NULL)
 #define CALL10(ret, t_type, target, key, comm2a, focus, num, mark, str, num2) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, NULL, NULL, 0, 0, NULL, NULL)
+                     key, focus, num, mark, str, num2, NULL, NULL, 0, 0, NULL)
 #define CALL9(ret, t_type, target, key, comm2a, focus, num, mark, str) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, 0, NULL, NULL, 0, 0, NULL, NULL)
+                     key, focus, num, mark, str, 0, NULL, NULL, 0, 0, NULL)
 #define CALL8(ret, t_type, target, key, comm2a, focus, num, mark) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, NULL, 0, NULL, NULL, 0, 0, NULL, NULL)
+                     key, focus, num, mark, NULL, 0, NULL, NULL, 0, 0, NULL)
 #define CALL7(ret, t_type, target, key, comm2a, focus, num) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, NULL, NULL, 0, NULL, NULL, 0, 0, NULL, NULL)
+                     key, focus, num, NULL, NULL, 0, NULL, NULL, 0, 0, NULL)
 #define CALL6(ret, t_type, target, key, comm2a, focus) \
        do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, 0, NULL, NULL, 0, NULL, NULL, 0, 0, NULL, NULL)
+                     key, focus, 0, NULL, NULL, 0, NULL, NULL, 0, 0, NULL)
 
 #define CALL(ret, t_type, target, key, ...) _doCALL(ret, t_type, target, key, NULL, __VA_ARGS__)
 
-#define _CCALL(...) VFUNC(CCALL, __VA_ARGS__)
-#define CCALL15(ccache, ret, t_type, target, key, comm2a, focus, num, mark, str, num2, mark2, str2, x, y) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, mark2, str2, x, y, NULL, ccache)
-#define CCALL13(ccache, ret, t_type, target, key, comm2a, focus, num, mark, str, num2, mark2, str2) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, mark2, str2, 0, 0, NULL, ccache)
-#define CCALL12(ccache, ret, t_type, target, key, comm2a, focus, num, mark, str, num2, mark2) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, mark2, NULL, 0, 0, NULL, ccache)
-#define CCALL11(ccache, ret, t_type, target, key, comm2a, focus, num, mark, str, num2) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, num2, NULL, NULL, 0, 0, NULL, ccache)
-#define CCALL10(ccache, ret, t_type, target, key, comm2a, focus, num, mark, str) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, str, 0, NULL, NULL, 0, 0, NULL, ccache)
-#define CCALL9(ccache, ret, t_type, target, key, comm2a, focus, num, mark) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, mark, NULL, 0, NULL, NULL, 0, 0, NULL, ccache)
-#define CCALL8(ccache, ret, t_type, target, key, comm2a, focus, num) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, num, NULL, NULL, 0, NULL, NULL, 0, 0, NULL, ccache)
-#define CCALL7(ccache, ret, t_type, target, key, comm2a, focus) \
-       do_call_##ret(TYPE_##t_type, CH(T_##t_type,target, NULL), CH(T_##t_type,comm2a,target), \
-                     key, focus, 0, NULL, NULL, 0, NULL, NULL, 0, 0, NULL, ccache)
-
-#define CCALL(ccache, ret, t_type, target, key, ...) _CCALL(ccache, ret, t_type, target, key, NULL, __VA_ARGS__)
-
 #define call(key, _focus, ...) CALL(val, focus, _focus, key, _focus, ##__VA_ARGS__)
-#define ccall(ccache, key, _focus, ...) CCALL(ccache, val, focus, _focus, key, _focus, ##__VA_ARGS__)
 /* comm_call() is only for callbacks, is it doesn't allow a separate 'home' */
 #define comm_call(_comm, key, ...) CALL(val, comm, _comm, key, ##__VA_ARGS__)
 #define comm_call_ret(_ret, _comm, key, ...) CALL(_ret, comm, _comm, key, ##__VA_ARGS__)
index 97c758f50074b07d0f93a004e6c085054285ade2..d268d2bf13ee2f24df276911758123a609d4da49 100644 (file)
@@ -871,7 +871,7 @@ DEF_CB(docs_callback_lookup)
                           ci->key, ci->focus,
                           ci->num, ci->mark, ci->str,
                           ci->num2, ci->mark2, ci->str2,
-                          ci->x, ci->y, ci->comm2, NULL);
+                          ci->x, ci->y, ci->comm2);
 }
 
 DEF_CMD(attach_docs)