chiark / gitweb /
slopecalc shows args more nicely
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 6 Nov 2010 13:35:42 +0000 (13:35 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 6 Nov 2010 13:35:42 +0000 (13:35 +0000)
layout/slopecalc

index fd42c16320d6fc5225b8b0c929465aac2f2d5a15..be0fd0d440605f3b2c7c5e002d62dcfa597e0a00 100755 (executable)
@@ -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:");