Current section
Files
Jump to
Current section
Files
src/galant.erl
-module(galant).
-compile(no_auto_import).
-export([open/0, black/2, bg_black/2, start_black/1, start_bg_black/1, red/2, bg_red/2, start_red/1, start_bg_red/1, yellow/2, bg_yellow/2, start_yellow/1, start_bg_yellow/1, magenta/2, bg_magenta/2, start_magenta/1, start_bg_magenta/1, cyan/2, bg_cyan/2, start_cyan/1, start_bg_cyan/1, white/2, bg_white/2, start_white/1, start_bg_white/1, default/2, bg_default/2, blue/2, bg_blue/2, start_blue/1, start_bg_blue/1, green/2, bg_green/2, start_green/1, start_bg_green/1, stop_color/1, stop_bg_color/1, color_256/3, color_rgb/5, color_bg_rgb/5, start_color_rgb/4, start_bg_color_rgb/4, color_hex/3, color_bg_hex/3, start_color_hex/2, start_bg_color_hex/2, text/2, placeholder/1, bold/2, start_bold/1, end_bold/1, dim/2, start_dim/1, end_dim/1, italic/2, start_italic/1, end_italic/1, underline/2, start_underline/1, end_underline/1, blinking/2, start_blinking/1, end_blinking/1, inverse/2, start_inverse/1, end_inverse/1, hidden/2, start_hidden/1, end_hidden/1, strikethrough/2, start_strikethrough/1, end_strikethrough/1, reset/1, to_string/1, save/1, to_string_styler/1]).
-export_type([styling/0]).
-opaque styling() :: {text, binary()} |
{black, binary()} |
{black_bg, binary()} |
start_black |
start_black_bg |
{red, binary()} |
{red_bg, binary()} |
start_red |
start_red_bg |
{green, binary()} |
{green_bg, binary()} |
start_green |
start_green_bg |
{yellow, binary()} |
{yellow_bg, binary()} |
start_yellow |
start_yellow_bg |
{blue, binary()} |
{blue_bg, binary()} |
start_blue |
start_blue_bg |
{magenta, binary()} |
{magenta_bg, binary()} |
start_magenta |
start_magenta_bg |
{cyan, binary()} |
{cyan_bg, binary()} |
start_cyan |
start_cyan_bg |
{white, binary()} |
{white_bg, binary()} |
start_white |
start_white_bg |
stop_color |
stop_bg_color |
{default, binary()} |
{default_bg, binary()} |
{color256, binary(), integer()} |
{color_rgb, binary(), integer(), integer(), integer()} |
{color_bg_rgb, binary(), integer(), integer(), integer()} |
{start_color_rgb, integer(), integer(), integer()} |
{start_color_bg_rgb, integer(), integer(), integer()} |
{bold, binary()} |
start_bold |
end_bold |
{dim, binary()} |
start_dim |
end_dim |
{italic, binary()} |
start_italic |
end_italic |
{underline, binary()} |
start_underline |
end_underline |
{blinking, binary()} |
start_blinking |
end_blinking |
{reverse, binary()} |
start_reverse |
end_reverse |
{hidden, binary()} |
start_hidden |
end_hidden |
{strikethrough, binary()} |
start_strikethrough |
end_strikethrough |
reset |
place_holder.
-spec color256_code(integer()) -> binary().
color256_code(Code) ->
<<<<"[38;5;"/utf8, (gleam@int:to_string(Code))/binary>>/binary, "m"/utf8>>.
-spec color_rgb_code(binary(), integer(), integer(), integer()) -> binary().
color_rgb_code(Code, Red, Green, Blue) ->
_pipe = gleam@string_builder:new(),
_pipe@1 = gleam@string_builder:append(_pipe, Code),
_pipe@2 = gleam@string_builder:append(_pipe@1, gleam@int:to_string(Red)),
_pipe@3 = gleam@string_builder:append(_pipe@2, <<";"/utf8>>),
_pipe@4 = gleam@string_builder:append(_pipe@3, gleam@int:to_string(Green)),
_pipe@5 = gleam@string_builder:append(_pipe@4, <<";"/utf8>>),
_pipe@6 = gleam@string_builder:append(_pipe@5, gleam@int:to_string(Blue)),
_pipe@7 = gleam@string_builder:append(_pipe@6, <<"m"/utf8>>),
gleam@string_builder:to_string(_pipe@7).
-spec esc() -> binary().
esc() ->
{ok, Escape@1} = case begin
_pipe = <<16#1b>>,
gleam@bit_string:to_string(_pipe)
end of
{ok, Escape} -> {ok, Escape};
_try ->
erlang:error(#{gleam_error => assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _try,
module => <<"galant"/utf8>>,
function => <<"esc"/utf8>>,
line => 174})
end,
Escape@1.
-spec code(binary()) -> binary().
code(Style_code) ->
<<(esc())/binary, Style_code/binary>>.
-spec style_text(
gleam@string_builder:string_builder(),
binary(),
binary(),
gleam@option:option(binary())
) -> gleam@string_builder:string_builder().
style_text(Builder, Text, Style, Reset_style) ->
_pipe = Builder,
_pipe@1 = gleam@string_builder:append(_pipe, code(Style)),
_pipe@2 = gleam@string_builder:append(_pipe@1, Text),
gleam@string_builder:append(
_pipe@2,
gleam@option:unwrap(
gleam@option:map(Reset_style, fun code/1),
<<""/utf8>>
)
).
-spec hex_to_rgb(integer()) -> {integer(), integer(), integer()}.
hex_to_rgb(Color) ->
{ok, [{ok, Red@1}, {ok, Green@1}, {ok, Blue@1}]} = case begin
_pipe = gleam@int:digits(Color, 16),
_pipe@1 = gleam@result:map(
_pipe,
fun(_capture) -> gleam@list:sized_chunk(_capture, 2) end
),
gleam@result:map(
_pipe@1,
fun(_capture@1) ->
gleam@list:map(
_capture@1,
fun(_capture@2) -> gleam@int:undigits(_capture@2, 16) end
)
end
)
end of
{ok, [{ok, Red}, {ok, Green}, {ok, Blue}]} -> {ok,
[{ok, Red}, {ok, Green}, {ok, Blue}]};
_try ->
erlang:error(#{gleam_error => assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _try,
module => <<"galant"/utf8>>,
function => <<"hex_to_rgb"/utf8>>,
line => 197})
end,
{Red@1, Green@1, Blue@1}.
-spec open() -> list(styling()).
open() ->
[].
-spec black(list(styling()), binary()) -> list(styling()).
black(Styled_text, Text) ->
[{black, Text} | Styled_text].
-spec bg_black(list(styling()), binary()) -> list(styling()).
bg_black(Styled_text, Text) ->
[{black_bg, Text} | Styled_text].
-spec start_black(list(styling())) -> list(styling()).
start_black(Styled_text) ->
[start_black | Styled_text].
-spec start_bg_black(list(styling())) -> list(styling()).
start_bg_black(Styled_text) ->
[start_black_bg | Styled_text].
-spec red(list(styling()), binary()) -> list(styling()).
red(Styled_text, Text) ->
[{red, Text} | Styled_text].
-spec bg_red(list(styling()), binary()) -> list(styling()).
bg_red(Styled_text, Text) ->
[{red_bg, Text} | Styled_text].
-spec start_red(list(styling())) -> list(styling()).
start_red(Styled_text) ->
[start_red | Styled_text].
-spec start_bg_red(list(styling())) -> list(styling()).
start_bg_red(Styled_text) ->
[start_red_bg | Styled_text].
-spec yellow(list(styling()), binary()) -> list(styling()).
yellow(Styled_text, Text) ->
[{yellow, Text} | Styled_text].
-spec bg_yellow(list(styling()), binary()) -> list(styling()).
bg_yellow(Styled_text, Text) ->
[{yellow_bg, Text} | Styled_text].
-spec start_yellow(list(styling())) -> list(styling()).
start_yellow(Styled_text) ->
[start_yellow | Styled_text].
-spec start_bg_yellow(list(styling())) -> list(styling()).
start_bg_yellow(Styled_text) ->
[start_yellow_bg | Styled_text].
-spec magenta(list(styling()), binary()) -> list(styling()).
magenta(Styled_text, Text) ->
[{magenta, Text} | Styled_text].
-spec bg_magenta(list(styling()), binary()) -> list(styling()).
bg_magenta(Styled_text, Text) ->
[{magenta_bg, Text} | Styled_text].
-spec start_magenta(list(styling())) -> list(styling()).
start_magenta(Styled_text) ->
[start_magenta | Styled_text].
-spec start_bg_magenta(list(styling())) -> list(styling()).
start_bg_magenta(Styled_text) ->
[start_magenta_bg | Styled_text].
-spec cyan(list(styling()), binary()) -> list(styling()).
cyan(Styled_text, Text) ->
[{cyan, Text} | Styled_text].
-spec bg_cyan(list(styling()), binary()) -> list(styling()).
bg_cyan(Styled_text, Text) ->
[{cyan_bg, Text} | Styled_text].
-spec start_cyan(list(styling())) -> list(styling()).
start_cyan(Styled_text) ->
[start_cyan | Styled_text].
-spec start_bg_cyan(list(styling())) -> list(styling()).
start_bg_cyan(Styled_text) ->
[start_cyan_bg | Styled_text].
-spec white(list(styling()), binary()) -> list(styling()).
white(Styled_text, Text) ->
[{white, Text} | Styled_text].
-spec bg_white(list(styling()), binary()) -> list(styling()).
bg_white(Styled_text, Text) ->
[{white_bg, Text} | Styled_text].
-spec start_white(list(styling())) -> list(styling()).
start_white(Styled_text) ->
[start_white | Styled_text].
-spec start_bg_white(list(styling())) -> list(styling()).
start_bg_white(Styled_text) ->
[start_white_bg | Styled_text].
-spec default(list(styling()), binary()) -> list(styling()).
default(Styled_text, Text) ->
[{default, Text} | Styled_text].
-spec bg_default(list(styling()), binary()) -> list(styling()).
bg_default(Styled_text, Text) ->
[{default_bg, Text} | Styled_text].
-spec blue(list(styling()), binary()) -> list(styling()).
blue(Styled_text, Text) ->
[{blue, Text} | Styled_text].
-spec bg_blue(list(styling()), binary()) -> list(styling()).
bg_blue(Styled_text, Text) ->
[{blue_bg, Text} | Styled_text].
-spec start_blue(list(styling())) -> list(styling()).
start_blue(Styled_text) ->
[start_blue | Styled_text].
-spec start_bg_blue(list(styling())) -> list(styling()).
start_bg_blue(Styled_text) ->
[start_blue_bg | Styled_text].
-spec green(list(styling()), binary()) -> list(styling()).
green(Styled_text, Text) ->
[{green, Text} | Styled_text].
-spec bg_green(list(styling()), binary()) -> list(styling()).
bg_green(Styled_text, Text) ->
[{green_bg, Text} | Styled_text].
-spec start_green(list(styling())) -> list(styling()).
start_green(Styled_text) ->
[start_green | Styled_text].
-spec start_bg_green(list(styling())) -> list(styling()).
start_bg_green(Styled_text) ->
[start_green_bg | Styled_text].
-spec stop_color(list(styling())) -> list(styling()).
stop_color(Styled_text) ->
[stop_color | Styled_text].
-spec stop_bg_color(list(styling())) -> list(styling()).
stop_bg_color(Styled_text) ->
[stop_bg_color | Styled_text].
-spec color_256(list(styling()), binary(), integer()) -> list(styling()).
color_256(Styled_text, Text, Color) ->
[{color256, Text, Color} | Styled_text].
-spec color_rgb(list(styling()), binary(), integer(), integer(), integer()) -> list(styling()).
color_rgb(Styled_text, Text, Red, Green, Blue) ->
[{color_rgb, Text, Red, Green, Blue} | Styled_text].
-spec color_bg_rgb(list(styling()), binary(), integer(), integer(), integer()) -> list(styling()).
color_bg_rgb(Styled_text, Text, Red, Green, Blue) ->
[{color_bg_rgb, Text, Red, Green, Blue} | Styled_text].
-spec start_color_rgb(list(styling()), integer(), integer(), integer()) -> list(styling()).
start_color_rgb(Styled_text, Red, Green, Blue) ->
[{start_color_rgb, Red, Green, Blue} | Styled_text].
-spec start_bg_color_rgb(list(styling()), integer(), integer(), integer()) -> list(styling()).
start_bg_color_rgb(Styled_text, Red, Green, Blue) ->
[{start_color_bg_rgb, Red, Green, Blue} | Styled_text].
-spec color_hex(list(styling()), binary(), integer()) -> list(styling()).
color_hex(Styled_text, Text, Color) ->
{Red, Green, Blue} = hex_to_rgb(Color),
[{color_rgb, Text, Red, Green, Blue} | Styled_text].
-spec color_bg_hex(list(styling()), binary(), integer()) -> list(styling()).
color_bg_hex(Styled_text, Text, Color) ->
{Red, Green, Blue} = hex_to_rgb(Color),
[{color_bg_rgb, Text, Red, Green, Blue} | Styled_text].
-spec start_color_hex(list(styling()), integer()) -> list(styling()).
start_color_hex(Styled_text, Color) ->
{Red, Green, Blue} = hex_to_rgb(Color),
[{start_color_rgb, Red, Green, Blue} | Styled_text].
-spec start_bg_color_hex(list(styling()), integer()) -> list(styling()).
start_bg_color_hex(Styled_text, Color) ->
{Red, Green, Blue} = hex_to_rgb(Color),
[{start_color_bg_rgb, Red, Green, Blue} | Styled_text].
-spec text(list(styling()), binary()) -> list(styling()).
text(Styled_text, Text) ->
[{text, Text} | Styled_text].
-spec placeholder(list(styling())) -> list(styling()).
placeholder(Styled_text) ->
[place_holder | Styled_text].
-spec bold(list(styling()), binary()) -> list(styling()).
bold(Styled_text, Text) ->
[{bold, Text} | Styled_text].
-spec start_bold(list(styling())) -> list(styling()).
start_bold(Styled_text) ->
[start_bold | Styled_text].
-spec end_bold(list(styling())) -> list(styling()).
end_bold(Styled_text) ->
[end_bold | Styled_text].
-spec dim(list(styling()), binary()) -> list(styling()).
dim(Styled_text, Text) ->
[{dim, Text} | Styled_text].
-spec start_dim(list(styling())) -> list(styling()).
start_dim(Styled_text) ->
[start_dim | Styled_text].
-spec end_dim(list(styling())) -> list(styling()).
end_dim(Styled_text) ->
[end_dim | Styled_text].
-spec italic(list(styling()), binary()) -> list(styling()).
italic(Styled_text, Text) ->
[{italic, Text} | Styled_text].
-spec start_italic(list(styling())) -> list(styling()).
start_italic(Styled_text) ->
[start_italic | Styled_text].
-spec end_italic(list(styling())) -> list(styling()).
end_italic(Styled_text) ->
[end_italic | Styled_text].
-spec underline(list(styling()), binary()) -> list(styling()).
underline(Styled_text, Text) ->
[{underline, Text} | Styled_text].
-spec start_underline(list(styling())) -> list(styling()).
start_underline(Styled_text) ->
[start_underline | Styled_text].
-spec end_underline(list(styling())) -> list(styling()).
end_underline(Styled_text) ->
[end_underline | Styled_text].
-spec blinking(list(styling()), binary()) -> list(styling()).
blinking(Styled_text, Text) ->
[{blinking, Text} | Styled_text].
-spec start_blinking(list(styling())) -> list(styling()).
start_blinking(Styled_text) ->
[start_blinking | Styled_text].
-spec end_blinking(list(styling())) -> list(styling()).
end_blinking(Styled_text) ->
[end_blinking | Styled_text].
-spec inverse(list(styling()), binary()) -> list(styling()).
inverse(Styled_text, Text) ->
[{reverse, Text} | Styled_text].
-spec start_inverse(list(styling())) -> list(styling()).
start_inverse(Styled_text) ->
[start_reverse | Styled_text].
-spec end_inverse(list(styling())) -> list(styling()).
end_inverse(Styled_text) ->
[end_reverse | Styled_text].
-spec hidden(list(styling()), binary()) -> list(styling()).
hidden(Styled_text, Text) ->
[{hidden, Text} | Styled_text].
-spec start_hidden(list(styling())) -> list(styling()).
start_hidden(Styled_text) ->
[start_hidden | Styled_text].
-spec end_hidden(list(styling())) -> list(styling()).
end_hidden(Styled_text) ->
[end_hidden | Styled_text].
-spec strikethrough(list(styling()), binary()) -> list(styling()).
strikethrough(Styled_text, Text) ->
[{strikethrough, Text} | Styled_text].
-spec start_strikethrough(list(styling())) -> list(styling()).
start_strikethrough(Styled_text) ->
[start_strikethrough | Styled_text].
-spec end_strikethrough(list(styling())) -> list(styling()).
end_strikethrough(Styled_text) ->
[end_strikethrough | Styled_text].
-spec reset(list(styling())) -> list(styling()).
reset(Styled_text) ->
[reset | Styled_text].
-spec to_string(list(styling())) -> binary().
to_string(Styled_text) ->
Parts = begin
_pipe = Styled_text,
_pipe@1 = reset(_pipe),
gleam@list:reverse(_pipe@1)
end,
_pipe@2 = Parts,
_pipe@73 = gleam@list:fold(
_pipe@2,
gleam@string_builder:new(),
fun(Builder, Part) -> case Part of
{black, Text} ->
_pipe@3 = Builder,
style_text(
_pipe@3,
Text,
<<"[30m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{black_bg, Text@1} ->
_pipe@4 = Builder,
style_text(_pipe@4, Text@1, <<"[40m"/utf8>>, none);
start_black ->
_pipe@5 = Builder,
gleam@string_builder:append(_pipe@5, code(<<"[30m"/utf8>>));
start_black_bg ->
_pipe@6 = Builder,
gleam@string_builder:append(_pipe@6, code(<<"[40m"/utf8>>));
start_red ->
_pipe@7 = Builder,
gleam@string_builder:append(_pipe@7, code(<<"[31m"/utf8>>));
start_red_bg ->
_pipe@8 = Builder,
gleam@string_builder:append(_pipe@8, code(<<"[41m"/utf8>>));
{red, Text@2} ->
_pipe@9 = Builder,
style_text(
_pipe@9,
Text@2,
<<"[31m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{red_bg, Text@3} ->
_pipe@10 = Builder,
style_text(_pipe@10, Text@3, <<"[41m"/utf8>>, none);
{yellow, Text@4} ->
_pipe@11 = Builder,
style_text(
_pipe@11,
Text@4,
<<"[33m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{yellow_bg, Text@5} ->
_pipe@12 = Builder,
style_text(_pipe@12, Text@5, <<"[43m"/utf8>>, none);
start_yellow ->
_pipe@13 = Builder,
gleam@string_builder:append(_pipe@13, code(<<"[33m"/utf8>>));
start_yellow_bg ->
_pipe@14 = Builder,
gleam@string_builder:append(_pipe@14, code(<<"[43m"/utf8>>));
{magenta, Text@6} ->
_pipe@15 = Builder,
style_text(
_pipe@15,
Text@6,
<<"[35m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{magenta_bg, Text@7} ->
_pipe@16 = Builder,
style_text(_pipe@16, Text@7, <<"[45m"/utf8>>, none);
start_magenta ->
_pipe@17 = Builder,
gleam@string_builder:append(_pipe@17, code(<<"[35m"/utf8>>));
start_magenta_bg ->
_pipe@18 = Builder,
gleam@string_builder:append(_pipe@18, code(<<"[45m"/utf8>>));
{cyan, Text@8} ->
_pipe@19 = Builder,
style_text(
_pipe@19,
Text@8,
<<"[36m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{cyan_bg, Text@9} ->
_pipe@20 = Builder,
style_text(_pipe@20, Text@9, <<"[46m"/utf8>>, none);
start_cyan ->
_pipe@21 = Builder,
gleam@string_builder:append(_pipe@21, code(<<"[36m"/utf8>>));
start_cyan_bg ->
_pipe@22 = Builder,
gleam@string_builder:append(_pipe@22, code(<<"[46m"/utf8>>));
{white, Text@10} ->
_pipe@23 = Builder,
style_text(
_pipe@23,
Text@10,
<<"[37m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{white_bg, Text@11} ->
_pipe@24 = Builder,
style_text(_pipe@24, Text@11, <<"[47m"/utf8>>, none);
start_white ->
_pipe@25 = Builder,
gleam@string_builder:append(_pipe@25, code(<<"[37m"/utf8>>));
start_white_bg ->
_pipe@26 = Builder,
gleam@string_builder:append(_pipe@26, code(<<"[47m"/utf8>>));
{blue, Text@12} ->
_pipe@27 = Builder,
style_text(
_pipe@27,
Text@12,
<<"[34m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{blue_bg, Text@13} ->
_pipe@28 = Builder,
style_text(_pipe@28, Text@13, <<"[44m"/utf8>>, none);
start_blue ->
_pipe@29 = Builder,
gleam@string_builder:append(_pipe@29, code(<<"[34m"/utf8>>));
start_blue_bg ->
_pipe@30 = Builder,
gleam@string_builder:append(_pipe@30, code(<<"[44m"/utf8>>));
{green, Text@14} ->
_pipe@31 = Builder,
style_text(
_pipe@31,
Text@14,
<<"[32m"/utf8>>,
{some, <<"[39m"/utf8>>}
);
{green_bg, Text@15} ->
_pipe@32 = Builder,
style_text(_pipe@32, Text@15, <<"[42m"/utf8>>, none);
start_green ->
_pipe@33 = Builder,
gleam@string_builder:append(_pipe@33, code(<<"[32m"/utf8>>));
start_green_bg ->
_pipe@34 = Builder,
gleam@string_builder:append(_pipe@34, code(<<"[42m"/utf8>>));
stop_color ->
_pipe@35 = Builder,
gleam@string_builder:append(_pipe@35, code(<<"[39m"/utf8>>));
stop_bg_color ->
_pipe@36 = Builder,
gleam@string_builder:append(_pipe@36, code(<<"[49m"/utf8>>));
{default, Text@16} ->
_pipe@37 = Builder,
style_text(_pipe@37, Text@16, <<"[39m"/utf8>>, none);
{default_bg, Text@17} ->
_pipe@38 = Builder,
style_text(_pipe@38, Text@17, <<"[49m"/utf8>>, none);
{color256, Text@18, Color} ->
_pipe@39 = Builder,
_pipe@40 = gleam@string_builder:append(
_pipe@39,
code(color256_code(Color))
),
gleam@string_builder:append(_pipe@40, Text@18);
{color_rgb, Text@19, Red, Green, Blue} ->
_pipe@41 = Builder,
_pipe@42 = gleam@string_builder:append(
_pipe@41,
code(
color_rgb_code(<<"[38;2;"/utf8>>, Red, Green, Blue)
)
),
gleam@string_builder:append(_pipe@42, Text@19);
{color_bg_rgb, Text@20, Red@1, Green@1, Blue@1} ->
_pipe@43 = Builder,
_pipe@44 = gleam@string_builder:append(
_pipe@43,
code(
color_rgb_code(
<<"[48;2;"/utf8>>,
Red@1,
Green@1,
Blue@1
)
)
),
gleam@string_builder:append(_pipe@44, Text@20);
{start_color_rgb, Red@2, Green@2, Blue@2} ->
_pipe@45 = Builder,
gleam@string_builder:append(
_pipe@45,
code(
color_rgb_code(
<<"[38;2;"/utf8>>,
Red@2,
Green@2,
Blue@2
)
)
);
{start_color_bg_rgb, Red@3, Green@3, Blue@3} ->
_pipe@46 = Builder,
gleam@string_builder:append(
_pipe@46,
code(
color_rgb_code(
<<"[48;2;"/utf8>>,
Red@3,
Green@3,
Blue@3
)
)
);
{bold, Text@21} ->
_pipe@47 = Builder,
style_text(
_pipe@47,
Text@21,
<<"[1m"/utf8>>,
{some, <<"[22m"/utf8>>}
);
start_bold ->
_pipe@48 = Builder,
gleam@string_builder:append(_pipe@48, code(<<"[1m"/utf8>>));
end_bold ->
_pipe@49 = Builder,
gleam@string_builder:append(_pipe@49, code(<<"[22m"/utf8>>));
{dim, Text@22} ->
_pipe@50 = Builder,
style_text(
_pipe@50,
Text@22,
<<"[2m"/utf8>>,
{some, <<"[22m"/utf8>>}
);
start_dim ->
_pipe@51 = Builder,
gleam@string_builder:append(_pipe@51, code(<<"[2m"/utf8>>));
end_dim ->
_pipe@52 = Builder,
gleam@string_builder:append(_pipe@52, code(<<"[22m"/utf8>>));
{italic, Text@23} ->
_pipe@53 = Builder,
style_text(
_pipe@53,
Text@23,
<<"[3m"/utf8>>,
{some, <<"[23m"/utf8>>}
);
start_italic ->
_pipe@54 = Builder,
gleam@string_builder:append(_pipe@54, code(<<"[3m"/utf8>>));
end_italic ->
_pipe@55 = Builder,
gleam@string_builder:append(_pipe@55, code(<<"[23m"/utf8>>));
{underline, Text@24} ->
_pipe@56 = Builder,
style_text(
_pipe@56,
Text@24,
<<"[4m"/utf8>>,
{some, <<"[24m"/utf8>>}
);
start_underline ->
_pipe@57 = Builder,
gleam@string_builder:append(_pipe@57, code(<<"[4m"/utf8>>));
end_underline ->
_pipe@58 = Builder,
gleam@string_builder:append(_pipe@58, code(<<"[24m"/utf8>>));
{blinking, Text@25} ->
_pipe@59 = Builder,
style_text(
_pipe@59,
Text@25,
<<"[5m"/utf8>>,
{some, <<"[25m"/utf8>>}
);
start_blinking ->
_pipe@60 = Builder,
gleam@string_builder:append(_pipe@60, code(<<"[5m"/utf8>>));
end_blinking ->
_pipe@61 = Builder,
gleam@string_builder:append(_pipe@61, code(<<"[25m"/utf8>>));
{reverse, Text@26} ->
_pipe@62 = Builder,
style_text(
_pipe@62,
Text@26,
<<"[7m"/utf8>>,
{some, <<"[27m"/utf8>>}
);
start_reverse ->
_pipe@63 = Builder,
gleam@string_builder:append(_pipe@63, code(<<"[7m"/utf8>>));
end_reverse ->
_pipe@64 = Builder,
gleam@string_builder:append(_pipe@64, code(<<"[27m"/utf8>>));
{hidden, Text@27} ->
_pipe@65 = Builder,
style_text(
_pipe@65,
Text@27,
<<"[8m"/utf8>>,
{some, <<"[28m"/utf8>>}
);
start_hidden ->
_pipe@66 = Builder,
gleam@string_builder:append(_pipe@66, code(<<"[8m"/utf8>>));
end_hidden ->
_pipe@67 = Builder,
gleam@string_builder:append(_pipe@67, code(<<"[28m"/utf8>>));
{strikethrough, Text@28} ->
_pipe@68 = Builder,
style_text(
_pipe@68,
Text@28,
<<"[9m"/utf8>>,
{some, <<"[29m"/utf8>>}
);
start_strikethrough ->
_pipe@69 = Builder,
gleam@string_builder:append(_pipe@69, code(<<"[9m"/utf8>>));
end_strikethrough ->
_pipe@70 = Builder,
gleam@string_builder:append(_pipe@70, code(<<"[29m"/utf8>>));
reset ->
_pipe@71 = Builder,
gleam@string_builder:append(_pipe@71, code(<<"[0m"/utf8>>));
{text, Text@29} ->
_pipe@72 = Builder,
gleam@string_builder:append(_pipe@72, Text@29);
place_holder ->
Builder
end end
),
gleam@string_builder:to_string(_pipe@73).
-spec save(list(styling())) -> fun((list(styling()), binary()) -> list(styling())).
save(This_styled_text) ->
fun(Styled_text, Text) ->
_pipe = This_styled_text,
_pipe@1 = gleam@list:map(_pipe, fun(Part) -> case Part of
place_holder ->
{text, Text};
Other ->
Other
end end),
gleam@list:append(_pipe@1, Styled_text)
end.
-spec to_string_styler(list(styling())) -> fun((binary()) -> binary()).
to_string_styler(This_styled_text) ->
fun(Text) ->
_pipe = This_styled_text,
_pipe@1 = gleam@list:map(_pipe, fun(Part) -> case Part of
place_holder ->
{text, Text};
Other ->
Other
end end),
to_string(_pipe@1)
end.