procedure LoadFromFile(const aFileName : string);
Loads a set of keyboard mappings from a text file.
The name of the file is given by aFileName.
The file is a text file in a particular format. LoadFromFile will follow these rules when reading the file:
·Any completely blank line is ignored.
·Any line starting with a * is a comment and is skipped.
·Any line starting with at least one space is a detail line. A detail line consists of two words, where a word is a set of up to 63 characters without an embedded space and is case sensitive. Words are separated by spaces (not tab characters). Any other character appearing after the two words is taken to be a comment and is skipped.
·Any detail line that cannot be parsed is simply ignored.
·Any line that doesn't match the above is skipped.
The words in a detail line have some formatting associated with them. The emulator imposes this formatting so that it can generate the correct key strings when the user presses a key. The LoadFromFile method does not validate these formats in any way.
"\e" in a word means the Escape character.
"\xnn", where nn is a hex number, represents that ASCII character.
If you want to specify shift keys with virtual key names, use the mnemonics "shift", "ctrl", and "alt". Combine them with the virtual key name using the + sign. If you want to specify more than one shifted key, make sure that they are in the order "shift", "ctrl", "alt".
An example of a virtual key code to virtual key name mapping would be:
* This is the definition of F1
\x1030 Key_F1
An example of a defining the sequence to be sent by a terminal key is:
* This is the definition of PF1 on a VT100
* (it sends <Esc>OP)
DEC_PF1 \eOP
An example of mapping Alt+F1 so that it acts like the PF1 key on a VT100 is:
* Map Alt+F1 to PF1
alt+Key_F1 DEC_PF1
Following is an explanation of how the emulator would use these mappings. The user presses Alt+F1. The emulator would convert the key code returned by the operating system (an integer equal to 1030 hex) into a string ("\x1030"). It would then lookup this string in the keyboard mapping object and get the value "Key_F1" back. It then prefixes the "alt" keyword to this value to give "alt+VK_F1" and looks this up. This returns the value "DEC_PF1". This is in turn looked up to return the value "\eOP". The emulator then interprets this string as <Esc>OP in order to send the correct sequence to the host. If a lookup fails at any stage, the keystroke is assumed to be unmapped. If the emulator cannot interpret the final control sequence string, it will just send it as is.
Please see AXKEYVT1.TXT for a complete set of mappings that define one way of mapping the VT100 keys onto the PC keyboard.
The only errors than can occur with LoadFromFile are file I/O errors. Internally LoadFromFile uses a string list (TStringList) to read the entire file into memory and so any exceptions raised will be those raised by this class.
See also: Add