Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
Terminal._on_csi() in src/libvt/terminal.py (#2) has no dispatch branches for ECMA-48 HPR (CSI Ps a, Character Position Relative) or VPR (CSI Ps e, Line Position Relative), recording both as unhandled and leaving the cursor stationary ('AB' at (0, 2) instead of 'A B' at (1, 4)).
Reproduction
- Feed
A,CSI 2 a,B,CSI 1 eon a fresh8x3DEFAULT_PROFILEterminal:
$ uv run python -c 'from libvt import Terminal; vt = Terminal(rows=3, cols=8); vt.feed(b"A\x1b[2aB\x1b[1e"); print(vt.lines, vt.cursor)'Expected
- Under
DEFAULT_PROFILEandXTERM_PROFILE,vt.linesstarts with'A B'and 0-basedvt.cursorsits at(row=1, col=4, pending_wrap=False). - When Origin Mode
DECOM(?6) is reset and the cursor starts insideDECLRMMorDECSTBMmargins,HPRandVPRpass through those margins and clamp only at physical screen edges (cols - 1,rows - 1), unlikeCUFandCUD. - When
DECOM(?6h) is set,HPRandVPRadvance from the current cell once and clamp at(bottom_margin, right_margin)without applyingleft_margin/top_margina second time. - Under inner-pane
TMUX_PROFILE,CSI aandCSI eremain ignored to match tmuxinput_csi_table(3.8).
Actual
('AB',) and Cursor(row=0, col=2, ...) across all profiles.
Environment
libvt:#2(feat/v2-architecture,0.1.0a0)- Python:
3.15.0(unicodedata17.0.0) - Reference
tmux:3.8a(tmux -f /dev/null) - OS: Linux
x86_64
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
Pnof0or omitted defaults to1, neitherHPRnorVPRscrolls the screen, and both cancelpending_wrap(even when clipped at the right edge).HPRandVPRnever aliasCUF/CUDwhenDECOMis reset (which would wrongly stop atright_margin/bottom_margin), and never pass physicalcur_col + n/cur_row + nintoHPA/VPAwhenDECOMis set (which would double-addleft_margin/top_margin).codec.py(explain) disassemblesCSI Ps a(HPR) andCSI Ps e(VPR) alongsideHPA(CSI Ps `/CSI Ps G) andVPA(CSI Ps d).
Intent (non-binding)
- Compute
max_col = right if decom else scr.cols - 1andmax_row = bottom if decom else scr.rows - 1(clamping intoleft..right/top..bottomwhendecomis set), mirroring GhosttycursorColRelativeandcursorRowRelative(vt-1.0.1) and xtermcharproc.c(xterm-412). - Gate
HPR/VPRexecution off whenProfileemulates an innertmuxpane (tmux_version is not None).
Not doing
- Changing
CUF(CSI C) orCUD(CSI B) margin-stop rules.
References
- Core(feat[vt]): Add sans-I/O VT engine, RLE grid, OSC 7501, input, and ADRs #2
Ghosttysrc/terminal/Terminal.zig(e9dc690/vt-1.0.1): https://github.com/ghostty-org/ghostty/blob/e9dc690/src/terminal/Terminal.zigxtermcharproc.c(xterm-412): https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-412/charproc.c#L3964-L3980tmuxinput.c(72c20dc/3.8): https://github.com/tmux/tmux/blob/72c20dc/input.c
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
Terminal(feat[csi]): Add HPR and VPR motions (#7)
Terminal(feat[csi]): Add HPR and VPR motions (#7)
tony commentedon Nov 23, 2026
Resolved in #2 (
0c7ee41).