summaryrefslogtreecommitdiff
path: root/dviware/psprint/vms/wide.ps
blob: 4b7e97eb54c735a946dd87469145240c6f106cdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
% Prologue for a /wide job.
% It assumes *_print.com has defined fspec and dev.
% The following definitions produce two logical pages (132 cols by 60 lines)
% on a single portrait sheet of A4 paper.
% Both pages have a headline showing fspec and page #.
% Every character after this file (until ^D) will be treated as a printing
% character (or control character) instead of being interpreted as PostScript.

/maxlines  60 def           % maximum lines per logical page
/maxchar  132 def           % maximum chars per line
/interline -6 def           % baseline skip
/Courier findfont           % Courier font (fixed-width chars)
6 scalefont setfont         % at 6pt
/inch { 72 mul } def        % convert inches to big points

/page1pos
{ 1 inch 0 translate           % 1 inch left margin
  /topline { 10.9 inch } def   % vertical location of top line (not headline)
  0 topline moveto             % start of first line
  /line 0 def                  % initialize line counter
  /char 0 def                  % initialize chars/line counter
} bind def

/page2pos
{ /topline { 5.4 inch } def    % vertical location of top line (not headline)
  0 topline moveto             % start of first line
  /line maxlines def           % in case formfeed occurred in 1st logical page
} bind def

/pagenum 0 def   % initialize logical page number

/headline
{ gsave                                         % save current pos and font
  /Courier-Bold findfont 9 scalefont setfont    % use Courier-Bold at 9pt
  0 topline moveto                              % move to top left corner
  0 interline 2 mul neg rmoveto                 % move up 2 lines
  fspec show
  % increment page number and show it right justified
    /pagenum pagenum 1 add def
    /pagestr pagenum 10 string cvs def
    charwidth maxchar mul topline moveto        % move to top right corner
    (p.) stringwidth pop
    pagestr stringwidth pop add neg             % move left by page # width
    interline 2 mul neg                         % move up 2 lines
    rmoveto
    (p.) show pagestr show
  grestore                                      % restore pos and font
} bind def

/formfeed    % start next logical page unless already there
{ line 0 gt
  { line maxlines lt
    { headline page2pos }                 % 0 < line < maxlines
    { line maxlines gt
      line maxlines 2 mul lt and
      { headline showpage page1pos } if   % maxlines < line < 2 * maxlines
    } ifelse
  } if
} bind def

/linefeed
{ /char 0 def                                  % reset chars/line counter
  /line line 1 add def                         % increment line counter
  line maxlines eq                             % if end of 1st page
  { headline                                   % show 1st headline
    page2pos }                                 % and start 2nd page
  { line maxlines 2 mul eq                     % elsif end of 2nd page
    { headline                                 %   then show 2nd headline
      showpage page1pos }                      %   and show both pages
    { currentpoint pop neg interline rmoveto   %   else start next line
    } ifelse
  } ifelse
} bind def

/showchar
{ currentchar 0 thischar put                % put thischar into 1-char string
  /char char 1 add def                      % increment chars/line counter
  char maxchar le { currentchar show } if   % ignore chars > maxchar
} bind def

/eachchar
{ infile read not {exit} if          % get next char
  /thischar exch def                 % save it in thischar
  thischar 32 ge                     % thischar >= space?
  { showchar }                       % if so, show it
  { thischar 10 eq                   % or does thischar = linefeed?
    { linefeed }
    { thischar 12 eq                 % or does thischar = formfeed?
      { formfeed }
      {                              % ignore any other control char
      } ifelse
    } ifelse
  } ifelse
} bind def

(%stdin) (r) file /infile exch def
/currentchar 1 string def
/charwidth ( ) stringwidth pop def   % assume fixed-width font
page1pos                             % start 1st page

/charloop
{ {eachchar} loop
  line 0 gt
    { headline showpage }          % flush last sheet with only 1st logical page
  if
  dev (LW) eq { @bannerpage } if   % print banner page if LaserWriter
} def

charloop