summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2018-06-24 01:30:51 +0200
committerPatrick Spek <p.spek@tyil.nl>2018-06-24 01:47:43 +0200
commit9a6b471e00fa61b62db2271d55dc8f45b7e8c3d1 (patch)
treec2553af780c0d7b244a7bbb69026e6d7cf2ae8b1 /lib
parentac336f0d2cb793cc178a5636f7c7a3c727c7789f (diff)
downloadPod::To::Pager-9a6b471e00fa61b62db2271d55dc8f45b7e8c3d1.tar.gz
Pod::To::Pager-9a6b471e00fa61b62db2271d55dc8f45b7e8c3d1.tar.bz2
Add minimum width for bordered blocks
Diffstat (limited to 'lib')
-rw-r--r--lib/Pod/To/Pager/BorderedBlock.pm69
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Pod/To/Pager/BorderedBlock.pm6 b/lib/Pod/To/Pager/BorderedBlock.pm6
index ac0b35e..06d2f58 100644
--- a/lib/Pod/To/Pager/BorderedBlock.pm6
+++ b/lib/Pod/To/Pager/BorderedBlock.pm6
@@ -21,6 +21,7 @@ class Pod::To::Pager::BorderedBlock
has Str $.content = "";
has Str $.header = "";
has Str $.footer = "";
+ has Int $.minimum-width = 66;
multi method render (
--> Str
@@ -29,13 +30,15 @@ class Pod::To::Pager::BorderedBlock
$!content,
header => $!header,
footer => $!footer,
+ minimum-width => $!minimum-width,
);
}
multi method render (
Str:D $content is copy,
- :$header = "",
- :$footer = "",
+ :$header = $!header,
+ :$footer = $!header,
+ :$minimum-width = $!minimum-width,
--> Str
) {
# Trim content
@@ -48,6 +51,8 @@ class Pod::To::Pager::BorderedBlock
for $header.lines { $longest-string = colorstrip($_).chars if $longest-string < colorstrip($_).chars; }
for $footer.lines { $longest-string = colorstrip($_).chars if $longest-string < colorstrip($_).chars; }
+ $longest-string = $minimum-width if $longest-string < $minimum-width;
+
# Create the top bar
my Str $block = %!box-characters<outer-top-left>;
$block ~= %!box-characters<outer-horizontal> x $longest-string;