diff --git a/config.h b/config.h index 763b936..1f63a9f 100644 --- a/config.h +++ b/config.h @@ -240,6 +240,16 @@ static char *openurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -o", "externalpipe static char *copyurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -c", "externalpipe", NULL }; static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL }; +const char * visualselectfmt = + "win=`xdotool getactivewindow`;" + "geom=%u\"x\"%u;" + "tmp=`mktemp`;" + "cat > $tmp;" + "st -w $win -g $geom -e " + "vim + +\"set nonumber norelativenumber laststatus=0 buftype=nowrite\" $tmp;" + "rm $tmp" +; +extern void visualselect(); static Shortcut shortcuts[] = { /* mask keysym function argument */ @@ -268,6 +278,7 @@ static Shortcut shortcuts[] = { { MODKEY, XK_l, externalpipe, {.v = openurlcmd } }, { MODKEY, XK_y, externalpipe, {.v = copyurlcmd } }, { MODKEY, XK_o, externalpipe, {.v = copyoutput } }, + { Mod1Mask, XK_Escape, visualselect, {0} }, }; /* diff --git a/st.c b/st.c index ab0a81d..54b2084 100644 --- a/st.c +++ b/st.c @@ -1990,6 +1990,16 @@ externalpipe(const Arg *arg) signal(SIGPIPE, oldsigpipe); } +void +visualselect (void) +{ + extern const char * visualselectfmt; + char visualselectcmd [200]; + snprintf (visualselectcmd, 200, visualselectfmt, (term.col + 2) % 10000, (term.row + 1) % 10000); + + externalpipe (& (Arg) {.v = (char * []) { "/bin/sh", "-c", visualselectcmd, NULL }}); +} + void strdump(void) {