SCO Merge User's Guide
Appendix C, Serial terminal information

Appendix C

Serial terminal information


Table of Contents

The primary requirement for DOS to run on a serial character terminal is a good description of the terminal's capabilities and how the terminal performs its various operations. Such descriptions are contained in the UNIX terminfo files.

This appendix describes how SCO Merge uses terminfo entries to run DOS sessions on serial terminals. It also presents various ways of enhancing your existing terminfo files for better DOS support.

This appendix is not a tutorial on how to construct terminfo descriptions for standard terminals. Study the terminfo(4) man page if you need more information about the structure and use of terminfo source files.

Why SCO Merge needs terminal information

DOS programs expect their keyboard input in the form of PC scancodes, and they write characters to the screen in a PC character set. Serial terminals use entirely different codes for their keyboard input and their screen output. Therefore, running DOS on serial terminals requires several conversions. The terminal's keyboard input must be converted to the PC scancodes that DOS programs expect. The PC character set output by the DOS program must be converted to whatever code sequences are used to position and display characters on that particular terminal's screen.

SCO Merge uses two processes that do this conversion. The tkbd process converts the input, and the crt process converts the output.


NOTE: These processes are run automatically; you do not have to do anything special for them to be used.

These processes use the terminfo descriptions for the terminal to do their processing. Besides hardware and the standard components already provided by the SCO Merge system, the only additional item you need to run DOS on a terminal is a good, complete terminfo description.

Two kinds of serial terminals

There are two basic varieties of serial terminals: standard terminals and PC scancode terminals.

Standard terminals are the type normally used with UNIX systems. These standard terminals display several different character sets. Some display only 7-bit ASCII characters. Others display 8-bit character sets, such as the ISO Latin-1 character set. Some terminals can display multiple character sets (though usually only one at a time). Note that the 7-bit ASCII character set is a subset of most character sets used by standard terminals, including PC character sets.

The principal characteristic of a standard terminal is that the keyboard sends the same character codes that the terminal displays (or a subset). For example, on an ASCII terminal, when you press the <A> key, the ASCII code for the lowercase letter A (a) is transmitted. Shift keys, control keys, and meta keys do not send codes. They merely modify the code that is sent when a regular key is pressed. A code is sent only when a key is pressed. No code is sent when a key is released.

Every PC scancode terminal is based on a standard terminal. Thus, they have many of the same qualities, with the PC feature as a special mode of the terminal. When in PC scancode mode, the terminal sends PC scancodes instead of the normal keyboard codes. A scancode is sent when a key is pressed, and another is sent when the key is released. All PC scancode terminals can display the entire PC character set, at least when in PC scancode mode.

The PC scancode mode is turned on and off with a command sent from the server system to the terminal. It is usually the responsibility of the program controlling the terminal (such as SCO Merge) to put the terminal in scancode mode when starting and to put it back into standard mode when finished.

Note that a terminal can have the ability to display the PC character set but still not be considered a PC scancode terminal. A PC scancode terminal must be able to send PC scancodes as well as display a PC character set. This is why they are called PC scancode terminals.

Some useful terms and concepts

Each terminfo file is a database of terminal capability descriptions. Conceptually, the descriptions can be split into two categories: terminal input and terminal output.

terminfo descriptions use two methods to describe each terminal capability. The variable name is the name the programmer uses to access the capability. The capability name (or capname) is a shortened name used in the text of the database, primarily by users updating the database.

For terminal input, the database describes how keyboard input is to be interpreted. These descriptions are called key definitions in this appendix and have terminfo variable names beginning with key_. For example, the terminfo key_f1 string (capname kf1) defines the characters that are generated when function key <F1> has been pressed.

For terminal output, the database describes how to display information on the screen, for example, indicating how characters are to be displayed in reverse video.

In addition, terminfo describes some special commands to control the operation of the terminal. One example is a command to turn on a special scrolling mode.

An escape sequence is a pattern of bytes used to send a special command. Programs can use escape sequences or users can enter them from the keyboard. SCO Merge escape sequences are patterns of key presses that SCO Merge traps before they reach the user's application program. SCO Merge may act on the key sequence itself or pass it on to the DOS program as keyboard input.

SCO Merge uses escape sequences for two purposes: key emulation and special actions.

DOS programs expect input from certain special DOS keys that may not be physically present on a particular terminal's keyboard. The <Home> and <End> keys are examples. If the key does not physically exist, you can emulate that key's action for DOS by pressing a predefined sequence of keys that does exist. SCO Merge intercepts this pattern and translates it into the codes expected by the DOS program. This is referred to as a key emulation escape sequence.

While running a DOS program, you sometimes need to communicate directly with SCO Merge itself to request some special action. For example, you may want the screen redrawn. SCO Merge provides special escape sequences for this, called special-action escape sequences.

The lead-in sequence is one or more keystrokes that initiate an escape sequence. SCO Merge uses both one- and two-character lead-ins. In some computing environments, the lead-in is the <Esc> key alone. In others it is <Ctrl><Esc>. The lead-in sequence is configurable, and you can specify any keys you find convenient.

The SCO Merge default key emulation escape sequence is the one-character lead-in <Esc> key plus a standard ASCII character. The codes for the emulated key are passed on to the DOS program as input.

The SCO Merge default special-action escape sequence is the two-character lead-in <Ctrl><Esc> plus a control character (<Ctrl> held down while another key is pressed). This sequence is acted on by SCO Merge itself.

Defining terminal output for standard terminals

This section discusses terminfo specifications that SCO Merge uses to display DOS characters on serial terminals.

Standard terminfo descriptors

The terminal must have the following minimum capabilities to support DOS:
 ---------------------------------------------------------
 Variable name    Capname
 ---------------------------------------------------------
 cursor_address   cup
 clear_screen     clear
 clr_eol          el
This value must also be set:
 --------------------------------------------------------
 Variable name   Capname
 --------------------------------------------------------
 lines           lines
Screen scrolling must be available. The first two capabilities listed below represent primitive, line-oriented capabilities that can be used if they are all that exist. The next three capabilities provide much better facilities. One group or the other must exist for DOS to use the terminal.
 ---------------------------------------------------------------
 Variable name          Capname
 ---------------------------------------------------------------
 insert_line            il1
 delete_line            dl1
 change_scroll_region   csr
 scroll_forward         ind
 scroll_reverse         ri
The following capabilities are used if they exist but are not required:
 ----------------------------------------------------------------
 Variable Name           Capname
 ----------------------------------------------------------------
 cursor_invisible        civis
 cursor_normal           cnorm
 cursor_up               cuu1
 cursor_down             cud1
 cursor_left             cub1
 cursor_right            cuf1
 enter_ca_mode           smcup
 exit_ca_mode            rmcup
 enter_am_mode           smam
 exit_am_mode            rmam
 enter_pc_charset_mode   smpch
 exit_pc_charset_mode    rmpch
All but two of the terminfo items listed above are explained in your UNIX terminfo documentation. The smpch (enter_pc_charset_mode) and rmpch (exit_pc_charset_mode) capabilities are special command strings. They set the modes of the terminal when starting and finishing a DOS task. For example, if the terminal has special commands to enable and disable a PC character set, those commands are put in smpch and rmpch.

Other commands can also be put in these strings to be executed when starting and finishing a DOS task. Examples are commands that change the cursor shape to an underscore when starting DOS and change it back to normal when exiting DOS. Refer to ``About PC scancode terminals'' for more information about PC scancode mode terminals.


NOTE: Commands that actually switch a terminal into and out of PC scancode mode must not be put into smpch and rmpch. There are separate commands for that. See smsc and rmsc in ``About PC scancode terminals''.

The following terminfo commands can be executed (if they exist) when starting and ending a DOS session. They are listed in the order that they are used.

 ----------------------------------------------------------------
 Variable name           Capname
 ----------------------------------------------------------------
 Starting: 
 enter_pc_charset_mode   smpch
 exit_am_mode            rmam
 enter_ca_mode           smcup
 clear_screen            clear
 set_attributes          sgr
 Ending: 
 change_scroll_region    csr
 cursor_address          cup
 clr_eol                 el
 exit_ca_mode            rmcup
 enter_am_mode           smam
 exit_attribute_mode     sgr0
 cursor_normal           vnorm
 exit_pc_charset_mode    rmpch
Other important settings describe the sequences for controlling the various display modes, such as bold, reverse, underline, and blink. The following is a list of the terminfo display mode commands used when displaying a DOS session. These are not required, but, if they are available, they make the display look much more like a real DOS console screen. Of these, sgr (set_attributes) is the most important. In fact, a well-written sgr entry can make all the difference between a good DOS display and a substandard one.
 ---------------------------------------------------------------
 Variable name          Capname
 ---------------------------------------------------------------
 set_attributes         sgr
 enter_reverse_mode     rev
 enter_secure_mode      invis
 enter_underline_mode   smul
 enter_bold_mode        bold
 enter_blink_mode       blink
 exit_attribute_mode    sgr0
Note that real PC monochrome text has more display modes than some terminals. Some terminals have only one brightness level. Others have brightness levels that do not match those of a PC monochrome display. (PC monochrome has normal and high-intensity levels; some terminals have only dim and full brightness levels.) For this reason, it is sometimes difficult to choose the terminal mode that best conveys the information the DOS program is trying to communicate.

PC monochrome characters have four mutually exclusive display modes:

In addition, the characters can be high-intensity or blinking. Thus, there are 16 possible ways to display a character (including four invisible ones). The only way all these combinations can be correctly displayed is with the sgr capability. The sgr string is a parameterized string. sgr and parameterized strings are discussed in the terminfo(4) manual page.

Special terminfo descriptors

The previous sections have discussed standard terminfo descriptors, plus two special ones, smpch and rmpch. SCO Merge uses additional special terminfo descriptors to enhance the operation of DOS on terminals. The next two sections discuss two of the most important: dispc and pctrm.
 ---------------------------------------------------------------
 Variable name          Capname
 ---------------------------------------------------------------
 pc_term_options        pctrm
 display_pc_character   dispc

pctrm

The pctrm string is used to set special input and output processing options for SCO Merge. The output options are: LRC_OK is set when programs can safely write to the lower right corner of the display. Many terminals incorrectly scroll when that location is written to, even when the automatic scroll mode is turned off. Consequently, by default, SCO Merge does not write to this location. If the terminal does not have this problem, set LRC_OK in the pctrm string.

The National Language Support (NLS) features of SCO Merge provide support for special character sets. (The prime example is ISO 8859.) SCO Merge offers special facilities for terminals that can display these character sets. For this type of terminal, put ISO_TERM into the pctrm string.

When you find it inconvenient to modify the terminfo to set this option, you can set the UNIX environment variable ISO_TERM instead. See ``Displaying PC characters on ISO terminals'' for details.

When an ISO terminal has a special mode that enables it to display a PC character set, you can use the options CS_SW_INDEPENDENT and PCMODECP. See ``Combined ISO and PC character set terminals''.

Any combination of options is valid within the pctrm string, and the options can be placed in any order. Every option in the pctrm string must be delimited by leading and trailing colons (:). For example:

   pctrm=:LRC_OK:ISO_TERM:,
   pctrm=:ISO_TERM:,

dispc

By default, SCO Merge uses an internal table to map each PC character to a matching ASCII character that the terminal can display. Many extended PC characters that have no ASCII match are displayed simply as an asterisk (*). See ``PC-character-to-ASCII conversions'' for these built-in conversions.

The terminfo string dispc can be used to override SCO Merge's built-in table. dispc can be used in one of two ways. It can either contain the name of an alternate conversion table (for example, dispc=/usr/lib/dispc/myterminal), or it can be a parameterized string that describes the rules for displaying PC characters.

If you have a serial terminal capable of displaying some of the PC characters (but not all), or if you want to redefine some of the built-in character conversions, the first form of dispc suits your needs best. However, for a PC scancode terminal or any terminal that can display most of the PC characters, the second form of dispc is more efficient.

The next section describes the first form of dispc. The section ``Defining terminal output for PC scancode terminals'' discusses the parameterized form of dispc.

Displaying PC characters on terminals

The first form of dispc string is used to specify a file containing a PC-character-to-terminal-code conversion table. This is known as a PCT file.

The PCT file is a normal UNIX text file, with each line defining a single PC-character-to-terminal-character conversion. In a PCT file, each line is composed of fields separated by space or tab characters. Any field that starts with /* starts a comment. In addition, lines that have # as the first character in the first field are comments. All comments end at the end of the line. Each line can have a maximum of eight usable fields.

The first field is the PC character code to be displayed. The following fields (up to seven) are the codes to be sent to the terminal to display this character. The order of the lines is not important. If a particular PC character conversion is not specified in the file, the built-in conversion is used for that PC character. Each field can be specified in four ways: as a 7-bit ASCII character, as a decimal number, as a hex number, or as an octal number.

A decimal number is represented as a number 0 to 255 with a period at the end (for example, 129.). A hex number is represented as a number 0 to FF with a letter h at the end (for example, A8h). An octal number is represented as a number 0 to 377 with a letter o at the end (for example, 267o). Here are a few sample PCT lines:

   z z		/* This converts z to z
   		/* (no conversion needed).
   e1h 33o 1. B	/* e1 is the beta symbol, and the
   		/* beta is displayed with an escape
   		/* (33 octal) followed by decimal
   		/* 1, which in turn is followed
   		/* by the ASCII character B.
   b3h 27. b3h	/* To be displayed, the b3 (vertical line)
   		/* character must be preceded
   		/* with an escape (27 decimal).

Displaying PC characters on ISO terminals

SCO Merge supports NLS automatic character set conversion. Each character in the PC character set being used by the DOS session is converted to the closest character in the ISO character set. The ISO character is then displayed on the terminal.

Not all NLS character sets are supported. Factory-supplied NLS character set support includes (at a minimum) ISO 8859 (the Latin-1 alphabet) plus PC code pages 437 and 850. Other character sets may also be supported.

Code set is the UNIX term for the character set your terminal uses. SCO Merge determines the code set that your terminal uses with the LANG environment variable or by reading /etc/default/lang if it exists. For details about the LANG environment variable and instructions on how it is used to specify the code set, refer to Chapter 4, ``Configuring DOS and Windows sessions'', and to the locale(4) manual page.

SCO Merge automatically keeps track of the current PC code page. Provided that both your terminal's code set and the PC code page in use are supported, translation between the two is automatic, even when you change the PC code page in the middle of a session.

For example, suppose the PC character to be displayed is code number 82h in PC code page 850 (that is, the letter é). SCO Merge translates this to the ISO 8859 code set number for the letter é so that your terminal can display it.

This automatic character set conversion is enabled whenever ISO_TERM has been included in the terminfo pctrm string or the ISO_TERM environment variable is set. ISO_TERM does not need to be set to anything in particular. It merely needs to exist. From the Bourne or Korn shell, use the following command to set it:

ISO_TERM=
export ISO_TERM

When an exact conversion for a character is not possible, SCO Merge uses the closest match it can find in its own built-in conversion table. If a specific conversion has been specified with dispc, SCO Merge uses that conversion instead.

Combined ISO and PC character set terminals

SCO Merge also supports those terminals that display both an ISO code set and a PC code page. Whenever the DOS process is using a code page that matches the code page supported by the terminal, the terminal is switched to PC character set mode. SCO Merge sends the same output to the terminal it would send to any terminal that can display that PC character set.

When the DOS process switches to a PC code page other than the one the terminal supports, the terminal is switched to ISO mode. SCO Merge then sends the same screen output it would send to a normal ISO terminal.

There are several restrictions. The smpch and rmpch terminfo items must be specified. They must contain only the commands that switch the terminal from ISO code set display to the PC code page display. The terminal cannot change its mode in any respect other than the character set being displayed. It cannot use a PC scancode mode that changes how the keyboard operates or changes how the character attributes are set. dispc must also be specified, so that SCO Merge knows how to display PC characters when in PC character mode.

By default, it is assumed that code page 437 is used by the terminal when in PC code page mode. If another code page is used, the string PCMODECP=pcnnn is set in pctrm. This specifies that code page nnn is used by this terminal.

To enable ISO-to-PC-character-set switching, the pctrm string must contain both ISO_TERM and CS_SW_INDEPENDENT. The PCMODECP=pcnnn string is optional. For example, if code page 850 is to be used, pctrm is set like this:

pctrm=:ISO_TERM:CS_SW_INDEPENDENT:PCMODECP=pc850:,

When the DOS session is using a code page that matches the PC code page the terminal can display, the terminal is switched into that mode with smpch. dispc is used to display the characters. When switching from that code page to another, rmpch is used to switch the terminal back to ISO display mode.

Defining terminal input for standard terminals

On standard terminals, the keyboard codes coming from the terminal are either 7-bit ASCII or 8-bit ISO 8859 (the Latin-1 character set). DOS programs assume that their input is coming from a PC keyboard and expect it in the form of PC scancodes. To emulate a DOS keyboard, SCO Merge translates serial terminal keyboard input codes into the scancode make and break signals sent by the corresponding keys on a PC keyboard.

SCO Merge uses internal tables to translate the ASCII or ISO input characters into the equivalent PC character. Then, the PC characters are sent to DOS as PC keyboard make and break scancodes.

To translate the keyboard input, SCO Merge needs to know what character set is being used on the terminal. It gets this information from the UNIX LANG setting. (Refer to ``How the UNIX operating system handles NLS'' in Appendix A for more information about the LANG setting and code sets.) SCO Merge keeps track of the current DOS code page character set and adjusts its translation from the UNIX code set as the DOS code page changes.

When the character code coming from the terminal corresponds to an unshifted PC keyboard key, the make and break for that key are simply delivered to the DOS process. For the A key, for example, scancode 1E for the make and scancode 9E for the break are used.

When the keyboard code coming from the terminal corresponds to a shifted PC key (either regular <Shift> or <Ctrl><Shift>), more is required. The make and break signals for that key are preceded by a make of the appropriate <Shift> key and followed by a break of that <Shift> key. For <Ctrl>A, four separate codes are used: 1D for the make of the <Ctrl> key, 1E for the make of the A key, 9E for the break of the A key, and 9D for the break of the <Ctrl> key. This behavior is called auto-break. Nothing special needs to be done to cause the key break to happen.

Where the DOS program requires input from PC keys that are not physically present on the terminal keyboard, SCO Merge provides key emulation escape sequences. For example, the sequence to simulate the <Sys Req> key is <Esc>=. You send keyboard codes equivalent to ASCII escape and the ASCII equal sign. SCO Merge translates this into the make and break scancodes for the <Sys Req> key and sends those codes to the DOS process.

``Serial terminal keyboard mapping'' in Appendix B lists the default key emulation escape sequences. All these keys are auto-break; when the sequence is received by SCO Merge, the make and break codes for the appropriate key are automatically sent to DOS.

The <Shift>-type keys (<Shift>, <Ctrl>, and <Alt>) are semi-auto-break. When received, the make code for the <Shift>-type key is sent. The break code is delayed until one of two events occurs:

The release-all-shifts sequence allows you to force the release of the <Shift>, <Ctrl>, or <Alt> key. The default release-all-shifts sequence is <Esc><Space>. This causes breaks for all made <Shift>-type keys, so that isolated <Shift>-type key actions may be simulated.

For example, if you need to simulate the pressing and releasing of the left and right <Shift> keys, use this keystroke sequence:

<Esc>Z<Esc>/<Esc><Space>.

Default key emulation escape sequences

Each key emulation escape sequence is made up of two keyboard codes. By default, the lead-in is the ASCII escape code (hex 1b) followed by an ASCII character code. See ``Serial terminal keyboard mapping'' in Appendix B for a list of the default key emulation escape sequences that SCO Merge uses to simulate DOS keys not physically present on the terminal keyboard.

Default special-action escape sequences

In addition to the key emulation escape sequences, SCO Merge intercepts and acts on special-action escape sequences.
 -----------------------------------------------------------
 Press <Esc>, then:   To activate:
 -----------------------------------------------------------
 <Ctrl>U              See top or bottom 24 lines
 <Ctrl>F              Fork a new shell
 <Ctrl>R              Redraw screen
 <Ctrl>K              Kill session
 <Ctrl>Z              Suspend DOS*
 -------------------
 *   The Suspend DOS
     function is only
     available under a
     job-control shell.
Again, each special-action escape sequence is a grouping of two codes: the lead-in sequence followed by a control-key combination. <Ctrl> is a <Shift>-type key. <Ctrl> plus a second key press is a single event. The <Ctrl>-plus-second-key combination is sent as a single code.

The default lead-in on standard terminals is the ASCII escape code (hex 1b). On PC scancode terminals, the default lead-in is <Ctrl><Esc>. The lead-in is followed with <Ctrl> plus one of the letter keys listed in this table.

Using terminfo descriptors for key emulation

The previous sections have described the escape sequences built into SCO Merge for key emulation. The built-in key emulation escape sequences cover every PC key a DOS program expects and assume that the terminal has no such keys.

Most terminals, however, have some of the same keys found on PC keyboards (such as the function and arrow keys). The code sequences those keys send are not standardized, but the keys are often physically present. Consequently, a well-constructed terminfo file for such a terminal already contains descriptors for whatever function and arrow keys the terminal has.

Whenever they exist, SCO Merge uses these pre-existing descriptors in addition to its own built-in key emulation escape sequences. If you are writing or editing a terminfo file, you can add to or modify its entries in any way you find convenient, and SCO Merge uses those values in addition to its built-ins.

Thus, when working at a terminal equipped with a physical <F11> key, you can send <F11> to SCO Merge in two ways: You can press the physical <F11> key on the keyboard or activate the built-in sequence with <Esc>; sequence.

SCO Merge constantly monitors the code sequences the terminal sends. Whenever a code sequence matches either its own built-in key emulation escape sequence or one of the key descriptions in terminfo, SCO Merge sends the make and break codes for that key to the DOS process.

Refer to ``terminfo escape sequences'' for a comprehensive list of terminfo entries and how they can be mapped to PC keyboard keys. Wherever a PC key has no corresponding key on the terminal keyboard, and thus no corresponding entry in the terminfo file, an unused entry has been chosen to represent it. For example, the PC <Sys Req> key has been mapped to the key_options (kopt) entry. Where no pre-existing entry bears any relationship to the PC key, an entry for an unused function key has been used. If you create or customize your own terminfo files, use ``terminfo escape sequences'' as a guide.

pctrm

If you want to configure the terminal so that it uses only the built-in key emulation escape sequences and ignores any existing terminfo key descriptions, use the pctrm string, whose output-related options have been discussed. The one input-related option is NO_TI.

Whenever this keyword is in the pctrm string, SCO Merge ignores the key descriptors in terminfo. This is useful when there are key descriptors that conflict with the built-in SCO Merge escape sequences.

Sometimes, it is easier to force SCO Merge to use only the built-in sequences than to make users resort to some new escape sequence. For example, if the <F1> key on the terminal transmits <Esc>A, it conflicts with the built-in escape sequence for the right <Alt> key. A new escape sequence for the right <Alt> key could be put into terminfo, but users might be more comfortable using all the default escape sequences.

In this example, the user would not press the <F1> key (or any of the special keys). The user would press <Esc>1 to simulate the <F1> key for DOS. All the other default escape sequences would also be used to simulate the special keys.

The following example shows how to set the NO_TI option:

   pctrm=:NO_TI:,

Changing the lead-in character

By default, the <Esc> key itself is used as the lead-in character for the default escape sequences. (An escape sequence must also be used for the <Esc> key. This sequence is <Esc><Esc>. That is, to send the <Esc> key to DOS, you must type it twice.)

Sometimes there are conflicts between the built-in escape sequences and other key combinations used by the terminal. When the terminal needs the <Esc> key for some other purpose, you can reconfigure the lead-in character. You specify another lead-in character with the terminfo scesc descriptor.

 -----------------------------------------------------------
 Variable name     Capname
 -----------------------------------------------------------
 scancode_escape   scesc
For example, scesc=Z sets the lead-in sequence to Z. Setting scesc=^X sets it to <Ctrl>X.

About PC scancode terminals

This section discusses the characteristics of PC scancode terminals and how their special capabilities can be activated by the information in terminfo.

PC terminals are based on standard serial terminals, so most of the foregoing issues apply to PC terminals just as they do to standard terminals. PC terminals have a special mode, however. In PC mode, they emulate a PC's monochrome display adapter (MDA) and the PC scancode keyboard.

The keyboard has the same layout as a PC keyboard and can send PC keyboard scancodes. The screen can display all the same characters as an IBM-compatible MDA.

These terminals are usually in standard mode, acting as normal serial terminals for the UNIX system. When a DOS session is started, SCO Merge switches the terminal into the PC scancode mode. When the DOS session is finished, SCO Merge switches the terminal back to the standard mode. The following terminfo items are used when switching between standard and PC scancode modes.

 ----------------------------------------------------
 Variable name         Capname
 ----------------------------------------------------
 enter_scancode_mode   smsc
 exit_scancode_mode    rmsc
 user0                 u0
 user1                 u1
 user2                 u2
 user3                 u3
 pc_term_options       pctrm

Switching commands

The first two (smsc and rmsc) are the switching commands. Note the name similarity between these two commands and two commands described earlier. smsc and rmsc put the terminal into PC scancode mode and return it to standard mode. smpch and rmpch, described earlier, are command strings that specify the modes of the terminal when the DOS process starts and when it exits.

Alternate flow control

Items u0, u1, and u2 control the so-called XPC feature. Many PC scancode terminals offer these alternate flow-control characters for PC scancode mode.

Standard terminals use two characters for flow control, normally referred to as XON and XOFF. On standard terminals, they are usually keyed with <Ctrl>Q and <Ctrl>S. These characters cannot be used in scancode mode, so alternate flow-control characters are needed.

The u0 string defines these scancode mode XPC flow-control characters. The first character in the string is the XON character, and the second is XOFF. The u1 string is sent to the terminal to enable the XPC flow control. u2 disables it. If the terminal automatically uses XPC flow control when put into scancode mode, u1 and u2 do not need to be specified.

For example, the typical XPC characters are 0x65 for XON and 0x67 for XOFF. Since the number 0x65 is the ASCII code for the letter e and 0x67 is the ASCII code for the letter g, the u0 specification that defines these XPC characters is:

   u0=eg,

Serial line parameters

The u3 string contains the command sent to the terminal to set the communication parameters: baud rate, number of bits, stop bits, and parity.

Whenever the terminal is in scancode mode, the serial line must be in 8-bit mode. Normally, the user sets up the serial line in such a way that it is always in 8-bit mode when using a PC terminal. In this case, the command is not needed.

The sole reason for this command is for those situations in which the line has not been so configured. If the user forgets to put the line into 8-bit mode, the software can perform the service automatically. The line is placed in 8-bit mode when the terminal enters scancode mode. The line is returned to 7-bit mode when the terminal exits scancode mode.

u3 is a terminfo parameterized string. For more information about parameterized strings, see the terminfo(4) manual page.

 ----------------------------------------------------------------
 Parameter   Use
 ----------------------------------------------------------------
 1st         Not used
 2nd         Number of data bits (7 or 8)
 3rd         Number of stop bits (1 or 2)
 4th         Parity (0=none, 1=odd, 2=even
 5th         Baud rate (1 - 15 decimal)
Baud rate IDs 1 through 15 correspond to baud rates of 50 through 38400. The baud IDs are drawn from the CBAUD field of termio(7) (They are defined in the file /usr/include/sys/termio.h). The following table defines the ID for each baud rate.
 ---------------------------------------------------------
 Baud   ID   Baud   ID   Baud    ID
 ---------------------------------------------------------
 50     1    300    7    9600    13
 75     2    600    8    19200   14
 110    3    1200   9    38400   15
 134    4    1800   10
 150    5    2400   11
 200    6    4800   12
The baud rate is included in a single command with the other communication parameters because some terminals have only a single command that sets all of these parameters at once. Any time you change any one parameter, all parameters, including the baud rate, must be specified.

pctrm

The pctrm string defines special options for either a standard terminal or a PC scancode terminal. They are activated by inserting specific terms in the pctrm string.

One special option relates to switching PC terminals between standard and PC scancode modes. This option is USE_TERM. The USE_TERM option is required when a terminal's PC scancode mode uses completely different commands than those used in standard mode.

One example is the WY-60 terminal. The Wyse terminfo descriptions for standard mode do not work when the terminal is in PC scancode mode. USE_TERM is employed to specify an alternate terminfo name for use when the terminal is in PC scancode mode. The syntax of this option is USE_TERM=n, where n is the terminfo name to be used when in PC scancode mode. As with the other pctrm options, any combination and order of options are valid within the pctrm string. Every option in the pctrm string must be delimited by leading and trailing colons (:).

For example, suppose the terminfo name is wy60-pc when the Wyse is in PC scancode mode. The pctrm string is defined in the standard terminfo as:

   pctrm=:USE_TERM=wy60-pc:,

Sequence of use

The following table presents a list of the terminfo commands used (if they exist) when a DOS session is started or ended on a PC scancode terminal.
 ------------------------------------------------------------
 Variable name           Capname
 ------------------------------------------------------------
 Starting: 
 user3                   u3
 enter_scancode_mode     smsc
 user1                   u1
 enter_pc_charset_mode   smpch
 exit_am_mode            rmam
 enter_ca_mode           smcup
 clear_screen            clear
 set_attributes          sgr
 Ending: 
 change_scroll_region    csr
 cursor_address          cup
 clr_eol                 el
 exit_ca_mode            rmcup
 enter_am_mode           smam
 exit_attribute_mode     sgr0
 cursor_normal           vnorm
 exit_pc_charset_mode    rmpch
 user2                   u2
 exit_scancode_mode      rmsc
 user3                   u3

SCO scancode terminal support

The SCO UNIX system has an application program interface (API) that provides a higher level of control over the switching of PC scancode terminals to and from PC scancode mode.

When the SCO scancode API is available, SCO Merge uses it instead of switching the mode of the terminal itself. Rather than using smsc, rmsc, u0, u1, u2, or u3, SCO Merge uses the API to put the terminal into scancode mode. In all other respects, SCO Merge uses the terminal in scancode mode as if the API does not exist.

The SCO scancode API uses smsc and rmsc to switch modes, just as SCO Merge does. The API does not use u0, u1, or u2 to set alternate XON/XOFF, and does not use u3 or the USE_TERM option in pctrm.

The API also needs some additional descriptors. Refer to the documentation on this API for more information on how it works and any special support it might need in terminfo.

A single terminfo file can serve both purposes. If you are writing a terminfo file and you want it to work in all cases, whether the API is available or not, specify all of the above in the file. Include the descriptors needed by SCO Merge and those needed by the API. The appropriate items are used or bypassed, according to whether the API is present or absent.

Defining terminal output for PC scancode terminals

This section discusses terminfo items used to display DOS characters on PC terminals.

In displaying characters on the screen, the only difference between standard serial terminals and PC terminals is the character set used. PC terminals use a PC character set; standard terminals use either the ASCII or the ISO 8859 character set. Typically, the PC character set used is based on DOS code page 437.

SCO Merge uses terminfo exactly the same way. The only difference lies in the dispc terminfo descriptor. This section discusses the form of dispc used for those terminals that can display the entire PC character set.

As previously discussed, the dispc terminfo descriptor is used to describe how PC characters are to be displayed on the terminal. There are two forms of the dispc descriptor. The first is the filename of a PCT file, which contains information about how each character is to be displayed. This form can be used for PC terminals, but a second form is preferred.

The second form for dispc is a terminfo parameterized string; it defines a conversion from PC characters to terminal commands that display each character. This second form is preferred because it is more efficient and self-contained and requires no external PCT file.

dispc has two forms because different methods work better on different terminal types. A parameterized string can be used for PC terminals because the rules for displaying PC characters are normally very easy and regular. Creating a parameterized string dispc for an ASCII terminal would normally be too complex for the limited size of a parameterized string.

Parameterized strings

A parameterized string is a small logic program that takes input, processes it, and produces output. It uses a stack to hold temporary values, handling it in the manner of a Reverse Polish Notation (postfix) calculator.

Logically, the program is called with a character as a parameter. It converts the input character to a string of zero or more output characters. The program can do arithmetic (addition, subtraction, multiplication, division, negation, and mod). It can also do logical operations (and, or, equal to, less than, greater than) and bit operations (and, or, xor, not). The logical operations are used in an if-then-else form that can be fully nested.

For more information about parameterized strings, see the terminfo(4) manual page.

dispc as a parameterized string

When you use the dispc parameterized string, the input character is the second parameter (%p2), not the first. (None of the other parameters is used internally by dispc.) This unusual usage is necessary because the terminfo library makes assumptions about the first parameters to parameterized strings that are not correct for what dispc needs to do.

The following example shows how to create a dispc parameterized string for the Kimtron KT70 PC terminal. The PC characters on the KT70 are displayed using these rules:

The parameterized string that encodes this rule is:
   %?%p2%{32}%<%p2%{127}%=%|%t\E%p2%c%e%p2%c%;
This may seem confusing at first glance. Actually it is quite straightforward. The percent sign (%) identifies operators. (For a full description of the operators, see the terminfo(4) manual page.) Here is a breakdown of the string:
 ------------------------------------------------------------------
 Operator      Meaning
 ------------------------------------------------------------------
 %?            if
 %p2%{32}%<    input character less than 32 decimal?
 %p2%{127}%=   input character equal to 127 decimal?
 %|            logical or of the previous two tests
 %t            then
 E             output the escape character
 %p2%c         output the input character
 %e            else
 %p2%c         output the input character
 %;            endif
Creating a parameterized string for dispc is a two-step process. First, determine the if-then-else logic for displaying PC characters. Then, translate it into the postfix parameterized string.

Code pages

The particular DOS code page (character set) displayed by the terminal when in PC mode is fixed. By default, it is assumed to be code page 437.

If the terminal uses another code page, put the PCMODECP option in the pctrm string. The syntax is PCMODECP=pcnnn, where nnn is the number of the code page used by the terminal. As with the other pctrm options, any combination and order of options is valid within the pctrm string. Each option is delimited by colons.

For example, if the code page is 850, pctrm is set like this:

   pctrm=:PCMODECP=pc850:,

Defining terminal input for PC scancode terminals

Input on PC terminals is not complex. PC terminals send exactly the scancodes the DOS session needs. Thus, for normal use of the keyboard, nothing special is needed in terminfo except the codes that switch the terminal into and out of PC scancode mode.

Nevertheless, some special-action escape sequences are used for the same functions previously described in ``Defining terminal input for standard terminals'': redrawing the screen, forking a new shell, terminating or suspending DOS, and shifting the screen.

The default lead-in is the two-key sequence Left <Ctrl><Esc>, that is, pressing the <Esc> key while the left <Ctrl> key is pressed. Then, you release those keys. This lead-in is followed by pressing <Ctrl> and another character. The second sequence determines the function to be done. (An alternative is to press and hold the left <Ctrl> key. While holding it down, press <Esc>, let it up, and press another key.).

 -----------------------------------------------------------------
 Press Left <Ctrl> <Esc>,   To activate:
 then:
 -----------------------------------------------------------------
 <Ctrl>K                    Kill session
 <Ctrl>U                    See top or bottom 24 lines
 <Ctrl>R                    Redraw screen
 <Ctrl>F                    Fork a new shell
 <Ctrl>Z                    Suspend DOS*
 -----------------------------------------------------------------
* The Suspend DOS function is only available under a job-control shell.

For example, to kill your DOS session, press the left <Ctrl> key and hold it. While keeping it down, press and release the <Esc> key. Still holding the left <Ctrl>, press and release the <K> key. You can also release and re-press the left <Ctrl> key between the <Esc> key and the <K>. Either method works.

Changing the lead-in sequence

Using terminfo, the Left <Ctrl><Esc> lead-in for the sequence can be changed to any other key combination. The terminfo scesc descriptor is used to specify a different initial key.
 ----------------------------------------------------------
 Variable name     Capname
 ----------------------------------------------------------
 scancode_escape   scesc
The scesc string must have at least one character. The first is the value of the scancode for the key. The following characters are the scancode values of the <Shift>-type keys that must be pressed at the same time.
 --------------------------------------------------------------------
 <Shift>-type key     Octal sequence
 --------------------------------------------------------------------
 Left <Ctrl>          35
 Right <Ctrl>         340 35
 Left <Alt>           70
 Right <Alt>          340 70
 Left <Shift>         52
 Right <Shift>        66
 <E0> Left <Shift>    340 52
 <E0> Right <Shift>   340 66
For example, suppose the lead-in is to be the <F12> function key (scancode value octal 130) with the left <Shift> and the left <Ctrl> keys held down. For this Left <Ctrl>Left <Shift><F12> lead-in, scesc is set like this:
   scesc=\130\035\052

PC-character-to-ASCII conversions

The following table shows the built-in PC-character-to-7-bit-ASCII conversions used to display PC characters on a serial terminal. The first field is the PC character number (in hex). The second is the 7-bit ASCII character to be displayed.
-----------------------------------------------------------------------------
 PC   A    PC    A    PC   A   PC   A    PC   A   PC   A    PC   A   PC    A
-----------------------------------------------------------------------------
 00h  *    20h        40h  @   60h  `    80h  c   a0h  a    c0h  +   e0h   *
 01h  *    21h   !    41h  A   61h  a    81h  u   a1h  i    c1h  +   e1h   *
 02h  *    22h   "    42h  B   62h  b    82h  e   a2h  o    c2h  +   e2h   *
 03h  *    23h   #    43h  C   63h  c    83h  a   a3h  u    c3h  +   e3h   *
 04h  *    24h   $    44h  D   64h  d    84h  a   a4h  n    c4h  -   e4h   *
 05h  *    25h   %    45h  E   65h  e    85h  a   a5h  N    c5h  +   e5h   *
 06h  *    26h   &    46h  F   66h  f    86h  a   a6h  a    c6h  +   e6h   *
 07h  *    27h   '    47h  G   67h  g    87h  c   a7h  o    c7h  +   e7h   *
 08h  *    28h   (    48h  H   68h  H    88h  e   a8h  ?    c8h  +   e8h   *
 09h  *    29h   )    49h  I   69h  i    89h  e   a9h  -    c9h  +   e9h   *
 0ah  *    2ah   *    4ah  J   6ah  j    8ah  e   aah  -    cah  +   eah   *
 0bh  *    2bh   +    4bh  K   6bh  k    8bh  i   abh  *    cbh  +   ebh   *
 0ch  *    2ch   ,    4ch  L   6ch  l    8ch  i   ach  *    cch  +   ech   *
 0dh  *    2dh   -    4dh  M   6dh  m    8dh  i   adh  !    cdh  -   edh   *
 0eh  *    2eh   .    4eh  N   6eh  n    8eh  A   aeh  <    ceh  +   eeh   *
 0fh  *    2fh   /    4fh  O   6fh  o    8fh  A   afh  >    cfh  +   efh   *
 10h  >    30h   0    50h  P   70h  p    90h  E   b0h  *    d0h  +   f0h   =   
 11h  <    31h   1    51h  Q   71h  q    91h  a   b1h  *    d1h  +   f1h   +
 12h  *    32h   2    52h  R   72h  r    92h  A   b2h  *    d2h  +   f2h   >
 13h  *    33h   3    53h  S   73h  s    93h  o   b3h  |    d3h  +   f3h   <
 14h  *    34h   4    54h  T   74h  t    94h  o   b4h  +    d4h  +   f4h   *
 15h  *    35h   5    55h  U   75h  u    95h  o   b5h  +    d5h  +   f5h   *
 16h  -    36h   6    56h  V   76h  v    96h  u   b6h  +    d6h  +   f6h   *
 17h  *    37h   7    57h  W   77h  w    97h  u   b7h  +    d7h  +   f7h   ~
 18h  ^    38h   8    58h  X   78h  x    98h  y   b8h  +    d8h  +   f8h   O
 19h  v    39h   9    59h  Y   79h  y    99h  o   b9h  +    d9h  +   f9h   *
 1ah  >    3ah   :    5ah  Z   7ah  z    9ah  u   bah  |    dah  +   fah   *
 1bh  <    3bh   ;    5bh  [   7bh  {    9bh  c   bbh  +    dbh  *   fbh   V
 1ch  *    3ch   <    5ch  \   7ch  |    9ch  L   bch  +    dch  *   fch   n
 1dh  *    3dh   =    5dh  ]   7dh  }    9dh  Y   bdh  +    ddh  *   fdh   2
 1eh  ^    3eh   >    5eh  ^   7eh  ~    9eh  P   beh  +    deh  *   feh   *
 1fh  v    3fh   ?    5fh  -   7fh  *    9fh  S   bfh  +    dfh  *   ffh    

terminfo escape sequences

These terminfo escape sequences provide alternatives to the standard, built-in escape sequences for each of the functions. Both the default sequences and those specified in terminfo work concurrently. The ones in terminfo take precedence over the defaults.
 -----------------------------------------------------------------------
 terminfo variable name      terminfo   AT keyboard key   default escape
                             capname    name              sequence
 -----------------------------------------------------------------------
 Numeric keypad: 
 key_sleft                   kLFT       left arrow (4)    <Esc>f 
 key_sright                  kRIT       right arrow (6)   <Esc>g 
 key_sr                      kri        up arrow (8)      <Esc>t 
 key_sf                      kind       down arrow (2)    <Esc>v 
 key_shome                   kHOM       <Home> (7)        <Esc>h 
 key_previous                kprv       <PgUp> (9)        <Esc>p 
 key_next                    knxt       <PgDn> (3)        <Esc>q 
 key_il                      kil1       <Ins> (0)         <Esc>i 
 key_sdc                     kDC        <Del> (.)         <Esc>d 
 key_send                    kEND       <End> (1)         <Esc>e 
 key_b2                      kb2        (5)               <Esc>.
 key_f53                     kf53       <Num Lock>        <Esc>n 
 key_f54                     kf54       /                 <Esc>& 
 key_f55                     kf55       *                 <Esc>* 
 key_f56                     kf56       -                 <Esc>- 
 key_f57                     kf57       +                 <Esc>+ 
 key_enter                   kent       <Enter>           <Esc>^ 

 Shift keys: 
 key_f58                     kf58       Left <Shift>      <Esc>z 
 key_f59                     kf59       Right <Shift>     <Esc>/ 
 key_f60                     kf60       Left <Ctrl>       <Esc>c 
 key_f61                     kf61       Right <Alt>       <Esc>a 
 key_f62                     kf62       Left <Ctrl>       <Esc>C 
 key_f63                     kf63       Right <Alt>       <Esc>A 

 Cursor keypad: 
 key_ic                      kich1      <Ins>             <Esc>I 
 key_home                    khome      <Home>            <Esc>H 
 key_ppage                   kpp        <PgUp>            <Esc>P 
 key_dc                      kdch1      <Del>             <Esc>D 
 key_end                     kend       <End>             <Esc>E 
 key_npage                   knp        <PgDn>            <Esc>Q 
 key_up                      kcuu1      up arrow          <Esc>T 
 key_left                    kcub1      left arrow        <Esc>F 
 key_down                    kcud1      down arrow        <Esc>V 
 key_right                   kcuf1      right arrow       <Esc>G 

 Special keys: 
 key_print                   kprt       <Print Screen>    <Esc>r 
 key_f50                     kf50       <Scroll Lock>     <Esc>s 
 key_restart                 krst       <Pause/Break>     <Esc>| 
 key_f51                     kf51       <Caps Lock>       <Esc>k 
 key_f52                     kf52       102nd key         <Esc>< 
 key_options                 kopt       <Sys Req>         <Esc>= 
 key_sic                     kIC        <Esc>             <Esc><Esc>

 Function keys: 
 key_f1                      kf1        <F1>              <Esc>1 
 key_f2                      kf2        <F2>              <Esc>2 
 key_f3                      kf3        <F3>              <Esc>3 
 key_f4                      kf4        <F4>              <Esc>4 
 key_f5                      kf5        <F5>              <Esc>5 
 key_f6                      kf6        <F6>              <Esc>6 
 key_f7                      kf7        <F7>              <Esc>7 
 key_f8                      kf8        <F8>              <Esc>8 
 key_f9                      kf9        <F9>              <Esc>9 
 key_f10                     kf10       <F10>             <Esc>0 
 key_f11                     kf11       <F11>             <Esc>; 
 key_f12                     kf12       <F12>             <Esc>: 

 Shifted function keys: 
 key_f13                     kf13       <Shift><F1>
 key_f14                     kf14       <Shift><F2>
 key_f15                     kf15       <Shift><F3>
 key_f16                     kf16       <Shift><F4>
 key_f17                     kf17       <Shift><F5>
 key_f18                     kf18       <Shift><F6>
 key_f19                     kf19       <Shift><F7>
 key_f20                     kf20       <Shift><F8>
 key_f21                     kf21       <Shift><F9>
 key_f22                     kf22       <Shift><F10>
 key_f23                     kf23       <Shift><F11>
 key_f24                     kf24       <Shift><F12>

 Controlled function keys: 
 key_f25                     kf25       <Ctrl><F1>
 key_f26                     kf26       <Ctrl><F2>
 key_f27                     kf27       <Ctrl><F3>
 key_f28                     kf28       <Ctrl><F4>
 key_f29                     kf29       <Ctrl><F5>
 key_f30                     kf30       <Ctrl><F6>
 key_f31                     kf31       <Ctrl><F7>
 key_f32                     kf32       <Ctrl><F8>
 key_f33                     kf33       <Ctrl><F9>
 key_f34                     kf34       <Ctrl><F10>
 key_f35                     kf35       <Ctrl><F11>
 key_f36                     kf36       <Ctrl><F12>

 Alted function keys: 
 key_f37                     kf37       <Alt><F1>
 key_f38                     kf38       <Alt><F2>
 key_f39                     kf39       <Alt><F3>
 key_f40                     kf40       <Alt><F4>
 key_f41                     kf41       <Alt><F5>
 key_f42                     kf42       <Alt><F6>
 key_f43                     kf43       <Alt><F7>
 key_f44                     kf44       <Alt><F8>
 key_f45                     kf45       <Alt><F9>
 key_f46                     kf46       <Alt><F10>
 key_f47                     kf47       <Alt><F11>
 key_f48                     kf48       <Alt><F12>

 Special actions: 
 key_f0                      kf0        All shifts        <Esc><Space>
                                         released
 key_exit                    kext       Kill session      <Esc><Ctrl>K 
 key_beg                     kbeg       Top/bottom        <Esc><Ctrl>U 
                                         shift screen
 key_refresh                 krfr       Redraw screen     <Esc><Ctrl>R 
 key_suspend                 kspd       Suspend DOS       <Esc><Ctrl>Z 
 key_resume                  kres       Fork a new        <Esc><Ctrl>F 
                                         shell

 –  –  –  –