OpenWindows User's Guide

Customizing Your Text Editor

There are two files used by the Text Editor that you can modify to customize the Extras submenu of the Text Pane pop-up menu and to specify function key mappings. This section describes these two files.

The .text_extras_menu File

You can customize the Extras menu to include your own commands by modifying the file .text_extras_menu. By default (and depending on how your system is configured), the Text Editor uses the information found in the file /usr/openwin/lib/locale/<locale>xview/.text_extras_menu. <locale> is a subdirectory that contains locale specific text files. The default is "C", but may vary depending on the country locale. You can create your own copy of this file and tell the Text Editor to use it instead of the default in either of the following two ways:

The standard Extras menu file is /usr/openwin/lib/locale/C/xview/.text_extras_menu and is shown in Figure 3-13. It will give you ideas about how to implement your own extras menu file. Once you've created a custom file and indicated where to find it using one of the previous methods, you can make changes to the file and see them immediately implemented in the Extras menu. These changes also affect other text panes in DeskSet applications, such as the Mail Tool Compose window.

Figure 3-13 Extras Menu File in /usr/lib/.text_extras_menu


The name of each Extras menu item is surrounded by double quotation marks. Each submenu begins with a MENU statement and ends with an END statement.

To include a backslash (\) character in the .text_extras_menu file--as in the troff inline font specifications \fB and \fP--you need to use four backslash characters; for example:

insert_brackets \\\\fB \\\\fP

Alternatively, you can use quotes in place of one pair of brackets; for example:

insert_brackets "\\fB" "\\fP"

The .textswrc File

You can associate filters (programs or routines) with unused function keys by modifying your own copy of the file .textswrc. When a text selection has been made and a function key pressed, the selected text is piped through the filter assigned to that key. The output is then piped back into the text at the caret, replacing the text that was selected.

If you want to specify your own set of bindings of filter keys to function keys, you must copy the file /usr/lib/.textswrc to a file called .textswrc in your home directory. The Text Editor reads the file .textswrc from your home directory, if the file exists.

Format of the .textswrc File

List the sample file /usr/lib/.textswrc to see an example of filters used with a right-handed keyboard. You can copy this file into your home directory, then modify it by adding filter bindings to unused function keys.

Here is the basic format of each .textswrc file entry:

key-name      FILTER


A function is assigned to one of the function keys by including a statement like the following in your .textswrc file:

* Note that:
*  insert_brackets  /* */ does NOT work
*   double quotes are needed 

insert_brackets "/* " " */"

This example shows how to include C language comment markers around a piece of text. You could enter this example into your .textswrc file, and save the file. Then, to use this added function, start up a new Text Editor application. Changes to your .textswrc file are only effective when you bring up a new Text Editor. Then select the text and press the key. The text will be replaced with a copy of itself surrounded with "/*" and "*/". Note the C-like syntax of comments in the .textswrc file.

When defining a filter in the .textswrc file, remember that the filter must appear in a directory accessible by your search path. If the command is not found, or if there is some other failure in the invocation of the filter, no change occurs in the document.