Control Code Translators

A translator is a driver that interprets embedded control codes in text files and prompts.  The Thought BBS engine has a pluggable architecture that allows you to select the specific control codes you want to support on your system.  You can also create your own translators or download new ones from the Internet.

Default Configuration

The default system enables a few common translators, including the ANSI, AVATAR and PCBoard translators.  Other translators are available but not loaded.  While it is nice to have flexibility to support every control code format ever invented, doing so increases memory usage and may cause incorrect displays due to conflicts.  For example, several different BBS packages used the pipe (|) and at (@) symbols as prefixes for completely incompatible codes.

Design

A translator is associated with one or more prefix characters.  A prefix character marks the beginning of a potential control code.  For example, ANSI-BBS codes are prefixed with an ASCII #27 (escape character) and RemoteAccess color codes are prefixed with a control-K character.

The BBS engine will call the translator whenever any of its prefix characters are encountered in a line of text.  The translator then examines the text and determines if the control code is a recognized (valid) code.  If so, it executes the code and returns control to the engine.  For invalid codes, the translator returns without performing any operations.

If multiple translators are associated with the same prefix character, then the BBS engine will give first opportunity to translator loaded first.  If that translator does not recognize the code, the BBS engine will try next translator and so on.  This allows multiple translators for identical prefix characters to co-exist at the same time.  Of course, you should load the translators in order of priority.  If one translator is handling 90% of the codes on your system, it should be loaded before a translator that handles a few esoteric codes.

If no translator recognizes the code, the text is sent unchanged to the remote system.  For example, if you do not load the ANSI-BBS translator, then all ANSI escape sequences will be sent unchanged.

A Note on Color Code Conversions

An intended side-effect of the translation engine is a re-conversion of color and cursor codes.  Every session is associated with a terminal driver (usually ANSI or AVATAR).  The terminal driver is responsible for sending the protocol strings for changing colors, moving the cursor, etc.  For example, if a session is attached to the AVATAR terminal driver, then all color changes are sent as AVATAR color code strings.  If you display an ANSI text file, the remote terminal will actually receive AVATAR color codes (not ANSI color codes).

Script authors can use the underlying Terminal I/O library to bypass the translation engine.  However, in most cases you should allow the translation engine to handle the conversions for you.  It allows you to create text files and prompts using whatever format you want -- with confidence that the remote system will see it correctly.

Included Translators