September 3rd, 2011 7:24:07 pm pst by Sterling Camden
Antoine Amarilli emailed me to suggest an enhancement to my url-picker extension for urxvt: number the URLs in reverse order, so that the most recently displayed URL will always be number 1. His rationale is that in a terminal window, you’re usually focused on what has been displayed last, and being able to use the same set of keystrokes to launch the most recently seen URL allows the action to become somewhat automatic.
I liked Antoine’s suggestion, but I decided not to change the default behavior. I, for one, find the ascending order makes more sense when viewing my feeds in mutt, because my rss-to-email mechanism adds the item’s web link as a custom header, so it’s always the first link on the page. So, I decided to add a resource to control the order. If you want descending numbering, add this to your .Xdefaults (or other resource source):
Now you can always launch the last one with the same finger!
Posted in Perl, Unix | 2 Comments » RSS 2.0
July 3rd, 2011 5:24:16 pm pst by Sterling Camden
Craig Balding emailed me about a “feature” that had already plagued me for some time in my url-picker extension for urxvt. Whenever a URL wrapped to a second line, url-picker would only see the portion on the first line. In many cases this only truncated useless parameters that you probably didn’t want to include anyway (I’m, looking at you, Facebook). But often some meaningful bits got truncated, forcing the user to resort to copy/paste. Not good.
In order to fix this, I had to change the way url-picker loops through the text. Instead of looking at the text row by row, I now gather all of the text to be considered into a single string in which to search for URLs. Because we’re dealing with Unicode here (that’s one of the reasons for using urxvt to begin with) I can’t calculate row and column by performing any clever math on the resulting offset. So instead, I build a hash of row => [start,end] and then search the hash for the offset of any URLs I find. Seems to work (after I refreshed my memory YET AGAIN on the syntax for Perl array references within hashes), but let me know if you encounter any difficulties.
Now you can pick and launch even bigger ones!
Of course, you have to make sure that your terminal display doesn’t interrupt the URL in other ways. For example, for mutt you’d want to have the following in your .muttrc file:
Otherwise, you’ll get a “+” embedded at the beginning of each wrapped line.
Posted in Perl, Unix | No Comments » RSS 2.0
November 26th, 2010 2:39:29 pm pst by Sterling Camden
I’ve made the following enhancements to my keyboard-centric URL pick-and-launch extension for urxvt. Scroll down for the download links.
Status message on launch
The url-picker extension has always launched the URL as soon as it was uniquely qualified, in order to save keystrokes. Depending on the browser, however, it might take a few seconds for the user to see that the launch has occurred. So, I added a status message across the bottom line of the terminal window prior to launching the URL. This message remains visible for five seconds. See below for controlling its renditions.
Restrict search to selected text
If part of the text of the window is visibly marked for selection, then url-picker will now restrict its search for URLs to that text. Otherwise, url-picker will use the entire visible portion of the terminal window. See below for a related correction.
Correction to search of scrolled text
I corrected a flaw in the URL search when the user has scrolled the terminal window to make previously invisible text visible again. That region is now searched and labeled properly.
Ability to override colors
I’ve added some X resources for controlling the colors used in the display of url-picker’s visible elements. Each of these takes the form:
where element is the name of the url-picker element to control. These are:
- input – the text (numbers) typed by the user
- label – the numbered labels placed over each URL in the window
- prompt – the “Follow:” prompt
- status – any status or error messages
You must specify the colors using a urxvt color index, as described in the urxvt(1) man page under COLORS AND GRAPHICS.
Have fun pickin’ and launchin’!
Posted in Perl, Unix | 1 Comment » RSS 2.0