A Rust crate for building text-based interfaces across UNIX and Windows terminals. Covers cursor, styling, terminal modes, and optional input events.
Overview
Crossterm is a terminal manipulation library written in Rust that targets cross-platform text interfaces. It is pure Rust and aims to support UNIX and Windows terminals, with testing noted on common console and terminal emulators on Linux, Windows, and macOS.
The library exposes cursor movement and visibility, styled output with base and extended colors where the terminal allows, and terminal operations such as clearing, scrolling, size queries, alternate screen, and raw mode. Optional features add input handling for keys, mouse, resize, and modifier keys, with poll, read, and optional async stream APIs.
Feature flags trim dependencies, for example disabling events or selecting file-descriptor-based polling instead of mio on UNIX. Optional modules cover clipboard via OSC52 and serde support for events.
Developers add it as a Cargo dependency to control terminal output and input in CLI and TUI programs without tying to a single operating system.
Key features
- Cross-platform cursor control
- 16, 256, and RGB styling
- Terminal clear, scroll, and size
- Alternate and raw screen modes
- Optional keyboard and mouse events
- Send and sync multi-thread use
- Feature flags for lean builds
- Optional async event stream
Use cases
- Build Rust terminal user interfaces
- Portable CLI styling and layout
- Interactive TUIs with input events
- Games and tools in the terminal
- Color and cursor control without curses