DECOM
DECOM (Mode 6) is a DECSET/DECRST mode that controls whether cursor positioning is relative to the scrolling region or absolute to the entire screen.
Syntax
CSI ? 6 h DECSET — Enable origin mode (relative positioning)
CSI ? 6 l DECRST — Disable origin mode (absolute positioning)
DECSET-mode6 = 0x1b, "[", "?", "6", "h" ; DECRST-mode6 = 0x1b, "[", "?", "6", "l" ;
Description
Per the VT100 User Guide and VT510 Programmer Reference, DECOM controls the reference point for cursor positioning sequences such as CUP (CSI H) and HVP (CSI f).
- Set (origin mode) — Cursor positioning is relative to the top of the scrolling region defined by DECSTBM. Row 1 refers to the first line of the scrolling region, and the cursor cannot move outside the region boundaries. The cursor is also confined within left/right margins if DECLRMM is enabled.
- Reset (absolute mode) — Cursor positioning is relative to the top-left corner of the entire screen. Row 1 is the first line of the display regardless of any scrolling region. This is the default.
Side effects
When DECOM is set or reset, the cursor moves to the home position. In origin mode, "home" is the top-left corner of the scrolling region. In absolute mode, "home" is row 1, column 1 of the screen.
Interaction with scrolling margins
DECOM is designed to work with DECSTBM (Set Top and Bottom Margins) and DECLRMM/DECSLRM (Left and Right Margins). When origin mode is set:
- CUP and HVP coordinates are offset by the margin origin
- The cursor is confined within both the vertical scrolling region and horizontal margins
- ED and EL still operate relative to the cursor position, not the margins
Applications that use scrolling regions typically enable DECOM so that their drawing coordinates are relative to the region, simplifying layout logic.
Examples
# Set a scrolling region (rows 5-20), then enable origin mode
printf '\e[5;20r' # DECSTBM: set scroll region to rows 5-20
printf '\e[?6h' # DECOM: enable origin mode
printf '\e[1;1H' # CUP: moves to row 5, column 1 (top of scroll region)
# Disable origin mode
printf '\e[?6l' # DECOM: disable origin mode
printf '\e[1;1H' # CUP: moves to row 1, column 1 (top of screen)
Specifications
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Origin mode implemented |
| Bobcat | ? | ? | Not explicitly configured in Bobcat. TerminalCtrl may support this, but cannot confirm from Bobcat's code. |
| contour | ✓ | v0.1.0 | DECOM (mode 6 - origin mode) implemented as DECMode::Origin in primitives.h lines 663-663 with full documentation, set via Terminal.cpp line 2484, affects cursor positioning relative to margins |
| foot | ✓ | Yes | Origin mode (relative to scroll region) |
| Ghostty | ✓ | v1.0.0 | Origin mode |
| iTerm2 | ✓ | Yes | Origin mode for cursor positioning relative to scroll region |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | Origin mode for relative positioning within scroll region |
| mintty | ✓ | Yes | DECOM (Mode 6) origin mode implemented at src/termout.c:2415-2420 |
| mlterm | ✓ | Yes | Fundamental VT100 mode, present since early versions |
| PuTTY | ✓ | 0.45 | DEC origin mode at terminal.c:3100-3102 |
| Rio | ? | ? | |
| rxvt-unicode | ✓ | 1.2 | PrivMode_relOrigin - Origin mode |
| st | ✓ | 0.4 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | DEC_ORIGIN mode |
| WezTerm | ✓ | 20200202-181957-765184e5 | Origin mode (relative to scroll region) |
| Windows Terminal | ✓ | Yes | |
| xterm | ✓ | xterm-1 | DECOM (mode 6) - Origin mode (relative to scroll region) |
| xterm.js | ✓ | 0.10 | Origin mode |
| Multiplexers | |||
| cy | ✓ | Yes | |
| GNU Screen | ✓ | v.4.2.0 | Origin mode (src/ansi.c:1108-1115) |
| tmux | ✓ | 2.9 | |
| tuios | ✓ | v0.0.15 | Origin mode (ModeOrigin) |
| Zellij | ✓ | v0.31.2 | |
See also
- DECSTBM — Set Top and Bottom Margins — Defines the vertical scrolling region
- DECSLRM — Set Left and Right Margins — Defines horizontal margins
- DECLRMM — Left and Right Margin Mode — Enables horizontal margins
- CHA/CUP — Cursor Positioning — Affected by origin mode