Skip to main content
ansicode

XTSMGRAPHICS — Sixel / ReGIS / color-register capacity query + set (CSI ? Pi ; Pa ; Pv S)

Read / set the terminal's graphics limits — number of sixel color registers, sixel graphics area, ReGIS area. The standard knob for image-aware TUIs to size their bitmaps.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[?<Pi>;<Pa>;<Pv>S
\\033[\033[?1;1S
\\e[\e[?1;1S
ESC [ESC [ ? Pi ; Pa ; Pv S
hex1b 5b 3f ... 53

Description

Xterm's graphics-capability primitive. The `?` prefix flips final-byte `S` from SU (scroll up) to XTSMGRAPHICS — note the parse ambiguity with SU (`\x1b[<Ps>S` without `?` is scroll-up). Three parameters: **`Pi` item** = `1` color registers, `2` sixel graphics area (rows×cols of pixels), `3` ReGIS graphics area. **`Pa` action** = `1` read current value, `2` reset to default, `3` set to `Pv`, `4` read maximum value. **`Pv` value** is only used when `Pa=3` (set). Reply is `\x1b[?<Pi>;<Ps>;<Pv>S` where `Ps` is a status code (`0` success, `1` error/no-graphics, `2` reset error, `3` set error, `4` out-of-range). Critical for sixel-emitting TUIs (like neovim's image.nvim, w3m-img, timg, chafa): before drawing they query `\x1b[?1;4S` (max color registers) and `\x1b[?2;1S` (current sixel area) to size their dither palette and tile dimensions correctly. xterm defaults are stingy (256 color registers, 1000×1000 pixel sixel area); kitty exposes huge values; alacritty/gnome-terminal/Windows Terminal return error or nothing (no sixel support). Always check the status code in the reply — `Ps=1` means the terminal said "no graphics for you" and you should fall back to half-block or ASCII art.

Spec citation: xterm-ctlseqs (XTSMGRAPHICS)

Parameters

PiItem selector: `1` color registers, `2` sixel area, `3` ReGIS area.
PaAction: `1` read, `2` reset, `3` set (with Pv), `4` read max.
PvValue to set when Pa=3. Omitted otherwise.

Examples

bash
printf '\033[?1;4S'   # query max color registers — reply: \x1b[?1;0;<max>S
python
import sys\nsys.stdout.write('\x1b[?2;1S')   # current sixel pixel area\n# reply: \x1b[?2;0;<rows>;<cols>S
go
fmt.Print("\x1b[?1;3;1024S")   // try to RAISE color registers to 1024 (kitty allows)
javascript
process.stdout.write('\x1b[?3;1S')   // query current ReGIS area
c
printf("\x1b[?2;4S");   /* before sixel encode: ask max canvas size, scale image to fit */

Terminal support

xterm
yes
Linux console (fbcon)
no
macOS Terminal.app
no
iTerm2
partial
Windows Terminal
no
cmd.exe / ConPTY
no
kitty
yes
alacritty
no
WezTerm
yes
Ghostty
partial
GNOME Terminal
no
Konsole
partial
tmux
no
GNU screen
no

Related sequences