Sign in

    chalk

    Terminal string styling support for MoonBit.

    string
    chalk
    color
    Download zip
    Version
    0.0.1
    License
    MIT
    Last updated
    4 months ago
    Downloads
    25K

    #MoonBit-Chalk

    MoonBit-Chalk provides some APIs for terminal color rendering, including rendering APIs for formatting, background color, and font color.

    #Usage

    Use chalk() to construct a Chalk object and attach properties to it through chain calls.

    Chalk provides three types of enum internally for setting properties: text color(Color enum), background color(BackGroundColors enum), and format(Modifier enum).

    Chalk is an immutable variable, which allows you to easily reuse and combine it, and finally use Render to render any value that conforms to the Show Trait.

    let str = chalk().background(BgRed).modifier(Bold).color(Red).render("hello")

    BackGroundColors

    pub(all) enum BackGroundColors {
    BgBlack
    BgRed
    BgGreen
    BgYellow
    BgBlue
    BgMagenta
    BgCyan
    BgWhite
    BgBlackBright
    BgRedBright
    BgGreenBright
    BgYellowBright
    BgBlueBright
    BgMagentaBright
    BgCyanBright
    BgWhiteBright
    }

    Chalk

    pub(all) enum Chalk {
    Cons(Chalk, Render)
    Nil
    }

    Chalk::background

    fn Chalk::background(self : Chalk, color : BackGroundColors) -> Chalk

    Chalk::color

    fn Chalk::color(self : Chalk, color : Colors) -> Chalk

    Chalk::modifier

    fn Chalk::modifier(self : Chalk, modifier : Modifier) -> Chalk

    Chalk::render

    fn[T : Show] Chalk::render(self : Chalk, to_render : T) -> String

    Colors

    pub(all) enum Colors {
    Black
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    White
    BlackBright
    RedBright
    GreenBright
    YellowBright
    BlueBright
    MagentaBright
    CyanBright
    WhiteBright
    }

    Modifier

    pub(all) enum Modifier {
    Reset
    Bold
    Dim
    Italic
    Underline
    Overline
    Inverse
    Hidden
    Strikethrough
    }

    Render

    pub(all) enum Render {
    RenderBackGround(BackGroundColors)
    RenderColor(Colors)
    RenderModifier(Modifier)
    }

    chalk

    fn chalk() -> Chalk

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io