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.
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
Blink: Rapid. MS-DOS ANSI.SYS; 150 per minute or more; not widely supported
Crossed-out. Characters legible, but marked for deletion. Not widely supported.
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"
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"
Sets primary (default) font
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.