From: Michael D. Lowis Date: Fri, 22 Nov 2019 21:37:50 +0000 (-0500) Subject: fixed execution handling while xpty active X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c73c106b59850b76c5a723889ee4a7aa998c11ff;p=projs%2Ftide.git fixed execution handling while xpty active --- diff --git a/src/lib/buf.c b/src/lib/buf.c index c5350c1..05c11f2 100644 --- a/src/lib/buf.c +++ b/src/lib/buf.c @@ -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); diff --git a/src/lib/editlog.c b/src/lib/editlog.c index c7a28d7..6d7cdc0 100644 --- a/src/lib/editlog.c +++ b/src/lib/editlog.c @@ -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); } } - - - diff --git a/src/tide.c b/src/tide.c index d915970..1b67ac9 100644 --- a/src/tide.c +++ b/src/tide.c @@ -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); }