Module

Choku

Package
purescript-choku
Repository
m15a/purescript-choku

This module imports and re-exports some default submodules for convenience, namely

  • Choku.Common
  • Choku.Color
  • Choku.Style
  • Choku.Stdout

The last one, Choku.Stdout, might not be for your use case, as it works in Eff and customized for the STDOUT stream. To use chalk in Aff, import Choku.Stdout.Aff or Choku.Stderr.Aff instead. To use chalk for the STDERR stream, import Choku.Stderr or Choku.Stderr.Aff instead.

Re-exports from Choku.Color

#Color Source

data Color

Constructors

Instances

#mkRGB Source

mkRGB :: Int -> Int -> Int -> Maybe Color

Safe constructor to make a Color from RGB values.

Returns Nothing with out-of-bounds inputs.

#mkHex Source

mkHex :: String -> Maybe Color

Safe constructor to make a Color from Hex string.

Returns Nothing with invalid Hex string. Prefix # is not mandatory. Hex digits of either length 6 (e.g., #0a0b0c) or 3 (e.g., #ABC) are accepted.

#mkANSI256 Source

mkANSI256 :: Int -> Maybe Color

Safe constructor to make a Color from ANSI256 integer value between 0 and 255.

Returns Nothing with out-of-bounds input.

Re-exports from Choku.Common

#ColorSupportLevel Source

data ColorSupportLevel

Level of color support.

| Level            | Int | Description                           |
| ---------------- | --- | ------------------------------------- |
| `HasNoColors`    |   0 | All colors disabled                   |
| `HasBasicColors` |   1 | Basic color support (16 colors)       |
| `Has256Colors`   |   2 | 256 color support                     |
| `Has16mColors`   |   3 | Truecolor support (16 million colors) |

See also https://github.com/chalk/chalk#chalklevel.

Constructors

Instances

#Choku Source

data Choku

The Choku type, simply wrapping a Chalk instance in the Javascript layer.

Instances

#withChokuFlipped Source

#withChoku Source

withChoku :: String -> Choku -> String

Modify a string with the chalk.

For example,

import Prelude
import Data.Maybe
import Partial.Unsafe
import Choku
let
  chk = unsafePartial $ fromJust (mkChoku 3) # bold # cyan
in
  "hello" `withChoku` chk

produces a bold cyan "hello" string.

#mkChoku Source

mkChoku :: ColorSupportLevel -> Choku

Create a new chalk instance with the specified level of color support.

#level Source

level :: Choku -> ColorSupportLevel

Return the color support level of the given chalk.

#(|&) Source

Operator alias for Choku.Common.withChokuFlipped (non-associative / precedence 7)

#(&|) Source

Operator alias for Choku.Common.withChoku (non-associative / precedence 7)

Re-exports from Choku.Stdout

#withStyle Source

withStyle :: String -> Style -> Effect String

Modify a string, using the default chalk for STDOUT, with the given style.

For example,

import Prelude
import Effect.Console
import Data.Maybe
import Partial.Unsafe
import Choku

log =<< "hello" `withStyle` (inverse >>> underline)

prints an inversed and underlined "hello" string.

#supportsColor Source

supportsColor :: Effect { has16m :: Boolean, has256 :: Boolean, hasBasic :: Boolean, level :: Int }

Provide detailed information of the color support level.

See https://github.com/chalk/chalk#supportscolor.

#choku Source

choku :: Effect Choku

Get the default chalk instance for STDOUT, automatically detecting the level of color support.

#(:&) Source

Operator alias for Choku.Stdout.withStyleFlipped (non-associative / precedence 7)

#(&:) Source

Operator alias for Choku.Stdout.withStyle (non-associative / precedence 7)

Re-exports from Choku.Style

#Style Source

type Style = Choku -> Choku

#yellowBright Source

#whiteBright Source

#underline Source

#strikethrough Source

#redBright Source

#magentaBright Source

#greenBright Source

#fg Source

fg :: Color -> Style

Modify foreground color.

#cyanBright Source

#blueBright Source

#blackBright Source

#bgYellowBright Source

#bgWhiteBright Source

#bgRedBright Source

#bgMagentaBright Source

#bgMagenta Source

#bgGreenBright Source

#bgCyanBright Source

#bgBlueBright Source

#bgBlackBright Source

#bg Source

bg :: Color -> Style

Modify background color.