Linux Console Control Sequences [INLINE] Author: [1]Gianpaolo Macario <[2]macario@mbox.vol.it>. Version 0.2 - Last revised on 08-JAN-1997. _________________________________________________________________ Introduction This document describes the control sequences of the Linux console. This is only a reference guide; more information should be found by looking directly at the source code, more specifically in file console.c in the directory drivers/char of the Linux source tree. Suggestions and corrections to this document are gladly welcome: please send your submissions to [3]macario@mbox.vol.it with "linux-console" in the subject field. Availability The source document is in HTML format. [4]Click here to get a text version, generated with the following command: $ lynx -dump linux-console.html >linux-console.txt Copyrights This document is Copyright (c) 1997 by Gianpaolo Macario. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this document under the conditions for verbatim copying, provided that this copyright notice is included exactly as in the original, and that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this document into another language, under the above conditions for modified versions. _________________________________________________________________ Commands defined in do_con_write() ESnormal Commands NUL Do nothing: ignorated when received. BEL Bell: generates bell tone if bell is enabled. BS Backspace: move cursor to the left one character position: if cursor is at left margin, no action occurs. LF Line feed: causes a new line feed or a new line operation, depending on the setting of new line mode. CR Carriage return: move cursor to left margin on current line. SO Set G0_charset SI Set G1_charset DC4 vc_state=ESnormal SYN vc_state=ESnormal ESC vc_state=ESesc DEL Delete ESC+128 vc_state=ESsquare ESesc Commands ESC 7 Do save_cur(currcons) ESC 8 Do restore_cur(currcons) ESC D Do lf(currcons) ESC E Do cr(currcons),lf(currcons) ESC H Set tab_stop (???) ESC M Do ri(currcons) ESC Z Do respond_ID(tty) ESC c Hard terminal reset (RIS): Replaces all set-up parameters with NVR values or power-up default values if NVR values do not exist. ESC > (VT52) Numeric keypad: exit alternate keypad mode. ESC = (VT52) Application keypad: enter alternate keypad mode. The following prefixes only change state: ESC ESC vc_state=ESnormal ESC [ vc_state=ESsquare ESC ] vc_state=ESnonstd ESC ( vc_state=ESsetG0 ESC ) vc_state=ESsetG1 ESC # vc_state=ESsethash ESC % vc_state=ESpercent ESnonstd Commands ESC ] P Palette escape sequence (???) ESC ] R Reset palette ESpalette Commands TBD ESsquare Commands ESC [ [ vc_state=ESfunckey ESC [ ? continue (???), else fallback to ESgetpars ESgetpars Commands TBD ESgotpars Commands Format: * Sequence1: ESC [ ; ; ... ; * Sequence2: CSI ; ; ... ; CSI A Cursor up: Move cursor up lines in the same column. CSI B Cursor down: Move cursor down lines in the same column. CSI C Cursor fwd: Move cursor right columns. CSI D Cursor back: Move cursor left columns. CSI E gotoxy(currcons,0,y+par[0]) /* Down posit, beg.lin */ CSI F gotoxy(currcons,0,y-par[0]) /* Up posit, beg.lin */ CSI G gotoxy(currcons,par[0],y) /* Locate curs. at row */ CSI ; H Cursor position: Moves cursor to line , column . The numbering of the lines and columns depends on the state (set/reset) of origin mode (DECOM). CSI a Cursor fwd: Move cursor right columns. ... c if (!par[0]) respond_ID(tty) ... d gotoxay(currcons,x,par[0]) CSI e Cursor down: Move cursor down lines in the same column. CSI ; f Cursor position: Moves cursor to line , column . The numbering of the lines and columns depends on the state (set/reset) of origin mode (DECOM). CSI 3 g Reset tab_stops CSI

g Set tab_stops (???) CSI ? 5 n status_report(tty)... CSI ? 6 n cursor_report(???)... CSI q setledstate(...) /* DECLL, but only 3 leds */ + CSI 0 q ==> Clear all LEDs + CSI 1 q ==> Turn on LED 1 + CSI 2 q ==> Turn on LED 2 + CSI 3 q ==> Turn on LED 3 + CSI 4 q ==> Turn on LED 4 /* VT100, unimplemented */ CSI ; r Set Top and Bottom Margins (DECSTBM): Selects top and bottom margins defining the scrolling region. is the line number of the first line in the scrolling region. is the line number of the bottom line. If you do not select either or , they default to top and bottom respectively. Lines are counted from 1. ... s save_cur(currcons) ... u restore_cur(currcons) ... ] setterm_command(currcons) CSI ` gotoxy(currcons,par[0],y) /* Locate curs. at row */ The following codes are better described below: ... @ csi_at(currcons,par[0]) ... J csi_J(currcons,par[0]) ... K csi_K(currcons,par[0]) ... L csi_L(currcons,par[0]) ... M csi_M(currcons,par[0]) ... P csi_P(currcons,par[0]) ... X csi_X(currcons,par[0]) ... h set_mode(currcons,1) ... l set_mode(currcons,0) ... m csi_m(currcons) ESpercent Commands ESC % 8 utf=1 /* retained for compatibility */ ESC % @ utf=0 /* defined in ISO 2022 */ ESC % G utf=1 /* prelim official escape code */ ESfunckey Commands => vc_state=ESnormal EShash Commands ESC # 8 ??? ESsetG0 Commands ESC ( 0 G0_charset=GRAF_MAP; set_translate(G0_charset) ESC ( B G0_charset=LAT1_MAP ESC ( U G0_charset=IBMPC_MAP ESC ( K G0_charset=USER_MAP ESsetG1 Commands ESC ) 0 G1_charset=GRAF_MAP; set_translate(G1_charset) ESC ) B G1_charset=LAT1_MAP ESC ) U G1_charset=IBMPC_MAP ESC ) K G1_charset=USER_MAP _________________________________________________________________ Commands defined in csi__xxx_() Commands defined in csi_at() TBD CSI @ while (nr--) insert_char(currcons) Commands defined in csi_J() CSI J Erase in display (ED): Erase from the cursor to the end of the screen, including the cursor position. CSI 0 J Same as above. CSI 1 J Erase from the beginning of the screen to the cursor, including the cursor position. CSI 2 J Erase the complete display. Commands defined in csi_K() CSI K Erase in line (EL): Erases from cursor to the end of line, including the cursor position. CSI 0 K Same as above. CSI 1 K Erase from the beginning of the line to the cursor, including the cursor position. CSI 2 K Erase the complete line. Commands defined in csi_L() CSI L Insert line (IL): Inserts lines at the cursor. Commands defined in csi_M() CSI M Delete line (DL): Deletes lines starting at the line with the cursor. Commands defined in csi_P() CSI P Delete character (DCH): Deletes characters starting with the character at the cursor position. Commands defined in csi_X() TBD ??? (not vt100?) Commands defined in csi_m() * Sequence1: ESC [ ... * Sequence2: CSI ... Note: numbers are represented in ASCII, i.e. 'CSI 10 m' actually means "\033[10m" CSI 0 m Default Attributes CSI 1 m Intensity=2 CSI 2 m Intensity=0 CSI 4 m Underline=1 CSI 5 m Blink=1 CSI 7 m Reverse=1 CSI 10 m ANSI X3.64-1979 (SCO-ish?) Select primary font, don't display control chars if defined, don't set bit 8 on output CSI 11 m ANSI X3.64-1979 (SCO-ish?) Select first alternate font, toggle high bit before displaying as ROM chars. CSI 12 m ANSI X3.64-1979 (SCO-ish?) Select second alternate font, toggle high bit before displaying as ROM chars. CSI 21 m Intensity=1 CSI 22 m Intensity=1 CSI 24 m Underline=0 CSI 25 m Blink=0 CSI 27 m Reverse=0 CSI 30 m color=color_table[0] CSI 31 m color=color_table[1] CSI 32 m color=color_table[2] CSI 33 m color=color_table[3] CSI 34 m color=color_table[4] CSI 35 m color=color_table[5] CSI 36 m color=color_table[6] CSI 37 m color=color_table[7] CSI 38 m ANSI X3.64-1979 (SCO-ish?) Enables underscore, white foreground with white underscore (Linux - use default foreground). CSI 39 m ANSI X3.64-1979 (SCO-ish?) Disable underline option. Reset color to default? It did this before... CSI 49 m ??? Commands defined in set_mode() * Prefix for ANSI modes set: CSI h * Prefix for ANSI modes reset: CSI l CSI 3 h disp_ctrl = 1 CSI 3 l disp_ctrl = 0 CSI 4 h decim = 1 CSI 4 l decim = 0 CSI 20 h Set LF,Enter==CRLF/LF: set_kbd(lnm) CSI 20 l Clr LF,Enter==CRLF/LF: clr_kbd(lnm) * Prefix for DEC private modes set: CSI ? h * Prefix for DEC private modes reset: CSI ? l CSI ? 1 h set_kbd(decckm) CSI ? 1 l clr_kbd(decckm) CSI ? 3 h do nothing /* 80/132 mode switch unimplemented */ CSI ? 3 l do nothing /* 80/132 mode switch unimplemented */ CSI ? 5 h Inverted screen on CSI ? 5 l Inverted screen off CSI ? 6 h Origin relative CSI ? 6 l Origin absolute CSI ? 7 h Autowrap on CSI ? 7 l Autowrap off CSI ? 8 h set_kbd(decarm) CSI ? 8 l clr_kbd(decarm) CSI ? 9 h report_mouse = 1 CSI ? 9 l report_mouse = 0 CSI ? 25 h deccm=1; set_cursor(currcons) CSI ? 25 l deccm=l; set_cursor(currcons) CSI ? 1000 h report_mouse = 2 CSI ? 1000 l report_mouse = 0 Commands defined in setterm_command() The following commands are Linux-specific: CSI 1 ; ] Set color for underline mode ( = 0 - 15) CSI 2 ; ] Set color for half intensity mode ( = 0 - 15) CSI 8 ] Store colors as defaults CSI 9 ; ] Set blanking interval (in seconds???) CSI 10 ; ] Set bell frequency in Hz CSI 11 ; ] Set bell duration in milliseconds CSI 12 ; ] Bring specified console to the front CSI 13 ] Unblank the screen CSI 14 ; ] Set VESA powerdown interval _________________________________________________________________ VT52 Control Sequences (not implemented in Linux) CSI ? 2 l Enter VT52 emulation. Only VT52 escape sequences are recognized. ESC < ANSI mode ESC F Character set: graphics ESC G Character set: ASCII ESC A Cursor up ESC B Cursor down ESC C Cursor right ESC D Cursor left (VT52) ESC H Home cursor ESC J Erase to end of screen ESC K Erase to end of line ESC Y Position cursor The parameters and are equal to the character whose value is the desired row and column plus 31. For example row 2 and column 4 would be ESC Y ! #. Escape Sequences as defined from VT100 doc * ESC ( {final} = G0 * ESC ) {final} = G1 * ESC * {final} = G2 * ESC + {final} = G3 _________________________________________________________________ ANSI Characters Symbol value(dec) Note NUL 0 SOH 1 STX 2 ETX 3 EOT 4 ENQ 5 ACK 6 BEL 7 BS 8 TAB 9 LF 10 VT 11 FF 12 CR 13 SO 14 SI 15 DLE 16 DC1 17 (also XON) DC2 18 DC3 19 (also XOFF) DC4 20 NAK 21 SYN 22 ETB 23 CAN 24 EM 25 SYN 26 ESC 27 FS 28 GS 29 RS 30 US 31 ... DEL 127 ... CSI 155 ... References 1. http://www.geocities.com/SiliconValley/Pines/5004/ 2. mailto:macario@mbox.vol.it 3. mailto:macario@mbox.vol.it 4. http://twin.macario.vol.it/~gianpi/geocities/linux-console.txt