The DEFINE_KEY procedure programs the keyboard function Key with the string Value , or with one of the actions specified by the available keywords.
DEFINE_KEY is primarily intended for use with IDL's command line interface (available under UNIX and VMS). IDL's graphical interface (IDLDE), which is available under all operating systems supported by IDL, uses different system-specific mechanisms.
A scalar string containing the name of a function key to be programmed. IDL maintains an internal list of function key names and the escape sequences they send.
Recall the first line containing text . If text is blank, recall the previous line |
|
In IDL for Windows, three special variables can be used to expand the current mouse selection, the current line, or the current filename into the output of defined keys.
Currently-selected text from an IDL Output Log or Editor window |
For example, to define F2 as a key that executes an IDL PRINT command with the current mouse selection as its argument, use the command:
DEFINE_KEY, 'F2', 'PRINT, "%S"'
Dragging the mouse over any text in an IDL Editor or Output Log window and pressing F1 causes the selected text to be printed. The
%l
and
%f
variables can be used in a similar fashion.
Set this keyword to program Key to prompt the user for a string, and then search the saved command buffer for the most recently issued command that contains that string. If a match is found, the matching command becomes the current command, otherwise the last command entered is used. Under Unix, the default match key is the up caret "^" key when pressed in column 1. Under VMS, the default match key is PF1.
Set this keyword to program Key to move the current cursor position left one character.
Set this keyword to indicate that Key is the name of a control key. The default is for Key to define a function key escape sequence. To view the names used by IDL for the control keys, type the following at the Command Input Line:
Set this keyword to program Key to delete the character directly underneath the cursor.
Set this keyword to program Key to delete from the cursor position to the end of the line.
Set this keyword to program Key to exit IDL if the current line is empty, and to end the current input line if the current line is not empty.
Set this keyword to program Key to enter the current line (i.e., the action normally performed by the "Return" key).
A scalar string that specifies the escape sequence that corresponds to Key . See Defining New Function Keys for further details.
Set this keyword to program Key to move the current cursor position right one character.
Set this keyword to program Key to toggle between "insert" and "overstrike" mode. When characters are typed into the middle of a line, insert mode causes the trailing characters to be moved to the right to make room for the new ones. Overstrike mode causes the new characters to overwrite the existing ones.
Set this keyword to program Key to move forward one command in the saved command buffer and make that command the current one.
Set this keyword to program Key to move back one command in the saved command buffer and make that command the current one.
Set this keyword to program Key to prompt the user for a command number. The saved command corresponding to the entered number becomes the current command. In order to view the currently saved commands and the number currently associated with each, enter the IDL command:
IDL> ; User presses key tied to RECALL.
Recall Line #: 2 ; Line 2 is requested.
IDL> PRINT, 1 ; Saved command 2 is recalled.
Recall Line #: ; User presses return.
Under VMS, IDL uses the SMG screen management package, which ensures that IDL command editing behaves in the standard VMS way. Hence, it is not possible to use a key SMG does not understand.
Under Unix, IDL can handle arbitrary function keys. When adding a definition for a function key that is not built into IDL's default list of recognized keys, you must use the ESCAPE keyword to specify the escape sequence it sends. For example, to add a function key named "HELP" which sends the escape sequence <Escape>[28~, use the command:
DEFINE_KEY, 'HELP', ESCAPE = '\033[28~'
This command adds the HELP key to the list of keys understood by IDL. Since only the key name and escape sequence were specified, pressing the HELP key will do nothing. The Value argument, or one of the keywords provided to specify command line editing functions, could have been included in the above statement to program it with an action.
Once a key is defined using the ESCAPE keyword, it is contained in the internal list of function keys. It can then be subsequently redefined without specifying the escape sequence.
It is convenient to include commonly used key definitions in a startup file, so that they will always be available. See Startup File .
Usually, the SETUP_KEYS procedure is used to define the function keys found on the keyboard, so it is not necessary to specify the ESCAPE keyword. For example, to program key "F2" on a Sun keyboard to redraw the current line:
The CONTROL keyword alters the action that IDL takes when it sees the specified characters defining the control keys. IDL may not be able to alter the behavior of some control characters. For example, Ctrl+S and Ctrl+Q are usually reserved by the operating system for flow control . Similarly, Ctrl+Z is usually The UNIX suspend character.
To print a reminder of how to exit IDL properly, type the following:
DEFINE_KEY, /CONTROL, '^D', "print, 'Enter EXIT to quit IDL'", $