Expand description
ANSI and terminal-control sequence subsystem.
§Scope
The modules under ansi are the byte-level building blocks used to emit,
parse, measure, strip, truncate, and wrap terminal control streams. They cover
cursor motion, screen editing, modes, SGR styling, OSC metadata, DCS/APC
payloads, C0/C1 controls, and ANSI-aware text utilities.
§Sequence families
Most writers emit 7-bit forms because they are broadly accepted on byte streams that are otherwise UTF-8 text:
CSI: ESC [ params intermediates final e.g. ESC [ ? 2048 h
OSC: ESC ] command ; payload BEL|ST e.g. ESC ] 2 ; title ESC \\
DCS: ESC P params payload ST e.g. ESC P + q 524742 ESC \\
APC: ESC _ command payload ST e.g. ESC _ G ... ESC \\Anatomy of a DEC private mode sequence:
ESC [ ? 2 0 4 8 h CSI ? 2048 h (enable mode 2048)
──┬── ─┬─ ───┬──── ┬
CSI priv params final§7-bit and 8-bit controls
The constants in c0 and c1 name single-byte controls. Parser utilities
recognize both the 7-bit ESC spellings and the 8-bit C1 bytes, while writer
functions generally choose explicit 7-bit byte strings.
§Mode interaction
Mode-aware features are represented by mode::Mode. Enable or disable
modes with mode::write_set_mode and mode::write_reset_mode before
expecting mode-controlled reports such as bracketed paste, focus events,
in-band resize, or light/dark notifications.
§Example
use uncurses::ansi::title::write_window_title;
let mut out = Vec::new();
write_window_title(&mut out, "my app")?; // ESC ] 2 ; my app ESC \\Modules§
- ascii
- Printable ASCII boundary constants used by the ANSI scanner.
- c0
- C0 control bytes (
0x00..=0x1f). - c1
- C1 control bytes (
0x80..=0x9f). - charset
- Character-set designation and locking-shift sequences.
- clipboard
- Clipboard and selection access through OSC 52.
- color
- Default foreground, background, cursor, and indexed palette colors.
- cost
- Byte-length predictors for emitted ANSI sequences.
- ctrl
- Terminal reset, device-attribute, and version requests.
- cursor
- Cursor addressing, movement, saving, reporting, and style sequences.
- cwd
- Current working directory notifications through OSC 7.
- finalterm
- Shell-integration prompt and command markers using OSC 133.
- focus
- Focus-event report sequences.
- graphics
- Inline graphics encoders for DCS and APC image protocols.
- hyperlink
- OSC 8 hyperlink writer and parser.
- inband
- In-band terminal resize reports for DEC private mode 2048.
- iterm2
- OSC 1337 payload framing.
- keypad
- Keypad application and numeric mode selectors.
- kitty
- Progressive keyboard enhancement protocol.
- mode
- ANSI and DEC private terminal mode management.
- notification
- Desktop notification OSC encoders.
- palette
- Linux-console palette sequences.
- params
- Lazy parser for CSI and DCS parameter bodies.
- passthrough
- DCS passthrough wrappers for terminal multiplexers.
- paste
- Bracketed-paste delimiter sequences.
- progress
- Progress-bar OSC sequences.
- screen
- Screen, line, scroll-region, and tab-stop manipulation.
- sgr
- Select Graphic Rendition (SGR) writer.
- status
- Device Status Reports and cursor-position reports.
- strip
- ANSI escape stripping built on the byte tokenizer.
- termcap
- XTGETTCAP capability queries.
- text
- ANSI-aware byte-stream tokenizer for text utilities.
- title
- Window title and icon-name OSC sequences.
- truncate
- Width-aware truncation and cutting for ANSI-decorated strings.
- urxvt
- OSC 777 extension-message framing.
- winop
- XTWINOPS window-operation requests and reports.
- wrap
- Width-aware wrapping for ANSI-decorated strings.
- xterm
- Key-modifier option controls.