^[control-codes
live in libghostty-vt

Operating system commands

OSC 22 Change Pointer Shape

View as Markdown

Change the shape of the mouse pointer while it is over the terminal.

OSC 22 ; Pt ST
ECMA-48
§8.3.89 OSC – Operating System Command, p. 51
Specification
Mouse pointer shapes, kitty documentation
xterm
Operating System Commands

OSC 22 ; Pt ST sets the shape of the mouse pointer over the terminal to Pt, so that a program can show a hand over a link or a watch while it is busy. It is xterm’s, and xterm takes Pt as a name from the X cursor font: left_ptr for an arrow, hand2, watch, xterm for the I-beam, and so on. A name it does not know, or none at all, gives the I-beam, its default (xtermSetupPointer, LookupCursorShape).

kitty extended it in its Mouse pointer shapes document, which uses the CSS cursor names (default, pointer, wait, text, …) rather than X’s, adds a stack, OSC 22 ; > name ST to push and OSC 22 ; < ST to pop, and lets a program ask, with OSC 22 ; ? names ST, which shapes the terminal has and which is current.

libghostty-vt keeps a shape its host can read and draw. It accepts the CSS names, and the X names that have a CSS equivalent: watch is wait, left_ptr is default, xterm is text. An empty Pt puts back text. It ignores a name it does not know, rather than falling back as xterm does, and it does not have kitty’s stack or queries. The cases follow a default xterm, and give each shape by its CSS name, which is what a case’s pointer line checks; the X cursors xterm sets are given by their CSS equivalents. Those where a name is one only libghostty-vt knows, or neither does, are known differences.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984NoOSC is not among the controls it recognizes (§4.2)
VT510manual, 1st ed., 1993Noignores an OSC string (chapter 4)
xtermpatch 412, xterm-411aYesX cursor font names; an unknown name gives the I-beam
libghostty-vt0f171f6PartlyCSS names and X names with a CSS equivalent; ignores unknown names; no stack or queries (OSC22-5, OSC22-6)
Konsole26.11.70, a24c3d71PartlyCSS names and Qt’s, not X’s hand2 or watch; an unknown name resets it; no stack or queries
kitty0.49.2, its documentationYesCSS names, a stack and queries: Mouse pointer shapes
ConEmubuild 230724, its documentationNonot in its ANSI escape codes

Validation

OSC22-1: The I-beam to begin with

A
|A_____|
pointer text

OSC22-2: An X cursor name

\e]22;watch\e\\
|______|
pointer wait

OSC22-3: Another

\e]22;left_ptr\e\\
|______|
pointer default

OSC22-4: Empty puts back the I-beam

\e]22;watch\e\\
\e]22;\e\\
|______|
pointer text

OSC22-5: A CSS name, which xterm does not know

\e]22;watch\e\\
\e]22;pointer\e\\  # not an X cursor: the I-beam
|______|
pointer text

OSC22-6: A name neither knows

\e]22;watch\e\\
\e]22;nosuch\e\\
|______|
pointer text

OSC22-7: kitty’s query is not answered

\e]22;?__current__\e\\
|______|
reply none
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.