Expand description
The terminal modes a client must read from the AUTHORITY, never from a parser of its own.
§Why these are ten types and not ten bools
A mode decides how a client encodes what the operator does. Get the wrong one and the failure is not cosmetic:
- bracketed paste gates paste SANITISATION. mado reads it, then
passes it to
sanitize_paste. A wrong answer there is a paste- injection surface, not a rendering glitch. - cursor keys (DECCKM) decides whether arrows are
ESC [ AorESC O A. Wrong, and every editor and pager receives the wrong keys. - mouse tracking decides whether a click is reported at all.
If these were bare bools, sanitize_paste(text, modes.focus_reporting)
would type-check. Ten distinct newtypes make substituting one mode for
another an E0308 — the compiler will not let a client confuse them.
§Why ModeSet is carried BY a view and never fetched separately
A client that could ask for modes independently could render frame N’s
cells while encoding a keystroke under frame N+1’s modes — bracketed
paste toggling in the gap between the grid you drew and the key you
sent. Because a ModeSet is only obtainable from the view it came
from, “modes from a different instant than the cells” has no
representation. The cost is ten bytes.
Structs§
- AltScreen
- The alternate screen buffer is active (vim, less, htop). Set via DEC 47 / 1047 / 1049.
- Auto
Wrap - DEC 7 (DECAWM) — autowrap at the right margin.
- Bracketed
Paste - DEC 2004 — bracketed paste. When on, a paste is framed with
ESC[200~/ESC[201~so the program can tell it from typing. - Cursor
Keys - DEC 1 (DECCKM) — application cursor keys. Arrows become
ESC O Ainstead ofESC [ A. - Cursor
Visible - DEC 25 (DECTCEM) — cursor visibility.
- Focus
Reporting - DEC 1004 — focus reporting. The program is told when the terminal
gains (
ESC[I) or loses (ESC[O) focus. - ModeSet
- Every mode a client needs, taken at ONE instant.
- Mouse
Sgr - DEC 1006 — SGR extended mouse encoding. Decides the REPORT format, independently of whether tracking is on at all.
- Sync
Output - DEC 2026 — synchronized output. The program has asked that nothing be presented until it says done, so a renderer holds the frame.
Enums§
- Mouse
Tracking - Mouse tracking level — DEC 1000 / 1002 / 1003.