SAS 9.1 Companion For Unix Enivronments

Techniques for Customizing Your Key Definitions

There are four ways to customize your key definitions:

You can define most of the keys on your keyboard. However, a few keys have dedicated functions that are associated with them. For example, the mouse buttons are dedicated to the cursor and cut-and-paste operations and are not available for user customization.

Defining Key Translations

What is a Key Translation?

Key customization for the X Window System consists of defining a key sequence and an action to be executed when that key sequence is typed on the keyboard. This is known as binding keys to actions ; together they are referred to as a translation .

What is the SAS.keyboardTranslations Resource?

The SAS.keyboardTranslations resource specifies the set of key bindings that SAS uses in all SAS windows. The default value for the SAS.keyboardTranslations resource is determined at run time based on the vendor identification string reported by the X server that you are using as the display. These defaults are listed in the files contained in !SASROOT/X11/resource_files . To modify the default bindings supplied by SAS, you must modify the keyboardTranslations resource.

Note  

The X Toolkit Intrinsics translations specified in this resource apply to both the user area and the command line of all SAS windows that are affected by this resource. This resource does not affect windows that are controlled by Motif interface resources, such as the Command window, the Open or Import dialog boxes, and some other pull-down menu dialog boxes.

Steps for Creating a Key Definition

To create a key definition, follow these steps:

  1. Determine the keysyms for the keys that you want to define. Keysyms are the symbols recognized by the X Window System for each key on a keyboard. See "Determining Keysyms" on page 75 for more information.

  2. Modify/add the SAS.keyboardTranslations resource in your resource file to include the definitions of the keys that you want to define. Use a keyboard action routine to define which action you want the key to perform. The definition in the right column in the KEYS window will no longer control the function of any keys that are defined with a keyboard action routine other than sas-function-key . The definitions of those keys in the KEYS window become labels that have no effect. See "Syntax of the SAS.keyboardTranslations Resource" on page 75 for more information.

  3. Modify/add the SAS.keysWindowLabels resource in your resource file. The SAS.keysWindowLabels resource specifies the set of valid labels that will appear in the SAS KEYS window. Modify this resource only if you want to add new labels or modify existing labels in the left column in the KEYS window.

    The SAS.keysWindowLabels resource defines only the mnemonics used in the KEYS window. For a specific key to perform an action, you must specify a SAS.keyboardTranslations definition for the key. See "Syntax of the SAS.keysWindowLabels Resource" on page 76 for more information.

  4. Start a SAS session and open the KEYS window.

  5. In the right-hand column in the KEYS window, type a command name or other description of each key that you have defined.

See "Examples: Defining Keys Using SAS Resources" on page 80 for examples of key definitions.

Determining Keysyms

You can use the xev utility to determine the keysyms associated with the keys on your keyboard. xev is distributed with most UNIX operating systems, but if xev is not installed on your operating system, contact your system administrator for information about other methods that are available in your UNIX environment.

xev prints a message for each X event that occurs. The KeyPress event specifies the keysym for each key that is pressed.

  1. Start xev on the X server for which you want to define keys. The xev client displays a small Event Tester window that lists the X events that occur. (The xev client generates a large amount of output, so you might want to save the output to a file for later review. You can issue the UNIX script command to save the output to a file.)

  2. Give keyboard focus to the Event Tester window by clicking the mouse pointer on the window, if necessary.

  3. Press the key that you want to define, and watch for the KeyPress event to be listed. The listing has a number of items that are separated by commas. One of the fields in the KeyPress event lists the keysym name that is associated with the key that was pressed.

    For example, when the 0 key on the keypad of an HP 9000/700 keyboard is pressed, it generates the following output:

    KeyPress event, serial 14, synthetic NO, window 0x4400001,root 0x23, subw 0x4400002, time 507920400, (54,37),root:(67,66), state 0x0, keycode 30 (keysym 0xffb0, KP_0), same_screen YES, XLookupString gives 1 characters: "0"

    In this example, the keysym name is KP_0 .

Note  

SAS defines a set of virtual keysyms with the SAS.defaultVirtualBindings resource. Virtual keysyms all begin with osf, such as osfPageDown, osfClear, and osfPrimaryPaste. If you remap these virtual bindings instead of using the defaults supplied by SAS, you might get unexpected results. If you specify a key translation that does not work, you might be trying to redefine a key that is bound to a virtual keysym. In this case, you must specify the virtual keysym in the SAS.keyboardTranslations resource instead of the keysym displayed by xev . To determine the virtual keysym that is bound to a key, you can start the Resource Helper, select Keys , and press the key or key combination that you want to define. Resource Helper will display the virtual keysym name. You can also refer to the key definition files in /Xll/resource_files in the directory where SAS is installed ( !SASROOT ) and to the man pages for VirtualBinding or xmbind.

Syntax of the SAS.keyboardTranslations Resource

Note  

Most SAS documentation uses angle brackets (<>) to indicate optional syntax. However, in this topic, optional syntax is shown with square brackets ([]). The angle brackets that are shown in this topic are part of the syntax and should be entered exactly as shown.

The syntax of the SAS.keyboardTranslations resource is

SAS.keyboardTranslations : #override \

[ modifier ] <Key> keysym : action-routine \n\

[ modifier ] <Key> keysym : action-routine

#override

modifier

<Key>

keysym

action-routine

\n

\

Note  

SAS does not prevent you from specifying invalid keys in the SAS.keyboardTranslations resource. In some cases, invalid keys will produce warnings in the shell window.

Syntax of the SAS.keysWindowLabels Resource

Note  

The square brackets ([]) in the following syntax indicate that the (InternalKeyName) is optional.

The syntax of the SAS.keysWindowLabels resource is

SAS.keyWindowLabels :\

KeyWindowLabel [( InternalKeyName )] \n\

KeyWindowLabel [( InternalKeyName )]

KeyWindowLabel

InternalKeyName

\n and \

SAS Keyboard Action Names

Note  

Most SAS documentation uses angle brackets (<>) to indicate optional syntax. However, in this topic optional syntax is shown with square brackets ([]). The angle brackets that are shown in this topic are part of the syntax and should be entered exactly as shown.

SAS declares a set of keyboard actions during X initialization. You can think of these keyboard actions as simple functions. When the actions are executed, they act on the window that currently has keyboard input focus.

The following list of keyboard actions represents action routines registered by the Motif interface for use with X toolkit keyboard event translations.

sas-cursor-down()

sas-cursor-left()

sas-cursor-right()

sas-cursor-up()

sas-delete()

sas-delete-begin()

sas-delete-char()

sas-delete-end()

sas-delete-prev-chr()

sas-delete-prev-word()

sas-delete-word()

sas-do-command()

sas-function-key(" InternalKeyName ")

sas-home-cursor()

sas-insert-char([" InsertionString "])

sas-kp-application()

sas-kp-numeric()

sas-move-begin()

sas-move-end()

sas-new-line()

sas-next-field()

sas-next-word()

sas-page-down()

sas-page-end()

sas-page-top()

sas-page-up()

sas-prev-field()

sas-prev-word()

sas-to-bottom()

sas-to-top()

sas-toggle-insert()

sas-xattr-key(< KeyType >[,< KeyParam >])

Examples: Defining Keys using SAS Resources

Note  

Most SAS documentation uses angle brackets (<>) to indicate optional syntax. However, in these examples, optional syntax is shown with square brackets ([]). The angle brackets that are shown in these examples are part of the syntax and should be entered exactly as shown.

In the following example, the sas-do-command action routine specifies that the COMMAND command is to override any existing definition for KP_0 .

SAS.keyboardTranslations: #override \n\ None<Key>KP_0: sas-do-command(COMMAND)

All other keys retain their current definitions.

The following example binds the key sequence CTRL-K to the KEYS command and specifies that CTRL-D deletes the character under the cursor. Commands entered in the KEYS window for CTRL-K and CTRL-D will have no effect.

SAS.keyboardTranslations: #override\ Ctrl<Key>k: sas-do-command(keys)\n\ Ctrl<Key>d: sas-delete-char()

The following example specifies that the key associated with the keysym hpClearLine performs the command entered beside the MyClrLn label in the KEYS window.

SAS.keyboardTranslations: #override \ <Key>hpClearLine : sas-function-key("ClearLn") SAS.keysWindowLabels: MyClrLn(ClearLn)

The character string that appears inside the parentheses in the SAS.keysWindowLabels resource must match the string entered as the parameter to the sas-function-key routine. The label ( MyClrLn ) can be any character string, and the keysym hpClearLine must be a valid keysym for your keyboard.

[1] For information on the #augment and #replace directives, refer to the documentation for the X Window System.

Категории