[Top] [Prev] [Next] [Contents] [Index]

Using VT320 Terminal Emulator Escape Sequences

An escape sequences is a series of non-printing characters, beginning with an Escape character, that sends commands to devices. Escape sequences are used for printing, communications, and display management. The command in an escape sequence results in specified actions by devices. Escape sequences are also called control codes or control sequences.

Escape sequences are most often used in scripts, as in the following examples:

cursoroff: echo "ESC[?25lcursor is off"

cursoron: echo "ESC[?25hcursor is on"

The NCD Terminal Emulator includes a subset of the VT320 command set, as well as NCD-specific sequences. These escape sequences, their actions, and associated functions are listed in Table 12-5. Some of the sequences are described in more detail following the table.

The table lists sequences that differ depending on whether the environment requires eight-bit or seven-bit mode. The eight-bit mode sequence (for example, CSI. . .) is listed first, followed by the equivalent seven-bit mode sequence (for example, Esc[. . .).

Numerical variables are represented as pn. Variables representing a number of rows or columns are represented as pr or pc, respectively. Variables requiring a parameter setting from a number of specific choices are represented by ps. Other variable types are defined in the table as required.

Table 12-5 Escape Sequences
Escape Sequence
Action
Control Function
CSI pn @

Esc [ pn @

Insert pn blank characters. Default: 1. ICH
CSI ps $ }

Esc [ ps $ }

See "Configuring the Status Line" for more information.

Select the status line. ps specifies the display to which the terminal sends data. Permissible values:
0 Send characters to main display
1 Send characters to status line
CSI ps $ -

Esc [ ps $ -

See "Configuring the Status Line" for more information.

Enable the status line. The variable parameter ps indicates the status line to use. Permissible values:
0 No status line
1 Indicator status line (no-op)
2 Host-writable status line
CSI ! p

Esc [ ! p

Soft reset
CSI > c

Esc [ > c

or

CSI > 0 c

Esc [ > 0 c

Request secondary device attributes. Response is C S I > id , ver , 0 c, in which id is terminal identification and ver is version.

Default response: CSI>1;1;0c

DA
CSI ? ps J

Esc [ ? ps J

Selective erase in display. Permissible values for ps: DECSED
0 Cursor to end of screen
1 Start to cursor
2 Entire screen
CSI ? ps K

Esc [ ps K

Selective erase in line. Permissible values for ps: DECSEL
0 Cursor to end of line
1 Beginning to cursor
2 Entire line
CSI ? ps ; ps ... h

Esc [ ? ps ; ps ... h

Set Digital private mode. Permissible values for ps:
1 Cursor keys mode (keypad application) DECCKM
3 Column mode (132 column) DECCOLM
4 Scrolling mode (smooth scroll) DECSCLM
5 Screen mode (reverse video) DECSCNM
6 Origin mode DECOM
7 Autowrap mode DECAWM
8 Auto-repeat mode DECARM
9 Send MIT mouse row and column on button press
25 Text cursor enable mode (cursor visible) DECTCEM
40 Allow 80-to-132 mode
41 curses (1) fix
42 National replacement character set mode (enabled) DECNRCM
44 Turn on margin bell
45 Reverse wraparound mode
46 Start logging
47 Use alternate screen buffer
CSI ? ps i

Esc [ ? ps i

Digital private print control mode. Permissible values for ps are:
1 Print line with cursor
4 Exit autoprint mode
5 Enter autoprint mode
10 Print main display
11 Print main display
CSI ? ps ; ps ... l

Esc [ ? ps ; ps ... l

Reset Digital private mode. Permissible values for ps include:
1 Cursor keys mode (normal cursor keys) DECCKM
3 Cursor keys mode (normal cursor keys) DECCOLM
4 Scrolling mode (jump/fast scroll) DECSCLM
5 Screen mode (normal video) DECSCNM
6 Origin mode (normal cursor) DECOM
7 Autowrap mode (wraparound) DECAWM
8 Auto-repeat mode (disabled) DECARM
9 Do not send MIT mouse row, column on button press
10 Text cursor enable mode (cursor invisible)
40 Do not allow 80-to-132 mode DECTCEM
41 No curses (1) fix
42 National replacement character set mode (disabled) DECNRCM
44 Turn off margin bell
45 No reverse wraparound mode
46 Stop logging
47 Use normal screen buffer
CSI ? ps n

Esc [ ? ps n

See CSI ps n.
CSI ? ps ; ps ... r

Esc [ ? ps ; ps ... r

Store Digital private mode. Permissible values for ps:
1 Cursor keys mode (normal/application keypad) DECCKM
3 Column mode (80/132 columns) DECCOLM
4 Scrolling mode (jump (fast)/scroll) DECSCLM
5 Screen mode (normal/reverse video) DECSCNM
6 Origin mode (normal/origin) DECOM
7 Autowrap mode (no wrap/wraparound) DECAWM
8 Auto-repeat mode (auto-repeat/no-auto-repeat) DECARM
9 Do not send/send MIT mouse row and column on button press
40 Disallow/allow 80-to-132 mode
41 Off/on curses (1) fix
42 National replacement character set mode (disabled) DECNRCM
44 Off/on margin bell
45 No reverse-wraparound/reverse wraparound mode
46 Stop/start logging
47 Use normal/alternate screen buffer
CSI ? ps ; ps ... s Restore Digital private mode. Permissible values for ps:
1 Cursor keys mode (normal/application keypad) DECCKM
3 Column mode (80/132 columns) DECCOLM
4 Scrolling mode (jump (fast)/scroll) DECSCLM
5 Screen mode (normal/reverse video) DECSCNM
6 Origin mode (normal/origin) DECOM
7 Autowrap mode (no wrap/ wraparound) DECAWM
8 Auto-repeat/no-auto-repeat keys DECARM
9 Do not send/send MIT mouse row and column on button press
40 Disallow/allow 80-to-132 mode
41 Off/on curses (1) fix
42 National replacement character set mode (disabled) DECNRCM
44 Off/on margin bell
45 No reverse-wraparound/reverse wraparound mode
46 Stop/start logging
47 Use normal/alternate screen buffer
CSI ps "q

Esc [ ps " q

Select character protection attribute. Permissible values for ps: DECSCA
0 Not protected
1 Protected
2 Not protected
CSI 0 c

CSI pn c

Esc [ pn c

Esc Z

Device attributes/terminal identification.

The response is CSI ?62;1;2;6;8c)

DA1 DECID
CSI pn A

Esc [ pn A

Cursor up pn times. Default: 1. CUU
CSI pn B

Esc [ pn B

Cursor down pn times. Default: 1. CUD
CSI pn C

Esc [ pn C

Cursor forward pn times. Default: 1. CUF
CSI pn D

Esc [ pn D

Cursor backward pn times. Default: 1. CUB
CSI pr ; pc H

Esc [ pr ; pc H

Cursor position. Default: [1,1]. CUP
CSI ps J

Esc [ ps J

Erase in display. Permissible values for ps: ED
0 Cursor to end of screen (default)
1 Start to cursor
2 Entire screen
CSI ps K

Esc [ ps K

Erase in line. Permissible values for ps: EL
0 Cursor to end of line (default)
1 Beginning to cursor
2 Entire line
CSI pn L

Esc [ pn L

Insert pn lines. Default: 1. IL
CSI pn M

Esc [ pn M

Delete pn lines. Default: 1. DL
CSI pn P

Esc [ pn P

Delete pn characters. Default: 1. DCH
CSI pn X

Esc [ pn X

Erase pn characters. ECH
CSI pr ; pc f

Esc [ pr ; pc f

Horizontal and vertical position. HVP
CSI ps g

Esc [ ps g

Tab clear. Permissible values for ps: TBC
0 Clear current tab stop (default)
2 Clear all tab stops
3 Clear all tab stops
CSI ps ; ps ; ps ... h

Esc [ ps ; ps ; ps ... h

Set Mode. Permissible values for ps:
4 Insert mode IRM
20 Line feed/new line LNM
CSI ps i

Esc [ ps i

Print control mode. Permissible values for ps:
0 Print page that has cursor
4 Exit printer controller mode
5 Enter printer controller mode
CSI ps ; ps ; ps ... l

Esc [ ps ; ps ; ps ... l

Reset Mode. Permissible values for ps:
4 Replace mode IRM
20 No line feed/no new line LNM
CSI ps ; ps ; ps ... m

Esc [ ps ; ps ; ps ... m (For more information, see "Configuring Color Text".)

Select graphic rendition (visual attributes). Permissible values for ps: SGR
0 Normal; clear all attributes
1 Bold
4 Underscore
5 Blink
7 Reverse video
22 Normal intensity, not bold
24 Not underlined
25 Not blinking
27 Normal video
Foreground text color:
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
Background text color:
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White
Color-pair selection (NCD-specific values):
90 Color-pair0
91 Color-pair1
92 Color-pair2
93 Color-pair3
94 Color-pair4
95 Color-pair5
96 Color-pair6
97 Color-pair7
CSI ps n

Esc [ ps n

or

CSI ? ps n

Esc [ ? ps n

Device status reports. DSR
ps, meaning, and response:
5 Status report: CSI 0 n
6 Cursor position report: CSI r c R
15 Printer ready: CSI ? 10 n
No printer: CSI ? 13 n 00
25 User-defined key status (unlocked):

CSI ? 20 n

26 Keyboard dialect: CSI ? 27 type n
Permissible values for type:
1 North American
2 British
3 Flemish
4 Canadian French
5 Danish
6 Finnish
7 German
8 Dutch
9 Italian
10 Swiss (French)
11 Swiss (German)
12 Swedish
13 Norwegian
14 French/Belgian
15 Spanish
16 Portuguese
CSI pt ; pb r

Esc [ pt ; pb r

Set top and bottom margins (pt =top; bp=bottom). Default: full-size window. DECSTBM
8-bit mode:

DCS pc ; pl | Ky1 / St1 ; . . . Kyn / Stn ST

or

DCS pc ; pl | Ky1 \ St1 ; . . . Kyn \ Stn ST

7-bit mode:

Esc P pc ; pl | Ky1 / St1 ; . . . Kyn / Stn ST

or

Esc P pc ; pl | Ky1 \ St1 ; . . . Kyn \ Stn ST

(See "Programming Function Keys on N-108LK Keyboards" for more information.)

User-defined keys (F6-F14, Do, Help, F17-F20): DECUDK
pc Clear parameter. Permissible values:
0 Clear all keys before starting (resetting)
1 Clear one key at a time, as overwritten
pl Lock parameter (no-op). Permissible values:
0 Lock the keys
1 Unlock the keys
Ky1/St1 or Ky1\St1 Key definition strings
ST String terminator character or ESC \
Esc G (embedded space required) Sending 8-bit C1 control characters S8C1T
Esc F (embedded space required) Sending 7-bit C1 control characters S7C1T
Esc } Select locking shift of G2 character set, right LS2R
Esc = Keypad application mode DECKPAM
Esc > Keypad numeric mode DECPNM
Esc # 3 Double-width, single-height line, top DECDHL
Esc # 4 Double-width, single-height line, bottom DECDHL
Esc # 5 Single-width, single-height line DECSWL
Esc # 6 Double-width, single-height line DECDWL
Esc # 8 Screen alignment pattern DECALN
Designate character sets: SCS
Esc ( ps Select character set G0.
Esc ) ps Select character set G1.
Esc * ps Select character set G2.
Esc + ps Select character set G3.
Permitted values for ps and corresponding character sets:
B ASCII
%5 Digital supplementary
< Digital user supplementary
0 Digital graphics
A United Kingdom
4 Dutch
C FINNISH
5 FINNISH 2
R French
Q French Canadian
9 French Canadian 2
K German
Y Italian
E Norwegian
6 Norwegian 2
\ Norwegian 3
%6 Portuguese
Z Spanish
H Swedish
7 Swedish 2
= Swiss
Esc | Select locking shift of G3 character set, right LS3R
Esc ~ Select locking shift of G1 character set, right LS1R
Esc 7 Save cursor DECSC
Esc 8 Restore cursor DECRC
Esc D Index IND
Esc E New line NEL
Esc H Horizontal tab set HTS
Esc M Reverse index RI
Esc N Select single-shift of G2 character set SS2
Esc O Select single-shift of G3 character set SS3
Esc Z

Esc [ c

Send device attributes/terminal identification. Response: CSI?62;1;2;6;8c DECID
Esc c Hard reset RIS
Esc n Select locking shift of G2 character set LS2
Esc o Select locking shift of G3 character set LS3
OSC ps ; string NP

Esc ] ps ; string NP (For more information, see "Configuring Window and Icon Titles".)

OSC Mode-Set icon and window titles. Variables are:
NP -Any non-printing character (discarded)
string-ASCII printable string (maximum 511 characters)
ps-
0 Use string as new icon name and title
1 Use string as new icon name only
2 Use string as new title only
OSC ps ND string NP

Esc ] ps ND string NP (For more information, see "Configuring Color Text".)

Color-pair specification (NCD-specific) Variables are defined as follows:
ps -90 to 97
ND-Any non-digit character
string -foreground/background
NP -Any non-printing character

Configuring the Status Line

The status line is referred to in Digital documents as "the 25th line of the display." Because NCD Terminal Emulator windows may have more than 24 lines, the status line must be treated as the hardware status line instead of line 25.

The NCD implementation of the status line allows the programmer to create a new line that appears at the bottom of the window. Normal programmatic editing operations are available for this line, but different character modes (such as blinking or bold) are not supported. To enter characters into the status line, the programmer switches from the main display to the status line display, then uses normal cursor control and text to add characters.

By default, the status line is not visible on the screen.

To use the status line, enable or disable it with the following sequence:


CSI ps $ -

where ps indicates which status line to use (or none):

0 No status line available
1 Indicator status line (no-op)
2 Host-writable status line

Hence, the value 2 makes the status line appear, and 0 makes it disappear. Note that content is not retained when the status line is hidden; the line is emptied.

To select the status line, use the following sequence:


CSI ps $ }

where ps represents the display area to which the terminal sends data:

0 Send characters to the main display
1 Send characters to the status line

Once the status line is selected, all character input is directed there until the main display is selected.

Programming Function Keys on N-108LK Keyboards

Fifteen of the twenty function keys on the N-108LK keyboards can be redefined by the user. The definable function keys are:

When redefined, the shifted state of these keys takes on the defined values. The unshifted keys still work as usual; you cannot programmatically rebind the unshifted state.

The two permissible formats of the escape sequences follow:


DCS pc ; pl | Ky1 / St1 ; ... Kyn / Stn ST
DCS  pc ; pl | Ky1 \ St1 ; ...  Kyn / Stn  ST

The parts of a function key definition are:

DCS Device control string
pc Clear parameter:
0 Clear all keys before starting (reset)
1 Clear one key at a time, as overwritten
pl Lock parameter (no-op on NCD terminals):
0 0 Lock the keys
1 Unlock the keys
Ky1/St1 or Ky1\St1 Key definition string. There can be n of these, separated by semicolons. The format is a key selector number, a slash, then the rebinding. (See Table 12-6). The Ky1/St1 version requires that you supply the hexadecimal values of the letters in the key definition string. NCD has added another option, Ky1\St1, which allows you to supply ASCII characters for the string.
ST String terminator character, or ESC \

Table 12-6 Key Selector Numbers
Key
Value
F6 17
F7 18
F8 19
F9 20
F10 21
F11 23
F12 24
F13 25
F14 26
Help 28
Do 29
F17 31
F18 32
F19 33
F20 34

Examples of function key definitions follow (spaces have been inserted for legibility, but must not be included in the definition):

DCS 0 ; 1 | ST Clears all key rebindings
DCS 1 ; 0 | ESC \ Locks keys (no-op on NCD terminals)
DCS 1 ; 1 | 34\ Print ST Rebinds F20 to string "Print"
DCS 1 ; 1 | 34/5052494E54 ST Rebinds F20 to string "Print"

In the Digital implementation, there is a limitation of 256 characters combined for all programmable function keys. NCD has a limitation of 256 characters per rebound key.

With Digital computers, key locking and unlocking can be set through hardware. Because NCD does not have this hardware, this function does not work. Locking is not enforced.

Configuring Window and Icon Titles

Icon and window titles can be configured through the following escape sequence:


OSC ps ND string NP

where:

ps Determines how the string is used:
0-Uses string as the new icon name and window title
1-Uses string as the new icon name only
2-Uses string as the new window name only
ND Is any non-alphanumeric character (and is discarded)
string Becomes the icon name and window title (or icon name only). This is an ASCII printable string that contains a maximum of 511 characters.
NP Is any non-printing character (and is also discarded)

Configuring Color Text

You can specify color text programmatically. This feature is based on the SGR (select graphic rendition) paradigm used to control blinking, bold, inverse, and other text attributes.

There are two methods of setting text color:

The color selection code is limited to eight combinations of colors at any given time.

The number of combinations can be effectively doubled by using the inverse graphics rendition, but the number of colors that can be displayed on the screen simultaneously is limited.

ISO 6429 Color Usage

The ISO specification defines SGR sequences to change the foreground and the background pens, as listed in Table 12-7.

Table 12-7 SGR Sequences for Foreground and Background Pens
Foreground Selection
Background Selection
30 black 40 black
31 red 41 red
32 green 42 green
33 yellow 43 yellow
34 blue 44 blue
35 magenta 45 magenta
36 cyan 46 cyan
37 white 47 white

For example:


CSI 31 m or ESC[ 31 m

renders foreground text in red, and


CSI 44 m or ESC[ 31 m

renders background text in blue.

These selections can be mixed to use combinations of the foreground and background colors when rendering text. However, only eight combinations are permitted simultaneously on the screen. The eight color cells are reused as needed.

Note also that the combination of black text on a white background is always reserved for the first color cell; hence, there are really only seven combinations of these colors that you can select.

If you attempt to use more than seven combinations at one time, the resulting text is displayed using color cell zero (black on white).

Hewlett-Packard Color-Pair Usage

The eight available color cells can be assigned to any combination of foreground and background colors using NCDware-specific functionality.

This functionality builds on the SGR method of text specification with the addition of the range of new selections listed in Table 12-8

Table 12-8 New Color-Pair Selection
Color Pair Selector
Color Pair
90 color-pair0
91 color-pair1
92 color-pair2
93 color-pair3
94 color-pair4
95 color-pair5
96 color-pair6
97 color-pair7

For example:


CSI 91 m or ESC[ 91 m

uses color-pair1 for rendering text.

Specify the colors associated with the selections by using an extension of the OSC functions in the following format:


OSC ps ND string NP

where:

ps ranges from 90 to 97 for the color-pair selection
ND is any non-alphanumeric character (and is discarded)
string is in the format foreground/background
NP is any non-printing character (and is discarded)

For example:


OSC 91 ; orange/brown ^G

or


ESC] 91 ; orange/brown ^G

sets color-pair1 to foreground orange, background brown.

The first color, color cell 0 (zero), is special-it is the default used for normal text. In addition, the background of the window is reset to the background specified with this color. In the ISO 6429 model, color cell 0 is always used for text specified as black text on a white background. Note that this may have been changed using the Hewlett-Packard method, which results in black text on a white background being stored in color-pair0.

You can use the two models together, but this is somewhat tricky in terms of cell reuse. The zero cell is never reused, but others are available to be reused if a free cell is needed and there are no matching colors for an existing cell on the screen. (The code scans the screen to determine if a color cell is in use when it needs to allocate a new color selection.) As a rule, you should limit color to eight combinations at any given time, or twice that using inverse text. If you attempt to use more colors, the result is plain color text.

Set up new color cells as early as possible and not within loops.

Reverse video inverts all the colors that are set programmatically. The user can select reverse video from the Options menu or use the reverseVideo resource.



[Top] [Prev] [Next] [Contents] [Index]

Send comments, suggestions, or questions about this document to the NCD Technical Publications Department by Internet e-mail. Write to us at techpubs@ncd.com.
Copyright © 1997, NCD Inc. All rights reserved.