Colorful
This module is a wrapper for IO.ANSI module.
iex> Colorful.string("hello", "red underline")
"[31m[4mhello[0m"
iex> Colorful.string("hello", ["red", "underline"])
"[31m[4mhello[0m"
iex> Colorful.string("hello", [:red, :underline])
"[31m[4mhello[0m"
iex> Colorful.puts("hello", "red")
hello # colored
iex> Colorful.inspect(:hello, "red")
:hello # colored
:hello # return value, an atom
Followings are valid decorators.
red
green
blue
cyan
magenta
yellow
black
white
default_color
red_background
green_background
blue_background
cyan_background
magenta_background
yellow_background
black_background
white_background
default_background
normal
bright
italic
overlined
underline
crossed_out
reverse
inverse
conceal
faint
framed
encircled
blink_slow
blink_rapid
reset
not_italic
not_overlined
no_underline
not_framed_encircled
blink_off
primary_font
font_1
font_2
font_3
font_4
font_5
font_6
font_7
font_8
font_9
home
clear
Summary
inspect(term, decorators \\ "reset") | This writes colored string to stdout.
The string is made of first argument according to |
inspect(device, term, decorators) | Inspects decorated text to specified device |
puts(text, decorators \\ "reset") | This outputs colored string to stdout as same as |
puts(device, text, decorators) | Outputs decorated text to specified device, similar to |
string(text, decorators \\ "reset") | This function makes given string decorated |
Types ↑
decorators :: String.t | atom | [String.t | atom]
Functions
Specs:
- inspect(String.t, decorators) :: String.t
This writes colored string to stdout.
The string is made of first argument according to Inspect
protocol.
This returns given first argument as it is.
Specs:
- inspect(atom | pid, String.t, decorators) :: :ok
Inspects decorated text to specified device.
Specs:
- puts(String.t, decorators) :: :ok
This outputs colored string to stdout as same as IO.puts
.
The return value is always :ok
.
Specs:
- puts(atom | pid, String.t, decorators) :: :ok
Outputs decorated text to specified device, similar to IO.puts/2
Specs:
- string(String.t, decorators) :: String.t
This function makes given string decorated.
The decoration is specified in the second argument. It is a string, or a list which members are string or atom.