DECELR, DECSLE, DECRQLP, DECEFR, DECLKD Locator
Report the position of a mouse or tablet, the locator, to the host.
DECELR Enable Locator Reports
CSI Ps ; Pu ' z
DECEFR Enable Filter Rectangle
CSI Pt ; Pl ; Pb ; Pr ' w
DECSLE Select Locator Events
CSI Pm ' {
DECRQLP Request Locator Position
CSI Ps ' |
DECLKD Locator Key Definition
DCS Pc $ w … ST
- Defaults
- Ps = 0, reports disabled; Pu = 0, character cells
- DEC STD 070
- §13, ch. 4 Enable Locator Reports, p. 5
- xterm
- Functions using CSI
DEC calls a mouse or a tablet a locator. With these functions a host can ask a terminal that has one to report where it is and which buttons are down:
| Sequence | Function | Does |
|---|---|---|
CSI Ps ; Pu ' z | DECELR, enable locator reports | Ps: 0 off, 1 on, 2 one report, then off; Pu: character cells or pixels |
CSI Pm ' { | DECSLE, select locator events | which button presses and releases send a report |
CSI Ps ' | | DECRQLP, request locator position | asks for one report now |
CSI Pt ; Pl ; Pb ; Pr ' w | DECEFR, enable filter rectangle | report once the locator leaves this rectangle |
DCS Pc $ w … ST | DECLKD, locator key definition | what each button sends in ReGIS graphics input |
A report is DECLRP, CSI Pe ; Pb ; Pr ; Pc ; Pp & w: the event, the buttons down, then the row, column and page of the locator.
All of this is DEC STD 070’s Text Locator Extension, section 13, an optional extension (its levels read “1x, 2x, 3x, 4x”). DECELR, DECSLE, DECRQLP and DECEFR are in its chapter 4, from p. 5, with DECLRP on p. 6; DECLKD, for the separate Locator Port Extension, is §5.4 on p. 13. A terminal that has the extension always answers a request, so an application never waits for a report that will not come. With locator reports disabled, DECRQLP is answered with event code 0, “the locator is unavailable”, and no other parameters, CSI 0 & w (p. 8), and so is a DECEFR received while reports are disabled.
A default xterm does not have the extension. It is built in only with --enable-dec-locator, which is off unless asked for (configure.in), and without it xterm’s parser maps the final byte of all four CSI sequences to the handling it gives a malformed one (VTPrsTbl.c). That does not end the sequence: it goes on ignoring until the next byte from @ to ~, and takes that as the end (charproc.c), so the first letter or the like after the sequence is swallowed. That is a bug, but this site follows a default xterm, bugs included. DECLKD is not implemented in any build: xterm’s DCS handling acts on $ only when t follows it (misc.c), and its graphics code lists “locator key definitions (DECLKD)” as still to do (graphics.c). The cases follow a default xterm, as the sources page explains, so they expect these sequences to draw no report, and to swallow the letter after them. That is what DEC STD 070 asks of a terminal without the extension, too, since it says a terminal ignores a function it does not implement (§3.5.1.3, p. 3-20); a terminal with it would answer DECRQLP. libghostty-vt has no handler for any of them, and ignores them, but ends each at its final byte, so the letter after it is printed; those cases are known differences.
xterm and libghostty-vt both have a different kind of mouse reporting, xterm’s own, mouse tracking, turned on with private modes such as CSI ? 1000 h. The locator’s own status request, CSI ? 55 n, is on the DEC status reports page.
Support
| Terminal | Version | Support | Notes |
|---|---|---|---|
| VT220 | manual, 2nd ed., 1984 | No | not in the manual |
| VT510 | manual, 1st ed., 1993 | No | not in the manual |
| xterm | patch 412, xterm-411a | Partly | only when built with --enable-dec-locator, off by default; without it the letter after the sequence is swallowed; DECLKD in no build |
| libghostty-vt | 0f171f6 | No | ignored, but ends each at its final byte (DECELR-1, DECELR-3) |
| ConEmu | build 230724, its documentation | No | not in its list: ANSI escape codes |
Validation
DECELR-1: The letter after it is swallowed
A
\e[1;2'z # DECELR: reports on, in character cells
B # taken as the end of the ignored sequence
|A_____|
cursor 1,2
reply none
DECELR-2: No locator, no report
\e[1;2'z # DECELR
\e['| # DECRQLP
|______|
reply none
DECELR-3: DECSLE and DECEFR are consumed, and so is the letter after
A
\e[1;3'{ # DECSLE: report presses and releases
\e[1;1;2;2'w # DECEFR
B
|A_____|
reply none
DECELR-4: DECLKD’s string is consumed
A
\eP0$w1/41/42\e\\ # DECLKD: button 1 sends A down, B up
B
|AB____|
reply none