> Please note that this is a "living document" and may lag or lead the state
> of the current stable release in a number of areas--as you might imagine,
> precisely documenting escape codes and their behaviors and cross-checking
> with the various technical documents is laborious and tedious and I only
> have so much spare time!
>
> If you notice that something is inaccurate or missing, please do [file an issue](https://github.com/wez/wezterm/issues/new/choose)
> so that it can be resolved!
## Output/Escape Sequences
WezTerm considers the output from the terminal to be a UTF-8 encoded stream of
codepoints. No other encoding is supported. As described below, some C1
control codes have both 7-bit ASCII compatible as well as 8-bit
representations. As ASCII is a compatible subset of UTF-8, the 7-bit
representations are preferred and processed without any special consideration.
The 8-bit values *are* recognized, but only if the 8-bit value is treated as a
unicode code point and encoded via a UTF-8 multi-byte sequence.
### Printable Codepoints
Codepoints with value 0x20 and higher are considered to be printable and are
applied to the terminal display using the following rules:
* Codepoints are buffered until a C0, C1 or other escape/control sequence is encountered,
which triggers a flush and processing continues with the next step.
* The buffered codepoint sequence is split into unicode graphemes, which means that
combining sequences and emoji are decoded. Processing continues for below for
each individually recognized grapheme.
* If DEC line drawing mode is active, graphemes `j-n`, `q`, `t-x` are translated
to equivalent line drawing graphemes and processing continues.
* If prior output/actions require it, the cursor position may be moved to a new line
and the terminal display may be scrolled to make accomodate it.
* An appropriate number of cells, starting at the current cursor position,
are allocated based on the column width of the current grapheme and are assigned
to the grapheme. The current current graphics rendition state (such as colors
and other presentation attributes) is also applied to those cells.
If insert mode is active, those cells will be inserted at the current cursor
position, otherwise they will overwrite cells at the current cursor position.
* The cursor position will be updated based on the column width of the grapheme.
After the graphemes are applied to the terminal display, the rendering portion of
WezTerm will attempt to apply your [font shaping](config/font-shaping.html) configuration
based on runs of graphemes with matching graphic attributes to determine which glyphs
should be rendered from your fonts; it is at this stage that emoji and ligatures are
resolved.
### C0 Control Codes
Codepoints in the range `0x00-0x1F` are considered to be `C0` control codes.
`C0` controls will flush any buffered printable codepoints before triggering
the action described below.
| Seq|Hex |Name|Description|Action |
|----|----|----|-----------|------ |
| ^@ |0x00|NUL |Null |Ignored|
| ^A |0x01|SOH |Start of Heading|Ignored|
| ^B |0x02|STX |Start of Text|Ignored|
| ^C |0x03|ETX |End of Text|Ignored|
| ^D |0x04|EOT |End of Transmission|Ignored|
| ^E |0x05|ENQ |Enquiry |Ignored|
| ^F |0x06|ACK |Acknowledge|Ignored|
| ^G |0x07|BEL |Bell |Logs `Ding! (this is the bell)` to stderr of the WezTerm process. See [#3](https://github.com/wez/wezterm/issues/3)|
| ^H |0x08|BS |Backspace |Move cursor left by 1, constrained by the left margin. If Reverse Wraparound and dec auto wrap modes are enabled, moving left of the left margin will jump the cursor to the right margin, jumping to bottom right margin if it was at the top left.|
| ^I |0x09|HT |Horizontal Tab|Move cursor right to the next tab stop|
| ^J |0x0A|LF |Line Feed |If cursor is at the bottom margin, scroll the region up, otherwise move cursor down 1 row|
| ^K |0x0B|VT |Vertical Tab|Treated as Line Feed|
| ^L |0x0C|FF |Form Feed |Treated as Line Feed|
| ^M |0x0D|CR |Carriage Return|If cursor is left of leftmost margin, move to column 0. Otherwise move to left margin|
|ESC \\|0x9C |ST |String Terminator |No direct effect; ST is used to delimit the end of OSC style escape sequences|
### Other Escape Sequences
As these sequences start with an `ESC`, which is a `C0` control, these will
flush any buffered printable codepoints before triggering the associated
action.
|Seq | Name | Description | Action |
|-------|--------|---------------------|--------|
|ESC c | [RIS](https://vt100.net/docs/vt510-rm/RIS.html) | Reset to Initial State | Resets tab stops, margins, modes, graphic rendition, palette, activates primary screen, erases the display and moves cursor to home position |
|ESC 7 | [DECSC](https://vt100.net/docs/vt510-rm/DECSC.html) | Save Cursor Position| Records cursor position |
|ESC 8 | [DECRC](https://vt100.net/docs/vt510-rm/DECRC.html) | Restored Saved Cursor Position | Moves cursor to location it had when DECSC was used |
|ESC > | [DECPNM](https://vt100.net/docs/vt510-rm/DECPNM.html) | Normal Keypad | Set Normal Keypad Mode |
|ESC (0 | | DEC Line Drawing character set | Translate characters `j-x` to line drawing glyphs |
|ESC (B | | US ASCII character set | Disables DEC Line Drawing character translation |
|ESC #8 | [DECALN](https://vt100.net/docs/vt510-rm/DECALN.html) | Screen Alignment Display | Fills the display with `E` characters for diagnostic/test purposes (for vttest) |
### CSI - Control Sequence Introducer Sequences
CSI sequences begin with the `C1``CSI` sequence, which is either the 7-bit
`ESC [` sequence or the codepoint `0x9B`.
WezTerm classifies these sequences into a number of functional families which
are broken out below.
#### Graphic Rendition (SGR)
SGR sequences are of the form `CSI DIGITS [; DIGITS ]+ m`. That is, any number
of semicolon separated numbers, terminated by the `m` codepoint. There are a handful
of slightly more modern sequences that use colon `:` codepoints to encode additional
context.
The digits map to one of the codes in the table below, which manipulate the
presentation attributes of subsequently printed characters.
It is valid to omit the code number; for example `CSI m` is equivalent to `CSI
0 m` which resets the presentation attributes.
|Code|Description|Action|
|--- |-----------|------|
|0 |Reset |Reset to default foreground/background colors, reset all presentation attributes, clear any explicit hyperlinks|
|1 |IntensityBold|Set the intensity level to Bold. This causes subsequent text to be rendered in a bold font variant and, if the foreground color is set to a palette index in the 0-7 range, effectively shifts it to the brighter value in the 8-15 range|
|2 |IntensityDim|Set the intensity level to Dim or Half-Bright. This causes text to be rendered in a lighter weight font variant|
|3 |ItalicOn|Sets the italic attribute on the text, causing an italic font variant to be selected|
|4 |UnderlineOn|Text will have a single underline|
|4:0 |UnderlineOff|Text will have no underline|
|4:1 |UnderlineOn|Text will have a single underline|
|4:2 |UnderlineDouble|Text will be rendered with double underline|
|4:3 |UnderlineCurly|Text will be rendered with a curly underline|
|4:4 |UnderlineDotted|Text will be rendered with a dotted underline|
|4:5 |UnderlineDashed|Text will be rendered with a dashed underline|
The `C1``DCS` escape places the terminal parser into a device control mode until the `C1``ST` is encountered.
In the table below, `DCS` can be either the 7-bit representation (`ESC P`) or the 8-bit codepoint (`0x90`).
|Seq | Name | Description |
|--------|-------|---------------------|
|DCS $ q " p ST | [DECRQSS](https://vt100.net/docs/vt510-rm/DECRQSS.html) for [DECSCL](https://vt100.net/docs/vt510-rm/DECSCL.html) | Request Conformance Level; Reports the conformance level |
|DCS $ q r ST | [DECRQSS](https://vt100.net/docs/vt510-rm/DECRQSS.html) for [DECSTBM](https://vt100.net/docs/vt510-rm/DECSTBM.html) | Request top and bottom margin report; Reports the margins |
|DCS $ q s ST | [DECRQSS](https://vt100.net/docs/vt510-rm/DECRQSS.html) for [DECSLRM](https://vt100.net/docs/vt510-rm/DECSLRM.html) | Request left and right margin report; Reports the margins |
|DCS \[PARAMS\] q \[DATA\] ST | Sixel Graphic Data | Decodes [Sixel graphic data](https://vt100.net/docs/vt3xx-gp/chapter14.html) and apply the image to the terminal model. Support is preliminary and incomplete; see [this issue](https://github.com/wez/wezterm/issues/217) for status. |
|DCS 1000 q | tmux control mode | Bridges tmux into the WezTerm multiplexer. Currently incomplete, see [this issue](https://github.com/wez/wezterm/issues/336) for status. |
### Operating System Command Sequences
Operating System Command (OSC) sequences are introduced via `ESC ]` followed by
a numeric code and typically have parameters delimited by `;`. OSC sequences
are canonically delimited by the `ST` (String Terminator) sequence, but WezTerm
also accepts delimiting them with the `BEL` control.
The table below is keyed by the OSC code.
|OSC|Description|Action|Example|
|---|-----------|------|-------|
|0 |Set Icon Name and Window Title | Clears Icon Name, sets Window Title. | `\x1b]0;title\x1b\\` |
|1 |Set Icon Name | Sets Icon Name, which is used as the Tab title when it is non-empty | `\x1b]1;tab-title\x1b\\` |
|2 |Set Window Title | Set Window Title | `\x1b]2;window-title\x1b\\` |
|3 |Set X11 Window Property | Ignored | |
|4 |Change/Query Color Number | Set or query color palette entries 0-255. | query color number 1: `\x1b]4;1;?\x1b\\`<br/> Set color number 2: `\x1b]4;2;#cccccc\x1b\\` |
|5 |Change/Query Special Color Number | Ignored | |
|6 |iTerm2 Change Title Tab Color | Ignored | |
|7 |Set Current Working Directory | [See Shell Integration](shell-integration.html#osc-7-escape-sequence-to-set-the-working-directory) ||
|133|FinalTerm semantic escapes| Informs the terminal about Input, Output and Prompt regions on the display | [See Shell Integration](shell-integration.html) |
|777|Call rxvt extension| Only the notify extension is supported; it shows a "toast" notification | `printf "\e]777;notify;%s;%s\e\\" "title" "body"` |