ANSI Console driver (QNX)
Dev.ansi [-C number] [-H] [-I number] [-k rate[,delay]] [-N name] [-n number] [-O number] [-Q] &
To prevent Dev.ansi from setting the keyboard rate to the default value of 30 Hz, specify -k 0. This may be necessary with some keyboards.
Start Dev.ansi; use defaults:
Dev.ansi &
Allow 4 virtual consoles:
Dev.ansi -n 4 &
The Dev.ansi driver manages console devices in a QNX system. Dev.ansi may not be started until the Device Manager (Dev) has been started.
If Dev.ansi detects that the video hardware can support hardware scrolling, it programs the hardware to do so, making scrolling a lot faster. However, when running a program that's sensitive to the state of the video hardware, this use of hardware scrolling might interfere with the program's video output. If it does interfere, specify the -H option.
When Dev.ansi is started, it makes the terminal type the same for all its consoles. By default, the consoles will all emulate the ANSI terminal. The Dev.ansi driver currently has the ability to emulate the historic QNX terminal type. If -Q is specified, they will all emulate the QNX terminal. If Dev.ansi is started as Dev.con, the default becomes QNX terminal emulation and -A should be used to override the default and use ANSI emulation. (See Dev.con.) Both of these features are deprecated and may be removed in a future release.
When users of the system are predominantly console users, it may prove convenient to modify the /etc/default/login file to set the TERM environment variable to the terminal type the driver is emulating. Some OS images (made by buildqnx) have set the TERM environment variable on the sinit command line. This practice is not the recommended way of setting TERM.
Each console keeps track of its terminal emulation mode. To change the emulation mode of a particular console, run the following commands on that console:
To change to: | Run these commands: |
---|---|
QNX emulation | export TERM=qnx stty protocol=0 term=$TERM |
ANSI emulation | export TERM=ansi stty protocol=1 term=$TERM |
The ANSI control codes and keyboard sequences are defined in this manpage. The control codes and keyboard codes for the deprecated QNX mode of this driver are listed in the man page for Dev.con.
Unlike the TERM environment variable, stty term= settings aren't restored when a shell script terminates. Therefore, if the above pairs of commands are run in a shell script, the stty settings must either reloaded before exiting from the shell script or reloaded from the command line after the script terminates.
The Dev.ansi driver, in ANSI mode, allows the character sets in use to be chosen from a "palette" of character sets, each of which is independently programmable to contain one of several built-in character sets.
The in-use range of characters is divided into four regions which span character numbers (in hexadecimal) 0x00 through 0xff. Two of these regions are fixed sets of control characters, while the other two are configurable to contain a choice of character sets:
Hex | Name | May be set to one of |
---|---|---|
0x00-0x1f | C0 (Control Zero) | Not configurable |
0x20-0x7f | GL (Graphics Left) | G0, G1, G2, G3 |
0x80-0x9f | C1 (Control One) | Not configurable |
0xa0-0xff | GR (Graphics Right) | G1, G2, G3 |
Each of the GL and GR in-use character sets can be set to a choice of several character sets from the G0, G1, G2 and G3 character sets. (For configuring these, see the section entitled "Setting the G0, G1, G2 and G3 Character Sets".)
The screen control codes to set GL and GR are as follows:
To set | To | Use |
---|---|---|
GL | G0 | {LS0} = {SI} (0f) |
GL | G1 | {LS1} = {SO} (0e) |
GL | G2 | {LS2} = {ESC n} (1b 6e) or {SS2} (8e) |
GL | G3 | {LS3} = {ESC o} (1b 6f) or {SS3} (8f) |
GR | G1 | {LS1R}= {ESC ~} (1b 7e) |
GR | G2 | {LS2R}= {ESC }} (1b 7d) |
GR | G3 | {LS3R}= {ESC |} (1b 7c) |
The {LS*} codes stand for "Locking Shift". When character sets are selected by these means, the remain in effect until another {LS*} code is sent.
The {SS*} codes stand for "Single Shift" and will affect the next character only. After that character, the character set in effect reverts to its previous setting. There are only two {SS*} codes, {SS2} and {SS3} which maps G2 into GL and G3 into GL, respectively.
The G0 through G3 characters sets may each be set to any of the available built-in fonts. The control code to do this is
ESC g s
Where:
g | Sets |
---|---|
( | G0 |
) | G1 |
* | G2 |
+ | G3 |
And:
s | Specifies |
---|---|
B | ASCII |
0 | Special (DEC Graphic) |
< | ISO-Latin1 Supplemental |
U | PC Character Set |
In-Use Character Set | Defaults to |
---|---|
GR | G2 |
GL | G0 |
Char Set | Defaults to |
---|---|
G0 | ASCII charset |
G1 | Special charset (DEC Graphic) |
G2 | Supplemental charset (ISO-Latin 1) |
G3 | Special charset (DEC Graphic) |
Set the GL in-service character set (0x20-0x7f) to the PC character set through G1, write some characters, then switch GL back to G0:
{ESC )U} 1e 29 55 (Set G1 to be the PC character set) {SO} 0e (Set GL to G1) . . (Write chars in PC graphics char set) . {SI} 0f (Set GL to G0)
Note the following abbreviations used in the tables:
ASCII | ANSI Mnemonic | Hex | Action |
---|---|---|---|
{NUL} | (00) | Null | |
{BEL} | (07) | Bell | |
{BS} | (08) | Back Space (VT100 defaults to no wrap from left margin) | |
{HT} | (09) | Horizontal Tab (VT100 defaults to no autowrap) | |
{LF} | (0A) | Linfeed or Newline | |
{VT} | (0B) | Same as LF | |
{FF} | (0C) | Clears Screen (QNX Extension) | |
{CR} | (0D) | Move cursor to left margin | |
{SO} | {LS1} | (0E) | GL is set to G1 |
{SI} | {LS0} | (0F) | GL is set to G0 (default) |
{XON} | {DC1} | (11) | XON |
{XOFF} | {DC0} | (13) | XOFF |
{CAN} | (18) | Cancels ESC sequence | |
{SUB} | (1A) | Cancels ESC sequence and prints ? | |
{ESC} | (1B) | Start of ESC sequence | |
{DEL} | (7F) | Ignored on output |
String | Hex | Action |
---|---|---|
{ESC 7} | (1B 37) | Save cursor |
{ESC 8} | (1B 38) | Restore cursor |
{ESC =} | (1B 3D) | Set application keypad mode |
{ESC >} | (1B 3E) | Set numeric keypad mode (default) |
{ESC D} | (1B 44) | 7 bit codes for {IND} (84) |
{ESC E} | (1B 45) | 7 bit codes for {NEL} (85) |
{ESC H} | (1B 48) | 7 bit codes for {HTS} (88) |
{ESC M} | (1B 4D) | 7 bit codes for {RI} (8D) |
{ESC N} | (1B 4E) | 7 bit codes for {SS2} (8E) |
{ESC O} | (1B 4F) | 7 bit codes for {SS3} (8F) |
{ESC P} | (1B 50) | 7 bit codes for {DCS} (90) |
{ESC [} | (1B 5B) | 7 bit codes for {CSI} (9B) |
{ESC \} | (1B 5C) | 7 bit codes for {ST} (9C) |
{ESC ]} | (1B 5D) | 7 bit codes for {OSC} (9D) |
{ESC ^} | (1B 5E) | 7 bit codes for {PM} (9E) |
{ESC _} | (1B 5F) | 7 bit codes for {APC} (9F) |
{ESC Z} | (1B 5A) | Identify terminal |
{ESC c} | (1B 63) | Hard Reset (clears screen) (use {CSI ! P} for soft-reset) |
{ESC n} | (1B 6E) | (LS2) GL is set to G2 (220+) |
{ESC o} | (1B 6F) | (LS3) GL is set to G3 (220+) |
{ESC |} | (1B 7C) | (LS3R) GR is set to G3 (220+) |
{ESC }} | (1B 7D) | (LS2R) GR is set to G2 (220+) (default) |
{ESC ~} | (1B 7E) | (LS1R) GR is set to G1 |
{ESC sp F} | (1B 20 46) | Keyboard generates 7 bit C1 codes (incl CSI) (default) |
{ESC sp G} | (1B 20 47) | keyboard generates 8 bit C1 codes (incl CSI) (220+) |
{ESC ( 0} | (1B 28 30) | Set G0 to special charset |
{ESC ( <} | (1B 28 3C) | Set G0 to supplemental charset |
{ESC ( A} | (1B 28 41) | Set G0 to U.K. charset (Not implemented; same as ASCII) |
{ESC ( B} | (1B 28 42) | Set G0 to ASCII charset (default) |
{ESC ( U} | (1B 28 55) | Set G0 to PCterm graphics |
{ESC ) 0} | (1B 29 30) | Set G1 to special charset (default) |
{ESC ) <} | (1B 29 3C) | Set G1 to supplemental charset |
{ESC ) A} | (1B 29 41) | Set G1 to U.K. charset (NI; same as ASCII) |
{ESC ) B} | (1B 29 42) | Set G1 to ASCII charset |
{ESC ) U} | (1B 29 55) | Set G1 to PCterm graphics |
{ESC * 0} | (1B 2A 30) | Set G2 to special charset (220+) |
{ESC * <} | (1B 2A 3C) | Set G2 to supplemental charset (220+) (default) |
{ESC * B} | (1B 2A 42) | Set G2 to ASCII charset (220+) |
{ESC * U} | (1B 2A 55) | Set G2 to PCterm graphics |
{ESC + 0} | (1B 2B 30) | Set G3 to special charset (220+) (default) |
{ESC + <} | (1B 2B 3C) | Set G3 to supplemental charset (220+) |
{ESC + B} | (1B 2B 42) | Set G3 to ASCII charset (220+) |
{ESC + U} | (1B 2B 55) | Set G3 to PCterm graphics |
Any 8-bit C1 code can be done with 7-bit ESC followed by the 8-bit code minus 0x40 hex. For instance, the CSI (control sequence introducer) can be represented in 8-bit mode as 0x9b, while in 7-bit mode it must be expressed as ESC [ (0x1b 0x5b).
ASCII | Hex | Action |
---|---|---|
{IND} | (84) | move cursor down with scroll |
{NEL} | (85) | move to left margin on next line with scroll |
{HTS} | (88) | Set horizontal tab |
{RI} | (8D) | move cursor up with scroll |
{SS2} | (8E) | GL is set to G2 for 1 character |
{SS3} | (8F) | GL is set to G3 for 1 character |
{DCS} | (90) | Start of Device control string |
{CSI} | (9B) | Control sequence introducer |
{ST} | (9C) | End of Device control string |
{OSC} | (9D) | Operating System Command |
{PM} | (9E) | Privacy Message |
{APC} | (9F) | Application Program Command |
In 7-bit mode, CSI is ESC [. In 8-bit mode, CSI is (hex)0x9B.
ASCII | Hex | Action |
---|---|---|
{CSI [n] @} | (9B [n] 40) | Insert n spaces at cursor (default = 1 space) |
{CSI [n] A} | (9B [n] 41) | Cursor up n rows, no wrap (default = 1 row) |
{CSI [n] B} | (9B [n] 42) | Cursor down n rows, no wrap (default = 1 row) |
{CSI [n] C} | (9B [n] 43) | Cursor right n columns, no wrap (default = 1 column) |
{CSI [n] D} | (9B [n] 44) | Cursor left n columns, no wrap (default = 1 column) |
{CSI [n] F} | (9B [n] 46) | Cursor up n rows, positioned in first column (default = 1 row) |
{CSI [n] G} | (9B [n] 47) | Move cursor to column n (default = column 1) |
{CSI [r[;c]] H} | (9B [r [3B c]] 48) | Cursor position (default = row 1; column 1) |
{CSI [n] J} | (9B [n] 4A) | Erase 0=cur-EOS 1=HOME-cur 2=screen (default = 0 (to end of screen)) |
{CSI [n] K} | (9B [n] 4B) | Erase 0=cur-EOL 1=BOL-cur 2=line (default = 0 (to end of line)) |
{CSI [n] L} | (9B [n] 4C) | Insert n lines (default = 1 line) |
{CSI [n] M} | (9B [n] 4D) | Delete n lines (default = 1 line) |
{CSI [n] P} | (9B [n] 50) | Delete n chars (default = 1 char) |
{CSI [n] S} | (9B [n] 53) | Scroll forward n lines (default = 1 line) |
{CSI [n] T} | (9B [n] 54) | Scroll backward n lines (default = 1 line) |
{CSI [n] X} | (9B [n] 58) | Erase cur for n-1 chars (default = 1 (0 chars)) |
{CSI Z} | (9B 5A) | Back tab |
{c CSI [n] b} | (c 9B [n] 62) | Repeat GR or GL character c, n times. c is the last displayable character; n defaults to 1 time. |
{CSI 0 c} | (9B 30 63) | Primary device attrib request |
{CSI [n] d} | (9B [n] 64) | Move cursor to line n (default = line 1) |
{CSI [n] g} | (9B [n] 67) | Tab clear 0=cursor 2=all (default = 0) |
{CSI [n[;n]...] h} | (9B [n[3B n]...] 68) | Standard Set mode (See modes table) (default=none) |
{CSI ? [n[;n]...] h} | (9B 3F [n[3B n]...] 68) | Private Set mode (See modes table) (default=none) |
{CSI [n[;n]...] l} | (9B [n[3B n]...] 6C) | Standard Reset mode (See modes table) (default=none) |
{CSI ? [n[;n]...] l} | (9B 3F [n[3B n]...] 6C) | Private Reset mode (See modes table) (default=none) |
{CSI [n[;n]...] m} | (9B [n[3B n]...] 6D) | Select Graphic Rendition (See below) (default = 0) |
{CSI n n} | (9B n 6E) | Device status 5=status 6=cursor/pos |
{CSI [r[;c]] r} | (9B [r [3B c]] 72) | Set scroll region and home cursor |
{CSI r} | (9B 72) | Disable scroll region & home cursor |
{CSI s} | (9B 73) | Save cursor |
{CSI u} | (9B 75) | Restore cursor |
{CSI ! p} | (9B 21 70) | Soft reset |
{CSI [n[;n]] ]} | (9B [n [3B n]...] 5D) | Set default 1=underline 2=half-intensity 8=colorset (default=none) |
{CSI = [f [;d]] B} | (9B 3D [f [3B d]] 46) | Set frequency(hz) and duration (ms) for bell (default=100Hz, 1/4sec) |
{CSI = [n] F} | (9B 3D [n] 46) | Set and Save foreground color |
{CSI = [n] G} | (9B 3D [n] 47) | Set and Save background color |
Number | Meaning |
---|---|
0 | All attributes off (except charset (10, 11, 12)) |
1 | Bold |
2 | Half intensity (default to cyan on color screen) |
4 | Underline (default to red on color screen) |
5 | Blink |
7 | Reverse |
9 | Invisible |
10 | Exit alternate char set (GR & GL are restored) |
11 | Enter PC-lower char set (GR & GL are ASCII, C0 & C1 are PC_LO except for ESC) |
12 | Enter PC-higher char set (GR, C1 & GL, C0 are PC_HI except for ESC) |
21 | Normal intensity (un-Bold) |
22 | Normal intensity (un-Half intensity) |
24 | Disable underline |
25 | Disable blink |
27 | Disable reverse |
29 | Visible |
30-37 | Set foreground color (30+color_number, see below) |
39 | set foreground to saved |
40-47 | Set background color (40+color_number, see below) |
49 | set background to saved |
color_numbers
color_number | Description |
---|---|
0 | Black |
1 | Red |
2 | Green |
3 | Brown |
4 | Blue |
5 | Violet |
6 | Cyan |
7 | White |
Mode string | Description |
---|---|
?1h | cursor key = Application |
?1l | cursor key = ANSI (default) |
?3h | 132 column (Not Implemented) |
?3l | 80 column (default) |
?5h | Reverse screen |
?5l | Not Reverse screen (default) |
?6h | Origin mode |
?6l | Absolute mode |
?7h | Auto wrap on |
?7l | Auto wrap off (default) |
?25h | Visible cursor (default) |
?25l | Invisible cursor |
?45h | Reverse wrap-around mode |
?45l | No reverse wrap-around |
?66h | keypad = Application |
?66l | keypad = ANSI |
?67h | Backspace key generates BS |
?67l | Backspace key generates DEL |
ASCII | Hex | Action |
---|---|---|
{CSI ? [p [;m]] + q} | (9B 3F p 3B m 2B 71) | Set protocol and reset mode. Default p=0; m=0 |
Where | Means |
---|---|
p = 0 | QNX4 emulation |
p = 1 | ANSI emulation |
m = 0 | No change |
m = 1 | Standard QNX defaults |
m = 2 | G2 is set to PC_HI & Backspace generates 08 |
m = 3 | Wrap-around off |
m = 4 | G2 is set to PC_HI & reverse wrap-around enabled |
ASCII | Hex | Action |
---|---|---|
ESC ? 1 + q | (1B 3F 31 2B 71) | set to ANSI mode from QNX4 mode |
Key | Normal | Shift | Ctrl | Alt |
---|---|---|---|---|
Enter | CR | CR | CR | CR |
Tab | TAB | CSI Z | CSI z | |
BS | BS | RUB | RUB | BS |
ESC | ESC | ESC | ESC | ESC |
F1 | SS3 P | SS3 p | CSI 1~ | CSI 17~ |
F2 | SS3 Q | SS3 q | CSI 2~ | CSI 18~ |
F3 | SS3 R | SS3 r | CSI 3~ | CSI 19~ |
F4 | SS3 S | SS3 s | CSI 4~ | CSI 20~ |
F5 | SS3 T | SS3 t | CSI 5~ | CSI 21~ |
F6 | SS3 U | SS3 u | CSI 6~ | CSI 22~ |
F7 | SS3 V | SS3 v | CSI 7~ | CSI 23~ |
F8 | SS3 W | SS3 w | CSI 8~ | CSI 24~ |
F9 | SS3 X | SS3 x | CSI 9~ | CSI 25~ |
F10 | SS3 Y | SS3 y | CSI 10~ | CSI 26~ |
F11 | SS3 Z | SS3 z | CSI 11~ | CSI 27~ |
F12 | SS3 A | SS3 a | CSI 12~ | CSI 28~ |
Home | CSI H | CSI h | CSI H | |
/\ | CSI A | CSI a | CSI A | |
PgUp | CSI V | CSI v | CSI V | |
Minus | CSI S | CSI s | CSI S | |
<-- | CSI D | CSI d | CSI D | |
kpd 5 | CSI G | CSI g | CSI G | |
--> | CSI C | CSI c | CSI C | |
Plus | CSI T | CSI t | CSI T | |
End | CSI Y | CSI y | CSI Y | |
\/ | CSI B | CSI b | CSI B | |
PgDn | CSI U | CSI u | CSI U | |
Ins | CSI @ | CSI ` | CSI @ | |
Del | CSI P | CSI p | CSI P | |
Prt | NOP | NOP | NOP | NOP |
SysRq | NOP | NOP | NOP | NOP |
a | a | A | SOH | SS2 a |
b | b | B | STX | SS2 b |
c | c | C | ETX | SS2 c |
d | d | D | EOT | SS2 d |
e | e | E | ENQ | SS2 e |
f | f | F | ACK | SS2 f |
g | g | G | BEL | SS2 g |
h | h | H | BS | SS2 h |
i | i | I | HT | SS2 i |
j | j | J | LF | SS2 j |
k | k | K | VT | SS2 k |
l | l | L | FF | SS2 l |
m | m | M | CR | SS2 m |
n | n | N | SO | SS2 n |
o | o | O | SI | SS2 o |
p | p | P | DLE | SS2 p |
q | q | Q | DC1 | SS2 q |
r | r | R | DC2 | SS2 r |
s | s | S | DC3 | SS2 s |
t | t | T | DC4 | SS2 t |
u | u | U | NAK | SS2 u |
v | v | V | SYN | SS2 v |
w | w | W | ETB | SS2 w |
x | x | X | CAN | SS2 x |
y | y | Y | EM | SS2 y |
z | z | Z | SUB | SS2 z |
Dev.ansi will terminate only upon receipt of a signal or upon encountering a problem during startup.
A common cause of failure on startup is that Dev has hit its maximum number of devices and rejects the driver's attempt to register. If this happens, increase the value of Dev's -n option.
Dev.ansi closes its standard input, standard output and standard error immediately upon startup.
Dev.ansi will cause Dev to adopt a number of character special files under it's directory (/dev). Usually these will be named ansin, where n will range from 1 to the number of console devices specified by the Dev.ansi -n option. The base filename (ansi) will be different if the -N is specified with an alternate name.