From 69d68746216863196d1b36e4170767aedc685895 Mon Sep 17 00:00:00 2001 From: Sean O'Rourke Date: Sat, 12 May 2012 07:39:51 -0600 Subject: [PATCH] Use Perl's format() to flow the help text. --- lib/Sepia.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Sepia.pm b/lib/Sepia.pm index d03bedb..8f3113c 100644 --- a/lib/Sepia.pm +++ b/lib/Sepia.pm @@ -878,11 +878,11 @@ sub Dump sub flow { - my $n = shift()-1; - my $n1 = $n-8; # XXX: arbitrary number - local $_ = shift; - s/(.{$n1,$n}) +/$1\n/g; - $_ + my $width = shift()-1; + my $format = "^" . ('<' x $width) . "~~\n"; + local $^A = ''; + formline($format, @_); + $^A; } =back @@ -1211,6 +1211,7 @@ sub repl_help if ($full) { my $short = $REPL_SHORT{$full}; my $flow = flow($width - length $short - 4, $REPL_DOC{$full}); + chomp $flow; $flow =~ s/(.)\n/"$1\n".(' 'x (4 + length $short))/eg; print "$short $flow\n"; } else { @@ -1222,6 +1223,7 @@ sub repl_help for (sort keys %REPL) { my $flow = flow($width - $left, $REPL_DOC{$_}); + chomp $flow; $flow =~ s/(.)\n/"$1\n".(' ' x $left)/eg; printf "%-${left}s%s\n", $REPL_SHORT{$_}, $flow; } -- 2.11.4.GIT