]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed execution handling while xpty active
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 22 Nov 2019 21:37:50 +0000 (16:37 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 22 Nov 2019 21:37:50 +0000 (16:37 -0500)
src/lib/buf.c
src/lib/editlog.c
src/tide.c

index c5350c13827d7cce032a29d09e97fc105fc883ed..05c11f2a55d1355faac54c11b7a1102fec7774fa 100644 (file)
@@ -367,9 +367,16 @@ void buf_del(Buf* buf)
     if (nbytes > 0)
     {
         /* adjust the point according to the characters deleted */
-        size_t bpoint = ((sel.beg <= buf->point.beg) ? min(nbytes, buf->point.beg - sel.beg) : 0u);
-        size_t inpoint = (buf->point.beg < sel.end && sel.end <= buf->point.end)
-            ?  (sel.end - buf->point.beg) : 0u ;
+        size_t bpoint = 0;
+        if (sel.beg <= buf->point.beg)
+        {
+            bpoint = min(nbytes, buf->point.beg - sel.beg);
+        }
+        size_t inpoint = 0;
+        if (sel.end >= buf->point.beg)
+        {
+            inpoint = min(sel.end, buf->point.end) - max(sel.beg, buf->point.beg);
+        }
         buf->point.beg -= bpoint;
         buf->point.end -= (bpoint + inpoint);
 
index c7a28d74f624dcc2a91ad932b670713f478cc294..6d7cdc06bf14e2fbdbdd64bbb402cb0efe683517 100644 (file)
@@ -190,6 +190,3 @@ void editlog_add(Buf* buf, size_t beg, size_t end, char* data)
         buf->log.undo = mklog(buf, beg, end, data, prev);
     }
 }
-
-
-
index d915970a2934a1fb47026025c5a97fbaf0b029a7..1b67ac92116da512710b9ac9c0b4afce5517f387 100644 (file)
@@ -14,7 +14,6 @@
 #include "config.h"
 
 /* predeclare some things */
-static void exec_or_send(char* str);
 static void exec(char* cmd, char* arg);
 void cut(char* arg);
 void paste(char* arg);
@@ -178,7 +177,7 @@ static void xmousebtn(XConf* x, XEvent* e)
         case MouseActExec:
         {
             char* str = view_fetch(win_view(Focused), row, col, riscmd);
-            exec_or_send(str);
+            exec(str, NULL);
             free(str);
             break;
         }
@@ -483,6 +482,22 @@ static void cmd_exec(char* cmd)
     }
 }
 
+static void exec_or_send(char* str)
+{
+    if (str && *str)
+    {
+        bool shellcmd = (str[0] == ':' && str[1] == ';');
+        if (xpty_active() && !rissigil(*str) && !shellcmd)
+        {
+            xpty_send(str);
+        }
+        else
+        {
+            cmd_exec(str);
+        }
+    }
+}
+
 static void exec(char* cmd, char* arg)
 {
     /* skip leading space */
@@ -500,27 +515,12 @@ static void exec(char* cmd, char* arg)
     else if (arg)
     {
         cmd = (arg ? strmcat(cmd, " '", arg, "'", 0) : strmcat(cmd));
-        cmd_exec(cmd);
+        exec_or_send(cmd);
         free(cmd);
     }
     else
     {
-        cmd_exec(cmd);
-    }
-}
-
-static void exec_or_send(char* str)
-{
-    if (str)
-    {
-        if (xpty_active())
-        {
-            xpty_send(str);
-        }
-        else
-        {
-            exec(str, NULL);
-        }
+        exec_or_send(cmd);
     }
 }
 
@@ -591,7 +591,7 @@ static void execute(char* arg)
 {
     (void)arg;
     char* str = view_getcmd(win_view(FOCUSED));
-    exec_or_send(str);
+    exec(str, NULL);
     free(str);
 }