[Previous] [Contents] [Next]

Dev.ansi

ANSI console driver (QNX)

Syntax:

Dev.ansi [-C number] [-H] [-I number] [-k rate[,delay]]
         [-L -N name] [-n number]
         [-O number] [-Q] &

Options:

-A
Start in ANSI terminal emulation mode (default).
-C number
Set the size of the canonical input buffer (default is 256 bytes).
-h
Enable hardware scrolling.
-H
Disable hardware scrolling. (Default)
-I number
Set the size of the raw input buffer (default is 256 bytes).
-J
Disable Japanese keyboard mapping.
-k rate[,delay]
Set the keyboard rate in Hz (default is 30) and the delay in milliseconds (default is 500).

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.

-K
No keyboard. Typically used (sometimes in conjunction with -S) to manage virtual consoles which may be manipulated with ditto, even though no physical keyboard is available.
-L [P][N][C][S]
Set the initial state of the keyboard and its LEDs:
-m hex_number
Value used to set VGA misc register on console switch.
-n number
Allow no more than this number of virtual consoles (default is 1, maximum 10).
-N name
Use this prefix for the device name. If a full path (i.e. one which includes the directory under which the device should be registered) is not specified, the name will implicitly be registered under /dev. (default is /dev/ansi)
-O number
Set the size of the output buffer (default is 2048 bytes).
-Q
Start in QNX terminal-emulation mode (default is ANSI).
-S
No screen. Typically used in conjunction with -K to manage virtual consoles which may be manipulated with ditto, even though no video adapter is installed in the machine.

Description:

The Dev.ansi driver manages console devices (i.e. text mode video and the system keyboard) in a QNX system. Dev.ansi may not be started until the Device Manager (Dev) has been started.

Use of hardware scrolling can greatly improve the speed at which text mode consoles can scroll. To enable hardware scrolling, specify the -h option. When -h is specified, if Dev.ansi detects that the video hardware can support hardware scrolling, it programs the hardware to do so. Using hardware scrolling and running programs that are sensitive to the state of the video hardware can result in interference with the program's video output. In such cases, disable hardware scrolling.

Keyboard control

Some functions of Dev.ansi are (or can be) controlled by keyboard keychords. These are:

Switching between virtual consoles

Each virtual console can be running different applications that use the entire screen. The keyboard is attach to the virtual console that's currently visible. You can switch from one virtual console to another -- and thus from one application to another -- by entering the following keychords:

If you want to see: Press:
the next active console Ctrl-Alt-Enter or
Ctrl-Alt-+ (plus)
the previous active console Ctrl-Alt-- (minus)

Note: The + (plus) and - (minus) keys used in the console-switching keychords are those found on the numeric keypad.

You can also jump to a specific console by using the Ctrl-Alt-n, where n is a numeric digit that represents the console number of a virtual console. For instance:

If you want to see: Press:
/dev/con1 Ctrl-Alt-1
/dev/con2 (if available) Ctrl-Alt-2
... ...
/dev/con10 (if available) Ctrl-Alt-0

You can disable keyboard console switching with the stty +noswitch command.

Changing the console fonts

If you are using standard VGA or EGA compatible video hardware, the console driver supports a variety of screen fonts. On all video hardware, the driver defines font 0 as a 80*25 text font. With a VGA-type adapter, an additional 80*50 font is defined as font 1. On an EGA adapter font 1 is defined as a 80*43 text font.

To load new fonts into Dev.ansi, use the cfont utility. You can use this utility to provide fonts of different sizes or fonts that contain alternate character sets. Up to four fonts may be loaded, which includes the two fonts which are defined by default. The cfont utility may be used to supplant the default font 0 and font 1 with alternate fonts, in addition to loading fonts 2 and 3.

To change the font associated with the current console (which may also change the console columns*rows), use the following keychords:

To select: Press:
the next font (up to 3) Ctrl-Alt->
the previous font (down to 0) Ctrl-Alt-<

The driver keeps track of the font being used by each virtual console. All consoles initially display font 0. You can disable keyboard font changing with the stty +noresize command.

Rebooting the computer

To reboot the computer, you can use this keychord:

Ctrl-Alt-Shift-Del

You can disable the ability to reboot the computer via the keychord by using the stty +noboot command.


Caution: Before entering the keychord to reboot the computer, make sure that no applications or utilities are running on your computer. If applications are running, they will be terminated in mid-process and may not leave their files in a state from which they can be recovered when the system comes up again. When the keychord is used to reboot the computer, the filesystem and other key resources will continue to run for a short time (typically 10 seconds or so) during which they will attempt to clean up open files and flush pending data to disk. It is possible that this period of time will be insufficient, in which case data may be lost and the filesystem will require maintenance using chkfsys. It is safest to ensure that applications have been shut down cleanly and the system is idle before rebooting. (See the shutdown utility.)

Invoking the low-level debugger

If the low-level debugger (Debugger32) is running, you can invoke it with this keychord:

Ctrl-Alt-Esc


WARNING: When the debugger is invoked, interrupts are disabled and the entire system will be frozen. Use this keychord with caution. Read the documentation for Debugger32 before using.

You can disable the ability to invoke the low-level debugger with the keyboard keychord by using the stty +nodebug command.

Terminal-emulation modes

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.)

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.

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

Note:

The ANSI control codes and keyboard sequences are defined in this manpage. The control codes and keyboard codes for the QNX mode of this driver are listed in the man page for Dev.con.



Caution:

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 be reloaded before exiting from the shell script or reloaded from the command line after the script terminates.


Character sets

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 builtin 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

Mapping the GL and GR character sets

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, they 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.

Setting the G0, G1, G2 and G3 character sets

The G0 through G3 characters sets may each be set to any of the available builtin 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

Character set defaults

In-use char 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)

Character set example

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)

The PC character set 0x00-0x7f

[PC character set 0x00-0x7f]

The PC character set 0x80-0xff

[PC character set 0x80-0xff]

ANSI screen control codes


Note:

Note the following abbreviations used in the tables:

(220+)
A VT220 Level 2 function
(NA)
Not ANSI standard
(NI)
Not implemented
(NFI)
Not fully implemented

C0 control codes

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

ESC control sequences

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

C1 control characters (220+)


Note:

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

CSI control sequences


Note:

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, 250ms)
{CSI = [n] F} 9B 3D [n] 46 Set and Save foreground color
{CSI = [n] G} 9B 3D [n] 47 Set and Save background color

Graphic rendition

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

Modes

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

Switching protocols/terminal mode control sequence

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

Returning to ANSI mode from QNX4 mode

ASCII Hex Action
ESC ? 1 + q 1B 3F 31 2B 71 set to ANSI mode from QNX4 mode

Mapping from QNX keyboard to ANSI keys

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

Examples:

Start Dev.ansi; use defaults:

    Dev.ansi  &

Allow 4 virtual consoles:

    Dev.ansi -n 4 &

Files:

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 its 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.

Exit status:

Dev.ansi will terminate only upon receipt of a signal or upon encountering a problem during startup.

0
received a SIGTERM signal and performed a clean shutdown
5
Failed to initialize display
12
Failed to mount driver with Dev
19
Failed to arm driver with Dev
23
Failed to register driver with Dev

Note:

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.


See also:

Dev, Dev.*, cfont, kbd, stty, tinit

QNX Installation & Configuration


[Previous] [Contents] [Next]