Skip to main content

Module cursor

Module cursor 

Source
Expand description

Cursor addressing, movement, saving, reporting, and style sequences.

§Category

This module emits cursor-related CSI, ESC, and OSC controls: absolute and relative movement, line/index movement, cursor save/restore forms, cursor style, pointer shape, and cursor-position reports.

§Coordinate conventions

Public cursor-position arguments are zero-based unless the item explicitly says otherwise. Writers add one when the terminal sequence is one-based and omit default parameters when the emitted bytes support a shorter spelling.

row=10 col=20  →  ESC [ 11 ; 21 H
                  ──┬── ─┬─  ┬─ ┬
                   CSI  row  col final

§Mode interaction

Origin mode (Mode::ORIGIN) changes how terminals interpret absolute row/column positions relative to scroll margins. Cursor visibility is controlled by Mode::CURSOR_VISIBLE, while this module emits movement and report bytes.

Enums§

CursorStyle
Cursor style values for DECSCUSR (ESC [ Ps SP q).

Functions§

write_backtab
Move backward by n tab stops with CBT, ESC [ <n> Z.
write_cha
Move the cursor to an absolute column with CHA, ESC [ <col+1> G.
write_cht
Advance n horizontal tab stops with CHT, ESC [ <n> I.
write_cnl
Move to the first column of a following line with CNL.
write_cpl
Move to the first column of a preceding line with CPL.
write_cub
Move the cursor backward/left n columns with CUB.
write_cud
Move the cursor down n rows with CUD.
write_cuf
Move the cursor forward/right n columns with CUF.
write_cup
Move the cursor to an absolute position with CUP, ESC [ <row+1> ; <col+1> H.
write_cursor_style
Set the cursor style with DECSCUSR, ESC [ <style> SP q.
write_cuu
Move the cursor up n rows with CUU.
write_hpa
Move to an absolute horizontal position with HPA, ESC [ <col+1> ` .
write_hpr
Move horizontally right by n columns with HPR, ESC [ <n> a.
write_hvp
Move the cursor with HVP, ESC [ <row+1> ; <col+1> f.
write_index
Move down one line with Index, ESC D.
write_request_cursor_position
Request a standard cursor-position report with ESC [ 6 n (DSR 6).
write_request_extended_cursor_position
Request an extended cursor-position report with ESC [ ? 6 n (DECXCPR).
write_restore_cursor
Restore the cursor with the DEC form ESC 8 (DECRC).
write_restore_cursor_position
Restore the cursor position with CSI u, exact bytes ESC [ u.
write_reverse_index
Move up one line with Reverse Index, ESC M.
write_save_cursor
Save the cursor with the DEC form ESC 7 (DECSC).
write_save_cursor_position
Save the cursor position with CSI s, exact bytes ESC [ s.
write_set_pointer_shape
Set the pointer shape with OSC 22, ESC ] 22 ; <shape> ESC \.
write_tab
Write a literal horizontal tab byte, HT (0x09).
write_vpa
Move the cursor to an absolute row with VPA, ESC [ <row+1> d.
write_vpr
Move vertically down by n rows with VPR, ESC [ <n> e.