Re: [dev] [st] mouse usage, right click to plumb selection
On Tue, Sep 12, 2017 at 8:41 PM, Hiltjo Posthumawrote: >> Please share what you think about when you say "already possible with >> minor changes in config.h", I'm interested :) >> > > Just adding a (plumb) hotkey and a plumb script which interacts with the > clipboard selection. For me it is capslock (bound to F13). The script uses > sselp and some grep patterns. > > Then it works like this: select text using the mouse/keyboard. Then press the > plumb key. > > Ofcourse you can make it as fancy as you want it to be. For me this works well > enough. Sure. You can see my "plumb.sh" does that if called without arguments, using xclip though. In dwm, it seems possible to bind actions like this to key or mouse button presses. In st, we seem to be restricted to key presse only, hence my patch proposal. Thanks
Re: [dev] [st] mouse usage, right click to plumb selection
On Tue, Sep 12, 2017 at 06:08:46PM +0200, Jérôme Andrieux wrote: > On Tue, Sep 12, 2017 at 5:57 PM, Hiltjo Posthuma> wrote: > >> wrote: > >> > TLDR: I use the mouse button3 to plumb the current selection in st, > >> > how would you feel about making this patch a core feature? > >> > >> I like the idea but it should only be part of the core if enough > >> people want it to be which I doubt. Having it as a patch is good > >> enough for me. > >> > > > > It is already possible with minor changes in the config.h using the > > clipboard selection for example. Adding a specific plumber solution > > might be outside the scope of st maybe. > > But keep sharing these ideas :) > > Please share what you think about when you say "already possible with > minor changes in config.h", I'm interested :) > Just adding a (plumb) hotkey and a plumb script which interacts with the clipboard selection. For me it is capslock (bound to F13). The script uses sselp and some grep patterns. Then it works like this: select text using the mouse/keyboard. Then press the plumb key. Ofcourse you can make it as fancy as you want it to be. For me this works well enough. -- Kind regards, Hiltjo
Re: [dev] [st] mouse usage, right click to plumb selection
On Tue, Sep 12, 2017 at 5:57 PM, Hiltjo Posthumawrote: >> wrote: >> > TLDR: I use the mouse button3 to plumb the current selection in st, >> > how would you feel about making this patch a core feature? >> >> I like the idea but it should only be part of the core if enough >> people want it to be which I doubt. Having it as a patch is good >> enough for me. >> > > It is already possible with minor changes in the config.h using the > clipboard selection for example. Adding a specific plumber solution > might be outside the scope of st maybe. > But keep sharing these ideas :) Please share what you think about when you say "already possible with minor changes in config.h", I'm interested :) When it comes to adding something something to st, it just the action/cmd behind the right click. I couldn't find a way to specify an action for mouse events like one could do in dwm.
Re: [dev] [st] mouse usage, right click to plumb selection
On Tue, Sep 12, 2017 at 02:55:29PM +0200, Silvan Jegen wrote: > Hi > > On Tue, Sep 12, 2017 at 1:38 PM, Jérôme Andrieux >wrote: > > TLDR: I use the mouse button3 to plumb the current selection in st, > > how would you feel about making this patch a core feature? > > I like the idea but it should only be part of the core if enough > people want it to be which I doubt. Having it as a patch is good > enough for me. > It is already possible with minor changes in the config.h using the clipboard selection for example. Adding a specific plumber solution might be outside the scope of st maybe. But keep sharing these ideas :) -- Kind regards, Hiltjo
Re: [dev] [st] mouse usage, right click to plumb selection
On Tue, Sep 12, 2017 at 3:26 PM, Jérôme Andrieuxwrote: >> I like the idea but it should only be part of the core if enough >> people want it to be which I doubt. Having it as a patch is good >> enough for me. > > Everything is good then, patch is online and discussion is starting. yepp >> Are you using the plumber from plan9 from user space or do you use >> something home-grown? Care to share? > > Both actually but I have been working on it yesterday. > > I use plumb within acme and a set of shell script elsewhere, with a > plumb fallback. > What I really need is a decent editor wrapper and everything could go > through plumber, even if I don't quite like its declarative rules > syntax. Interesting. Thanks for sharing the script! Using `file` to get the mime-type is an interesting idea. > My main workflow is to send some `path/file:line:col` (those would > hopefully be sam expressions) to vim via `vim --remote` and > https://github.com/kopischke/vim-fetch. > I'm trying https://github.com/martanne/vis lately, but boy, habits die hard. Yeah, I know the problem... I am trying to get into the habit of using vis more often so I set it to be my mail editor for mutt. Still not used to it... Cheers, Silvan
Re: [dev] [st] mouse usage, right click to plumb selection
> I like the idea but it should only be part of the core if enough > people want it to be which I doubt. Having it as a patch is good > enough for me. Everything is good then, patch is online and discussion is starting. > Are you using the plumber from plan9 from user space or do you use > something home-grown? Care to share? Both actually but I have been working on it yesterday. I use plumb within acme and a set of shell script elsewhere, with a plumb fallback. What I really need is a decent editor wrapper and everything could go through plumber, even if I don't quite like its declarative rules syntax. My main workflow is to send some `path/file:line:col` (those would hopefully be sam expressions) to vim via `vim --remote` and https://github.com/kopischke/vim-fetch. I'm trying https://github.com/martanne/vis lately, but boy, habits die hard. cat bin/plumb.sh ``` #!/bin/zsh pattern="$@" if [[ "x" == "x$pattern" ]]; then pattern=`xclip -o` fi patternbase=${pattern%%:*} filename="" if [[ -e "$pattern" ]]; then filename="$pattern" elif [[ -e "$patternbase" ]]; then filename="$patternbase" fi mimetype=`file -b -L --mime-type "$filename"` case "$mimetype" in text\/*) edit.sh "$pattern" ;; application\/pdf) zathura "$pattern" ;; image\/*) feh -Z "$pattern" ;; inode\/directory) rox "$pattern" ;; *) plumb "$pattern" esac ``` cat bin/edit.sh ``` #!/bin/zsh running=`vim --serverlist | wc -l` if [[ "$running" -eq 0 ]] ; then st vim "$@" else vim --remote "$@" fi ```
Re: [dev] [st] mouse usage, right click to plumb selection
On Tue, Sep 12, 2017 at 2:13 PM, Truls Beckenwrote: > Plumbing with cwd sounds interesting if it works reliably. I see that > one has to configure > ones shell specifically to output an escape code that the patched ST > will recognize. It was once done by descending the child pids from the terminal and getting cwd from /proc/pid/cwd It is both more generic and less portable. I find the shell/OSC7 approach convenient. > Question about the patch itself; why start a shell and construct a > command that involves > cd to change directory? Wouldn't a chdir() in the forked process suck > less? Then exec > plumber_cmd, sel.primary directly. Also the child pid variable seems > unnecessary. Sure, these are remains from different approaches to context passing : chdir, cd'in in the command (sometimes, cd is just a builtin), ... As I said, I am not sure whether to: - chdir somehow and only pass the selection as argument, which makes it easier to specify a generic plumber command - pass cwd, sel.primary and eventually st pid as arguments, but that would require some thoughts about how to serialize properly the list of arguments, not to have issues with spaces, separators and so on. -- Jérôme Andrieux
Re: [dev] [st] mouse usage, right click to plumb selection
Hi On Tue, Sep 12, 2017 at 1:38 PM, Jérôme Andrieuxwrote: > TLDR: I use the mouse button3 to plumb the current selection in st, > how would you feel about making this patch a core feature? I like the idea but it should only be part of the core if enough people want it to be which I doubt. Having it as a patch is good enough for me. > For those unfamiliar with plan9/acme, "right click to plumb" means > "right click in your terminal to send its current text selection to > some plumbing script": open a PDF with zathura, jump to > path/file:line:cal in your editor, launch browser at URL ... > acme packs together a lot of features, being a "window manager", a > shell and an editor at the same time, and integrating with the > surrounding system via its plumber and its 9pfs system. It can get > quite addictive integration-wise but also quite frustrating when you > are used to vi, non-dumb terminals and generic tiling window managers. > mpu has even written its own acme/vi hybrid editor. Are you using the plumber from plan9 from user space or do you use something home-grown? Care to share? Cheers, Silvan
Re: [dev] [st] mouse usage, right click to plumb selection
Plumbing with cwd sounds interesting if it works reliably. I see that one has to configure ones shell specifically to output an escape code that the patched ST will recognize. Question about the patch itself; why start a shell and construct a command that involves cd to change directory? Wouldn't a chdir() in the forked process suck less? Then exec plumber_cmd, sel.primary directly. Also the child pid variable seems unnecessary.
[dev] [st] mouse usage, right click to plumb selection
Bonjour suckless, TLDR: I use the mouse button3 to plumb the current selection in st, how would you feel about making this patch a core feature? I pushed a patch for st yesterday that I have been using for a while, after getting addicted to some plan9/9term/acme features : https://st.suckless.org/patches/right_click_to_plumb/ (Thanks Evil_Bob) For those unfamiliar with plan9/acme, "right click to plumb" means "right click in your terminal to send its current text selection to some plumbing script": open a PDF with zathura, jump to path/file:line:cal in your editor, launch browser at URL ... acme packs together a lot of features, being a "window manager", a shell and an editor at the same time, and integrating with the surrounding system via its plumber and its 9pfs system. It can get quite addictive integration-wise but also quite frustrating when you are used to vi, non-dumb terminals and generic tiling window managers. mpu has even written its own acme/vi hybrid editor. Using the mouse to trigger the plumbing within st has an advantage over using a keybinding from dwm, since it eventually allows to get some context and most importantly the current working directory of the shell within st, and thus allows to plumb path relative to cwd. Both are not mutually exclusive, I use a binding to trigger something like "plumber `xclip -o`" from anywhere. The mouse just makes it a bit nicer within st. Now, I get that URL matching/launching is explicitly marked as a non goal for st but I understood that as "we don't provide a parser and a plumber, double click to select is smart enough". For some reason, rxvt, VTE based terminal emulators & others preferred the complex logic of parsing, matching ... URLs only. The termite terminal emulator requires a vte-ng fork to provide features that won't even match a path/file:line ... Tilix provides its own sub-par regex only plumber, tabs and sub-par tiling system. Now, with st, it is just a matter of a dozen LOC to feed the plumber of your choosing and get on with your life. The patch I mentioned above introduce : - a "cwd" global that is fed from a shell function pushing an OSC7 escape sequence, instead of descending the st child pid. It's simple to code at the expense of more work on the user side. - "plumber_cmd" configuration entry for the user to set, that is executed in a shell, in `cwd`. I am not sure whether changing directory before executing is preferable to passing `cwd` as an argument alongside sel.primary Is this feature of any interest? Bloat? Not enough? -- Jérôme