if (nbytes > 0)
{
/* adjust the point according to the characters deleted */
- size_t bpoint = ((sel.beg <= buf->point.beg) ? (buf->point.beg - sel.beg) : 0u);
- size_t inpoint = (min(buf->point.end, sel.end) - max(buf->point.beg, sel.beg));
+ 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 ;
buf->point.beg -= bpoint;
buf->point.end -= (bpoint + inpoint);
{
char* str = buf_getsat(&(EditView->buffer), EditView->buffer.point.beg, EditView->buffer.point.end);
EditView->buffer.point.beg = EditView->buffer.point.end;
- printf("write '%s'\n", str);
+// printf("write '%s'\n", str);
writefd(Pty_Fd, str, strlen(str));
free(str);
}
#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);
- if (str) exec(str, NULL);
+ exec_or_send(str);
free(str);
break;
}
}
}
+static void exec_or_send(char* str)
+{
+ if (str)
+ {
+ if (xpty_active())
+ {
+ xpty_send(str);
+ }
+ else
+ {
+ exec(str, NULL);
+ }
+ }
+}
+
/* Keyboard and Tag Handlers
******************************************************************************/
static void change_focus(char* arg)
{
(void)arg;
char* str = view_getcmd(win_view(FOCUSED));
- if (str)
- {
- if (xpty_active())
- {
- xpty_send(str);
- }
- else
- {
- exec(str, NULL);
- }
- }
+ exec_or_send(str);
free(str);
}