Module lua-color.terminal

Style terminal output

Standard colors:

  • black
  • red
  • green
  • yellow
  • blue
  • pink
  • cyan
  • white
  • default

! Not all terminals support all effects
! Generally you can expect the colors from the list above to work on all *nix systems
More information

Functions

set (options) Set a format.
reset () Reset the format.
apply (options) Set a format for a string.

Fields

Effect Effect flags


Functions

set (options)
Set a format.

Options table:
  • color: Foreground color
  • bg or background: Background color
  • font: Number between 0 (default) and 9 to select font
  • An effect as <effect_name> = true
  • Flags for effects as index 1

Parameters:

Returns:

    string Escape sequence

Usage:

  • -- Blue, underlined and italic
    local tc = require "lua-color.terminal"
    print(tc.set {
      color = "blue",
      tc.Effect.underline | tc.Effect.italic,
    } .. "Hello world!" .. tc.reset())
  • -- Red background, font number 3 and underlined
    print(tc.set {
      bg = Color {1, 0, 0},
      font = 3,
      underline = true,
    } .. "Hello world!" .. tc.reset())
reset ()
Reset the format.

Returns:

    string Escape sequence
apply (options)
Set a format for a string.

Sets the format before the string and resets it after.

Parameters:

  • options table Same as the options for set, but with a to option for the string

Returns:

    string Escape sequence

Usage:

    -- Red on green background
    local tc = require "lua-color.terminal"
    print(tc.apply {
      color = "red",
      bg = "green",
      to = "Hello world!",
    })

Fields

Effect
Effect flags
  • reset
  • bold
  • faint
  • italic
  • underline
  • blink
  • bright
  • invert
  • hide
  • strike
generated by LDoc 1.4.6 Last updated 2022-12-30 15:01:58