Terminal Emulation  
 

The Terminal Emulation control provides a virtual terminal interface for emulating an ANSI or DEC VT-220 compatible character-based terminal. It can be used in conjunction with the Telnet interface or the Remote Command interface to display the output of commands executed on a server. It can also be used independently of any other networking control, such as providing emulation services for a serial connection.

Display Management

The control provides a number of properties and methods to manage and update the virtual display. The most commonly used methods are:

BackColor
This property can be used to change the background color displayed by the virtual terminal.

ColorMap
This property array can be used to change the default colors which are used when escape sequences are used to change the foreground or background color of a character cell. In most cases the default color map will be appropriate, but applications can change the RGB values associated with an entry in the color map if needed. For example, the default value for the color gray is at position 8 in the color map index with an RGB value of 192,192,192. If you wanted to use a darker color, you could change the RGB value to 128,128,128

Emulation
This property specifies the type of emulation that will be performed by the control. The control is capable of emulating an ANSI console, a DEC VT-100 and DEC VT-220/320 terminal.

FontName
This property sets the name of the font which is used by the control to draw text on the display window. Note that there is also a Font property which returns a Font object for more control over the font used by the emulator. It is recommended that you only used fixed-width fonts such as Terminal or Courier New.

FontSize
This property sets the size of the font which is used by the control to draw text on the display window. Note that there is also a Font property which returns a Font object for more control over the font used by the emulator.

ForeColor
This property can be used to change the foreground color displayed by the virtual terminal.

Write
This is the most commonly used method of writing to the display. This method will automatically parse the data being written for escape sequences and update the display appropriately.

Refresh
Refresh the virtual display, updating the current cursor position and caret. The control will periodically refresh the display automatically based on its own internal state, but the application can call this if it wishes to force the display to refresh at that time.

Reset
This method can be used to reset the display window, the font being used and the size of the display. Note that resetting the display causes the contents of the display to be cleared.

Cursor Control

There are a number of properties and methods which enable an application to have direct control over cursor positioning, clearing the display and so on. In most cases these methods are called automatically by the control as the result of processing the escape sequences found in the data being written to the display. However, an application can choose to manage the display itself. One important thing to keep in mind is that the X,Y positions used by these properties and methods refer to the cursor position in the virtual display and correspond to columns and rows, not pixels.

There is also a slight difference in terminology that you should be aware of when reading the technical reference documentation. In Windows, the term "cursor" is typically used to refer to the mouse pointer, while "caret" is used to refer to the blinking marker that is displayed at the current position in the display. In the documentation for the emulator, the term "cursor" is used in the same way that it is used for character based terminals, as the marker for the current position in the display. Therefore, in terms of the control, you can think of the cursor and the caret as being synonymous.

CursorX
This property returns the current position of the cursor in the display, or can be used to change the current position. The current position is given in columns and indicates where the next text character will be displayed.

CursorY
This property returns the current position of the cursor in the display, or can be used to change the current position. The current position is given in rows and indicates where the next text character will be displayed.

Clear
This method clears the contents of the display. You can clear from the start of the display to the current cursor position, from the current position to the end of the display or the entire display.

DelLine
This method deletes the line at the current cursor position, shifting the remaining lines in the display up.

InsLine
This method inserts a blank line at the current cursor position, shifting the following lines down.

ScrollDown
This method scrolls the display down by one line.

ScrollUp
This method scrolls the display up by one line.

Function Key Mapping

Another aspect of terminal emulation is how function keys and other special keys are handled by the application. The emulation control can be used to convert Windows virtual key codes into the escape sequences that are generated by character based terminals.

KeyMap
This property array allows the application to define character sequences that should be mapped to special keys. When a special key is pressed in the emulation window and there is an entry for it in the key map, the KeyMapped event is fired. For example, if the user presses the F1 key on the keyboard, the control will translate that key code into the three characters escape sequence ESC O P (the ASCII codes 27, 79, 80). That sequence of characters should be sent to the server, which will recognize it as the F1 function key being pressed. It is important to note that the different emulation types have different key mappings. Therefore, the server must be set to recognize the same type of terminal that you are emulating. If you have the emulation set as VT-220 but the server thinks that you are emulating a VT-100, it will not recognize some of the escape sequences correctly.

KeyMapped
This event is generated when the user presses a special key while the emulation window has focus, and that key is mapped to a string using the KeyMap property array. Typically an application will use this event to send the mapped key escape sequence to a server, such as a Telnet server.