Skip to main content

DSR/CPR

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard

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)
Formal syntax
(* 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)​

ValueDescription
5Request device status
6Request 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​

SpecificationSection
VT510 Reference—
ECMA-48§8.3.35 (DSR), §8.3.14 (CPR)

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesCSI 5n and CSI 6n supported
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.1.0
foot✓YesImplemented at csi.c:1429-1448, supports both DSR (CSI 5n) and CPR (CSI 6n)
Ghostty✓v1.0.0DSR 5n and CPR 6n supported
iTerm2✓YesDevice status report (DSR) and cursor position report (CPR) fully implemented via VT100CSI_DSR token. Handles CSI 5n (status) and CSI 6n (cursor position).
Kitty✓YesSupports DSR 5 (device status) and DSR 6 (cursor position)
Konsole✓YesCSI 5n reports device status (ready), CSI 6n reports cursor position via CSI r ; c R
mintty✓YesImplemented at src/termout.c:3535-3541. Supports both DSR 5n (status) and 6n (cursor position report).
mlterm✓YesCSI 5n and CSI 6n supported since early versions
PuTTY✓0.43DSR (CSI 5n and CSI 6n) implemented at terminal.c:4516-4527
Rio✓v0.0.3
rxvt-unicode✓1.2
st✓0.5DSR 5n (OK) added in 0.9.1, DSR 6n (CPR) in 0.5
terminology✓v0.1.0Supports DSR 5n (status) and 6n (cursor position report)
VT100✓Yes
VTE✓YesSupports DSR parameter 5 (operating status) and 6 (cursor position report)
WezTerm✓YesDSR (CSI 5n) and CPR (CSI 6n) both supported
Windows Terminal✓YesSupports DSR 5n (operating status) and DSR 6n (cursor position report)
xterm✓YesVT100 feature, supported since earliest versions
xterm.js✓2.3.0
Multiplexers
cy✓v0.1.0DSR responds with CSI 0n, CPR responds with cursor position
GNU Screen✓v.4.2.0CSI 5n and CSI 6n implemented at src/ansi.c:1036-1039
tmux✓1.3Both DSR 5n (status) and DSR 6n (cursor position) supported
tuios✓v0.0.15
Zellij✓v0.12.0Supports both DSR (CSI 5n) status report and CPR (CSI 6n) cursor position report

See also​