terminal colors, multi-line strings; bump to 0.8
This commit is contained in:
16
src/main/kotlin/blitz/term/AnsiiStr.kt
Normal file
16
src/main/kotlin/blitz/term/AnsiiStr.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package blitz.term
|
||||
|
||||
class AnsiiMode(internal val values: MutableList<Int>) {
|
||||
constructor(mo: Int): this(mutableListOf(mo))
|
||||
|
||||
operator fun plus(other: AnsiiMode): AnsiiMode =
|
||||
AnsiiMode((values + other.values).toMutableList())
|
||||
}
|
||||
|
||||
private val escape = (27).toChar()
|
||||
|
||||
fun ansiiStr(str: String, vararg modes: AnsiiMode) =
|
||||
if (modes.isEmpty())
|
||||
str
|
||||
else
|
||||
"$escape[${modes.flatMap { it.values }.joinToString(separator = ";")}m$str$escape[0m"
|
Reference in New Issue
Block a user