
Parses ANSI escape sequences into ratatui-styled text, converting terminal color/style codes (4-, 8-, 24-bit colors; bold, italic, underline, reset) for TUI rendering.
A Kotlin Multiplatform Native library to parse text with ANSI color codes and turn them into
ratatui.text.Text. This is a port of the Rust ansi-to-tui library by Uttarayan Mondal.
Parse ANSI escape sequences from terminal output and convert them to styled text objects compatible with ratatui-kotlin for TUI rendering.
| Color | Supported | Examples |
|---|---|---|
| 24 bit | ✓ | \x1b[38;2;<R>;<G>;<B>m |
| 8 bit | ✓ | \x1b[38;5;<N>m |
| 4 bit | ✓ | \x1b[30..37;40..47m |
This library is not yet published to Maven Central. The recommended approach is to include it as a git submodule or vendored dependency:
git submodule add https://github.com/KotlinMania/ansi-to-tui-kotlin.gitThen in your settings.gradle.kts:
include(":ansi-to-tui-kotlin")And in your module's build.gradle.kts:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":ansi-to-tui-kotlin"))
}
}
}
}Once published to Maven Central, you'll be able to add it directly:
dependencies {
implementation("io.github.kotlinmania:ansi-to-tui-kotlin:1.0.0")
}// Parse ANSI-colored text from a string
val text = "\u001b[38;2;225;192;203mPink Text\u001b[0m".intoText()
// Parse from a ByteArray
val bytes = someFile.readBytes()
val styledText = bytes.intoText()Notes:
ORG_GRADLE_PROJECT_*).v0.1.0) or run the workflow with release=true. For snapshots, keep the project version ending with -SNAPSHOT and push to main.38;5;N and 48;5;N
38;2;R;G;B and 48;2;R;G;B
Licensed under MIT license (LICENSE)
This Kotlin Multiplatform port was created by Sydney Renee of The Solace Project for KotlinMania.
Special thanks to the original author:
A Kotlin Multiplatform Native library to parse text with ANSI color codes and turn them into
ratatui.text.Text. This is a port of the Rust ansi-to-tui library by Uttarayan Mondal.
Parse ANSI escape sequences from terminal output and convert them to styled text objects compatible with ratatui-kotlin for TUI rendering.
| Color | Supported | Examples |
|---|---|---|
| 24 bit | ✓ | \x1b[38;2;<R>;<G>;<B>m |
| 8 bit | ✓ | \x1b[38;5;<N>m |
| 4 bit | ✓ | \x1b[30..37;40..47m |
This library is not yet published to Maven Central. The recommended approach is to include it as a git submodule or vendored dependency:
git submodule add https://github.com/KotlinMania/ansi-to-tui-kotlin.gitThen in your settings.gradle.kts:
include(":ansi-to-tui-kotlin")And in your module's build.gradle.kts:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":ansi-to-tui-kotlin"))
}
}
}
}Once published to Maven Central, you'll be able to add it directly:
dependencies {
implementation("io.github.kotlinmania:ansi-to-tui-kotlin:1.0.0")
}// Parse ANSI-colored text from a string
val text = "\u001b[38;2;225;192;203mPink Text\u001b[0m".intoText()
// Parse from a ByteArray
val bytes = someFile.readBytes()
val styledText = bytes.intoText()Notes:
ORG_GRADLE_PROJECT_*).v0.1.0) or run the workflow with release=true. For snapshots, keep the project version ending with -SNAPSHOT and push to main.38;5;N and 48;5;N
38;2;R;G;B and 48;2;R;G;B
Licensed under MIT license (LICENSE)
This Kotlin Multiplatform port was created by Sydney Renee of The Solace Project for KotlinMania.
Special thanks to the original author: