[Previous] [Contents] [Next]

Translate (t)

translate a key on input

Syntax:

t character replacement_text

t character

t ? character

T character replacement_text

T character

T ? character

Description:

This command translates an input character into a string of characters. It is this command which makes the macro definition of the function and cursor keys possible.

The first form translates the indicated character character into the string of characters replacement_text whenever that character is typed. The second form removes any translation in effect.

The third form will display the current translation of the indicated character on the command line allowing you to modify it if desired.

The definition of character may be a \hh sequence. If you wish to enter the character to be translated directly (you may not know its hexadecimal value) you should precede the character with the "-" key on the numeric keypad. This suppresses any translation currently in effect for the key. It is recommended that you not translate the "-" or "\" keys. You should keep in mind that one level of backslash escapes is stripped off during the translate command. This unfortunately means that if you wanted to match a backslash in a substitute command, you would have to type four of them to get one.

Entering this:

t  \84  \ffs/\\\\/?/\0a

would save the following for the definition of F4.

\ffs/\\/?/\0a

The Substitute command would turn the \\ into a single \ when the macro was executed.

If you use the little t command, then recursive definitions are allowed. If you use a capital T, then a macro within a macro aren't expanded.

The special character \ff (see section on special characters) should be prefixed to any translation that you wish executed as a command. It causes all characters up to the next record separator \0a to be collected (no echo) in a hidden buffer and then executed as a command. Any current text on the command line is not affected. This allows you to define command translations which are independent of where your active cursor is. For example:

t  \01  \ff/procedure/\0a

would cause a Ctrl-a to be translated into a scan for the pattern /procedure/. Note that the \0a was necessary to force execution. Without it you would have to type the carriage return key yourself at the keyboard. If we were to omit the \ff, then the text would be entered at the active cursor which would probably be ok if you were on the command line, but unpleasant if you were in the text area.

As a further example, to translate the F1 key into the string "QNX Software Systems" you would enter the command:

t  \81  QNX Software Systems

Note that we did not prefix the replacement text with a \ff, nor did we end it with a \0a. Anytime you now type an F1, the string "QNX Software Systems" will be entered at the active cursor, exactly as if you had typed the characters on the keyboard yourself.

Current line:

Not affected.

Condition register:

Not affected.


[Previous] [Contents] [Next]