crossterm-kotlin
0.1.4indexedTerminal manipulation toolkit: cursor control, rich color/styling (16/256/RGB) and attributes, screen/raw-mode management, event polling (keyboard, mouse, resize), command-pattern ANSI batching.
Terminal manipulation toolkit: cursor control, rich color/styling (16/256/RGB) and attributes, screen/raw-mode management, event polling (keyboard, mouse, resize), command-pattern ANSI batching.
This is a Kotlin Multiplatform line-by-line transliteration port of crossterm-rs/crossterm.
Original Project: This port is based on crossterm-rs/crossterm. All design credit and project intent belong to the upstream authors; this repository is a faithful port to Kotlin Multiplatform with no behavioural changes intended.
This is an in-progress port. The goal is feature parity with the upstream Rust crate while providing a native Kotlin Multiplatform API. Every Kotlin file carries a // port-lint: source <path> header naming its upstream Rust counterpart so the AST-distance tool can track provenance.
crossterm-rs/crosstermThe text below is reproduced and lightly edited from
https://github.com/crossterm-rs/crossterm. It is the upstream project's own description and remains under the upstream authors' authorship; links have been rewritten to absolute upstream URLs so they continue to resolve from this repository.

Crossterm is a pure-rust, terminal manipulation library that makes it possible to write cross-platform text-based interfaces (see features). It supports all UNIX and Windows terminals down to Windows 7 (not all terminals are tested, see Tested Terminals for more info).
This crate supports all UNIX terminals and Windows terminals down to Windows 7; however, not all of the terminals have been tested. If you have used this library for a terminal other than the above list without issues, then feel free to add it to the above list - I really would appreciate it!
see the examples directory and documentation for more advanced examples.
[dependencies]
crossterm = "0.27"
Checkout this list with all possible commands.
[dependencies.crossterm]
version = "0.27"
features = ["event-stream"]
To use crossterm as a very thin layer you can disable the events feature or use filedescriptor feature.
This can disable mio / signal-hook / signal-hook-mio dependencies.
We highly appreciate when anyone contributes to this crate. Before you do, please, read the Contributing guidelines.
This project, crossterm and all its sub-crates: crossterm_screen, crossterm_cursor, crossterm_style,
crossterm_input, , , are licensed under the MIT
License - see the file for details.
dependencies {
implementation("io.github.kotlinmania:crossterm-kotlin:0.1.6")
}
./gradlew build
./gradlew test
See AGENTS.md and CLAUDE.md for translator discipline, port-lint header convention, and Rust → Kotlin idiom mapping.
This Kotlin port is distributed under the same MIT license as the upstream crossterm-rs/crossterm. See LICENSE (and any sibling LICENSE-* / NOTICE files mirrored from upstream) for the full text.
Original work copyrighted by the crossterm authors.
Kotlin port: Copyright (c) 2026 Sydney Renee and The Solace Project.
Thanks to the crossterm-rs/crossterm maintainers and contributors for the original Rust implementation. This port reproduces their work in Kotlin Multiplatform; bug reports about upstream design or behavior should go to the upstream repository.
use std::io::{stdout, Write};
use crossterm::{
execute,
style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor},
ExecutableCommand,
event,
};
fn main() -> std::io::Result<()> {
// using the macro
execute!(
stdout(),
SetForegroundColor(Color::Blue),
SetBackgroundColor(Color::Red),
Print("Styled text here."),
ResetColor
)?;
// or using functions
stdout()
.execute(SetForegroundColor(Color::Blue))?
.execute(SetBackgroundColor(Color::Red))?
.execute(Print("Styled text here."))?
.execute(ResetColor)?;
Ok(())
}
| Feature | Description |
|---|
event-stream | futures::Stream producing Result<Event>. |
serde | (De)serializing of events. |
events | Reading input/system events (enabled by default) |
filedescriptor | Use raw filedescriptor for all events rather then mio dependency |
derive-more | Adds is_* helper functions for event types |
osc52 | Enables crossterm::clipboard |
| Dependency | Used for | Included |
|---|
bitflags | KeyModifiers, those are differ based on input. | always |
parking_lot | locking RwLocks with a timeout, const mutexes. | always |
libc | UNIX terminal_size/raw modes/set_title and several other low level functionality. | optional (events feature), UNIX only |
Mio | event readiness polling, waking up poller | optional (events feature), UNIX only |
signal-hook | signal-hook is used to handle terminal resize SIGNAL with Mio. | optional (events feature),UNIX only |
winapi | Used for low-level windows system calls which ANSI codes can't replace | windows only |
futures-core | For async stream of events | only with event-stream feature flag |
serde | serializing and deserializing of events | only with serde feature flag |
derive_more | Adds is_* helper functions for event types | optional (derive-more feature), included by default |
base64 | Encoding clipboard data for OSC52 sequences in crossterm::clipboard | only with osc52 feature flag |
crossterm_terminalcrossterm_winapicrossterm_utilsSurfaced from shared tags and platforms — no rankings paid for.