### ----------------------------------------------------
### -- Gzz::Text::Utils
### -- Licenses: LGPL-3.0-or-later
### -- Authors: Francis Grizzly Smit <grizzly@smit.id.au>
### -- File: rakulib/Gzz/Text/Utils.rakumod
### ----------------------------------------------------
### -- Chunk 8 of 8
-screen;
                .rethrow;
            }
        }
    } # try #
    print t.show-cursor ~ t.restore-screen;
    return $result;
} #`««« sub dropdown(MultiT:D $id, Int:D $window-height, Str:D $id-name,
                        &setup-option-str:(Int:D $c, Int:D $p, @a --> Str:D),
                        &find-pos:(MultiT $r, Int:D $p, @a --> Int:D),
                        &get-result:(MultiT:D $res, Int:D $p, Int:D $l, @a --> MultiT:D),
                        @array,
                        Str:D :$highlight-bg-colour = t.bg-color(0, 0, 127) ~ t.bold, 
                        Str:D :$highlight-fg-colour = t.bright-yellow, 
                        Str:D :$bg-colour0 = t.bg-yellow ~ t.bold, 
                        Str:D :$fg-colour0 = t.bright-blue, 
                        Str:D :$bg-colour1 = t.bg-color(0, 127, 0) ~ t.bold, 
                        Str:D :$fg-colour1 = t.bright-blue,  
                        Str:D :$bg-prompt = t.bg-green ~ t.bold, 
                        Str:D :$fg-prompt = t.bright-blue --> MultiT) is export »»»

=begin pod

=head3 lead-dots(…)

Returns B<C<$text>> in a field of B<C<$width>> with a line of dots preceding it.
Sort of like B<C<left>> with B<C<$fill>> defaulting to B<C<.>> but with a single
space between the text and the padding.

=begin code :lang<raku>

sub lead-dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export

=end code

=item Where:
=item2 B<C<$text>> the text to be preceded by the dots.
=item2 B<C<$width>> the width of the total field.
=item2 B<C<$fill>> the fill char or string.

L<Top of Document|#table-of-contents>

=end pod

sub lead-dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export {
    my Str $result = " $text";
    $width -= hwcswidth($result);
    $width = $width div hwcswidth($fill);
    $result = $fill x $width ~ $result;
    return $result;
} # sub lead-dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export #

=begin pod

=head3 trailing-dots(…)

Returns B<C<$text>> in a field of B<C<$width>> with a line of dots trailing after it.
Sort of like B<C<right>> with B<C<$fill>> defaulting to B<C<.>> but with a single
space between the text and the padding.

=begin code :lang<raku>

sub trailing-dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export

=end code

=item Where:
=item2 B<C<$text>> the text to be trailed by the dots.
=item2 B<C<$width>> the width of the total field.
=item2 B<C<$fill>> the fill char or string.

L<Top of Document|#table-of-contents>

=end pod

sub trailing-dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export {
    my Str $result = $text;
    $width -= hwcswidth($result);
    $width = $width div hwcswidth($fill);
    $result ~= $fill x $width;
    return $result;
} # sub trailing-dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export #

=begin pod

=head3 dots(…)

Returns B<C<$text>> in a field of B<C<$width>> with a line of dots preceding it.
Sort of like B<C<left>> with B<C<$fill>> defaulting to B<C<.>>.

=begin code :lang<raku>

sub dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export

=end code

=item Where:
=item2 B<C<$text>> the text to be preceded by the dots.
=item2 B<C<$width>> the width of the total field.
=item2 B<C<$fill>> the fill char or string.

L<Top of Document|#table-of-contents>

=end pod

sub dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export {
    my Str $result = $text;
    $width -= hwcswidth($result);
    $width = $width div hwcswidth($fill);
    $result ~= $fill x $width;
    return $result;
} # sub dots(Str:D $text, Int:D $width is copy, Str:D $fill = '.' --> Str) is export #


