keys: clean up mode defaults setup in print_rows()
[sheet.git] / Shiar_Sheet / Keyboard.pm
index 90ec4e827daee68cc9279315a470de17719b0d73..0ccd9c2e43ecdeef60e4af7d35e01394254f57ac 100644 (file)
@@ -125,11 +125,13 @@ sub print_key {
 
 sub print_rows {
        my $self = shift;
 
 sub print_rows {
        my $self = shift;
+       my ($rowsspec, $defrows) = @_;
+       $defrows ||= [2, 1, 0];
        my %moderows = (
        my %moderows = (
-               -DEFAULT => !@_ ? '' : split(/(?:\s*([^=\s]*)=\s*)/, shift),
+               -DEFAULT => defined $rowsspec && $rowsspec ne '' &&
+                       split(/\s* ([^=\s]*) = \s*/x, $rowsspec),
                # plus specific mode overrides prefixed by '='
        );
                # plus specific mode overrides prefixed by '='
        );
-       my $defrows = shift || [2, 1, 0];
        my @modes = sort keys %{ $self->{def} };
 
        print '<table id="rows" class="keys">'."\n\n";
        my @modes = sort keys %{ $self->{def} };
 
        print '<table id="rows" class="keys">'."\n\n";
@@ -141,7 +143,7 @@ sub print_rows {
                for my $basemode (@modes) {
                        my @moderows = split /\s+/,
                                $row < 0 ? "0" :
                for my $basemode (@modes) {
                        my @moderows = split /\s+/,
                                $row < 0 ? "0" :
-                               defined $moderows{$basemode} ? $moderows{$basemode} : $moderows{-DEFAULT};
+                               $moderows{$basemode} // $moderows{-DEFAULT};
 
                for my $submode (@moderows ? @moderows : '') {
                        my $mode = $basemode . $submode;
 
                for my $submode (@moderows ? @moderows : '') {
                        my $mode = $basemode . $submode;