Skip to content

Functionality to render ANSI escape sequences. Clone of module IO.ANSI but supporting named xterm colors.

Notifications You must be signed in to change notification settings

RaymondLoranger/io_ansi_plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

118 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IO ANSI Plus

Functionality to render ANSI escape sequences. Clone of module IO.ANSI but supporting named xterm colors.

Installation

Add io_ansi_plus to your list of dependencies in mix.exs:

def deps do
  [
    {:io_ansi_plus, "~> 0.1"}
  ]
end

Notes

In addition to the 16 standard ANSI colors1 and their background counterparts, this package also supports the 256 xterm colors (foreground and background).

All of these 256 colors were given names like:

  • ! :aqua
  • ! :chartreuse
  • ! :psychedelic_purple

For the full list of color names (there are 1,378 of them), see the section Color Samples below. Most of these color names are based on the post Naming the 256 XTerm colors.

You can also use color number atoms instead of specific names:

alias IO.ANSI.Plus, as: ANSI
["Hello, ", :color163, "world!"] |> ANSI.format(true) |> IO.puts()
["Hi, ", :color163_background, "world!"] |> ANSI.format(true) |> IO.puts()

Most colors have multiple names, for example, :moccasin and :navajo_white for color code 223.

Shortcuts

The package also provides shortcuts allowing to drop the format calls in the following expressions:

alias IO.ANSI.Plus, as: ANSI
["Hello, ", :brown, "world!"] |> ANSI.format(true) |> IO.puts()
["Hello, ", :purple, "world!"] |> ANSI.format(true) |> IO.write()
[:aqua, "Your move:", :reset, " "] |> ANSI.format(true) |> IO.gets()

The above expressions can be respectively shortened to:

alias IO.ANSI.Plus, as: ANSI
["Hello, ", :brown, "world!"] |> ANSI.puts(true)
["Hello, ", :purple, "world!"] |> ANSI.write(true)
[:aqua, "Your move:", :reset, " "] |> ANSI.gets(true)

Note

You can click on any of the 3 images below for a clearer view.

Examples

examples

Color Chart

color_chart

Color Samples

color_samples

Footnotes

  1. Actually 8 colors and their "bright" variants.

About

Functionality to render ANSI escape sequences. Clone of module IO.ANSI but supporting named xterm colors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages