X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=commitid.scad.pl;h=6d7459e5f88eaf88ae7c2982f729b6b08bf0ee62;hb=07cbfbf7662bcc767da1ae02b27518f8484ca2ed;hp=ebdbe917a39a6cb73db24da322d83a22e85af045;hpb=bf19d2a95b043beeab235234d8f2aaebf774c370;p=reprap-play.git diff --git a/commitid.scad.pl b/commitid.scad.pl index ebdbe91..6d7459e 100755 --- a/commitid.scad.pl +++ b/commitid.scad.pl @@ -105,10 +105,7 @@ $SIG{__WARN__} = sub { die @_; }; # Full6 abcdef Full8 abcdef01 # 23456* _123456* # -# Full6T -# Full9T -# Full12T -# Full15T +# Full6T Full9T Full12T ... Full30T # as Full but commit is split over two lines # for a 3-line message; eg # Full9T abc @@ -144,9 +141,9 @@ our $gtm_demo_i = -1; our $gtm_demo_j; our @gtm_demo_o; -sub gentextmodule_demo_start_batch ($;$) { - ($gtm_demo_i, $gtm_demo_j) = @_; - $gtm_demo_j //= 0; +sub gentextmodule_demo_start_batch () { + $gtm_demo_j = 0; + $gtm_demo_i++; } sub gentextmodule ($@) { @@ -268,16 +265,21 @@ our $do_git; # contains may chars 'c' (count) and/or 'o' (object) our $do_git_untracked = 1; our $argcounter; -sub rjustt ($$) { # right justify and truncate (ie, pad and truncate at left) - my ($sz, $whole) = @_; +sub rjustt ($$;$) { # right justify and truncate (ie, pad and truncate at left) + # always includes prefix + my ($sz, $whole, $prefix) = @_; + $prefix //= ''; my $lw = length $whole; - return $lw > $sz - ? substr($whole, $lw-$sz) - : sprintf "%${sz}s", $whole; + my $spare = $sz - $lw - (length $prefix); + return + ($spare > 0 ? (' ' x $spare) : ''). + $prefix. + substr($whole, ($spare < 0 ? -$spare : 0)); } -sub ljustt ($$$) { # always includes $suffix +sub ljustt ($$;$) { my ($sz, $whole, $suffix) = @_; + $suffix //= ''; $sz -= length $suffix; return sprintf "%-${sz}.${sz}s%s", $whole, $suffix; } @@ -354,9 +356,9 @@ sub do_git () { } foreach my $sz (3..10) { - gentextmodule_demo_start_batch($sz-3); + gentextmodule_demo_start_batch(); - gentextmodule_plusq("Small$sz", rjustt($sz, $git_count.$git_dirty)) + gentextmodule_plusq("Small$sz", rjustt($sz, $git_count, $git_dirty)) if defined $git_count; gentextmodule_plusq("Git$sz", ljustt($sz, $git_object, $git_dirty)) @@ -364,16 +366,14 @@ sub do_git () { if (defined $git_count && defined $git_object) { gentextmodule("Full$sz", - ljustt($sz, $git_object, ''), - rjustt($sz, $git_count.$git_dirty)); - - if (!($sz % 2)) { - my $e = $sz/2; - gentextmodule("Full".($e*3)."T", - ljustt($e*2, $git_object, $git_dirty) - =~ m/.{$e}/g, - rjustt($e, $git_count)); - } + ljustt($sz, $git_object), + rjustt($sz, $git_count, $git_dirty)); + + my $e = $sz; + gentextmodule("Full".($e*3)."T", + ljustt($e*2, $git_object, $git_dirty) + =~ m/.{$e}/g, + rjustt($e, $git_count)); } } } @@ -402,7 +402,7 @@ while (@ARGV) { $do_git //= defined($argcounter) ? '' : 'co'; -gentextmodule_demo_start_batch(-1); +gentextmodule_demo_start_batch(); gentextmodule('FontDemo', @demo); do_git();