'\" te .\" Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. .\" Copyright 2021 Peter Tribble. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH WSCONS 4D "August 29, 2021" .SH NAME wscons \- workstation console .SH SYNOPSIS .nf \fB#include \fR .fi .LP .nf \fBioctl\fR(\fIfd\fR, SRIOCSREDIR, \fItarget\fR); .fi .LP .nf \fBioctl\fR(\fIfd\fR, SRIOCISREDIR, \fItarget\fR); .fi .SH DESCRIPTION The \fBwscons\fR workstation console consists of a workstation keyboard and frame buffer that act together to emulate an \fBASCII\fR terminal. It includes a redirection facility that allows I/O issued to the workstation console to be diverted to a STREAMS device, enabling window systems to redirect output that would otherwise appear directly on the frame buffer in corrupted form. .SS "Redirection" The \fBwscons\fR redirection facility maintains a list of devices that are designated as redirection targets through the \fBSRIOCSREDIR\fR ioctl described below. Only the current entry is active; when the active entry is closed, the most recent remaining entry becomes active. The active entry acts as a proxy for the device being redirected and handles all \fBread\fR(2), \fBwrite\fR(2), \fBioctl\fR(2), and \fBpoll\fR(2) calls issued against the redirectee. .sp .LP The ioctls described below control the redirection facility. In both cases, \fIfd\fR is a descriptor for the device being redirected (or workstation console) and \fItarget\fR is a descriptor for a STREAMS device. .sp .ne 2 .na \fB\fBSRIOCSREDIR\fR\fR .ad .RS 16n Designates \fItarget\fR as the source and destination of I/O ostensibly directed to the device denoted by \fIfd\fR. .RE .sp .ne 2 .na \fB\fBSRIOCISREDIR\fR\fR .ad .RS 16n Returns 1 if \fItarget\fR names the device currently acting as proxy for the device denoted by \fIfd\fR, and 0 if it is not. .RE .SS "ANSI Standard Terminal Emulation" The Solaris kernel terminal emulator provides ANSI X3.64 emulation both on SPARC and x86 systems. .sp .LP On SPARC systems, the PROM monitor is used to emulate an ANSI X3.64 terminal if the kernel terminal emulator is not available for emulation. See \fBvisual_io\fR(4I) for more details. .sp .LP Note: The \fBVT100\fR adheres the \fBANSI\fR X3.64 standard. However, because the \fBVT100\fR features nonstandard extensions to \fBANSI\fR X3.64, it is incompatible with Sun terminal emulators. .sp .LP The SPARC console displays 34 lines of 80 ASCII characters per line. The x86 console displays 25 lines of 80 ASCII characters per line. Devices with smaller text capacities may display less. On SPARC systems, the \fBscreen-#rows screen-#columns\fR should be set to 34 or 80 respectively or text capacities will vary from those described above. On SPARC systems, the \fBscreen-#rows and screen-#columns\fR fields are stored in \fBNVRAM/EEPROM\fR. See \fBeeprom\fR(8) for more information. Both SPARC and x86 consoles offer scrolling, (x, y) cursor addressing ability and a number of other control functions. .sp .LP The console cursor marks the current line and character position on the screen. \fBASCII\fR characters between \fB0x20 \fR(space) and \fB0x7E\fR (tilde) inclusive are printing characters. When a print character is written to the 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. .sp .LP On SPARC based systems, later \fBPROM\fR revisions have the full 8-bit ISO Latin-1 (\fIISO 8859-1\fR) character set. Earlier \fBPROM\fR revisions display characters in the range \fB0xA0 \fRthrough \fB0xFE \fRas spaces. .sp .LP When the cursor is at the right edge of the screen, it moves to the first character position on the next line. When the cursor is at the screen's right-bottom edge, the line-feed function is performed (see \fBCTRL-J\fR below). The line-feed function scrolls the screen up by one or more lines before moving the cursor to the first character position on the next line. .SS "Control Sequence Syntax" The \fBwscons\fR console defines a number of control sequences that may occur during input. When a control sequence is written to the console, it affects one of the control functions described below. Control sequences are not displayed on screen. .sp .LP A number of control sequences (or control character functions) are of the form: .sp .LP \fBCTRL-\fR\fIx\fR .sp .LP where \fIx\fR represents a single character, such as \fBCNTRL-J\fR for a line feed. .sp .LP Other \fBANSI\fR control sequences are of the form: .sp .in +2 .nf ESC [ \fIparams char\fR .fi .in -2 .LP Note - .sp .RS 2 Spaces are included only for readability; these characters must occur in the given sequence without the intervening spaces. .RE .sp .ne 2 .na \fBESC\fR .ad .RS 10n \fBASCII\fR escape character (\fBESC, CTRL-[, 0x1B\fR). .RE .sp .ne 2 .na \fB[\fR .ad .RS 10n Left square bracket `[' (\fB0x5B)\fR. .RE .sp .ne 2 .na \fB\fIparams\fR\fR .ad .RS 10n Sequence of zero or more decimal numbers made up of digits between 0 and 9, separated by semicolons. Parameters are represented by \fIn\fR in the syntax descriptions for escape sequence functions. .RE .sp .ne 2 .na \fB\fIchar\fR\fR .ad .RS 10n Function character, which is different for each control sequence and it represented by \fIx\fR in the syntax descriptions for control character functions. .RE .sp .LP In the following examples of syntactically valid escape sequences, \fBESC \fRrepresent the single \fBASCII\fR character, Escape: .sp .ne 2 .na \fBESC[m\fR .ad .RS 22n Select graphic rendition with default parameter .RE .sp .ne 2 .na \fBESC[7m\fR .ad .RS 22n Select graphic rendition with reverse image .RE .sp .ne 2 .na \fBESC[33;54H\fR .ad .RS 22n Set cursor position .RE .sp .ne 2 .na \fBESC[123;456;0;;3;B\fR .ad .RS 22n Move cursor down .RE .sp .LP Syntactically valid control characters and \fBANSI\fR escape sequences that are not currently interpreted by the console are ignored. .sp .LP Each control function requires a specified number of parameters. If fewer parameters are supplied, the remaining parameters (with certain exceptions noted below) default to 1. If more parameters are supplied, the first \fIn\fR parameters are used by kernel terminal emulator. In contrast, only the last \fIn\fR parameters are used by PROM based emulator, where \fIn\fR is the number required by that particular command character. .sp .LP Parameters which are omitted or set to 0 are reset to the default value of 1 (with certain exceptions). For example, the command character \fBM\fR requires one parameter. \fBESC[;M\fR, \fBESC[0M\fR, \fBESC[M\fR and \fBESC[23;15;32;1M\fR are all equivalent to \fBESC[1M\fR and provide a parameter value of 1. Note that \fBESC[;5M\fR (interpreted as \fB`ESC[5M\fR') is \fInot\fR equivalent to \fBESC[5;M\fR (interpreted as `\fBESC[5;1M\fR') which is ultimately interpreted as `\fBESC[1M\fR'). .SS "ANSI Control Functions" The following paragraphs specify the \fBANSI\fR control functions implemented by the console. Each description provides: .RS +4 .TP .ie t \(bu .el o Control sequence syntax .RE .RS +4 .TP .ie t \(bu .el o Hexadecimal equivalent of control characters where applicable .RE .RS +4 .TP .ie t \(bu .el o Control function name and \fBANSI\fR or Sun abbreviation (if any). .RE .RS +4 .TP .ie t \(bu .el o Description of parameters required, if any .RE .RS +4 .TP .ie t \(bu .el o Description of the control function .RE .RS +4 .TP .ie t \(bu .el o Initial setting of the mode for functions that set a mode. To restore the initial settings, use the \fBSUNRESET\fR escape sequence. .RE .SS "Control Character Functions" The \fBwscons \fRcontrol character functions are: .sp .ne 2 .na \fBBell (BEL),\fR .ad .br .na \fBCTRL-G\fR .ad .br .na \fB0x7\fR .ad .RS 22n Used for consoles that are not equipped with an audible bell. Current Sun workstation models also flash the screen if the keyboard is not the console input device. .RE .sp .ne 2 .na \fBBackspace (BS),\fR .ad .br .na \fBCTRL-H,\fR .ad .br .na \fB0x8\fR .ad .RS 22n The cursor moves one position to the left on the current line. If it is already at the left edge of the screen, no change takes place. .RE .sp .ne 2 .na \fBTab (TAB),\fR .ad .br .na \fBCTRL-I,\fR .ad .br .na \fB0x9\fR .ad .RS 22n The cursor moves right on the current line to the next tab stop. The tab stops are fixed at every multiple of eight columns. If the cursor is already at the right edge of the screen, nothing change takes place. Otherwise, the cursor moves right a minimum of one and a maximum of eight character positions. .RE .sp .ne 2 .na \fBLine-feed (LF),\fR .ad .br .na \fBCTRL-J,\fR .ad .br .na \fB0xA\fR .ad .RS 22n The cursor, while remaining at the same character position on the line, moves down one line. If the cursor is at the bottom line, the screen either scrolls up or wraps around depending on the setting of an internal variable \fIn\fR (initially 1) . The internal variable can be changed using the \fBESC[r\fR control sequence. If \fIn\fR is greater than zero, the entire screen (including the cursor) is scrolled up by \fIn\fR lines before executing the line-feed. The top \fIn\fR lines scroll off the screen and are lost. New blank lines \fIn\fR scroll onto the bottom of the screen. After scrolling, move the cursor down one line to execute the line feed. .sp If \fIn\fR is zero, wrap-around mode is entered. The \fBESC [ 1 r\fR 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. During line-feeds, the line that the cursor moves to is cleared and no scrolling occurs. Wrap-around mode is not implemented in the window system. .sp On SPARC based systems, the speed at which the screen scrolls is dependent on the amount of data waiting to be printed. Whenever a scroll occurs and the console is in normal scroll mode (\fBESC [ 1 r\fR), it scans the rest of the data awaiting printing to see how many line-feeds occur in it. This scan stops when the console finds a control character from the set {\fBVT\fR, \fBFF\fR, \fBSO\fR, \fBSI\fR, \fBDLE\fR, \fBDC1\fR, \fBDC2\fR, \fBDC3\fR, \fBDC4\fR, \fBNAK\fR, \fBSYN\fR, \fBETB\fR, \fBCAN\fR, \fBEM\fR, \fBSUB\fR, \fBESC\fR, \fBFS\fR, \fBGS\fR, \fBRS\fR, \fBUS\fR} . At that point, the screen is scrolled by \fIn\fR lines (\fIn\fR \(>= 1) and processing continues. The scanned text is processed normally and fills in the newly created lines. As long as escape codes or other control characters are not intermixed with the text, this results in faster scrolling .RE .sp .ne 2 .na \fBReverse Line-feed,\fR .ad .br .na \fBCTRL-K,\fR .ad .br .na \fB0xB\fR .ad .RS 22n With kernel terminal emulator (while remaining at the same character position on the line), the cursor moves down one line. However, with PROM based emulator (while remaining at the same character position on the line), the cursor moves up one line. If the cursor is already at the top line, no change takes place. .RE .sp .ne 2 .na \fBForm-feed (FF)\fR .ad .br .na \fBCTRL-L,\fR .ad .br .na \fB0xC\fR .ad .RS 22n The cursor is positioned to the home position (upper-left corner) and the entire screen is cleared. .RE .sp .ne 2 .na \fBReturn (CR),\fR .ad .br .na \fBCTRL-M,\fR .ad .br .na \fB0xD\fR .ad .RS 22n The cursor moves to the leftmost character position on the current line. .RE .SS "Escape Sequence Functions" The \fBwscons \fRescape sequence functions are: .sp .ne 2 .na \fBEscape (ESC),\fR .ad .br .na \fBCTRL-[,\fR .ad .br .na \fB0x1B\fR .ad .sp .6 .RS 4n The escape character. Escape initiates a multi-character control sequence. .RE .sp .ne 2 .na \fBInsert Character (ICH)\fR .ad .br .na \fBESC[#@\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Inserts \fIn\fR spaces at the current cursor position. The current line, starting at the current cursor position inclusive, is shifted to the right by \fIn\fR character positions to make room for the spaces. The rightmost \fIn\fR character positions shift off the line and are lost. The position of the cursor is unchanged. .RE .sp .ne 2 .na \fBCursor Up (CUU),\fR .ad .br .na \fBESC[#A\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Moves the cursor up \fIn\fR lines. If the cursor is fewer than \fIn\fR 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. .RE .sp .ne 2 .na \fBCursor Down (CUD),\fR .ad .br .na \fBESC[#B\fR .ad .sp .6 .RS 4n Takes one parameter, (default 1). Moves the cursor down \fIn\fR lines. If the cursor is fewer than \fIn\fR 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. .RE .sp .ne 2 .na \fBCursor Forward (CUF),\fR .ad .br .na \fBESC[#C\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Moves the cursor to the right by \fIn\fR character positions on the current line. If the cursor is fewer than \fIn\fR positions from the right edge of the screen, moves the cursor to the rightmost position on the current line. .RE .sp .ne 2 .na \fBCursor Backward (CUB),\fR .ad .br .na \fBESC[#D\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Moves the cursor to the left by \fIn\fR character positions on the current line. If the cursor is fewer than \fIn\fR positions from the left edge of the screen, moves the cursor to the leftmost position on the current line. .RE .sp .ne 2 .na \fBCursor Next Line (CNL),\fR .ad .br .na \fBESC[#E\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Positions the cursor at the leftmost character position on the \fIn\fR-th line below the current line. If the current line is less than \fIn\fR lines from the bottom of the screen, positions the cursor at the leftmost character position on the bottom line. .RE .sp .ne 2 .na \fBHorizontal and Vertical Position (HVP),\fR .ad .br .na \fBESC[#1;#2f\fR .ad .sp .6 .RS 4n or .RE .sp .ne 2 .na \fBCursor Position (CUP),\fR .ad .br .na \fBESC[#1;#2H\fR .ad .sp .6 .RS 4n Takes two parameters, \fIn\fR1 and \fIn\fR2 (default 1, 1). Moves the cursor to the \fIn\fR2-th character position on the \fIn\fR1-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. .RE .sp .ne 2 .na \fBErase in Display (ED),\fR .ad .br .na \fBESC[J\fR .ad .sp .6 .RS 4n Takes no parameters. Erases from the current cursor position inclusive to the end of the screen, that is, to the end of the current line and all lines below the current line. The cursor position is unchanged. .RE .sp .ne 2 .na \fBErase in Line (EL),\fR .ad .br .na \fBESC[K\fR .ad .sp .6 .RS 4n Takes no parameters. Erases from the current cursor position inclusive to the end of the current line. The cursor position is unchanged. .RE .sp .ne 2 .na \fBInsert Line (IL),\fR .ad .br .na \fBESC[#L\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Makes room for \fIn\fR new lines starting at the current line by scrolling down by \fIn\fR lines the portion of the screen from the current line inclusive to the bottom. The \fIn\fR new lines at the cursor are filled with spaces; the bottom \fIn\fR lines shift off the bottom of the screen and are lost. The position of the cursor on the screen is unchanged. .RE .sp .ne 2 .na \fBDelete Line (DL),\fR .ad .br .na \fBESC[#M\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Deletes \fIn\fR lines beginning with the current line. The portion of the screen from the current line inclusive to the bottom is scrolled upward by \fIn\fR lines. The \fIn\fR new lines scrolling onto the bottom of the screen are filled with spaces; the \fIn\fR old lines beginning at the cursor line are deleted. The position of the cursor on the screen is unchanged. .RE .sp .ne 2 .na \fBDelete Character (DCH),\fR .ad .br .na \fBESC[#P\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 1). Deletes \fIn\fR characters starting with the current cursor position. Shifts the tail of the current line to the left by \fIn\fR character positions from the current cursor position, inclusive, to the end of the line. Blanks are shifted into the rightmost \fIn\fR character positions. The position of the cursor on the screen is unchanged. .RE .sp .ne 2 .na \fBSelect Graphic Rendition (SGR),\fR .ad .br .na \fBESC[#m\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 0). Note that 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. With PROM-based emulator, only two graphic renditions are defined: .sp .ne 2 .na \fB0\fR .ad .RS 5n Normal rendition .RE .sp .ne 2 .na \fB7\fR .ad .RS 5n Negative (reverse) image .RE 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 \fIn\fR is currently equivalent to 7 and selects the negative image rendition. .sp In addition to the two renditions mentioned above, the following\fI ISO 6429-1983\fR graphic rendition values support color text with kernel terminal emulator: .sp .ne 2 .na \fB30\fR .ad .RS 6n black foreground .RE .sp .ne 2 .na \fB31\fR .ad .RS 6n red foreground .RE .sp .ne 2 .na \fB32\fR .ad .RS 6n green foreground .RE .sp .ne 2 .na \fB33\fR .ad .RS 6n brown foreground .RE .sp .ne 2 .na \fB34\fR .ad .RS 6n blue foreground .RE .sp .ne 2 .na \fB35\fR .ad .RS 6n magenta foreground .RE .sp .ne 2 .na \fB36\fR .ad .RS 6n cyan foreground .RE .sp .ne 2 .na \fB37\fR .ad .RS 6n white foreground .RE .sp .ne 2 .na \fB40\fR .ad .RS 6n black background .RE .sp .ne 2 .na \fB41\fR .ad .RS 6n red background .RE .sp .ne 2 .na \fB42\fR .ad .RS 6n green background .RE .sp .ne 2 .na \fB43\fR .ad .RS 6n brown background .RE .sp .ne 2 .na \fB44\fR .ad .RS 6n blue background .RE .sp .ne 2 .na \fB45\fR .ad .RS 6n magenta background .RE .sp .ne 2 .na \fB46\fR .ad .RS 6n cyan background .RE .sp .ne 2 .na \fB47\fR .ad .RS 6n white background .RE .RE .sp .ne 2 .na \fBBlack On White (SUNBOW),\fR .ad .br .na \fBESC[p\fR .ad .sp .6 .RS 4n Takes no parameters. On SPARC, 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) are white-on-black. This comprises the initial setting of the screen mode on reset. On x86 systems, use \fBESC[q\fR to set black-on-white. .RE .sp .ne 2 .na \fBWhite On Black (SUNWOB),\fR .ad .br .na \fBESC[q\fR .ad .sp .6 .RS 4n Takes no parameters. On SPARC, 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) are black-on-white. Initial setting of the screen mode on reset is black on white. On x86 systems, use \fBESC[p\fR to set white-on-black. .RE .sp .ne 2 .na \fBESC[#r\fR .ad .br .na \fBSet Scrolling (SUNSCRL)\fR .ad .sp .6 .RS 4n Takes one parameter, \fIn\fR (default 0). Sets to \fIn\fR 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. .sp A parameter of zero initiates wrap mode instead of scrolling. If a linefeed occurs on the bottom line during wrap mode, the cursor goes to the same character position in the top line of the screen. When a line feed occurs, the line that the cursor moves to is cleared and no scrolling occurs. \fBESC [ 1 r\fR exits back to scroll mode. .sp For more information, see the description of the Line-feed (\fBCTRL-J\fR) control function above. .RE .sp .ne 2 .na \fBESC[s\fR .ad .br .na \fBReset terminal emulator (SUNRESET)\fR .ad .sp .6 .RS 4n Takes no parameters. Resets all modes to default, restores current font from \fBPROM.\fR Screen and cursor position are unchanged. .RE .SH RETURN VALUES When there are no errors, the redirection ioctls have return values as described above. Otherwise, they return \fB\(mi1\fR and set \fBerrno\fR to indicate the error. If the target stream is in an error state, \fBerrno \fRis set accordingly. .sp .LP If the \fItarget\fR stream is in an error state, \fBerrno\fR is set accordingly. .SH ERRORS .ne 2 .na \fB\fBEBADF\fR\fR .ad .RS 10n \fItarget\fR does not denote an open file. .RE .sp .ne 2 .na \fB\fBENOSTR\fR\fR .ad .RS 10n \fItarget\fR does not denote a \fBSTREAMS\fR device. .RE .SH FILES .ne 2 .na \fB\fB/dev/wscons\fR\fR .ad .RS 16n Workstation console, accessed via the redirection facility .RE .sp .ne 2 .na \fB\fB/dev/systty\fR\fR .ad .RS 16n Devices that must be opened for the \fBSRIOCSREDIR\fR and \fBSRIOCISREDIR\fR ioctls. .RE .sp .ne 2 .na \fB\fB/dev/syscon\fR\fR .ad .RS 16n Access system console .RE .sp .ne 2 .na \fB\fB/dev/console\fR\fR .ad .RS 16n Access system console .RE .SH ATTRIBUTES See \fBattributes\fR(7) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Stable .TE .SH SEE ALSO .BR ioctl (2), .BR poll (2), .BR read (2), .BR write (2), .BR console (4D), .BR visual_io (4I), .BR eeprom (8) .SH WARNINGS The redirection ioctls block while there is I/O outstanding on the device instance being redirected. If you try to redirect the workstation console while there is a outstanding read, the workstation console will hang until the read completes.