Angry Red Planet

Terminal Library








The ArpTerminal library contains various classes for implementing a terminal-style control with protocols for implementing add-on emulators and devices that are attached to it.


Overview

Most of the ArpTelnet classes are implemented in the ArpCommon class library. This library contains classes for the terminal, telnet client, VT200 emulator, add-on manager, and various other useful things. You will need the library distribution to rebuild the telnet application from its source; it should be available from the same place at which you got the application distribution.

Briefly, the most important classes that ArpTelnet uses in the library are:

Terminal Classes
ArpTerminalInterface
An abstract interface to a terminal-like device.
ArpCoreTerminal
The basic terminal implementation and view.
ArpTerminal
Based on ArpCoreTerminal, this adds cut&paste and emulation support.
ArpRemoteTerminal
A subclass of ArpTerminal that talks with a remote BMessenger. The message protocol it implements is defined in ArpTerminalMsg.h.
Emulation Classes
ArpEmulatorInterface
An abstract interface to the code that implements a particular emulator.
ArpEmulator
Auseful base class of a terminal emulator; it also implements a dumb emulation.
ArpVT200
An actual VT200/VT52/XTerm terminal emulation. Note that this class is not actually in the ArpTerminal library, but instead a part of the ArpTelnet distribution.
ArpEmulatorManager
Based on ArpAddonManager, this keeps track of all the terminal emulations that are available, both as add-ons and those that are statically linked to the application.
Telnet Classes
ArpTelnet
Implements the TELNET client protocol. The class understands the ArpTerminalMsg protocol, and can be attached to a ArpRemoteTerminal object to create a complete telnet client. Note that this class is actually implemented in the ArpNetwork library.

Architecture

There are two major pieces to the terminal architecture: the terminal classes implement the actual rendering and user interaction code of the terminal, while the emulator classes implement specific terminal emulations. Both of these class hierarchies are rooted with an abstract class, ArpTerminalInterface and ArpEmulatorInterface, respectively; the communication between the two sides of the terminal occurs only through these two interfaces.

The following figure shows these two class hierarchies, and which classes in each hierarchy work with the other. The hierarchies go from most basic (at the top) to the more fleshed out classes (at the bottom). Abstract interface classes are in *red*.

At the left are the terminal classes, and to the right are the emulator classes, located at the same level as the terminal class that "knows" about it. Thus ArpTerminal is the class that actually implements communication with the ArpEmulatorInterface class, and can be associated with an emulator to implement a complete terminal emulation. Similarily, ArpRemoteTerminal knows about ArpEmulatorManager, which is an aggregation of one ore more emulator interfaces. Thus ArpRemoteTerminal knows about a set of emulators, and can be asked to use a particular one of those.

+----------------------+
|*ArpTerminalInterface*|
+----------------------+
           ||
           \/
   +-----------------+
   | ArpCoreTerminal |
   +-----------------+
           ||
           \/                  ArpEmulatorAddon >-----\
     +-------------+       +----------------------+   |
     | ArpTerminal |. . . .|*ArpEmulatorInterface*|   |
     +-------------+       |----------------------+   |
           ||                         \/              |
           ||                    ArpEmulator          |   ArpMultiDir
           ||                         \/              |        \/
           ||                     ArpVT200            |  ArpAddonManager
           \/                                         V        \/
 +-------------------+                               +--------------------+
 | ArpRemoteTerminal |. . . . . . . . . . . . . . . .| ArpEmulatorManager |
 +-------------------+                               +--------------------+

Next is a diagram of the basic architecture, showing how instances of these classes work together and interact with the outside world. In general, it shows that the ArpEmulatorInterface collects data -- both coming from the user and from the remote device -- that it then transforms: input from the user becomes a character stream the remote device can understand, and the character stream from the remote device becomes the basic terminal operations needed to display it. The ArpEmulatorInterface then uses its ArpTerminalInterface to send the character stream to the remote device or execute the basic terminal operations, respectively.

(Although note that, since the ArpTerminal actually contains an ArpEmulator, to the external user this appears much simpler. In general, everything just attaches to the ArpTerminal, and data is then routed with its Emulator() through the system as shown here.)

    +-----------+ Draw(), etc. +--------------------------+
    |  SCREEN   |<=============|   ArpTerminalInterface   |
    +-----------+              +--------------------------+
                                /\   /\                 ||
                    TermSendTTY ||   || TermSendRemote  ||
                                ||   ||                 ||
+-----------+ EmulateToRemote +----------------------+  ||
| KEYBOARD  |================>| ArpEmulatorInterface |  || TermSendRemote
+-----------+                 +----------------------+  ||
                                         /\             ||
                            EmulateToTTY ||             ||
                                         ||             \/
                                       +-------------------+
                                       |  (Remote Device)  |
                                       +-------------------+
                                       .                   .
                                       .                   .
                                       +-------------------+
                                       | ArpRemoteTerminal |
                                       +-------------------+
                                             /\     ||
                          TERM_XFER_TEXT_MSG ||     || TERM_XFER_TEXT_MSG
                                             ||     \/
                                       +-------------------+
                                       | ArpRemoteInterface|
                                       +-------------------+

The bottom part of the preceeding diagram shows how various kinds of remote devices interface with the terminal. You basically have two choices:


Classes

ArpTerminalInterface (header file)

Defines an abstract programmable interface to a terminal-like device. This is the interface that the terminal class exports to its plug-in emulators, which they in turn use to implement their particular emulation. This interface is used both to write text to the terminal display, and send data to the remote device.

ArpCoreTerminal (header file)

Implements the core functionality of ArpTerminalInterface, and inherits from BView to render its screen and interact with the user. On its own, it is not very useful: it does not know about emulations, so all you can do is receive raw user input as you would from any BView, and perform raw terminal operations as defined by ArpTerminalInterface.

ArpTerminal (header file)

Builds on ArpCoreTerminal to implement a complete terminal with emulation. You can connect this to an object that implements an ArpEmulatorInterface, and they will work together to operate on a character I/O stream that conforms to the selected terminal type. In addition, the user can highlight regions of text with the mouse, and perform standard cut&paste and drag&drop operations. This class does not know anything about remote devices, though, so you will need to subclass it and override TermSendRemote() to process user input.

ArpTerminalMsg (header file)

This is the definition of a system to communicate between an instance of the terminal class and some remote device, based on BMessage objects. The intention is to provide a character-stream-like interface to a terminal, but with the ability to also exchange higher-level information. In particular, it can be used to negotiate with the terminal about the actual terminal emulation that the remote device would like to use and to negotiate about the terminal size.

ArpRemoteTerminal (header file)

A subclass of ArpTerminal that implements the above ArpTerminalMsg protocol. One simply attaches a BMessenger to the class, and it communicates with the terminal and its emulator through the BMessage protocol. This class can also interface with an ArpEmulatorManager to keep track of the emulations that are currently available.

ArpEmulatorInterface (header file)

Defines an abstract base class that is an interface to an add-on emulator; particular implementations will derive from this class, overriding its functions to implement their emulation,

ArpEmulator (header file)

Defines the common base class upon which a particular emulation can be built. While not required to write an emulator, this class takes care of a lot of the grunge work of parsing BMessages and other house-keeping. In addition, this base class can be used by itself as the prototypical "dumb" terminal.

ArpVT200

A subclass of ArpEmulator that implements a fairly complete XTerm/VT200/VT100/VT52 emulation mode. This is not actually in the ArpTerminal library, but a part of the ArpTelnet distribution.


Copyright

All files and code contained in this package are Copyright ©1999 Angry Red Planet, except where otherwise noted.

The files contained here-in are distrubuted under a modifed form of the Artistic License. See the file @License.html or @License.txt for a copy of this license.