You are not logged in.
Hi,
I've finished solo-testing my first real perl extension for the rxvt-unicode terminal emulator.
I post it here because it might be of interest for others: url-select. Just copy the linked file into "/usr/lib/urxvt/perl/" to install it.
It's based on -- initially forked, but at the end only inspired by -- mark-yank-urls. I've written my own version, because mark-yank-urls did not suspend terminal updates while cycling through the URLs, which causes a lot of distortions.
To activate this extension, put the following lines into your .Xdefaults:
URxvt.perl-ext-common: ...,url-select
URxvt.urlLauncher: firefox
URxvt.underlineURLs: true
URxvt.keysym.M-u: perl:url-select:select_next
The meaning of the lines should be self-explanatory. The "..." in the first line means, that you have to append "url-select", if a line with the same key already exists in your .Xdefaults.
After that, you could start URL selection mode by hitting Meta-U. Subsequent key-presses cycle through the available URLs from bottom to top. You could also use the 'j/k' keys to select the next down-/upward URL. Escape cancels the selection mode, 'y' copies the currently selected URL to the primary buffer and the Return key opens it using the specified browser ("urlLauncher", see above).
Please notice one last difference to the original mark-yank-urls extension: When activating the URL selection mode, the search starts at the last line of the currently visible area, whereas the original extension starts at the last line of the complete text buffer.
Enjoy or move on,
Bert
Last edited by ber_t (2011-03-29 12:38:30)
Offline
Thank you.
I'll make a PKGBUILD for it when I have time.
Offline
It's nice to see another example of this, since mark-yank-urls hasn't worked very well for me.
It would be nice if you could add a general copy mode too. It's a shame that you have to run a shell inside of a tmuxer to get what I consider to be an integral function all terminals need: marking and yanking text. Really URLs are just a subset of that.
Your code looks a little more clean than mark-yank-urls, so I will be using it to explore the possibility of implementing my own script. Of course if yours turns out well, then I won't need to!
Also just for others' information, they can also put the script somewhere local such as ~/.urxvt and include the location using:
URxvt.perl-lib:
EDIT: After trying to test this, I haven't gotten it to work once unfortunately. It works with urxvtc right?
Last edited by egan (2010-08-11 23:52:26)
Offline
I'll make a PKGBUILD for it when I have time.
I thought of that myself but refused to do so, because it's just one script that you have to download and move into a specific directory on your computer. The hardest part is to modify your .Xdefaults, what pacman can't do for you.
But I'll sure appreciate it, if you do so!
It would be nice if you could add a general copy mode too. It's a shame that you have to run a shell inside of a tmuxer to get what I consider to be an integral function all terminals need: marking and yanking text. Really URLs are just a subset of that.
I already thought of that, too. But personally I think that the mouse is much more elegent for selecting text. But I'll try to implement this just for the fun of it -- it shouldn't be that hard.
EDIT: After trying to test this, I haven't gotten it to work once unfortunately. It works with urxvtc right?
Yes, I've just checked this!
Offline
Works for me (in urxvtc), very nice. Thanks for this, ber_t.
Ogion
Last edited by Ogion (2010-08-12 08:36:05)
(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
@ber_t - The upside to adding it to AUR is if/when you release any modifications to the script, all users will get a copy on their next update.
Last edited by steve___ (2010-08-12 13:12:23)
Offline
@ber_t, I uploaded my PKGBUILD to the AUR, but I'm not I should've called it ...-git. Anyway, I hope you only push stable versions to the master branch.
Offline
@ber_t - The upside to adding it to AUR is if/when you release any modifications to the script, all user will get a copy on their next update.
You're absolutely right! I'll write/upload it in the next few hours...
Offline
@ber_t, I uploaded my PKGBUILD to the AUR, but I'm not I should've called it ...-git. Anyway, I hope you only push stable versions to the master branch.
Argh, parallel posting...
Thank you, but I may upload one for myself. I plan to use version tags on the master branch. I will also bundle the whole set (currently two, more work in progress) of the urxvt-perls repository, because tags only make sense this way.
Please also notice that url-select does not require perl-clipboard.
Offline
dawn wrote:@ber_t, I uploaded my PKGBUILD to the AUR, but I'm not I should've called it ...-git. Anyway, I hope you only push stable versions to the master branch.
Argh, parallel posting...
Thank you, but I may upload one for myself. I plan to use version tags on the master branch. I will also bundle the whole set (currently two, more work in progress) of the urxvt-perls repository, because tags only make sense this way.
Please also notice that url-select does not require perl-clipboard.
Yeah wasn't sure about perl-clipboard. Should've tested it. I'll find a way to remove mine, then.
EDIT: or maybe if you'd like to keep that name, I'll disown it and you can maintain it.
Last edited by dawn (2010-08-12 13:26:28)
Offline
EDIT: or maybe if you'd like to keep that name, I'll disown it and you can maintain it.
You could also keep your version online. I will not use the -git suffix because I will use only the tagged and thus stable versions, whereas your PKGBUILD uses the current master ref.
Last edited by ber_t (2010-08-12 13:50:34)
Offline
Nice script, thank you, but there is a problem: while scrolling through links using j and k it also passes those characters (allthough you don't see that while using them). So, using urxvt, tmux and weechat, if I highlight an url and hit enter, it opens the website but also enters j's and/or k's into the chatroom. The same in the shell, where it results in 'command not found'. I hope you can fix that.
Offline
Finally, I've uploaded my own PKGBUILD. Turns out there is a Download-Section on GitHub, I've never seen before, which renders the usage of tags unnecessary and allows to package only parts of the repo.
Offline
but there is a problem: while scrolling through links using j and k it also passes those characters (allthough you don't see that while using them).
I could not confirm this. I've had this problems in the past but one of the last commits should fix that. Did you accidentally download an older version?
Offline
egan wrote:It would be nice if you could add a general copy mode too. It's a shame that you have to run a shell inside of a tmuxer to get what I consider to be an integral function all terminals need: marking and yanking text. Really URLs are just a subset of that.
I already thought of that, too. But personally I think that the mouse is much more elegent for selecting text. But I'll try to implement this just for the fun of it -- it shouldn't be that hard.
egan wrote:EDIT: After trying to test this, I haven't gotten it to work once unfortunately. It works with urxvtc right?
Yes, I've just checked this!
Well some of us don't like the mouse...
I will look into it some more to see if I can get it to work.
Offline
I just installed on my system. It works for urxvt/urxvtc (you don't need to restart urxvtd, just open a new window).
I think the greatest thing of it is it won't interrupt when I try to open a link from Vim, the middle mouse button will paste stuff from clipboard into my text. This url-select won't have such problem.
Offline
VCoolio wrote:but there is a problem: while scrolling through links using j and k it also passes those characters (allthough you don't see that while using them).
I could not confirm this. I've had this problems in the past but one of the last commits should fix that. Did you accidentally download an older version?
No, I have the latest here 13/08 17:00 CET. Does it matter that I have perl 5.12.1-1? Also I manually compiled urxvt 9.07 to enable something I forgot.
Edit: strange thing: the j's and k's need only one backspace strike to delete them all.
Last edited by VCoolio (2010-08-13 15:09:06)
Offline
No, I have the latest here 13/08 17:00 CET. Does it matter that I have perl 5.12.1-1? Also I manually compiled urxvt 9.07 to enable something I forgot.
Edit: strange thing: the j's and k's need only one backspace strike to delete them all.
Did you rebuild your urxvt after the perl 5.12.1 update? See this for more information: http://bugs.archlinux.org/task/20352
Offline
Updated to version 1.1
Pressing an unused key does not cause scrolling to the end of the buffer anymore.
Offline
Did you rebuild your urxvt after the perl 5.12.1 update? See this for more information: http://bugs.archlinux.org/task/20352
Ah, that's probably it, should have thought of that. Will try that soon; if you don't hear from me anymore you have a happy customer. Thanks.
Offline
I've updated the wiki page and replaced mark-yank-urls with urxvt-url-select.
http://wiki.archlinux.org/index.php/Rxv … elessly.29
I'll keep the my mark-yank-urls pkg in the AUR just incase anyone still wants to use that one.
EDIT: Almost forgot to mention. I found you have to have your mouse over the terminal window in order to enter selection mode (at least this is so with xmonad WM), I've added this as a note on the wiki. The original mark-yank-urls also suffered from this problem.
Last edited by StephenB (2010-08-14 21:41:19)
Offline
Are you sure that that isn't just because of sloppy focuse, i.e. Focus-follows-mouse, so the urxvt has to have focus?
Ogion
(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
Are you sure that that isn't just because of sloppy focuse, i.e. Focus-follows-mouse, so the urxvt has to have focus?
Very sure. My xmonad draws a large yellow box around the window with focus (so that I can't get confused which one it is). So, if my mouse is over Firefox, and urxvt has focus (that's where my keyboard input goes), then if I press Alt+U, nothing happens. But if I move my mouse over urxvt, then it works. Maybe it is just xmonad being strange, if no one else has this problem?
Offline
Are you sure that that isn't just because of sloppy focuse, i.e. Focus-follows-mouse, so the urxvt has to have focus?
Very sure. My xmonad draws a large yellow box around the window with focus (so that I can't get confused which one it is). So, if my mouse is over Firefox, and urxvt has focus (that's where my keyboard input goes), then if I press Alt+U, nothing happens. But if I move my mouse over urxvt, then it works. Maybe it is just xmonad being strange, if no one else has this problem?
For me it works as expected in dwm using sloppy-focus. The selection mode is activated when the window has the focus regardless of the mouse cursor position.
Offline
Well for me in i3 it works with the mouse elsewhere too. Like i would move the mouse to another window, get focus back to my urxvtc by keyboard command and then alt-u works.
Ogion
(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