sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

simple_plumb_double_click-0.8.5.diff (1388B)


      1 From e2794629844c97ad4d39bf300e66ce3de0be7799 Mon Sep 17 00:00:00 2001
      2 From: yasumori <ysmr@protonmail.com>
      3 Date: Mon, 1 Aug 2022 15:07:46 -0400
      4 Subject: [PATCH] allow plumbing with double click
      5 
      6 ---
      7  config.def.h | 5 +++++
      8  x.c          | 6 ++++++
      9  2 files changed, 11 insertions(+)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 548f76a..2a65fab 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -477,6 +477,11 @@ static char ascii_printable[] =
     16  	"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
     17  	"`abcdefghijklmnopqrstuvwxyz{|}~";
     18  
     19 +/*
     20 + * PLUMBMASK runs plumb_cmd on the selected word when double clicking while held down
     21 + */
     22 +#define PLUMBMASK ShiftMask
     23 +
     24  /*
     25   * plumb_cmd is run on mouse button 3 click, with first NULL set to
     26   * current selection and with cwd set to the cwd of the active shell
     27 diff --git a/x.c b/x.c
     28 index 35fca28..f0c7eda 100644
     29 --- a/x.c
     30 +++ b/x.c
     31 @@ -174,6 +174,7 @@ static void resize(XEvent *);
     32  static void focus(XEvent *);
     33  static uint buttonmask(uint);
     34  static int mouseaction(XEvent *, uint);
     35 +static void plumb(char *);
     36  static void brelease(XEvent *);
     37  static void bpress(XEvent *);
     38  static void bmotion(XEvent *);
     39 @@ -502,6 +503,11 @@ bpress(XEvent *e)
     40  		xsel.tclick1 = now;
     41  
     42  		selstart(evcol(e), evrow(e), snap);
     43 +
     44 +		if (snap == SNAP_WORD && match(PLUMBMASK, e->xbutton.state)) {
     45 +			xsetsel(getsel());
     46 +			plumb(xsel.primary);
     47 +		}
     48  	}
     49  }
     50  
     51 -- 
     52 2.37.1
     53