Adding open selected text patch

This commit is contained in:
Bakkeby 2025-02-20 22:36:51 +01:00
parent 08b53c4960
commit 978e25f23b
7 changed files with 34 additions and 1 deletions

View file

@ -15,7 +15,7 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog: ### Changelog:
2025-02-20 - Added the drag-n-drop patch 2025-02-20 - Added the drag-n-drop and open-selected-text patches
2024-05-31 - Added the anygeometry patch 2024-05-31 - Added the anygeometry patch
@ -235,6 +235,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [open-copied-url](https://st.suckless.org/patches/open_copied_url/) - [open-copied-url](https://st.suckless.org/patches/open_copied_url/)
- open contents of the clipboard in a user-defined browser - open contents of the clipboard in a user-defined browser
- [open-selected-text](https://st.suckless.org/patches/open_selected_text)
- open the selected text using `xdg-open`
- [openurlonclick](https://www.reddit.com/r/suckless/comments/cc83om/st_open_url/) - [openurlonclick](https://www.reddit.com/r/suckless/comments/cc83om/st_open_url/)
- allows for URLs to be opened directly when you click on them - allows for URLs to be opened directly when you click on them

View file

@ -371,6 +371,9 @@ static uint forcemousemod = ShiftMask;
*/ */
static MouseShortcut mshortcuts[] = { static MouseShortcut mshortcuts[] = {
/* mask button function argument release screen */ /* mask button function argument release screen */
#if OPEN_SELECTED_TEXT_PATCH
{ ControlMask, Button2, selopen, {.i = 0}, 1 },
#endif // OPEN_SELECTED_TEXT_PATCH
#if CLIPBOARD_PATCH #if CLIPBOARD_PATCH
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 }, { XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
#else #else

13
patch/openselectedtext.c Normal file
View file

@ -0,0 +1,13 @@
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);
}

3
patch/openselectedtext.h Normal file
View file

@ -0,0 +1,3 @@
#include <sys/wait.h>
static void selopen(const Arg *);

View file

@ -38,6 +38,9 @@
#elif NETWMICON_LEGACY_PATCH #elif NETWMICON_LEGACY_PATCH
#include "netwmicon_legacy.c" #include "netwmicon_legacy.c"
#endif #endif
#if OPEN_SELECTED_TEXT_PATCH
#include "openselectedtext.c"
#endif
#if OPENURLONCLICK_PATCH #if OPENURLONCLICK_PATCH
#include "openurlonclick.c" #include "openurlonclick.c"
#endif #endif

View file

@ -35,6 +35,9 @@
#if NETWMICON_PATCH || NETWMICON_FF_PATCH || NETWMICON_LEGACY_PATCH #if NETWMICON_PATCH || NETWMICON_FF_PATCH || NETWMICON_LEGACY_PATCH
#include "netwmicon.h" #include "netwmicon.h"
#endif #endif
#if OPEN_SELECTED_TEXT_PATCH
#include "openselectedtext.h"
#endif
#if RIGHTCLICKTOPLUMB_PATCH #if RIGHTCLICKTOPLUMB_PATCH
#include "rightclicktoplumb_x.h" #include "rightclicktoplumb_x.h"
#endif #endif

View file

@ -299,6 +299,11 @@
*/ */
#define OPENCOPIED_PATCH 0 #define OPENCOPIED_PATCH 0
/* Open the selected text using xdg-open.
* https://st.suckless.org/patches/open_selected_text/
*/
#define OPEN_SELECTED_TEXT_PATCH 0
/* This patch allows for URLs to be opened directly when you click on them. This may not work with /* This patch allows for URLs to be opened directly when you click on them. This may not work with
* all terminal applications. * all terminal applications.
* *