IO.ANSI

Functionality to render ANSI escape sequences (http:\en.wikipedia.org/wiki/ANSIescapecode) — characters embedded in text used to control formatting, color, and other output options on video text terminals.

Source

Summary

black()

Sets foreground color to black

black_background()

Sets background color to black

blink_off()

Blink: off

blink_rapid()

Blink: Rapid. MS-DOS ANSI.SYS; 150 per minute or more; not widely supported

blink_slow()

Blink: Slow. Less than 150 per minute

blue()

Sets foreground color to blue

blue_background()

Sets background color to blue

bright()

Bright (increased intensity) or Bold

clear()

Clear screen

conceal()

Conceal. Not widely supported

crossed_out()

Crossed-out. Characters legible, but marked for deletion. Not widely supported

cyan()

Sets foreground color to cyan

cyan_background()

Sets background color to cyan

default_background()

Default background color

default_color()

Default text color

encircled()

Encircled

escape(string, emit \\ terminal?)

Escapes a string by converting named ANSI sequences into actual ANSI codes

escape_fragment(string, emit \\ terminal?)

Escapes a string by converting named ANSI sequences into actual ANSI codes

faint()

Faint (decreased intensity), not widely supported

font_1()

Sets alternative font 1

font_2()

Sets alternative font 2

font_3()

Sets alternative font 3

font_4()

Sets alternative font 4

font_5()

Sets alternative font 5

font_6()

Sets alternative font 6

font_7()

Sets alternative font 7

font_8()

Sets alternative font 8

font_9()

Sets alternative font 9

framed()

Framed

green()

Sets foreground color to green

green_background()

Sets background color to green

home()

Send cursor home

inverse()

Image: Negative. Swap foreground and background

italic()

Italic: on. Not widely supported. Sometimes treated as inverse

magenta()

Sets foreground color to magenta

magenta_background()

Sets background color to magenta

no_underline()

Underline: None

normal()

Normal color or intensity

not_framed_encircled()

Not framed or encircled

not_italic()

Not italic

not_overlined()

Not overlined

overlined()

Overlined

primary_font()

Sets primary (default) font

red()

Sets foreground color to red

red_background()

Sets background color to red

reset()

Resets all attributes

reverse()

Image: Negative. Swap foreground and background

terminal?(device \\ :erlang.group_leader())

Checks whether the default I/O device is a terminal or a file

underline()

Underline: Single

white()

Sets foreground color to white

white_background()

Sets background color to white

yellow()

Sets foreground color to yellow

yellow_background()

Sets background color to yellow

Functions

black()

Sets foreground color to black

Source
black_background()

Sets background color to black

Source

Blink: off

Source

Blink: Rapid. MS-DOS ANSI.SYS; 150 per minute or more; not widely supported

Source

Blink: Slow. Less than 150 per minute

Source
blue()

Sets foreground color to blue

Source
blue_background()

Sets background color to blue

Source
bright()

Bright (increased intensity) or Bold

Source
clear()

Clear screen

Source
conceal()

Conceal. Not widely supported

Source
crossed_out()

Crossed-out. Characters legible, but marked for deletion. Not widely supported.

Source
cyan()

Sets foreground color to cyan

Source
cyan_background()

Sets background color to cyan

Source
default_background()

Default background color

Source
default_color()

Default text color

Source
encircled()

Encircled

Source
escape(string, emit \\ terminal?)

Specs:

Escapes a string by converting named ANSI sequences into actual ANSI codes.

The format for referring to sequences is %{red} and %{red,bright} (for multiple sequences).

It will also append a %{reset} to the string. If you don't want this behaviour, use escape_fragment/2.

An optional boolean parameter can be passed to enable or disable emitting actual ANSI codes. When false, no ANSI codes will emitted. By default, standard output will be checked if it is a terminal capable of handling these sequences (using terminal?/1 function)

Examples

iex> IO.ANSI.escape("Hello %{red,bright,green}yes", true)
"Hello \e[31m\e[1m\e[32myes\e[0m"
Source
escape_fragment(string, emit \\ terminal?)

Specs:

Escapes a string by converting named ANSI sequences into actual ANSI codes.

The format for referring to sequences is %{red} and %{red,bright} (for multiple sequences).

An optional boolean parameter can be passed to enable or disable emitting actual ANSI codes. When false, no ANSI codes will emitted. By default, standard output will be checked if it is a terminal capable of handling these sequences (using terminal?/1 function)

Examples

iex> IO.ANSI.escape_fragment("Hello %{red,bright,green}yes", true)
"Hello \e[31m\e[1m\e[32myes"
iex> IO.ANSI.escape_fragment("%{reset}bye", true)
"\e[0mbye"
Source
faint()

Faint (decreased intensity), not widely supported

Source
font_1()

Sets alternative font 1

Source
font_2()

Sets alternative font 2

Source
font_3()

Sets alternative font 3

Source
font_4()

Sets alternative font 4

Source
font_5()

Sets alternative font 5

Source
font_6()

Sets alternative font 6

Source
font_7()

Sets alternative font 7

Source
font_8()

Sets alternative font 8

Source
font_9()

Sets alternative font 9

Source
framed()

Framed

Source
green()

Sets foreground color to green

Source
green_background()

Sets background color to green

Source
home()

Send cursor home

Source
inverse()

Image: Negative. Swap foreground and background

Source
italic()

Italic: on. Not widely supported. Sometimes treated as inverse.

Source
magenta()

Sets foreground color to magenta

Source
magenta_background()

Sets background color to magenta

Source
no_underline()

Underline: None

Source
normal()

Normal color or intensity

Source
not_framed_encircled()

Not framed or encircled

Source
not_italic()

Not italic

Source
not_overlined()

Not overlined

Source
overlined()

Overlined

Source
primary_font()

Sets primary (default) font

Source
red()

Sets foreground color to red

Source
red_background()

Sets background color to red

Source
reset()

Resets all attributes

Source
reverse()

Image: Negative. Swap foreground and background

Source
terminal?(device \\ :erlang.group_leader())

Specs:

  • terminal?(:io.device) :: boolean

Checks whether the default I/O device is a terminal or a file.

Used to identify whether printing ANSI escape sequences will likely be displayed as intended.

Source
underline()

Underline: Single

Source
white()

Sets foreground color to white

Source
white_background()

Sets background color to white

Source
yellow()

Sets foreground color to yellow

Source
yellow_background()

Sets background color to yellow

Source