From 1f166193fdae70800f0764cdce64eb9924013d1b Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sun, 12 Jan 2025 15:47:24 -0600 Subject: add patch open selected --- PATCHES | 1 + config.def.h | 2 ++ st.c | 10 ++++++++++ x.c | 16 ++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/PATCHES b/PATCHES index 204f294..290d230 100644 --- a/PATCHES +++ b/PATCHES @@ -5,6 +5,7 @@ st-csi_22_23-0.8.5.diff st-desktopentry-0.8.5.diff st-drag-n-drop-0.9.2.diff st-expected-anysize-0.9.diff +st-open-selected-0.9.2.diff st-scrollback-0.9.2.diff st-scrollback-reflow-0.9.2.diff st-themed_cursor-0.8.1.diff diff --git a/config.def.h b/config.def.h index c95f93a..d9ce6cc 100644 --- a/config.def.h +++ b/config.def.h @@ -196,6 +196,7 @@ static MouseShortcut mshortcuts[] = { { ControlMask, Button5, zoom, {.f = -1}, 0 }, { XK_ANY_MOD, Button4, kscrollup, {.i = 3}, 0 }, { XK_ANY_MOD, Button5, kscrolldown, {.i = 3}, 0 }, + { ControlMask, Button2, selopen, {.i = 0}, 1 }, { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, { XK_ANY_MOD, Button3, selpaste, {.i = 0}, 1 }, { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, @@ -226,6 +227,7 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, { MODKEY, XK_l, copyurl, {.i = 0} }, { MODKEY|ShiftMask, XK_L, copyurl, {.i = 1} }, + { TERMMOD, XK_l, selopen, {.i = 0} }, { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} }, { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} }, }; diff --git a/st.c b/st.c index 95dcac4..876f5cc 100644 --- a/st.c +++ b/st.c @@ -2236,6 +2236,16 @@ strhandle(void) if (narg > 1) xsettitle(strescseq.args[1], 0); return; + case 7: + if (strstr(strescseq.args[1], "file://") != strescseq.args[1]) { + fprintf(stderr, "erresc: dir %s must have prefix 'file://'\n", + strescseq.args[1]); + return; + } + if (chdir(strescseq.args[1] + 7) != 0) /* +7 to remove prefix */ + fprintf(stderr, "erresc: invalid directory %s\n", + strescseq.args[1]); + return; case 52: if (narg > 2 && allowwindowops) { dec = base64dec(strescseq.args[2]); diff --git a/x.c b/x.c index 7e361d5..71a95ac 100644 --- a/x.c +++ b/x.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ static void clipcopy(const Arg *); static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); +static void selopen(const Arg *); static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); @@ -312,6 +314,20 @@ selpaste(const Arg *dummy) xw.win, CurrentTime); } +void +selopen(const Arg *dummy) +{ + pid_t chpid; + + if ((chpid = fork()) == 0) { + if (fork() == 0) + execlp("xdg-open", "xdg-open", getsel(), NULL); + exit(1); + } + if (chpid > 0) + waitpid(chpid, NULL, 0); +} + void numlock(const Arg *dummy) { -- cgit v1.2.3