Rio Terminal Documentation
repository·main·Indexed 27 days ago
https://github.com/raphamorim/rioA modern, cross-platform terminal emulator designed for high performance and visual flexibility. The project includes rio-vt, an embeddable terminal core with a VT state machine and ANSI parser; librio, a C ABI wrapper for non-Rust consumers; and supporting libraries such as rio-window (a Winit fork), teletypewriter for TTY emulation, and corcovado, a non-blocking IO library based on mio 0.6.x.
What's inside Rio
- Teletypewriter is a Rust crate designed to create a pseudoterminal (pty) that emulates a TTY (TeleTYpewriter). While it was primarily developed for use within the Rio terminal, it is available for general use in other Rust projects requiring TTY emulation.
Overview of rio-window
mainrio-windowis a specialized fork of theWinitlibrary, maintained specifically for use with the Rio terminal. It provides the windowing primitives required by the Rio ecosystem.Overview of Rio Terminal
mainRio is a modern terminal designed to run across multiple platforms. For detailed documentation, installation guides, and configuration instructions, visit the official website at rioterm.com.Overview of librio
mainlibrio is an embeddable terminal core extracted from the Rio project. It provides PTY spawning, VT (Virtual Terminal) parsing, terminal state management, and a host-pulled render-state API with per-row dirty tracking.
Key characteristics:
- No drawing or windowing code: It is designed for developers to bring their own renderer.
- C ABI Wrapper: It wraps
rio-vtas a C ABI, making it suitable for non-Rust consumers like Swift or C. - Distribution: It is not published to crates.io. It is distributed as the
RioKit.xcframeworkstatic library in Rio's GitHub releases. - Rust Users: If you are writing in Rust, you should depend on
rio-vtdirectly instead of usinglibrio.
Overview of Corcovado
mainCorcovado is a maintained fork ofmio0.6.x. It is designed to work with Windows 11 by utilizing the Windows API and includes integrations withmio-signal-hookandmio-extras. Unlike the originalmio0.6.x, Corcovado uses Rust edition 2021 and leverages the Rust standard library for networking (net) and I/O operations instead of relying onmio0.6.x for those specific tasks.Security and Constraints of Glyph Protocol
mainThe Glyph Protocol is designed to allow applications to register custom glyphs without altering the semantic meaning of existing text. Key security and operational constraints include:
- PUA Restriction: Registration is strictly limited to the three Unicode Private Use Areas (PUA). Any attempt to register a non-PUA codepoint must be rejected with
reason=out_of_namespace. - Cell Buffer Authority: Text extraction tools (selection, copy, search, hyperlinks, shell history) must return the original emitted codepoint, not the rendered glyph.
- Resource Limits: There is a 1024-slot cap for simultaneous registrations per session and a 64 KiB cap per payload, limiting the memory footprint to approximately 64 MiB per session.
- No Code Execution: The
glyfsubset excludes executable hinting instructions; the protocol is purely declarative. - Session Isolation: Glossaries are not shared between terminal tabs, windows, or PTY sessions.
- PUA Restriction: Registration is strictly limited to the three Unicode Private Use Areas (PUA). Any attempt to register a non-PUA codepoint must be rejected with
Understand the Glyph Protocol Overview
mainGlyph Protocol is a terminal protocol that allows applications to ship custom vector glyphs (monochrome or full-color) to the terminal at runtime. This eliminates the need for users to install patched fonts like Nerd Fonts.
Key features:
- Vector-based: Glyphs are resolution-independent and scale to any cell size.
- Safe: Registrations are restricted to Unicode Private Use Areas (PUA) to avoid modifying standard text.
- Graceful Degradation: Terminals that do not support the protocol simply ignore the messages. Applications can detect support via a protocol-detection ping.
- Payload Formats: Supports monochrome via OpenType
glyf, and color via OpenTypeCOLRv0 (layered) orCOLRv1 (paint graph).
Use librio for embeddable terminal functionality
mainlibriois an embeddable terminal library that provides PTY and VT (Virtual Terminal) state management. It is designed to be used from Swift, C, or any language that can interface with a C ABI, without requiring a windowing stack.Key characteristics:
- VT-only: It manages the PTY, VT state, and provides a render-state API, but it does not include a renderer. The host application is responsible for pulling the render state and drawing it (e.g., via a CPU renderer, WASM canvas, or TUI).
- Pull Model: The host pulls a snapshot of the terminal state with per-row dirty flags. The host is responsible for resetting these flags after rendering.
- Threading: A
Surfaceowns a dedicated PTY IO thread. Callbacks likewakeup_cbandaction_cbmay fire on this IO thread and should only be used to flag or schedule work on the host thread.
Setup and run WASM tests for Sugarloaf
mainTo run tests targeting WebAssembly (WASM), you must first install the
wasm-bindgen-clitool globally to provide the necessary test runner harness.1. Install wasm-bindgen-cli
cargo install wasm-bindgen-cli2. Run WASM tests
Execute the following command from the root
sugarloafdirectory:CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test --target wasm32-unknown-unknown -p sugarloaf --testsFlag details:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner: Instructs Cargo to use thewasm-bindgen-clitest harness.-p sugarloaf: Limits the test execution to thesugarloafpackage.--tests: Runs only the tests and skips building examples (which may fail to compile to WASM due to networking dependencies).
cargo install wasm-bindgen-cli CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test --target wasm32-unknown-unknown -p sugarloaf --testsPipeline for generating `glyf` data
mainSince most applications do not hand-author
glyfbytes, use the following pipeline to extract glyphs from existing fonts (like Nerd Fonts):- Open the source TTF (e.g., a Nerd Font) using
fontTools. - Extract the glyph record for the desired codepoint.
- If the glyph is composite, flatten it using
fontTools.pens.ttGlyphPen.TTGlyphPen. - Strip hinting instructions (set
instructionLength := 0) to comply with theglyfsubset. - Compile the result to bytes, base64-encode it, and register it at a chosen PUA codepoint (ideally in the Supplementary PUA-B range
U+100000+).
- Open the source TTF (e.g., a Nerd Font) using
Distribute and integrate librio
mainlibriois not published to crates.io. It is distributed as static artifacts via Rio's GitHub releases.- For Swift/C users: Use the
RioKit.xcframeworkprovided in the releases. This includes the static library, curated headers, and amodule.modulemapfor easy integration in Xcode. - For Rust users: Do not use
librio. Instead, depend on therio-vtcrate directly, which is the idiomatic, published Rust crate.
- For Swift/C users: Use the
Author `COLR` glyph payloads
mainTo create colored glyphs for the Glyph Protocol, do not hand-author
COLRbytes. Use one of the following workflows:- From an existing colour font: Use
fontToolsto extract theCOLR/CPALtables for specific glyphs, then pack them with the referenced outlines into the protocol container. - From SVG: Use tools like
nanoemojiormaximum-color(from the Skia team) to compile a directory of SVGs into aCOLRv1 font, then use the output in your packer.
- From an existing colour font: Use