From 0a3c77e23d26a985f00072bd285fcde671139b77 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 6 Nov 2010 13:35:42 +0000 Subject: [PATCH] slopecalc shows args more nicely --- layout/slopecalc | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/layout/slopecalc b/layout/slopecalc index fd42c16..be0fd0d 100755 --- a/layout/slopecalc +++ b/layout/slopecalc @@ -163,6 +163,7 @@ sub parse_args () { } else { arg_error("bad argument `$_'"); } + push @{ $cp[$#cp]{Args} }, $_; } complete_current_point("completing as it is the final point"); die "$progname: errors in argument(s)\n" if $arg_errors; @@ -181,7 +182,7 @@ sub dump_schedule ($) { my $last; for ($i=0; $i<@cp; $i++) { my $this= $cp[$i]; - lprintf("%4s %7s %7s =%5.2f %s %5.02f%%", + lprintf("%4s %7s %7s =%5.2f %s %5.02f%% %s", "#$i", '+'.($this->{L} - $last_l), '@'.($this->{L} - $absoffset), @@ -189,7 +190,8 @@ sub dump_schedule ($) { ($this->{S} < 0 ? '/' : $this->{S} > 0 ? '\\' : '|'), - $this->{S} * 100); + $this->{S} * 100, + "@{ $this->{Args} }"); my $next= $cp[$i+1]; if ($interpolate and defined $next) { my $more_l= 0; @@ -235,7 +237,44 @@ sub dump_schedule ($) { } parse_args(); -lprintf("args: %s", "@ARGV"); +sub dump_args () { + my @oargs; + my @ounders; + my @opoints; + foreach (my $i=0; $i<@cp; $i++) { + my $cp= $cp[$i]; + my @iargs= @{ $cp->{Args} }; + + if (@iargs && $iargs[0] =~ m/^\+$numre$/) { + my $relmove= shift @iargs; + push @oargs, $relmove; + my $spc= ' 'x length $relmove;; + push @ounders, '-'x length $relmove;; + push @opoints, $spc; + } elsif ($i) { + push @oargs, ' '; + push @ounders, '-'; + push @opoints, ' '; + } + + my $ipoint= "#$i"; + my $lipoint= length $ipoint; + my $iargs= "@iargs"; + my $lip= $lipoint; + my $l= $lipoint > length($iargs) ? $lipoint : length($iargs); + + push @oargs, sprintf "%-*s", $l, $iargs; + push @ounders, ' 'x $l; + + my $pad= int(($l-$lipoint)/2); + push @opoints, (' 'x $pad). $ipoint. (' ' x ($l-$lipoint-$pad)); + } + lprintf("args: %s", join ' ', @oargs); + lprintf(" %s", join '|', @ounders); + lprintf(" %s", join ' ', @opoints); +} + +dump_args(); lprintf(""); lprintf("control points:"); -- 2.30.2