diff -r 1c8e6796c6fe config.def.h --- a/config.def.h Sun Aug 14 17:15:19 2011 +0200 +++ b/config.def.h Thu Aug 25 15:40:02 2011 +0100 @@ -72,3 +72,5 @@ /* double-click timeout (in milliseconds) between clicks for selection */ #define DOUBLECLICK_TIMEOUT 300 #define TRIPLECLICK_TIMEOUT (2*DOUBLECLICK_TIMEOUT) + +static const char *pipecmd[] = { "pipetest.sh", NULL }; diff -r 1c8e6796c6fe st.c --- a/st.c Sun Aug 14 17:15:19 2011 +0200 +++ b/st.c Thu Aug 25 15:40:02 2011 +0100 @@ -232,6 +232,8 @@ static void selcopy(void); static void selpaste(); +static void extpipe(); + static int utf8decode(char *, long *); static int utf8encode(long *, char *); static int utf8size(char *); @@ -607,6 +609,37 @@ } void +extpipe(const char **cmd) { + int fd[2], pid; + + if(pipe(fd)) return; + pid = fork(); + + if(pid == -1) return; + if(pid == 0) { /* child */ + close(fd[1]); + if(fd[0] != STDIN_FILENO) { + dup2(fd[0], STDIN_FILENO); + close(fd[0]); + } + execvp(cmd[0], (char **)cmd); + exit(0); + } else { /* parent */ + int x, y; + close(fd[0]); + + for(y = 0; y < term.row; y++) { + for(x = 0; x < term.col; x++) { + if(term.line[y][x].state & GLYPH_SET) + write(fd[1], term.line[y][x].c, utf8size(term.line[y][x].c)); + } + write(fd[1], "\n", 1); + } + close(fd[1]); + } +} + +void bmotion(XEvent *e) { if(IS_SET(MODE_MOUSE)) { mousereport(e); @@ -684,7 +717,7 @@ default: close(s); cmdfd = m; - signal(SIGCHLD, sigchld); + //signal(SIGCHLD, sigchld); } } @@ -1877,6 +1910,10 @@ if(shift) selpaste(); break; + case XK_bar: + if(meta) + extpipe(pipecmd); + break; case XK_Return: if(IS_SET(MODE_CRLF)) ttywrite("\r\n", 2);