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);
#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);
case MouseActExec:
{
char* str = view_fetch(win_view(Focused), row, col, riscmd);
- exec_or_send(str);
+ exec(str, NULL);
free(str);
break;
}
}
}
+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 */
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);
}
}
{
(void)arg;
char* str = view_getcmd(win_view(FOCUSED));
- exec_or_send(str);
+ exec(str, NULL);
free(str);
}