DSR/CPR
DSR (Device Status Report) and CPR (Active Position Report) are CSI sequences used to query the terminal's status and cursor position.
Syntax
CSI Ps n DSR — Device Status Report (request)
CSI Pn ; Pn R CPR — Active Position Report (response)
(* Status query *)
DSR-status = 0x1b, "[", "5", "n" ;
(* Cursor position query *)
DSR-position = 0x1b, "[", "6", "n" ;
(* Cursor position response *)
CPR = 0x1b, "[", Pn, ";", Pn, "R" ;
Pn = digit, { digit } ;
digit = "0" | "1" | "2" | "3" | "4"
| "5" | "6" | "7" | "8" | "9" ;Parameters (Request)
| Value | Description |
|---|---|
5 | Request device status |
6 | Request cursor position (CPR) |
Response
DSR 5 (Status Report):
The terminal responds with CSI 0 n to indicate "ready, no malfunction detected." Per ECMA-48 §8.3.35, other status codes (1-4) indicate busy or malfunction states, but modern terminals always report status 0.
DSR 6 (Cursor Position Report):
The terminal responds with CSI Pr ; Pc R where Pr is the current row and Pc is the current column. Positions are 1-based. If DECOM (origin mode) is set, the reported row is relative to the top margin.
Description
Per ECMA-48 §8.3.35, DSR is used either to report the status of the sending device or to request a status report from the receiving device. Parameter value 5 requests a general status report; parameter value 6 requests an Active Position Report (CPR).
Per ECMA-48 §8.3.14, CPR reports the active position as row and column numbers. The response is sent from terminal to host on the input stream.
DSR/CPR is one of the most fundamental query/response sequences and has been supported since the original VT100. Applications use it for terminal capability detection, screen size measurement, and synchronization.
Examples
# Query device status (response: ESC [ 0 n)
printf '\e[5n'
# Query cursor position (response: ESC [ Pr ; Pc R)
printf '\e[6n'
# Read the CPR response
printf '\e[6n'; read -sdR response; echo "$response"
Specifications
| Specification | Section |
|---|---|
| VT510 Reference | — |
| ECMA-48 | §8.3.35 (DSR), §8.3.14 (CPR) |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | CSI 5n and CSI 6n supported |
| Bobcat | ✓ | 0.9.0 | Supported via TerminalCtrl library |
| contour | ✓ | v0.1.0 | |
| foot | ✓ | Yes | Implemented at csi.c:1429-1448, supports both DSR (CSI 5n) and CPR (CSI 6n) |
| Ghostty | ✓ | v1.0.0 | DSR 5n and CPR 6n supported |
| iTerm2 | ✓ | Yes | Device status report (DSR) and cursor position report (CPR) fully implemented via VT100CSI_DSR token. Handles CSI 5n (status) and CSI 6n (cursor position). |
| Kitty | ✓ | Yes | Supports DSR 5 (device status) and DSR 6 (cursor position) |
| Konsole | ✓ | Yes | CSI 5n reports device status (ready), CSI 6n reports cursor position via CSI r ; c R |
| mintty | ✓ | Yes | Implemented at src/termout.c:3535-3541. Supports both DSR 5n (status) and 6n (cursor position report). |
| mlterm | ✓ | Yes | CSI 5n and CSI 6n supported since early versions |
| PuTTY | ✓ | 0.43 | DSR (CSI 5n and CSI 6n) implemented at terminal.c:4516-4527 |
| Rio | ✓ | v0.0.3 | |
| rxvt-unicode | ✓ | 1.2 | |
| st | ✓ | 0.5 | DSR 5n (OK) added in 0.9.1, DSR 6n (CPR) in 0.5 |
| terminology | ✓ | v0.1.0 | Supports DSR 5n (status) and 6n (cursor position report) |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | Supports DSR parameter 5 (operating status) and 6 (cursor position report) |
| WezTerm | ✓ | Yes | DSR (CSI 5n) and CPR (CSI 6n) both supported |
| Windows Terminal | ✓ | Yes | Supports DSR 5n (operating status) and DSR 6n (cursor position report) |
| xterm | ✓ | Yes | VT100 feature, supported since earliest versions |
| xterm.js | ✓ | 2.3.0 | |
| Multiplexers | |||
| cy | ✓ | v0.1.0 | DSR responds with CSI 0n, CPR responds with cursor position |
| GNU Screen | ✓ | v.4.2.0 | CSI 5n and CSI 6n implemented at src/ansi.c:1036-1039 |
| tmux | ✓ | 1.3 | Both DSR 5n (status) and DSR 6n (cursor position) supported |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.12.0 | Supports both DSR (CSI 5n) status report and CPR (CSI 6n) cursor position report |
See also
- DECXCPR — Extended Cursor Position Report — DEC extended version with page number
- CUP — Cursor Position — Set cursor position