]> git.neil.brown.name Git - edlib.git/commitdiff
export do_comm_call and use it from TYPE_pane and TYPE_comm
authorNeilBrown <neil@brown.name>
Fri, 15 Sep 2023 03:28:30 +0000 (13:28 +1000)
committerNeilBrown <neil@brown.name>
Fri, 15 Sep 2023 03:38:14 +0000 (13:38 +1000)
This simplifies the inline code for do_call_val(), and
includes pane and comm calls in the backtrace from LOG_BT()

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

index 59f408a337649a6a2630541207e0038b4608fa13..c48117d0fdff489b6f81f8b590d80292e21b8e1e 100644 (file)
@@ -117,7 +117,7 @@ Core features
       hitting a python error - there will be no active view so the
       screen will be meaningless.  I need to properly abort and
       auto-choose a new pane.
-- [ ] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls.
+- [X] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls.
 - [ ] LOG should take a pane arg, and not use any static vars.
 - [ ] reduce size of $(nm O/*.o | grep ' b ' | grep -v '_map$')
 - [X] give every pane a link to root/editor main and use that
index 703ca2b13a5fa1caceb6b9815a0bada9bc1951f7..fdcd0cf1a1b4342b70beb37df74de4151f753a0d 100644 (file)
@@ -435,14 +435,19 @@ void LOG_BT(void)
        LOG("End Backtrace");
 }
 
-static int do_comm_call(struct command *comm safe,
-                       const struct cmd_info *ci safe)
+int do_comm_call(struct command *comm safe, const struct cmd_info *ci safe)
 {
        struct backtrace bt;
        int ret;
 
+       if (ci->home->damaged & DAMAGED_DEAD)
+               return Efail;
        if (times_up_fast(ci->home))
                return Efail;
+       if ((ci->home->damaged & DAMAGED_CLOSED) &&
+           !comm->closed_ok)
+               return Efallthrough;
+
        if (backtrace_depth > 100) {
                backtrace_depth = 0;
                LOG("Recursion limit of 100 reached");
@@ -569,7 +574,7 @@ int key_handle(const struct cmd_info *ci safe)
                        vci->home = p;
                        vci->comm = p->handle;
                        /* Don't add this to the call stack as it
-                        * should simple call the desired function and
+                        * should simply call the desired function and
                         * that will appear on the call stack.
                         */
                        ret = p->handle->func(ci);
index 907cc1b1fd4f7059e09d745230e3972d874ea568..b726acb3faa45490c3234828a192c0e6f85bdc3c 100644 (file)
@@ -106,6 +106,7 @@ static inline void pane_put(struct pane *p safe)
        pane_free(p);
 }
 
+int do_comm_call(struct command *comm safe, const struct cmd_info *ci safe);
 static inline int do_call_val(enum target_type type, struct pane *home,
                              struct command *comm2a,
                              const char *key safe, struct pane *focus safe,
@@ -136,32 +137,17 @@ static inline int do_call_val(enum target_type type, struct pane *home,
                ret = key_handle(&ci);
                break;
        case TYPE_pane:
-               if (!home->handle || (home->damaged & DAMAGED_DEAD))
-                       return Efail;
-               if (times_up_fast(focus))
-                       return Efail;
-               if (home)
-                       ci.home = home;
-               if ((home->damaged & DAMAGED_CLOSED) &&
-                   !home->handle->closed_ok)
-                       /* This pane cannot accept anything but
-                        * close_ok commands.
-                        */
-                       return Efallthrough;
-               ci.comm = home->handle;
-               ret = ci.comm->func(&ci);
+               ci.home = home;
+               if (home->handle)
+                       ci.comm = home->handle;
+               ret = do_comm_call(ci.comm, &ci);
                break;
        case TYPE_comm:
-               if (times_up_fast(focus))
-                       return Efail;
                if (home)
                        ci.home = home;
-               if (ci.home->damaged & DAMAGED_CLOSED &&
-                   !comm2a->closed_ok)
-                       return Efallthrough;
                ci.comm = comm2a;
                ci.comm2 = comm2b;
-               ret = ci.comm->func(&ci);
+               ret = do_comm_call(ci.comm, &ci);
                break;
        }
        return ret;