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
+ $prefix.
+ ($spare > 0 ? (' ' x $spare) : '').
+ 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;
}