Unix Power ToolsUnix Power ToolsSearch this book

5.14. Defining What Makes Up a Word for Selection Purposes

You probably already know how to select text (Section 5.13) in an xterm, and you've probably discovered that double-clicking (Section 5.13 will select the entire word around the pointer. What you may not know is that it is possible to change what defines a "word."

xterm maintains a table of all the ASCII characters and their character classes. Any sequence of adjacent characters of the same class is treated as a word. Numbers, letters, and the underscore are in class 48 (which is the ASCII code for the character 0) and SPACE and TAB are in class 32 (the ASCII code for SPACE). By default, all the other characters are in classes by themselves.

For Unix users, this isn't the most useful default; it would be better if you could select filenames, email addresses, URLs, resource specifications, etc. as single words even though they often contain punctuation characters.

You can modify the character class table with xterm's charClass resource variable (Section 6.3). The value this resource accepts is a comma-separated list; each item on the list is an ASCII character code or range of characters, followed by a colon, followed by the character class to which the character should be added. I set the charClass resource as follows:

xterm*charClass: 33:48, 37:48, 42:48, 45-47:48, 63-64:48, 126:48

This tells xterm to treat !, %, *, -, ., /, ?, @, and ~ as characters of the same class as numbers and letters. You may also want to treat : as a member of this class, for URLs; in that case, use the following charClass string:

xterm*charClass: 33:48, 37:48, 42:48, 45-47:48, 58:48, 63-64:48, 126:48

--DJF and SJC



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.