You are not logged in.

#1 2010-08-16 18:46:04

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

urxvt-keyboard-select - mouseless text selection in urxvt

Hello again,

my next urxvt extension reached a stable stage, so it's time to post it here: keyboard-select

Please have a look at the top of the file for details on how to use it, or read the README on github.
The usage is comparable to tmux/gnu screen, but its mappings are more vim-like.

As for now, the most basic cursor movement keys are available, I'm planning to add the following in the near future: [fFwWbBeE;,/?nN]

And this time I've also managed to upload a PKGBUILD before writing this post...

Last edited by ber_t (2011-03-29 12:36:50)

Offline

#2 2010-08-16 18:49:05

DPX-Infinity
Member
From: Russia
Registered: 2009-10-16
Posts: 35

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Great! Always wanted something like this.
But is it possible to add emacs-like keybindings? That would be very useful smile

Offline

#3 2010-08-16 20:16:19

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Very useful script! Nice work smile

Offline

#4 2010-08-16 21:06:12

VCoolio
Member
From: Netherlands
Registered: 2010-01-05
Posts: 120

Re: urxvt-keyboard-select - mouseless text selection in urxvt

an even happier customer! and emacs-like keybindings +1, but we could also modify the keys in the script ourselves of course. If only I wasn't that lazy... but who knows.

Offline

#5 2010-08-16 22:11:24

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: urxvt-keyboard-select - mouseless text selection in urxvt

yikes you implemented ctrl-v?!

AWESOME.

/me bows

Ogion

(The above may be irc style, but it was just meant to show my surprised awe at just randomly trying out ctrl-v after installing your script and going yikes as it worked)


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#6 2010-08-17 04:49:31

hitsmaxft
Member
From: guangzhou
Registered: 2010-06-02
Posts: 13
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Offline

#7 2010-08-17 08:12:38

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

@hitsmaxft: Your extension looks nice, I will try it out later. But your one always uses urxvt's selection for highlighting; I use rendition bits for that, because I want a chance to cancel visual mode without losing the content of the primary buffer. It also misses some delete statements, for example, it always creates a new overlay without deleting the old one.
I will continue developing mine (at least just for the fun of it), even if your one already features everything I'd plan to implement.

For all the emacs lovers: I will try to provide vim and emacs keybindings, but I didn't come up with a nice way of handling this. And by nice I mean no code duplication and no complex key dispatcher, taking up more code than the real functionality.

Be patient, or:

VCoolio wrote:

... but we could also modify the keys in the script ourselves of course. If only I wasn't that lazy... but who knows.

Offline

#8 2010-08-17 13:30:45

chneukirchen
Member
Registered: 2010-02-11
Posts: 100

Re: urxvt-keyboard-select - mouseless text selection in urxvt

The functionality is nice, but I rather wanted to have it in tmux, so I wrote tmux-open-url:

#!/bin/sh
# tmux-open-url - open last URL in current tmux pane in firefox

LAST_URL=$(tmux capture-pane \; show-buffer -b0 \; delete-buffer -b0 |
           grep -P -o '(?:https?://|ftp://|news://|mailto:|file://|\bwww\.)[a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*(\([a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*\)|[a-zA-Z0-9\-\@;\/?:&=%\$_+*~])+' |
           tail -1)
[ -n "$LAST_URL" ] && firefox "$LAST_URL"

and put into my tmux.conf:

bind u run tmux-open-url

This will only open the last URL, but a parameter can be added easily.

Offline

#9 2010-08-17 15:11:41

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

@chneukirchen: You're in the wrong thread, the titles are a little bit confusing though.

Last edited by ber_t (2010-08-17 15:13:04)

Offline

#10 2010-08-17 16:25:06

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Hey, i tried both keyboard-select and clipboard, but I can't get them to work.

in my .Xdefaults:

URxvt.perl-lib: /home/dieter/.local/share/urxvt/plugins/
URxvt.perl-ext-common: default,matcher,tabbed,clipboard,keyboard-select
!URxvt.keysym.M-c:   perl:clipboard:copy
URxvt.keysym.M-v:   perl:clipboard:paste
URxvt.keysym.M-C-v: perl:clipboard:paste_escaped
URxvt.keysym.M-c: perl:keyboard-select:activate

I downloaded the files to /home/dieter/.local/share/urxvt/plugins/, chmodded +x (not sure if that's needed)
I fail to activate any of the plugins.  I changed the keybinding from M-Escape because my WM (awesome) seems to grab those, but M-c and M-v have no effect. modkey = superkey right? anyway i tried with alt, ctrl, altgr and right control as well..


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#11 2010-08-17 17:59:12

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

@Dieter@be: Just a guess: Have you run xrdb after changing your .Xdefaults:

xrdb -merge ~/.Xdefaults

What's happening when you start urxvt from within another terminal? Does it report anything? You could also add a print statement to the on_start subroutine to check if the scripts are actually parsed by urxvt.

Offline

#12 2010-08-18 04:37:09

vae77
Member
Registered: 2010-07-02
Posts: 75
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

That exactly what I'm looking for, thanks!

Offline

#13 2010-08-18 07:45:12

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

ber_t wrote:

@Dieter@be: Just a guess: Have you run xrdb after changing your .Xdefaults:

xrdb -merge ~/.Xdefaults

What's happening when you start urxvt from within another terminal? Does it report anything? You could also add a print statement to the on_start subroutine to check if the scripts are actually parsed by urxvt.

I think I falsely assumed that spawning a new terminal was enough. (so I didn't do the xrdb - merge yesterday).
Today I'm in a fresh X session and it works smile both the clipboard (awesome!) and the keyboard-select work. although just pressing 'y' (without return) is enough to copy it to my primary buffer and exist the selection mode


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#14 2010-08-18 09:01:21

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Dieter@be wrote:

although just pressing 'y' (without return) is enough to copy it to my primary buffer and exist the selection mode

The README is a bit ambigous, but I meant that the either y or Return can be used for this. This is going to change in the next version, where y copies the selection, but let's you stay in selection mode, whereas Return also deactivates it.

Offline

#15 2010-08-19 09:31:18

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Updated to version 1.1

It now uses logical lines instead of terminal rows and columns, so cursor movement works a lot more like in vim. The cursor should also never leave the displayed text.
Changing lines after using '$' always moves the cursor to the end of the new line.
The Ctrl-[fbdu] mappings now scroll the buffer instead of moving the cursor, so that the cursor position inside the window is preserved.

Offline

#16 2010-08-19 13:27:45

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Hey ber_t,
Typo, should you care:
http://github.com/muennich/urxvt-perls/ … /README.md

After installing, put the folling lines in your .Xdefaults:

s/folling/following/

The typo is shown twice.

Last edited by steve___ (2010-08-19 13:28:25)

Offline

#17 2010-08-29 19:09:46

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Updated to version 1.2

Added [fF;,wWbB] mappings. I did my best to make them work exactely the same as in vim.

Offline

#18 2010-08-29 21:51:21

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: urxvt-keyboard-select - mouseless text selection in urxvt

ber_t wrote:

Updated to version 1.2

Added [fF;,wWbB] mappings. I did my best to make them work exactely the same as in vim.

Awesome.

Offline

#19 2010-08-31 07:59:44

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

It's because of amazing software like this that pops up that I take the time to routinely scan the Community Contributions. This is the greatest thing since sliced bread! Sometimes when I boot my computer my mouse won't select text (don't know why), but with this extension, I won't be forced to restart my computer in order to copy and paste text from the terminal. Thanks!


Registed Linux User 483618

Offline

#20 2010-09-01 02:21:36

ntness
Member
From: The World
Registered: 2009-12-29
Posts: 97

Re: urxvt-keyboard-select - mouseless text selection in urxvt

/unplugs his mouse

I love you.


transcend to the fifth abode

Offline

#21 2010-09-26 17:54:12

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Updated to version 1.3

Fixed some cursor movement inconsistencies and added [/?nN] mappings.

You can directly enter the backward search mode (?)---without using Meta-Escape first---by adding the following line to your .Xdefaults:

URxvt.keysym.M-s: perl:keyboard-select:search

This overwrites/replaces the default Meta-s search mode, provided by the searchable-scrollback extension, which is therefore no longer needed.

Offline

#22 2010-11-12 22:59:36

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Updated to version 1.4

No big changes since the last update, but I wanted to move them into a stable version, because there has not been any development in roughly two months.
To me, this extension seems to be feature complete with this release...

Offline

#23 2010-11-13 00:23:12

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Nice work, thank you.

Offline

#24 2010-11-28 10:17:22

iosonofabio
Member
From: Australia
Registered: 2008-10-09
Posts: 105

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Thanks for this wonderful work!

I suspect this extension is not working correctly in ncurses (in mutt, at least). Do you think that it can be solved? your other extension, url-select, is already working in mutt flawlessly.

Offline

#25 2010-11-28 18:56:49

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-keyboard-select - mouseless text selection in urxvt

Mutt uses rxvt-unicode's facility to make the cursor invisible. There is no way to make it temporarily visible within the perl extension.

But you can either patch (and recompile) mutt or rxvt-unicode, to prevent this behaviour. I prefer to patch rxvt-unicode because I have already customized and compiled it for some other reasons. Below you'll find my simple one-line patch and the modified PKGBUILD. Please note, that no application will be able to hide the cursor inside an urxvt, when using this patch, which you might prefer, if you like using keyboard-select.

If you would rather patch mutt, then you are on your own, but it's a simple task, too. Just do a `grep mutt_curs_set *' inside mutt's src-dir and you should know what to do...

rxvt-unicode-9.07-vis_curs-bm.diff
PKGBUILD

Offline

Board footer

Powered by FluxBB