chiark / gitweb /
o_amble
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 Mar 2019 01:48:26 +0000 (01:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 Mar 2019 01:48:26 +0000 (01:48 +0000)
generate-board

index b2f8e8110ee9e71bdf34010e6ebb4a0e28636dbd..70a4e3a83f8bc66ab5deab1fcef6fd0b58c107cb 100755 (executable)
@@ -312,18 +312,27 @@ sub pscolour ($;$) {
   return $r;
 }
 
+sub o_amble (@) {
+  # CPerl-mode does a really awful thing with %s in the preamble
+  # and postamble, causing constant useless flashing
+  # So we write & in the here docs and transform them back:
+  my ($t) = join '', @_;
+  $t =~ s/^\&+/ '%' x length $& /mge;
+  o($t);
+}
+      
 sub preamble() {
   my $tprinteredge = ($xopts =~ m/M/ ? $max_printeredge : 0) * MM2PT;
   my $xmax = $a4_h - $tprinteredge;
   my $ymax = ($a4_w + $a3_h) - 2 * $max_printeredge - $tprinteredge;
-  o(<<END);
-%!PS-Adobe-3.0
-%%BoundingBox $tprinteredge $tprinteredge $xmax $ymax
-%%Pages: 1
-%%EndComments
-%%BeginProlog
-%%EndProlog
-%%BeginSetup
+  o_amble(<<END);
+&!PS-Adobe-3.0
+&&BoundingBox $tprinteredge $tprinteredge $xmax $ymax
+&&Pages: 1
+&&EndComments
+&&BeginProlog
+&&EndProlog
+&&BeginSetup
 /board {
   gsave
   40 -26 translate
@@ -332,18 +341,18 @@ END
 }
 
 sub postamble () {
-  o(<<END);
+  o_amble(<<END);
   grestore
 } bind def
-%%EndSetup
-%%Page: 1
-%%BeginPageSetup
+&&EndSetup
+&&Page: 1
+&&BeginPageSetup
 /pgsave save def
-%%EndPageSetup
+&&EndPageSetup
 board
 pgsave restore
 showpage
-%%EOF
+&&EOF
 END
 }