wscons(7D) manual page
Table of Contents
wscons - workstation console
#include <sys/strredir.h>
ioctl(fd, SRIOCSREDIR, target);ioctl(fd, SRIOCISREDIR, target);
The ‘workstation console’ is a device consisting of the combination of the
workstation keyboard and frame buffer, acting in concert to emulate an
ASCII
terminal. It includes a redirection facility that allows I/O issued
to the workstation console to be diverted to some other STREAMS
device,
so that, for example, window systems can arrange to redirect output that
would otherwise appear directly on the frame buffer, corrupting its appearance.
The redirection facility maintains a list of devices that have
been named as redirection targets, through the SRIOCSREDIR
ioctl described
below. All entries but the most recent are inactive; when the currently
active entry is closed, the most recent remaining entry becomes active.
The active entry acts as a proxy for the device being redirected; it handles
all read(2)
, write(2)
, ioctl(2)
, and poll(2)
calls issued against the redirectee.
The following two ioctls control the redirection facility. In both cases,
fd is a descriptor for the device being redirected (that is, the workstation
console) and target is a descriptor for a STREAMS
device.
- SRIOCSREDIR
- Make
target be the source and destination of I/O ostensibly directed to the
device denoted by fd.
- SRIOCISREDIR
- Returns 1 if target names the device
currently acting as proxy for the device denoted by fd, and 0 if it is
not.
On SPARC
systems, the PROM
monitor emulates an ANSI
X3.64 terminal.
On PowerPC systems,
the kernel display subsystem performs the same emulation.
Note: the VT
100
also follows the ANSI
X3.64 standard but both the Sun and the VT
100 have
nonstandard extensions to the ANSI
X3.64 standard. The Sun terminal emulator
and the VT
100 are not compatible in any true sense.
The Sun console displays
34 lines of 80 ASCII
characters per line, with scrolling, (x, y) cursor
addressability, and a number of other control functions.
While the display
size is usually 34 by 80, there are instances where it may be a different
size.
- If the display device is not large enough to display 34 lines of text.
- On SPARC systems, if either screen-#rows or screen-#columns is set by the
user to a value other than the default of 34 or 80 respectively. screen-#rows
and screen-#columns are fields stored in NVRAM/EEPROM, see
eeprom(1M)
.
The
Sun console displays a cursor which marks the current line and character
position on the screen. ASCII
characters between 0x20 (space) and 0x7E (tilde)
inclusive are printing characters -- when one is written to the Sun console
(and is not part of an escape sequence), it is displayed at the current
cursor position and the cursor moves one position to the right on the current
line.
On SPARC systems, later PROM
revisions have the full 8-bit ISO Latin-1
(ISO 8859-1) character set, not just ASCII.
Earlier PROM
revisions display
characters in the range 0xA0 - 0xFE as spaces.
PowerPC systems have the full
8-bit ISO Latin-1 (ISO 8859-1) character set.
If the cursor is already at the
right edge of the screen, it moves to the first character position on the
next line. If the cursor is already at the right edge of the screen on
the bottom line, the Line-feed function is performed (see CTRL-J
below),
which scrolls the screen up by one or more lines or wraps around, before
moving the cursor to the first character position on the next line.
The Sun console defines a number
of control sequences which may occur in its input. When such a sequence
is written to the Sun console, it is not displayed on the screen, but effects
some control function as described below, for example, moves the cursor
or sets a display mode.
Some of the control sequences consist of a single
character. The notation
CTRL-X
for some character X, represents a control
character.
Other ANSI
control sequences are of the form
ESC [ params char
Spaces are included only for readability; these characters
must occur in the given sequence without the intervening spaces.
- ESC
- represents
the ASCII
escape character (ESC
, CTRL-[
, 0x1B).
- [
- The next character is a
left square bracket ‘[’ (0x5B).
- params
- are a sequence of zero or more decimal
numbers made up of digits between 0 and 9, separated by semicolons.
- char
- represents a function character, which is different for each control sequence.
Some examples of syntactically valid escape sequences are (again, ESC
represent
the single ASCII
character ‘Escape’):
ESC[m select graphic rendition with default parameter
ESC[7m select graphic rendition with reverse image
ESC[33;54H set cursor position
ESC[123;456;0;;3;B move cursor down
Syntactically valid ANSI
escape sequences which are not currently interpreted
by the Sun console are ignored. Control characters which are not currently
interpreted by the Sun console are also ignored.
Each control function requires
a specified number of parameters, as noted below. If fewer parameters are
supplied, the remaining parameters default to 1, except as noted in the
descriptions below.
If more than the required number of parameters is supplied,
only the last n are used, where n is the number required by that particular
command character. Also, parameters which are omitted or set to zero are
reset to the default value of 1 (except as noted below).
Consider, for example,
the command character M which requires one parameter. ESC
[;M and ESC
[0M
and ESC
[M and ESC
[23;15;32;1M are all equivalent to ESC
[1M and provide
a parameter value of 1. Note: ESC
[;5M (interpreted as ‘ESC
[5M’) is not equivalent
to ESC
[5;M (interpreted as ‘ESC
[5;1M’) which is ultimately interpreted as
‘ESC
[1M’).
In the syntax descriptions below, parameters are represented as
‘#’ or ‘#1;#2’.
The following
paragraphs specify the ANSI
control functions implemented by the Sun console.
Each description gives:
- the control sequence syntax
- the hex equivalent
of control characters where applicable
- the control function name and ANSI
or Sun abbreviation (if any).
- description of parameters required, if any
- description of the control function
- for functions which set a mode, the
initial setting of the mode. The initial settings can be restored with the
SUNRESET
escape sequence.
CTRL-G (0x7) Bell
(BEL)
- The Sun Workstation Model 100 and 100U is not equipped with an audible
bell. It ‘rings the bell’ by flashing the entire screen. The window system
flashes the window. The screen will also be flashed on current models if
the Sun keyboard is not the console input device.
- CTRL-H (0x8) Backspace (BS)
- The cursor moves one position to the left on the current line. If it is
already at the left edge of the screen, nothing happens.
- CTRL-I (0x9) Tab
(TAB)
- The cursor moves right on the current line to the next tab stop.
The tab stops are fixed at every multiple of 8 columns. If the cursor is
already at the right edge of the screen, nothing happens; otherwise the
cursor moves right a minimum of one and a maximum of eight character positions.
- CTRL-J (0xA) Line-feed (LF)
- The cursor moves down one line, remaining at the
same character position on the line. If the cursor is already at the bottom
line, the screen either scrolls up or ‘‘wraps around’’ depending on the setting
of an internal variable S (initially 1) which can be changed by the ESC
[r
control sequence. If S is greater than zero, the entire screen (including
the cursor) is scrolled up by S lines before executing the line-feed. The
top S lines scroll off the screen and are lost.
S new blank lines scroll onto the bottom of the screen. After scrolling,
the line-feed is executed by moving the cursor down one line.
- If
- S is zero,
‘wrap-around’ mode is entered. ‘ESC
[ 1 r’ exits back to scroll mode. If a line-feed
occurs on the bottom line in wrap mode, the cursor goes to the same character
position in the top line of the screen. When any line-feed occurs, the line
that the cursor moves to is cleared. This means that no scrolling occurs.
Wrap-around mode is not implemented in the window system.
- On SPARC systems,
the screen scrolls as fast as possible depending on how
- much data is backed
up waiting to be printed. Whenever a scroll must take place and the console
is in normal scroll mode (‘ESC
[ 1 r’), it scans the rest of the data awaiting
printing to see how many line-feeds occur in it. This scan stops when any
control character from the set {VT
, FF
, SO
, SI
, DLE
, DC
1, DC
2, DC
3, DC
4,
NAK
, SYN
, ETB
, CAN
, EM
, SUB
, ESC
, FS
, GS
, RS
, US
} is found. At that point,
the screen is scrolled by N lines (N >= 1) and processing continues. The
scanned text is still processed normally to fill in the newly created lines.
This results in much faster scrolling with scrolling as long as no escape
codes or other control characters are intermixed with the text.
- See also
the discussion of the ‘Set scrolling’
- (ESC
[r) control function below.
- CTRL-K
(0xB) Reverse Line-feed
- The cursor moves up one line, remaining at the same
character position on the line. If the cursor is already at the top line,
nothing happens.
- CTRL-L (0xC) Form-feed (FF)
- The cursor is positioned to the
Home position (upper-left corner) and the entire screen is cleared.
- CTRL-M
(0xD) Return (CR)
- The cursor moves to the leftmost character position on
the current line.
- CTRL-[
(0x1B) Escape (ESC)
- This is the escape character. Escape initiates a multi-character
control sequence.
- ESC[#@ Insert Character (ICH)
- Takes one parameter, # (default
1). Inserts # spaces at the current cursor position. The tail of the current
line starting at the current cursor position inclusive is shifted to the
right by # character positions to make room for the spaces. The rightmost
# character positions shift off the line and are lost. The position of
the cursor is unchanged.
- ESC[#A Cursor Up (CUU)
- Takes one parameter, # (default 1). Moves the cursor
up # lines. If the cursor is fewer than # lines from the top of the screen,
moves the cursor to the topmost line on the screen. The character position
of the cursor on the line is unchanged.
- ESC[#B Cursor Down (CUD)
- Takes one
parameter, # (default 1). Moves the cursor down # lines. If the cursor
is fewer than # lines from the bottom of the screen, move the cursor to
the last line on the screen. The character position of the cursor on the
line is unchanged.
- ESC[#C Cursor Forward (CUF)
- Takes one parameter, # (default
1). Moves the cursor to the right by # character positions on the current
line. If the cursor is fewer than # positions from the right edge of the
screen, moves the cursor to the rightmost position on the current line.
- ESC[#D Cursor Backward (CUB)
- Takes one parameter, # (default 1). Moves the
cursor to the left by # character positions on the current line. If the
cursor is fewer than # positions from the left edge of the screen, moves
the cursor to the leftmost position on the current line.
- ESC[#E Cursor Next
Line (CNL)
- Takes one parameter, # (default 1). Positions the cursor at
the leftmost character position on the #-th line below the current line.
If the current line is less than # lines from the bottom of the screen,
positions the cursor at the leftmost character position on the bottom line.
- ESC[#1;#2f Horizontal And Vertical Position (HVP)
- or
- ESC[#1;#2H Cursor Position
(CUP)
- Takes two parameters, #1 and #2 (default 1, 1). Moves the cursor
to the #2-th character position on the #1-th line. Character positions are
numbered from 1 at the left edge of the screen; line positions are numbered
from 1 at the top of the screen. Hence, if both parameters are omitted,
the default action moves the cursor to the home position (upper left corner).
If only one parameter is supplied, the cursor moves to column 1 of the
specified line.
- ESC[J Erase in Display (ED)
- Takes no parameters. Erases
from the current cursor position inclusive to the end of the screen. In
other words, erases from the current cursor position inclusive to the end
of the current line and all lines below the current line. The cursor position
is unchanged.
- ESC[K Erase in Line (EL)
- Takes no parameters. Erases from the
current cursor position inclusive to the end of the current line. The cursor
position is unchanged.
- ESC[#L Insert Line (IL)
- Takes one parameter, # (default
1). Makes room for # new lines starting at the current line by scrolling
down by # lines the portion of the screen from the current line inclusive
to the bottom. The # new lines at the cursor are filled with spaces; the
bottom # lines shift off the bottom of the screen and are lost. The position
of the cursor on the screen is unchanged.
- ESC[#M Delete Line (DL)
- Takes one
parameter, # (default 1). Deletes # lines beginning with the current line.
The portion of the screen from the current line inclusive to the bottom
is scrolled upward by # lines. The # new lines scrolling onto the bottom
of the screen are filled with spaces; the # old lines beginning at the
cursor line are deleted. The position of the cursor on the screen is unchanged.
- ESC[#P Delete Character (DCH)
- Takes one parameter, # (default 1). Deletes
# characters starting with the current cursor position. Shifts to the left
by # character positions the tail of the current line from the current
cursor position inclusive to the end of the line. Blanks are shifted into
the rightmost # character positions. The position of the cursor on the
screen is unchanged.
- ESC[#m Select Graphic Rendition (SGR)
- Takes one parameter,
# (default 0). Note: unlike most escape sequences, the parameter defaults
to zero if omitted. Invokes the graphic rendition specified by the parameter.
All following printing characters in the data stream are rendered according
to the parameter until the next occurrence of this escape sequence in the
data stream. Currently only two graphic renditions are defined:
- Normal rendition.
- Negative (reverse) image.
- Negative image displays characters as white-on-black
if the screen mode
- is currently black-on white, and vice-versa. Any non-zero
value of # is currently equivalent to 7 and selects the negative image
rendition.
- ESC[p Black On White (SUNBOW)
- Takes no parameters. Sets the screen
mode to black-on-white. If the screen mode is already black-on-white, has no
effect. In this mode spaces display as solid white, other characters as
black-on-white. The cursor is a solid black block. Characters displayed in
negative image rendition (see ‘Select Graphic Rendition’ above) is white-on-black
in this mode. This is the initial setting of the screen mode on reset.
- ESC[q White On Black (SUNWOB)
- Takes no parameters. Sets the screen mode
to white-on-black. If the screen mode is already white-on-black, has no effect.
In this mode spaces display as solid black, other characters as white-on-black.
The cursor is a solid white block. Characters displayed in negative image
rendition (see ‘Select Graphic Rendition’ above) is black-on-white in this
mode. The initial setting of the screen mode on reset is the alternative
mode, black on white.
- ESC[#r Set scrolling (SUNSCRL)
- Takes one parameter,
# (default 0). Sets to # an internal register which determines how many
lines the screen scrolls up when a line-feed function is performed with
the cursor on the bottom line. A parameter of 2 or 3 introduces a small
amount of ‘‘jump’’ when a scroll occurs. A parameter of 34 clears the screen
rather than scrolling. The initial setting is 1 on reset.
- A parameter of
zero initiates ‘‘wrap mode’’ instead of scrolling. In
- wrap mode, if a linefeed
occurs on the bottom line, the cursor goes to the same character position
in the top line of the screen. When any linefeed occurs, the line that
the cursor moves to is cleared. This means that no scrolling ever occurs.
‘ESC
[ 1 r’ exits back to scroll mode.
- For more information, see the description
of the Line-feed (CTRL-J)
- control function above.
- ESC[s Reset terminal emulator
(SUNRESET)
- Takes no parameters. Resets all modes to default, restores current
font from PROM
. Screen and cursor position are unchanged.
When
there are no errors, the redirection ioctls have return values as described
above. Otherwise, they return -1 and set errno to indicate the error.
If
the target stream is in an error state, errno is set accordingly.
- EBADF
- target does not denote an open file.
- ENOSTR
- target does not denote a STREAMS
device.
- EINVAL
- (x86 only) fd does not denote /dev/console.
- /dev/systty
- (x86 only)
- /dev/syscon
- (x86 only)
- /dev/console
- (x86 only) the device that
must be opened for the SRIOCSREDIR
and SRIOCISREDIR
ioctls
- /dev/wscons
- the workstation console, accessed by way of the redirection facility
console(7D)
The redirection ioctls block while there is I/O
outstanding on the device instance being redirected. Thus, attempting to
redirect the workstation console while there is a read outstanding on it
will hang until the read completes.
Table of Contents