-@cols_order = ( 0,1,3,2 ); # pins outside on the right
-@cols_align = ( '','-','-','' );
+my @cols_shuffle = @cols_order;
+
+if ( $opt_edge ) {
+ # pins outside on the right
+ @cols_shuffle = ( 0,1,3,2 ) if $opt_edge;
+ @cols_align = ( '-','-','','' );
+} elsif ( $opt_middle ) {
+ # pins in middle
+ @cols_shuffle = ( 1,0,2,3 );
+ @cols_align = ( '','','-','-' );
+}
+
+sub cols_shuffle {
+ my ( $what, $order ) = @_;
+ my $new = [];
+ foreach my $i ( 0 .. $#$what ) {
+ $new->[$i] = $what->[ $order->[$i] ];
+ }
+ warn "# cols_shuffle what=",dump($what)," order=",dump($order)," new=",dump($new);
+ return @$new;
+}
+
+@cols_order = cols_shuffle( \@cols_order, \@cols_shuffle );
+@max_len = cols_shuffle( \@max_len, \@cols_shuffle );
+
+warn "# cols_order = ",dump( \@cols_order );
+warn "# cols_align = ",dump( \@cols_align );
+
+my $fmt = "%$cols_align[0]$max_len[0]s %$cols_align[1]$max_len[1]s %$cols_align[2]$max_len[2]s %$cols_align[3]$max_len[3]s\n";