? QShColor

QShColor is a single-file Kotlin library which can color your console output.



No dependent libraries except test code.

Refer to build.gradle.kts to check directly.

How to use

See QShColorTest.kt for more code examples.

This test file is also single-file, self-contained and copy-pastable.

fun main() {
    var txt = "c".yellow + "o".blue + "l".red + "o".magenta + "u".green + "r".cyan + "f".yellow + "u".blue + "l".red


    txt = "you can set background".qColor(fg = QShColor.RED, bg = QShColor.BLUE)


    txt = """val color = "you can use regex to color targeted text"""".qColorTarget(
        ptn = """val(?!\S)""".toRegex(),
        color = QShColor.MAGENTA
        ptn = """".*?"""".toRegex(),
        color = QShColor.GREEN


How did I create this library

In my own chaotic codebase, I created a program which automatically resolves dependencies at the method or property level, extracts necessary code elements, and automatically generates a compact self-contained single-file library.

It utilizes PSI to resolve dependencies for function calls and references to the classes.

My original repository is currently quite chaotic, so I decided to extract it little by little and publish some small libraries.

Also, I would like to prepare the original repository and publish it in the future.



View Github