1 /* 2 * control_codes.h 3 * Copyright (C) 2016 Kovid Goyal <kovid at kovidgoyal.net> 4 * 5 * Distributed under terms of the GPL3 license. 6 */ 7 8 #pragma once 9 10 // Space 11 #define SP ' ' 12 13 // *Null*: Does nothing. 14 #define NUL 0 15 16 // *Bell*: Beeps. 17 #define BEL 0x07 18 19 // *Backspace*: Backspace one column, but not past the beginning of the 20 // line. 21 #define BS 0x08 22 23 // *Horizontal tab*: Move cursor to the next tab stop, or to the end 24 // of the line if there is no earlier tab stop. 25 #define HT 0x09 26 27 // *Linefeed*: Give a line feed, and, if LNM (new 28 // line mode) is set also a carriage return. 29 #define LF 10 30 31 // *Vertical tab*: Same as :data:`LF`. 32 #define VT 0x0b 33 // *Form feed*: Same as :data:`LF`. 34 #define FF 0x0c 35 36 // *Carriage return*: Move cursor to left margin on current line. 37 #define CR 13 38 39 // *Shift out*: Activate G1 character set. 40 #define SO 0x0e 41 42 // *Shift in*: Activate G0 character set. 43 #define SI 0x0f 44 45 // *Cancel*: Interrupt escape sequence. If received during an escape or 46 // control sequence, cancels the sequence and displays substitution 47 // character. 48 #define CAN 0x18 49 // *Substitute*: Same as :data:`CAN`. 50 #define SUB 0x1a 51 52 // *Escape*: Starts an escape sequence. 53 #define ESC 0x1b 54 55 // *Delete*: Is ignored. 56 #define DEL 0x7f 57 58 #define IND 0x84 59 #define NEL 0x85 60 #define HTS 0x88 61 #define RI 0x8d 62 #define DCS 0x90 63 #define CSI 0x9b 64 #define ST 0x9c 65 #define OSC 0x9d 66 #define PM 0x9e 67 #define APC 0x9f 68 69 // Sharp control codes 70 // ------------------- 71 72 // Align display 73 #define DECALN '8' 74 75 // Esc control codes 76 // ------------------ 77 78 #define ESC_DCS 'P' 79 #define ESC_OSC ']' 80 #define ESC_CSI '[' 81 #define ESC_ST '\\' 82 #define ESC_PM '^' 83 #define ESC_APC '_' 84 85 // *Reset*. 86 #define ESC_RIS 'c' 87 88 // *Index*: Move cursor down one line in same column. If the cursor is 89 // at the bottom margin, the screen performs a scroll-up. 90 #define ESC_IND 'D' 91 92 // *Next line*: Same as LF. 93 #define ESC_NEL 'E' 94 95 // Tabulation set: Set a horizontal tab stop at cursor position. 96 #define ESC_HTS 'H' 97 98 // *Reverse index*: Move cursor up one line in same column. If the 99 // cursor is at the top margin, the screen performs a scroll-down. 100 #define ESC_RI 'M' 101 102 // Save cursor: Save cursor position, character attribute (graphic 103 // rendition), character set, and origin mode selection (see 104 // :data:`DECRC`). 105 #define ESC_DECSC '7' 106 107 // *Restore cursor*: Restore previously saved cursor position, character 108 // attribute (graphic rendition), character set, and origin mode 109 // selection. If none were saved, move cursor to home position. 110 #define ESC_DECRC '8' 111 112 // Set normal keypad mode 113 #define ESC_DECKPNM '>' 114 115 // Set alternate keypad mode 116 #define ESC_DECKPAM '=' 117 118 // ECMA-48 CSI sequences. 119 // --------------------- 120 121 // *Insert character*: Insert the indicated # of blank characters. 122 #define ICH '@' 123 124 // *Cursor up*: Move cursor up the indicated # of lines in same column. 125 // Cursor stops at top margin. 126 #define CUU 'A' 127 128 // *Cursor down*: Move cursor down the indicated # of lines in same 129 // column. Cursor stops at bottom margin. 130 #define CUD 'B' 131 132 // *Cursor forward*: Move cursor right the indicated # of columns. 133 // Cursor stops at right margin. 134 #define CUF 'C' 135 136 // *Cursor back*: Move cursor left the indicated # of columns. Cursor 137 // stops at left margin. 138 #define CUB 'D' 139 140 // *Cursor next line*: Move cursor down the indicated # of lines to 141 // column 1. 142 #define CNL 'E' 143 144 // *Cursor previous line*: Move cursor up the indicated # of lines to 145 // column 1. 146 #define CPL 'F' 147 148 // *Cursor horizontal align*: Move cursor to the indicated column in 149 // current line. 150 #define CHA 'G' 151 152 // *Cursor position*: Move cursor to the indicated line, column (origin 153 // at ``1, 1``). 154 #define CUP 'H' 155 156 // *Erase data* (default: from cursor to end of line). 157 #define ED 'J' 158 159 // *Erase in line* (default: from cursor to end of line). 160 #define EL 'K' 161 162 // *Insert line*: Insert the indicated # of blank lines, starting from 163 // the current line. Lines displayed below cursor move down. Lines moved 164 // past the bottom margin are lost. 165 #define IL 'L' 166 167 // *Delete line*: Delete the indicated # of lines, starting from the 168 // current line. As lines are deleted, lines displayed below cursor 169 // move up. Lines added to bottom of screen have spaces with same 170 // character attributes as last line move up. 171 #define DL 'M' 172 173 // *Delete character*: Delete the indicated # of characters on the 174 // current line. When character is deleted, all characters to the right 175 // of cursor move left. 176 #define DCH 'P' 177 178 // Scroll up by the specified number of lines 179 #define SU 'S' 180 181 // Scroll down by the specified number of lines 182 #define SD 'T' 183 184 // *Erase character*: Erase the indicated # of characters on the 185 // current line. 186 #define ECH 'X' 187 188 // *Horizontal position relative*: Same as :data:`CUF`. 189 #define HPR 'a' 190 191 // Repeat the preceding graphic character Ps times. 192 #define REP 'b' 193 194 // *Device Attributes*. 195 #define DA 'c' 196 197 // *Vertical position adjust*: Move cursor to the indicated line, 198 // current column. 199 #define VPA 'd' 200 201 // *Vertical position relative*: Same as :data:`CUD`. 202 #define VPR 'e' 203 204 // *Horizontal / Vertical position*: Same as :data:`CUP`. 205 #define HVP 'f' 206 207 // *Tabulation clear*: Clears a horizontal tab stop at cursor position. 208 #define TBC 'g' 209 210 // *Set mode*. 211 #define SM 'h' 212 213 // *Reset mode*. 214 #define RM 'l' 215 216 // *Select graphics rendition*: The terminal can display the following 217 // character attributes that change the character display without 218 // changing the character 219 #define SGR 'm' 220 221 // *Device status report*. 222 #define DSR 'n' 223 224 // Soft reset 225 #define DECSTR 'p' 226 227 // *Horizontal position adjust*: Same as :data:`CHA`. 228 #define HPA '`' 229 230 // Back tab 231 #define CBT 'Z' 232 233 // Forward tab 234 #define CHT 'I' 235 236 // Misc sequences 237 // ---------------- 238 239 // Change cursor shape/blink 240 #define DECSCUSR 'q' 241