Saturday July 15, 2006 at 14:44
Subject: xterm Regex Matching for Cut Selection.
Keywords:
Regex, Technical, X-Windows
Posted by: Sean Reifschneider
I know a lot of people prefer *term or *onsole to xterm, but I'm a
pretty die-hard xterm user. A while ago I noticed that an Ubuntu system I
was using had the double-click to select text acting slightly differently
than I was used to. I dug a little deeper and found that you could specify
a "charClass" setting to group characters that would be considered similar
and grouped when you double-clicked to select a word. Last week I found an
even cooler option...
xterm has resources for "on2Clicks" through "on5Clicks". These can be
set to various values, one of which is "regex". That's right, you can use
a regex to determine what sorts of things are matched, for more and more
clicks.
I'm running pretty simple values of:
(Post Reply)
xterm*on2Clicks: regex [^/@ \n]+ xterm*on3Clicks: regex [^ \n]+ xterm*on4Clicks: regex [^#$]+ xterm*on5Clicks: lineIn other words, a double click will allow me to select the last component of a path, the local or domain part of an e-mail address, or a simple word. 3 clicks will get anything up separated by white-space, and 4 clicks will get everything up to my prompt, including tailing newline. 4 is one I'm really looking forward to. Finally, 5 clicks will snag the whole line. If you want to do this, you need to put the above into your ~/.Xdefaults file and get X to pick up the changes. Probably easiest is to log out and back in. You can write these lines to a file and do "xrdb -merge <filename", then start up a new xterm and try it out. It will not impact the currently running xterms (they've already loaded their resources).
(Post Reply)
| Comment |
Kai Sattler Subject: xterm Regex Matching for Cut Selection |
This is a very neat feature! Thanks for posting your resource settings.
I tried to remove the "\n"s in order to avoid that RETURN is included into the selection, but it doesn't seem to work. As soon as the last non-whitespace character is 'detected' through the regex and included into the selection, "new line" is also selected. This makes that in such cases RETURN is pasted, too. If pasted into the shell in an xterm, the pasted text would be 'executed' imediately.
I wonder whether you observe this behaviour, too.
| Comment |
Author:
Sean Reifschneider Subject: I have also noticed this. |
Yes, I have also noticed this and tried things like you have to restrict the match for the end of the line. I sometimes like matching the newline at the end, sometimes don't, but mostly would just like the regex to treat the end of line in a way that I can control.
After some looking, I've come to the conclusion that this is a bug in xterm's regex handling. I haven't had time to dig into it any further though. I'm reporting it to the maintainer right now though.
Sean
| Comment |
Pete Subject: xterm*on?Clicks: |
I modified the last two. On 4 clicks goes till the end of line with no white spaces. On 5 clicks; it selects the entire page; including scrolled lines.
xterm*on2Clicks: regex [^ \n]+ xterm*on3Clicks: line xterm*on4Clicks: regex [^*\n]+ xterm*on5Clicks:allPS: Sorry; I am several years late for a reply. Next stop; back to the future. :-)