From: ian Date: Wed, 11 Feb 2004 21:25:48 +0000 (+0000) Subject: allow -e=*...; actually support -l; default display is everything X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=7afe35ab51ea825b740ff1df641d6457c06bc698;p=trains.git allow -e=*...; actually support -l; default display is everything --- diff --git a/layout/informat.txt b/layout/informat.txt index 251cbac..0907a06 100644 --- a/layout/informat.txt +++ b/layout/informat.txt @@ -35,16 +35,16 @@ Commands layer K[L] K is layer kind (letters and `_', may be empty), L is a layer depth - (digits, or `=' meaning current layer; default for L is `='; default - KL at start of file is `layer 5'). Controls drawing style, by - selecting appropriate parts of the track and locs to draw, according - to element selection rules. Default outcomes: - K L result (description) result (element letters) - any other nothing - - empty current default track RLMNasco - `s' current nothing (`silent') - - `l' current centrelines only CLMNarso - other current everything ARSCLMNO + (digits, or `=' meaning current layer, or `*' meaning output layer; + default for L is `='; default KL at start of file is `layer 5'). + Controls drawing style, by selecting appropriate parts of the track + and locs to draw, according to element selection rules. Default + outcomes: + K result (description) result (element letters) + empty default track RLMNasco + `s' nothing (`silent') - + `l' centrelines only CLMNarso + other everything ARSCLMNO extend F T len L [R] length L extend F T upto U [R] s.t. perpendicular at T passes through U @@ -171,7 +171,7 @@ Command-line options layer is `*'). N may be empty or `~'; the latter simply inverts the sense of the match. If C is omitted then `=' is assumed. If the final output layer is `*' then we pretend, for the moment, that L was - D. + D. N[D][C][V] may be N[=]* to match, or not match, all layers. If V is present then C must be exactly one character and it is as if V (must be an integer) copies of C were specified. diff --git a/layout/layout b/layout/layout index 928d3c1..14fea84 100755 --- a/layout/layout +++ b/layout/layout @@ -933,9 +933,7 @@ sub cmd__runobj ($) { sub layer_draw ($$) { my ($k,$l) = @_; my ($eo,$cc, $r); - if ($output_layer ne '*' && $l != $output_layer) { - $r = ''; - } elsif ($k eq '') { + if ($k eq '') { $r= 'RLMN'; } elsif ($k eq 's') { $r= ''; @@ -945,13 +943,17 @@ sub layer_draw ($$) { $r= 'ARSCLMNO'; } foreach $eo (@eopts) { +#print STDERR "$. layer $k$l eo $eo re $eo->{GlobRe} then $eo->{DrawMods} now $r\n"; next unless $k =~ m/^$eo->{GlobRe}$/; +#print STDERR "$. layer $k$l eo re $eo->{GlobRe} match\n"; next unless &{ $eo->{LayerCheck} }($l); +#print STDERR "$. layer $k$l eo re $eo->{GlobRe} checked\n"; foreach $cc (split //, $eo->{DrawMods}) { $r =~ s/$cc//ig; $r .= $cc if $cc =~ m/[A-Z]/; } } +#print STDERR "layer $k$l gives $r (before map)\n"; $r= &{ $ctx->{DrawMap} }($r); return $r; } @@ -959,8 +961,9 @@ sub layer_draw ($$) { sub cmd_layer { my ($kl, $k,$l); $kl= can(\&cva_identity); - $kl =~ m/^([A-Za-z_]*)(\d*|\=)$/ or die "invalid layer spec"; + $kl =~ m/^([A-Za-z_]*)(\d*|\=|\*)$/ or die "invalid layer spec"; ($k,$l)=($1,$2); + $l= $output_layer if $l eq '*'; $l= $ctx->{Layer}{Level} if $l =~ m/^\=?$/; $ctx->{Layer}{Kind}= $k; $ctx->{Layer}{Level}= $l; @@ -1215,29 +1218,34 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { if (s/^D(\d+)//) { $debug= $1; } elsif (s/^D//) { $debug++; } elsif (s/^q//) { $quiet=1; } + elsif (s/^l(\d+|\*)//) { $output_layer=$1; } elsif (s/^(e) ((?:[a-z]|\*|\?|\[[a-z][-a-z]*\])*?) - (\~?) (\d*) (\=*|\-+|\++) (\d*) + (\~?) (\d*) (\=*|\-+|\++) (\d*|\*) ([a-z]+)$//ix) { my ($ee,$g,$n,$d,$c,$v,$cc) = ($1,$2,$3,$4,$5,$6,$7); my ($eo, $invert, $lfn, $ccc, $sense,$limit); $g =~ s/\?/\./g; $g =~ s/\*/\.\*/g; + die '-[eE]GND[=]* not allowed' if $v eq '*' && length $d; $d= $output_layer if !length $d; $d= 5 if $d eq '*'; $invert= length $n; $c= '=' if !length $c; - if (length $v) { + if (length $v && $v ne '*') { die '-[eE]GN[D]CCV not allowed' if length $c > 1; $c= $c x $v; } if ($c =~ m/^[-+]/) { - $sense= ($c.'1') + 0; + die '-[eE]GN+/-* not allowed' if $v eq '*'; + $sense= ($&.'1') + 0; $limit= ($sense * $d) + length($c) - 1; $lfn= sub { ($output_layer eq '*' ? $d : $_[0]) * $sense >= $limit xor $invert; }; + } elsif ($v eq '*') { + $lfn= sub { !$invert; }; } else { $limit= length($c) - 1; $lfn= sub { @@ -1259,6 +1267,7 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { $eo->{GlobRe}= $g; $eo->{LayerCheck}= $lfn; $eo->{DrawMods}= $ccc; +#print STDERR "created eo $eo re $eo->{GlobRe} n=$n d=$d v=$v c=$c limit=$limit\n"; push @eopts, $eo; } else { die "unknown option -$_";