IO ANSI Plus v0.1.22 IO.ANSI.Plus View Source

Functionality to render ANSI escape sequences.

ANSI escape sequences are characters embedded in text used to control formatting, color, and other output options on video text terminals.

In addition to the 16 regular ANSI colors and their background counterparts, this module also supports the 256 Xterm colors (foreground and background).

New shortcut functions IO.ANSI.Plus.gets/2, IO.ANSI.Plus.puts/2 and IO.ANSI.Plus.write/2 are also provided.

Link to this section Summary

Functions

Sets foreground color to black

Sets background color to black

Blink: off

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

Blink: slow. Less than 150 per minute

Sets foreground color to blue

Sets background color to blue

Bright (increased intensity) or bold

Clears screen

Clears line

Sets foreground color

Sets the foreground color from individual RGB values

Sets background color

Sets the background color from individual RGB values

Conceal. Not widely supported

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

Sends cursor to the absolute position specified by line and column

Sends cursor lines down

Sends cursor columns to the left

Sends cursor columns to the right

Sends cursor lines up

Sets foreground color to cyan

Sets background color to cyan

Default background color

Default text color

Checks if ANSI coloring is supported and enabled on this machine

Encircled

Faint (decreased intensity). Not widely supported

Sets alternative font 1

Sets alternative font 2

Sets alternative font 3

Sets alternative font 4

Sets alternative font 5

Sets alternative font 6

Sets alternative font 7

Sets alternative font 8

Sets alternative font 9

Formats a chardata-like argument by converting named ANSI sequences into actual ANSI codes

Formats a chardata-like argument by converting named ANSI sequences into actual ANSI codes

Framed

Sets foreground color to green

Sets background color to green

Sends cursor home

Image: negative. Swap foreground and background

Image: positive. Normal foreground and background

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

Sets foreground color to light black

Sets background color to light black

Sets foreground color to light blue

Sets background color to light blue

Sets foreground color to light cyan

Sets background color to light cyan

Sets foreground color to light green

Sets background color to light green

Sets foreground color to light magenta

Sets background color to light magenta

Sets foreground color to light red

Sets background color to light red

Sets foreground color to light white

Sets background color to light white

Sets foreground color to light yellow

Sets background color to light yellow

Sets foreground color to magenta

Sets background color to magenta

Underline: none

Normal color or intensity

Not framed or encircled

Not italic

Not overlined

Overlined

Sets primary (default) font

Sets foreground color to red

Sets background color to red

Resets all attributes

Image: negative. Swap foreground and background

Image: positive. Normal foreground and background

Underline: single

Sets foreground color to white

Sets background color to white

Sets foreground color to yellow

Sets background color to yellow

Link to this section Types

Link to this type

ansicode() View Source
ansicode() :: atom()

Link to this type

ansidata() View Source
ansidata() :: ansilist() | ansicode() | binary()

Link to this section Functions

Link to this function

air_force_blue_background() View Source

Link to this function

aths_special_background() View Source

Link to this function

bittersweet_background() View Source

Sets foreground color to black.

Sets background color to black.

Sets foreground color to blue.

Sets background color to blue.

Link to this function

blue_lagoon_background() View Source

Link to this function

blue_marguerite_background() View Source

Link to this function

blue_ribbon_background() View Source

Link to this function

blue_violet_background() View Source

Bright (increased intensity) or bold.

Link to this function

bright_green_background() View Source

Link to this function

bright_turquoise_background() View Source

Link to this function

buddha_gold_background() View Source

Link to this function

caribbean_green_background() View Source

Link to this function

chartreuse_yellow_background() View Source

Link to this function

chelsea_cucumber_background() View Source

Clears screen.

Clears line.

Link to this function

color(code) View Source
color(0..255) :: String.t()

Sets foreground color.

Link to this function

color(r, g, b) View Source
color(0..5, 0..5, 0..5) :: String.t()

Sets the foreground color from individual RGB values.

Valid values for each color are in the range 0 to 5.

Link to this function

color_background(code) View Source
color_background(0..255) :: String.t()

Sets background color.

Link to this function

color_background(r, g, b) View Source
color_background(0..5, 0..5, 0..5) :: String.t()

Sets the background color from individual RGB values.

Valid values for each color are in the range 0 to 5.

Link to this function

columbia_blue_background() View Source

Conceal. Not widely supported.

Link to this function

cornflower_blue_background() View Source

Link to this function

cotton_candy_background() View Source

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

Sends cursor to the absolute position specified by line and column.

Line 0 and column 0 would mean the top left corner.

Link to this function

cursor_down(lines \\ 1) View Source
cursor_down(pos_integer()) :: String.t()

Sends cursor lines down.

Link to this function

cursor_left(columns \\ 1) View Source
cursor_left(pos_integer()) :: String.t()

Sends cursor columns to the left.

Link to this function

cursor_right(columns \\ 1) View Source
cursor_right(pos_integer()) :: String.t()

Sends cursor columns to the right.

Link to this function

cursor_up(lines \\ 1) View Source
cursor_up(pos_integer()) :: String.t()

Sends cursor lines up.

Sets foreground color to cyan.

Sets background color to cyan.

Link to this function

dark_goldenrod_background() View Source

Link to this function

dark_magenta_background() View Source

Link to this function

dark_orange_background() View Source

Link to this function

dark_sea_green_background() View Source

Link to this function

dark_slate_gray_background() View Source

Link to this function

dark_turquoise_background() View Source

Link to this function

dark_violet_background() View Source

Link to this function

deep_magenta_background() View Source

Link to this function

deep_sky_blue_background() View Source

Default background color.

Default text color.

Link to this function

dodger_blue_background() View Source

Link to this function

electric_blue_background() View Source

Link to this function

electric_indigo_background() View Source

Link to this function

electric_purple_background() View Source

Link to this function

electric_violet_background() View Source

Checks if ANSI coloring is supported and enabled on this machine.

This function simply reads the configuration value for :ansi_enabled in the :elixir application. The value is by default false unless Elixir can detect during startup that both stdout and stderr are terminals.

Encircled.

Faint (decreased intensity). Not widely supported.

Sets alternative font 1.

Sets alternative font 2.

Sets alternative font 3.

Sets alternative font 4.

Sets alternative font 5.

Sets alternative font 6.

Sets alternative font 7.

Sets alternative font 8.

Sets alternative font 9.

Link to this function

format(chardata, emit? \\ enabled?()) View Source

Formats a chardata-like argument by converting named ANSI sequences into actual ANSI codes.

The named sequences are represented by atoms.

It will also append an IO.ANSI.reset/0 to the chardata when a conversion is performed. If you don't want this behaviour, use format_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 checks if ANSI is enabled using the enabled?/0 function.

Examples

iex> IO.ANSI.Plus.format(["Hello, ", :red, :bright, "world!"], true)
[[[[[[], "Hello, "] | "\e[31m"] | "\e[1m"], "world!"] | "\e[0m"]
Link to this function

format_fragment(chardata, emit? \\ enabled?()) View Source

Formats a chardata-like argument by converting named ANSI sequences into actual ANSI codes.

The named sequences are represented by atoms.

An optional boolean parameter can be passed to enable or disable emitting actual ANSI codes. When false, no ANSI codes will emitted. By default checks if ANSI is enabled using the enabled?/0 function.

Examples

iex> IO.ANSI.Plus.format_fragment([:bright, 'Word'], true)
[[[[[[] | "\e[1m"], 87], 111], 114], 100]
Link to this function

fountain_blue_background() View Source

Framed.

Link to this function

free_speech_red_background() View Source

Link to this function

french_lilac_background() View Source

Link to this function

french_pass_background() View Source

Link to this function

fresh_eggplant_background() View Source

Link to this function

fuchsia_pink_background() View Source

Link to this function

gets(chardata, emit? \\ enabled?()) View Source
gets(ansidata(), boolean()) :: IO.chardata() | IO.nodata()

Link to this function

golden_poppy_background() View Source

Sets foreground color to green.

Sets background color to green.

Link to this function

green_yellow_background() View Source

Link to this function

guardsman_red_background() View Source

Link to this function

hippie_green_background() View Source

Link to this function

hollywood_cerise_background() View Source

Sends cursor home.

Link to this function

hot_magenta_background() View Source

Image: negative. Swap foreground and background.

Image: positive. Normal foreground and background.

Link to this function

islamic_green_background() View Source

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

Link to this function

japanese_laurel_background() View Source

Link to this function

laser_lemon_background() View Source

Link to this function

lavender_blue_background() View Source

Link to this function

lavender_blush_background() View Source

Link to this function

lavender_rose_background() View Source

Sets foreground color to light black.

Link to this function

light_black_background() View Source

Sets background color to light black.

Sets foreground color to light blue.

Sets background color to light blue.

Link to this function

light_coral_background() View Source

Sets foreground color to light cyan.

Sets background color to light cyan.

Sets foreground color to light green.

Link to this function

light_green_background() View Source

Sets background color to light green.

Sets foreground color to light magenta.

Link to this function

light_magenta_background() View Source

Sets background color to light magenta.

Sets foreground color to light red.

Sets background color to light red.

Link to this function

light_sea_green_background() View Source

Link to this function

light_slate_blue_background() View Source

Link to this function

light_slate_grey_background() View Source

Link to this function

light_steel_blue_background() View Source

Sets foreground color to light white.

Link to this function

light_white_background() View Source

Sets background color to light white.

Sets foreground color to light yellow.

Link to this function

light_yellow_background() View Source

Sets background color to light yellow.

Link to this function

macaroni_and_cheese_background() View Source

Sets foreground color to magenta.

Sets background color to magenta.

Link to this function

mango_tango_background() View Source

Link to this function

medium_blue_background() View Source

Link to this function

medium_orchid_background() View Source

Link to this function

medium_purple_background() View Source

Link to this function

medium_spring_green_background() View Source

Link to this function

medium_turquoise_background() View Source

Link to this function

medium_violet_red_background() View Source

Link to this function

neutral_green_background() View Source

Link to this function

new_midnight_blue_background() View Source

Link to this function

night_rider_background() View Source

Underline: none.

Normal color or intensity.

Not framed or encircled.

Not italic.

Not overlined.

Link to this function

observatory_background() View Source

Link to this function

olive_green_background() View Source

Overlined.

Link to this function

pacific_blue_background() View Source

Link to this function

pale_violet_red_background() View Source

Link to this function

pastel_green_background() View Source

Link to this function

persian_green_background() View Source

Link to this function

picton_blue_background() View Source

Link to this function

pink_flamingo_background() View Source

Sets primary (default) font.

Link to this function

psychedelic_purple_background() View Source

Link to this function

purple_pizzazz_background() View Source

Link to this function

puts(chardata, emit? \\ enabled?()) View Source
puts(ansidata(), boolean()) :: :ok

Sets foreground color to red.

Sets background color to red.

Resets all attributes.

Image: negative. Swap foreground and background.

Image: positive. Normal foreground and background.

Link to this function

rose_of_sharon_background() View Source

Link to this function

safety_orange_background() View Source

Link to this function

sandy_brown_background() View Source

Link to this function

school_bus_yellow_background() View Source

Link to this function

science_blue_background() View Source

Link to this function

screamin_green_background() View Source

Link to this function

shakespeare_background() View Source

Link to this function

silver_chalice_background() View Source

Link to this function

spring_green_background() View Source

Link to this function

tickle_me_pink_background() View Source

Link to this function

trendy_pink_background() View Source

Link to this function

tyrian_purple_background() View Source

Underline: single.

Link to this function

verdun_green_background() View Source

Link to this function

violet_blue_background() View Source

Sets foreground color to white.

Sets background color to white.

Link to this function

white_smoke_background() View Source

Link to this function

wild_watermelon_background() View Source

Link to this function

write(chardata, emit? \\ enabled?()) View Source
write(ansidata(), boolean()) :: :ok

Sets foreground color to yellow.

Sets background color to yellow.