WebTerm Terminal Emulator and Telnet Client

Implementation Details


Java classes that implement a low-level terminal screen handler, a VT200/XTerm/VT100/VT52 terminal emulator, and a Telnet session client. These can be used together to form a complete TELNET applet.

Parameters

The "WebTerm.class" applet recognizes the following parameters:

HOST

Name of initial host machine. If not supplied, it is the machine the applet was retrieved from.

PORT

Number of port for connection. If not suppled, it is 23, the standard Telnet port.

FONTSIZE

Point size of font to use as terminal's screen text. If not supplied, it is the size if the default Component font.

REGISTER

Name to register under which to terminal, in a class registry. By sending a "send" command to a WebTerm applet through this registry, other applets can insert data into the terminal's input stream as if the user had directly typed it.

PROMPT#, REPLY#, ENDPROMPTS#

A set of parameters for specifying automatic replies to incoming text. The '#' represents the prompt number -- prompts should start at 1, and be consecutively numbered. 'PROMPT' is the trigger text, 'REPLY' is the text to send when the trigger is encountered, and if 'ENDPROMPTS' is true then this will turn off all prompts for the rest of the telnet session.

The supplied strings may contain standard Java escape sequences, including \n, \r, \t, \b, \f, \###, \u####, and \x##.

FOREGROUND and BACKGROUND

Set the foreground and background colors, respectively, of the terminal. May be a standard Java color string or the word "default" for the system default colors; if not supplied, uses a black on light grey combination.

HISTORY

Set the number of lines in the history buffer. A value of zero means no history buffer, though this doesn't yet keep the scrollbar from being displayed. Note that each line in the buffer takes (6*cols) bytes, so be careful with how large you make it!

Features not yet implemented

Java classes

WebTerm

A full applet, which combines the below classes to provide an actual VT100 terminal emulator. It includes controls to select a host and port, opening and closing the network connection, bringing up an options window, and the actual terminal screen and scrollbar.

Telnet

Implements a complete Telnet session client. As far as we know, this client implements the Telnet protocol correctly, though fairly minimally; it supports the standard Telnet options TERMINAL TYPE and NAWS (the latter is used to communicate the terminal dimensions to the server), and partially supports BINARY, TERMINAL-SPEED, and NAOHTD. When connecting to a server, it always tries to turn on the server's ECHO option; if the server refuses, it echos characters back locally. This implementation was based on the March 1995 protocol standards.

The Telnet client communicates with the user through an instance of an Emulator class, from which it also receives information about the emulation name and terminal dimensions.

It also defines a private class, named PromptInfo. An instance of this class is made for each prompt argument, and is used to the state information needed to watch for that prompt.

Emulator

A generic base class for terminal emulations; this implements a set of methods that the terminal uses to send data to the Telnet session, and that the Telnet session uses to send data to the terminal.

EmulatorOptions

The emulation options control window, created by the "Options..." button. Allows the user to dynamically load emulators and set their emulation type.

VT200

A subclass of the Emulator that implements VT200, VT100, VT52, and XTerm control sequences. The following sequences are currently implemented:

ESC A      (VT52) Cursor up.
ESC B      (VT52) Cursor down.
ESC C      (VT52) Cursor right.
ESC D      Index (Cursor left in VT52 mode).
ESC E      Next line.
ESC H      Set tab stop (Cursor home in VT52 mode).
ESC I      Not a VT220 sequence (Reverse line feed in VT52 mode).
ESC J      (VT52) Erase to end of screen.
ESC K      Not a VT220 sequence (Erase to end of line VT52 mode).
ESC L      Not a VT220 sequence.
ESC M      Reverse index.
ESC N      SS2: Not yet implemented.
ESC O      SS3: Not yet implemented.
ESC P      Begin DCS.
ESC V      (VT52) Print cursor line.  Not implemented.
ESC W      (VT52) Print control.  Not implemented.
ESC X      (VT52) Print control.  Not implemented.
ESC Y      (VT52) Direct cursor address.
ESC Z      (VT52) Identify.
ESC c      Reset to initial state
ESC Spc    Enter ASCII mode.
ESC >      Normal keypad mode.
ESC =      Application keypad mode.
ESC 8      Restore cursor position.  (Doesn't yet restore modes.)
ESC 7      Save cursor position.  (Doesn't yet save modes.)
ESC [      Begin CSI.
ESC ]      Begin OSC (Print screen, unimplemented, in VT52 mode).
ESC ^      Begin PM.
ESC _      Begin APC (Exit autoprint, unimplemented, in VT52 mode).
ESC \      Terminate command data string.
ESC # 3    Double-height line (top).  Not implemented.
ESC # 4    Double-height line (bottom).  Not implemented.
ESC # 5    Single-width line.  Not implemented.
ESC # 6    Double-width line.  Not implemented.
ESC [ @    ICH: Insert blanks.
ESC [ A    CUU: Move cursor up.
ESC [ B    CUD: Move cursor down.
ESC [ C    CUF: Move cursor right.
ESC [ D    CUB: Move cursor left.
ESC [ E    CNL: Move to next line.
ESC [ F    CPL: Move to previous line.
ESC [ H    CUP: Set cursor position.
ESC [ I    CHT: Move to tabstop N.
ESC [ J    ED: Erase in display.
ESC [ K    EL: Erase in line.
ESC [ L    IL: Insert lines at cursor.
ESC [ M    DL: Delete lines at cursor.
ESC [ P    DCH: Delete character.
ESC [ X    ECH: Erase character.
ESC [ c    DA: Device attribute report.
ESC [ f    HVP: Set cursor position.
ESC [ g    TBC: Tabulation clear.
ESC [ h    Set mode.
           3    = line feed / new line
           ? 5  = ANSI / VT52
           ? 7  = smooth scroll on / off
           ? 8  = screen reverse / normal
           ? 9  = origin mode
           ? 10 = autowrap mode
           ? 15 = text cursor on / off
           (many other modes are recognized but not currently implemented.)
ESC [ l    Reset mode.
ESC [ m    SGR: Set graphics rendition.
           0  = plain
           1  = bold
           4  = underscore
           5  = italic (replaces the VT terminal's blinking mode)
           7  = inverse
           22 = bold off
           24 = underscore off
           25 = italic off
           27 = inverse off
           30-39 = set foreground color
           40-49 = set background color
ESC [ n    DSR: Device status report.
           5 = terminal status report
           6 = cursor position report
           ? 15 = printer status report
           ? 21 = report user defined keys locked / unlocked
ESC [ ! p  DECSTR: Soft reset.
ESC [ r    Set scroll region.
ESC [ ? r  (XTerm) Restore mode.
ESC [ ? s  (XTerm) Save mode.
ESC [ q    DECLL: Load LEDs
ESC [ x    DECREQTPARM: Request terminal parameters.
ESC [ y    DECTST: Invoke confidence tests.  (ESC [ 2 0 y is a reset.)

This implements the basic VT220 control sequences. The major missing functionality is: character set control, selective erase, user defined keys, and down-line loaded characters. It also does not yet report all of the important key and mouse events.

RubberTextField

A variation on the standard TextField that allows more control over its size and layout.

Terminal

The basic functionality of an ASCII terminal. Implements functions for writing text to the terminal, moving the cursor, scrolling regions of the screen, insert and deleting lines, and history. The class has a small amount of smarts for optimizing redrawing, but could use quite a bit more.

Implementation interfaces

Parameters

An interface used to hand the applet parameters to the Telnet and Terminal classes.


Back to WebTerm home page.
Back to NACSE home page.
Comments and questions to nacse-questions@nacse.org.