aboutsummaryrefslogtreecommitdiff
path: root/aoc2023/build/packages/adglent/src/showtime@internal@reports@styles.erl
blob: ec6230c566517897a1fa4a2babce5176a2eb755b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
-module(showtime@internal@reports@styles).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).

-export([not_style/1, module_style/1, heading_style/1, stacktrace_style/1, failed_style/1, error_style/1, got_highlight/1, passed_style/1, expected_highlight/1, ignored_style/1, function_style/1, strip_style/1]).

-spec not_style(binary()) -> binary().
not_style(Text) ->
    gleam_community@ansi:bold(Text).

-spec module_style(binary()) -> binary().
module_style(Text) ->
    gleam_community@ansi:cyan(Text).

-spec heading_style(binary()) -> binary().
heading_style(Text) ->
    gleam_community@ansi:cyan(Text).

-spec stacktrace_style(binary()) -> binary().
stacktrace_style(Text) ->
    Text.

-spec bold_red(binary()) -> binary().
bold_red(Text) ->
    gleam_community@ansi:bold(gleam_community@ansi:red(Text)).

-spec failed_style(binary()) -> binary().
failed_style(Text) ->
    bold_red(Text).

-spec error_style(binary()) -> binary().
error_style(Text) ->
    bold_red(Text).

-spec got_highlight(binary()) -> binary().
got_highlight(Text) ->
    bold_red(Text).

-spec bold_green(binary()) -> binary().
bold_green(Text) ->
    gleam_community@ansi:bold(gleam_community@ansi:green(Text)).

-spec passed_style(binary()) -> binary().
passed_style(Text) ->
    bold_green(Text).

-spec expected_highlight(binary()) -> binary().
expected_highlight(Text) ->
    bold_green(Text).

-spec bold_yellow(binary()) -> binary().
bold_yellow(Text) ->
    gleam_community@ansi:bold(gleam_community@ansi:yellow(Text)).

-spec ignored_style(binary()) -> binary().
ignored_style(Text) ->
    bold_yellow(Text).

-spec bold_cyan(binary()) -> binary().
bold_cyan(Text) ->
    gleam_community@ansi:bold(gleam_community@ansi:cyan(Text)).

-spec function_style(binary()) -> binary().
function_style(Text) ->
    bold_cyan(Text).

-spec strip_style(binary()) -> binary().
strip_style(Text) ->
    {New_text, _} = begin
        _pipe = Text,
        _pipe@1 = gleam@string:to_graphemes(_pipe),
        gleam@list:fold(
            _pipe@1,
            {<<""/utf8>>, false},
            fun(Acc, Char) ->
                {Str, Removing} = Acc,
                Bit_char = gleam_stdlib:identity(Char),
                case {Bit_char, Removing} of
                    {<<16#1b>>, _} ->
                        {Str, true};

                    {<<16#6d>>, true} ->
                        {Str, false};

                    {_, true} ->
                        {Str, true};

                    {_, false} ->
                        {<<Str/binary, Char/binary>>, false}
                end
            end
        )
    end,
    New_text.