Expand description
OSC 7501, the Program Status Protocol, spec revision 0.4.
This crate re-exports termstate_core (builder, encoder, parser,
scanner) and termstate_store (the terminal-side record set) under one
name. Depend on those directly for no_std use.
use termstate::{Report, State};
let report = Report::builder(State::Done).app("brew").msg("Upgraded 12 packages").build()?;
assert_eq!(report.to_string(), "\x1b]7501;state=done:app=brew:msg=VXBncmFkZWQgMTIgcGFja2FnZXM=\x1b\\");Modules§
- detect
- Feature detection from the program side, as a pure state machine.
- limits
- Hard limits from the “Limits” section of the spec (revision 0.4).
- scan
- Extracting OSC 7501 sequences from a byte stream, such as the output a multiplexer or PTY wrapper reads from a program.
Structs§
- App
- A validated program identifier:
[A-Za-z0-9_.+-]{1,32}. - Capabilities
- What a terminal accepts, from its feature-detection reply.
- Id
- A validated record id:
segment ("/" segment)*, segment[A-Za-z0-9_.+-]{1,32}, at most 128 bytes and 8 levels. The root record has no id; it is represented asOption<Id>::None. - Record
- What one record holds: exactly the keys of the last report for its id.
- Report
- One validated report: exactly what the addressed record holds after it is applied.
- Report
Builder - Builds a
Reportfrom unvalidated program input. SeeReport::builder. - Store
- The records of one terminal. See the crate docs.
- Text
- A free-text value (
msgortitle): one line of UTF-8 with no control characters, already validated against its limits.
Enums§
- Change
- One change to the store. Ids are
Nonefor the root record. - Error
- Why a report was discarded (terminal side) or refused (program side).
- Field
- A field that a limit or validation error refers to.
- Kind
- What a
blockedprogram needs from the user. - Message
- One OSC 7501 sequence, decoded.
- State
- A record state.
clearis not a state; it isMessage::Clear. - Terminator
- The string terminator to end a sequence with.
Functions§
- parse_
body - Parses the body of one OSC 7501 sequence: the bytes after
ESC ] 7501 ;and before the string terminator. - sanitize
- Makes arbitrary text safe to send as
msgortitle: every control character (including newline and tab) becomes a space, and text longer thanmax_bytesis cut at a character boundary and ends with…. - write_
clear - Writes
state=clear, removing the recordidand everything beneath it, or every record whenidisNone. - write_
query - Writes the program’s feature-detection query,
OSC 7501 ; ? ST.