IO ANSI Table v0.4.29 IO.ANSI.Table.Style View Source
Defines functions returning the properties of configured table styles.
Link to this section Summary
Functions
Returns the border attribute of a given table style
and line type
Returns the border spreads of a given table style
and line type
Returns the borders of a given table style
and line type
Returns the dash of a given table style
and line type
Returns the filler attribute of a given table style
and line type
Converts a switch argument
to a table style
Returns the key attribute of a given table style
and line type
Returns the line types of a given table style
Returns the non key attribute of a given table style
and line type
Returns the list of all table styles
Returns a list of interpolated texts (one per table style) and optionally passes each one to a function
Converts a table style
to a switch argument
Link to this section Types
attr() View Source
border()
View Source
border() :: String.t()
border() :: String.t()
t()
View Source
t() :: atom()
t() :: atom()
Link to this section Functions
border_attr(style, type)
View Source
border_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
border_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
Returns the border attribute of a given table style
and line type
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.border_attr(:green, :top)
[:light_white, :green_background]
border_spreads(style, type)
View Source
border_spreads(t(), IO.ANSI.Table.LineType.t()) ::
[IO.ANSI.Table.Column.spread()] | []
border_spreads(t(), IO.ANSI.Table.LineType.t()) :: [IO.ANSI.Table.Column.spread()] | []
Returns the border spreads of a given table style
and line type
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.border_spreads(:plain, :bottom)
[[0, 2, 0], [0, 3, 0], [0, 2, 0]] # borders: "└─", "─┴─", "─┘"
iex> alias IO.ANSI.Table.Style
iex> Style.border_spreads(:plain, :header)
[[0, 1, 1], [1, 1, 1], [1, 1, 0]] # borders: "│" , "│" , "│"
borders(style, type)
View Source
borders(t(), IO.ANSI.Table.LineType.t()) :: [border()] | []
borders(t(), IO.ANSI.Table.LineType.t()) :: [border()] | []
Returns the borders of a given table style
and line type
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.borders(:cyan, :bottom)
["╚═", "═╩═", "═╝"]
dash(style, type)
View Source
dash(t(), IO.ANSI.Table.LineType.t()) :: String.t() | nil
dash(t(), IO.ANSI.Table.LineType.t()) :: String.t() | nil
Returns the dash of a given table style
and line type
.
Examples
iex> IO.ANSI.Table.Style
iex> Style.dash(:dark, :top)
"═"
iex> IO.ANSI.Table.Style
iex> Style.dash(:dark, :row)
nil
filler_attr(style, type)
View Source
filler_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
filler_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
Returns the filler attribute of a given table style
and line type
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.filler_attr(:mixed, :row)
:green_background
from_switch_arg(arg) View Source
Converts a switch argument
to a table style.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.from_switch_arg("green-alt")
{:ok, :green_alt}
iex> alias IO.ANSI.Table.Style
iex> Style.from_switch_arg("lite")
:error
key_attr(style, type)
View Source
key_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
key_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
Returns the key attribute of a given table style
and line type
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.key_attr(:light, :row)
:chartreuse
iex> alias IO.ANSI.Table.Style
iex> Style.key_attr(:light, :header)
[:gold, :underline]
line_types(style)
View Source
line_types(t()) :: [IO.ANSI.Table.LineType.t()] | []
line_types(t()) :: [IO.ANSI.Table.LineType.t()] | []
Returns the line types of a given table style
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.line_types(:light)
[:top, :header, :separator, [:row], :bottom]
iex> alias IO.ANSI.Table.Style
iex> Style.line_types(:green_alt)
[:top, :header, :separator, [:even_row, :odd_row]]
non_key_attr(style, type)
View Source
non_key_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
non_key_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
Returns the non key attribute of a given table style
and line type
.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.non_key_attr(:cyan, :row)
[:black, :cyan_background]
styles()
View Source
styles() :: [t()]
styles() :: [t()]
Returns the list of all table styles.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.styles() |> length()
36
texts(template, fun \\ &(&1)) View Source
Returns a list of interpolated texts (one per table style) and optionally passes each one to a function.
Examples
alias IO.ANSI.Table.Style
Style.texts(" - `&style`&filler - ¬e\n")
alias IO.ANSI.Table.Style
Style.texts(" - `&style`&filler - ¬e", &IO.puts/1)
Interpolation placeholders
&style
- table style (e.g. ":light_alt")&arg
- table style switch arg (e.g. "light-alt")&filler
- padding after &style or &arg¬e
- table style note&rank
- table style rank (3 digits)
to_switch_arg(style) View Source
Converts a table style
to a switch argument.
Examples
iex> alias IO.ANSI.Table.Style
iex> Style.to_switch_arg(:green_alt)
"green-alt"
iex> alias IO.ANSI.Table.Style
iex> Style.to_switch_arg(:lite)
nil