crossterm-rs/crossterm
75.8
Strong · 30 September 2026
10.8k
lines of production code
Rust
primary language
2
measurements over time
What this system is
This system is a cross-platform Rust library for terminal manipulation, providing a unified API for cursor movement, text styling, and input event handling. It abstracts platform-specific differences between Unix and Windows to support features like raw mode control, synchronized output, and asynchronous event streams. The library also includes comprehensive examples and an interactive demo for testing core capabilities such as clipboard integration, hyperlinks, and keyboard modifiers.
How it got here
2018–2019 — Initial release and platform-specific implementation
15 changes.
This period marks the initial release of the crossterm library, establishing a cross-platform API for terminal manipulation with dedicated system-level implementations for Unix and Windows. The work focused on building core modules for cursor control, styling, and event handling, while introducing platform-specific backends to ensure accurate behavior across different operating systems.
2020–2026 — polling backend abstraction and color control
4 changes.
The codebase introduced pluggable polling backends for the Unix event source, allowing a choice between mio and a new filedescriptor-based implementation. It also added support for colored underlines and strict adherence to the NO\_COLOR environment variable to disable ANSI output when requested.
Features
Initial release of the crossterm terminal manipulation library
This change introduces the initial version of the crossterm crate, providing a cross-platform API for terminal manipulation. It includes modules for cursor movement and styling, terminal resizing and raw mode control, and an event system for reading keyboard, mouse, and resize inputs. The library implements a Command API that allows users to queue or directly execute actions like printing styled text, moving the cursor, and managing screen buffers, with platform-specific fallbacks to WinAPI on older Windows versions and ANSI escape codes on modern systems and Unix.
src · high confidence
New and updated terminal examples
The examples directory has been reorganized and expanded with new demonstrations for key features. A new README documents the structure and provides run instructions. New examples include \copy-to-clipboard\ for OSC52 clipboard integration, \event-match-modifiers\ for handling keyboard modifiers, \event-poll-read\ for blocking event polling, \event-read-char-line\ for character and line input, \event-read\ for comprehensive event handling with keyboard enhancement flags, \event-stream-smol\ and \event-stream-tokio\ for asynchronous event streams, \key-display\ for key event formatting, \link\ for OSC 8 hyperlinks, and \stderr\ for writing to standard error. Existing examples have been updated to reflect current APIs.
examples · high confidence
New interactive demo application for testing crossterm features
The interactive demo has been restructured into a new standalone application located in \examples/interactive-demo/src\. This change introduces a menu-driven interface that allows users to individually test core crossterm capabilities, including cursor movement, color attributes, input events, and synchronized output. The implementation consolidates the test logic into modular components (\cursor\, \color\, \attribute\, \event\, \synchronized\_output\) and utilizes a custom macro for streamlined test execution and navigation.
examples/interactive-demo/src · high confidence
Platform-specific event system implementation for Windows
The event system now includes a dedicated Windows implementation in \src/event/sys/windows.rs\, providing platform-specific input handling, mouse capture enable/disable logic, and console mode management. This file exposes internal modules for parsing, polling, and waker functionality (conditional on the \event-stream\ feature), establishing the Windows backend for the events module.
src/event/sys · high confidence
Behavioural changes
Add focus event support and refine Windows event source implementation
The Windows event source now emits FocusGained and FocusLost events when the terminal window gains or loses focus, allowing applications to react to visibility changes. Additionally, the implementation ensures that Windows resize events match the terminal size reported by the standard size function by adjusting the coordinate offset (adding one to replicate Unix behavior starting at 1 instead of 0). The code also handles mouse button state tracking for left, right, and middle buttons more explicitly and conditionally initializes the poller based on the event-stream feature.
src/event/source · high confidence
Cursor position and movement now use platform-specific system implementations
The cursor module now delegates to dedicated platform-specific implementations for Unix and Windows. On Unix, cursor position is retrieved by sending an escape sequence and filtering for the response, ensuring accurate reporting even when other events are pending. On Windows, cursor positioning and movement are handled via WinAPI calls, with relative Y-coordinates calculated based on the terminal window's position in the screen buffer. This change introduces a new internal structure for managing cursor state and visibility on Windows, replacing previous generic logic with OS-native behavior.
src/cursor/sys · high confidence
Improved Windows event parsing and optional event-stream waker support
The Windows event subsystem now features a dedicated \parse.rs\ module that improves keyboard input handling by correctly managing Unicode surrogate pairs for characters outside the Basic Multilingual Plane and respecting the active keyboard layout for character case. Mouse event handling has been enhanced to support left, right, and middle button states, including release events. Additionally, when the \event-stream\ feature is enabled, the polling mechanism (\poll.rs\) integrates a \Waker\ (implemented in \waker.rs\) using a Windows semaphore, allowing asynchronous wake-ups of the poll loop.
src/event/sys/windows · high confidence
Platform-specific terminal implementation module introduced
A new \src/terminal/sys.rs\ module has been added to centralize platform-specific terminal operations. This module exposes functions for managing raw mode (enabling, disabling, and checking status), retrieving terminal size and window size, and handling scrolling on Windows, while also providing keyboard enhancement support checks on Unix and Windows. It acts as the concrete system-level interface for terminal control, delegating to platform-specific sub-modules.
src/terminal · high confidence
Raise MSRV to Rust 1.85 and migrate to Rust 2024 edition
The minimum supported Rust version (MSRV) has been raised from 1.63 to 1.85, and the crate has been migrated to the Rust 2024 edition. As part of this update, the custom \IsTty\ trait has been removed in favor of the standard library's \std::io::IsTerminal\ trait. Additionally, color commands (such as \SetForegroundColor\ and \SetBackgroundColor\) no longer emit a bare \CSI m\ escape sequence when colors are disabled via \NO\COLOR\, preventing unintended attribute resets. Several parser bugs have also been fixed, including an integer underflow in mouse/cursor-position parsers and a logic error where \Colors::from(Colored::UnderlineColor(\))\ incorrectly set the background color.
(repo-wide) · high confidence
Refactored event module with internal filtering and optional async stream
The event handling logic has been restructured to improve modularity and performance. Internal event processing is now encapsulated in a dedicated \internal\ module, and a new \Filter\ trait allows specific event types (such as cursor position or keyboard enhancement flags) to be filtered out before they reach the public API, reducing unnecessary processing. Additionally, the asynchronous event stream capability is now an optional feature (\event-stream\), requiring explicit opt-in to use the \EventStream\ type for integration with async runtimes like \smol\ or \tokio\.
src/event · high confidence
Refactored style module with new Attributes bitset and OSC 8 hyperlink support
The style module has been restructured to improve performance and add new capabilities. The \Attributes\ type is now backed by a \u32\ bitset, enabling const-context construction and efficient bitwise operations for managing text attributes. A new \ContentStyle\ struct centralizes foreground, background, and underline colors alongside attributes, exposed via the unified \Stylize\ trait which provides fluent methods for styling text. Additionally, the library now supports OSC 8 hyperlinks through \StartHyperlink\ and \EndHyperlink\ commands, allowing users to create clickable links in supported terminals.
src/style · high confidence
Support for colored underlines and NO\_COLOR environment variable
The style types now support setting an underline color via the new \Colored::UnderlineColor\ variant, allowing terminals that support SGR 58 to render underlines in specific colors. Additionally, the library now respects the \NO\_COLOR\ environment variable; when set, ANSI color sequences are disabled, and the output remains plain text. This behavior can be overridden programmatically using the new \Colored::set\_ansi\_color\_disabled\ API.
src/style/types · high confidence
Unified file descriptor handling with optional libc/rustix backend
The terminal system layer now uses a new \FileDesc\ wrapper in \src/terminal/sys/file\_descriptor.rs\ to manage raw file descriptors, automatically closing them on drop when opened. This abstraction supports two backends: the traditional \libc\ crate (when the \libc\ feature is enabled) and \rustix\ (the default), allowing the library to reduce unsafe code and dependency surface. This change affects how terminal attributes, window sizes, and keyboard enhancement flags are queried and set on both Unix and Windows, ensuring consistent resource management across platforms.
src/terminal/sys · high confidence
Unix event parsing and waker implementation
The Unix subsystem now includes a new event parser (src/event/sys/unix/parse.rs) that handles key events, mouse events, and focus changes, along with a conditional waker module (src/event/sys/unix/waker.rs) that switches between a TTY-based and mio-based implementation depending on the 'use-dev-tty' feature flag.
src/event/sys/unix · high confidence
Unix event source now supports pluggable polling backends (mio or filedescriptor)
The Unix event source implementation has been refactored to support two distinct polling backends: the existing \mio\-based implementation and a new \filedescriptor\-based implementation. This change allows the library to switch between different low-level polling mechanisms, potentially improving compatibility or performance depending on the selected feature. The new \filedescriptor\ backend uses \rustix\ for file descriptor handling and \signal-hook\ for signal management, replacing the previous \libc\-based approach in that specific backend. Both backends provide the same \EventSource\ interface, ensuring that higher-level code remains unchanged regardless of the underlying polling mechanism.
src/event/source/unix · high confidence
Unix waker implementation switched from mio to UnixStream
The Unix waker mechanism has been replaced to no longer depend on the mio library for waking up the event loop. Instead, the implementation now uses a UnixStream to send a single byte, providing a direct pipe-based wake-up signal. This change removes the mio dependency from this specific component, simplifying the internal event signaling path.
src/event/sys/unix/waker · high confidence
Windows console styling now uses crossterm-winapi for color handling
The Windows-specific styling implementation in \src/style/sys/windows.rs\ has been rewritten to use the \crossterm-winapi\ crate instead of direct WinAPI calls. This change updates how foreground and background colors are applied to the console, ensuring compatibility with the broader crossterm ecosystem while maintaining support for legacy Windows versions that do not support ANSI escape codes. The new implementation correctly handles color attributes, intensity flags, and resets by interacting with the current screen buffer via crossterm's abstractions.
src/style/sys · high confidence
Test coverage
Added interactive demo tests for style, color, cursor, events, and synchronized output; Added tests for NO\_COLOR environment variable behavior.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 79 → 76 (-3.3)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 93 → 93 (-0.0)
- Architecture 100 → 90 (-10.4)
- Maturity 62 → 62 (+0.1)
- Readiness 89 → 81 (-8.0)
- Security 100 → 100 (+0.0)
- Event Sourcing 100 → 100 (+0.0)
Resolved (6)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Hotspot: src/event.rs (src/event.rs)
- Hotspot: src/event/source/unix/mio.rs (src/event/source/unix/mio.rs)
- Hotspot: src/event/sys/unix/parse.rs (src/event/sys/unix/parse.rs)
- Off-boarding risk: anonymized user #1
New (6)
- Dependency hygiene PARTLY measured — Cargo dependencies read, dependency currency not (crates.io unreachable)
- Inconsistent method naming pattern. The methods to_clipboard_from and to_primary_from follow a 'destination_from_source' pattern, but the struct is named CopyToClipboard. This is slightly confusing as to_primary_from implies copying to the primary selection, not the clipboard. While distinct operations, the naming could be clearer. However, the bigger issue is the lack of a unified builder method if destination is a property.
- Inconsistent naming convention for event state checks. The Event type uses snake_case with a prefix indicating the event type (is_key_press), while the KeyEvent type uses snake_case without the prefix (is_press). This forces developers to remember which type they are inspecting to use the correct method name, despite the semantic intent being identical.
- Off-boarding risk: anonymized user #1
- Projects may be oversized for their cohesion
- Redundant methods with overlapping intent. as_key_event and as_key_press_event both return a KeyEvent. Since KeyEvent is the specific type for key events, as_key_event is the more general and appropriate name. as_key_press_event implies a specific state (press) but returns the same type as a generic key event, which is confusing because a KeyEvent can also be a release or repeat.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
crossterm-rs/crossterm was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 30 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit f6cb07514195edbe6c75547f15b0b82679726626 — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-cb25ca4feafa.