Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
## Lout output
2
# Copyright (C) 1993-1995 Ian Jackson.
3
 
4
# This file is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2, or (at your option)
7
# any later version.
8
 
9
# It is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
 
14
# You should have received a copy of the GNU General Public License
15
# along with GNU Emacs; see the file COPYING.  If not, write to
16
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
# Boston, MA 02111-1307, USA.
18
 
19
# (Note: I do not consider works produced using these BFNN processing
20
# tools to be derivative works of the tools, so they are NOT covered
21
# by the GPL.  However, I would appreciate it if you credited me if
22
# appropriate in any documents you format using BFNN.)
23
 
24
sub lout_init {
25
    open(LOUT,">$prefix.lout");
26
    chop($dprint= `date '+%d %B %Y'`);
27
    $dprint =~ s/^0//;
28
}
29
 
30
sub lout_startup {
31
    local ($lbs) = &lout_sanitise($user_brieftitle);
32
    print LOUT <<END;
33
\@SysInclude{ fontdefs }
34
\@SysInclude{ langdefs }
35
\@SysInclude{ dl }
36
\@SysInclude{ docf }
37
\@Use { \@DocumentLayout
38
  \@OddTop { \@Null }
39
  \@EvenTop { \@Null }
40
  \@StartOddTop { \@Null }
41
  \@StartEvenTop { \@Null }
42
  \@OddFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } }
43
  \@EvenFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } }
44
  \@StartOddFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } }
45
  \@StartEvenFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } }
46
  \@ParaGap { 1.70vx }
47
  \@InitialBreak { 1.0fx ragged hyphen }
48
}
49
\@Use { \@OrdinaryLayout }
50
END
51
    $lout_textstatus= 'p';
52
}
53
 
54
sub lout_pageref {
55
    print LOUT "Q$_[1] (page {\@PageOf{$_[0]}}) ";
56
    &lout_text("\`");
57
}
58
 
59
sub lout_endpageref {
60
    &lout_text("'");
61
}
62
 
63
sub lout_finish {
64
    print LOUT "\@End \@Text\n";
65
    close(L);
66
}
67
 
68
sub lout_startmajorheading {
69
    $lout_styles .= 'h';
70
    print LOUT <<END
71
\@CNP
72
{
73
  newpath   0  ysize 0.3 ft sub  moveto
74
            xsize  0  rlineto
75
 
76
            xsize neg  0  rlineto
77
  closepath fill
78
} \@Graphic { //1.6f \@HAdjust \@Heading{
79
END
80
    ;
81
    $endh= "}\n{\@PageMark s_$_[0]}\n/1.0fo\n";
82
    &lout_text($_[0] ? "Section $_[0].  " : '');
83
}
84
 
85
sub lout_startminorheading {
86
    $lout_styles .= 'h';
87
    print LOUT "//0.2f \@CNP {\@PageMark $_[0]} \@Heading{\n";
88
    $endh= '';
89
}
90
 
91
sub lout_endheading {
92
    $lout_styles =~ s/.$//; print LOUT "}\n$endh";
93
    $lout_status= 'p';
94
}
95
 
96
sub lout_endmajorheading { &lout_endheading(@_); }
97
sub lout_endminorheading { &lout_endheading(@_); }
98
 
99
sub lout_courier {
100
    $lout_styles .= 'f';
101
    print LOUT "{{0.7 1.0} \@Scale {Courier Bold} \@Font {";
102
}
103
 
104
sub lout_endcourier {
105
    $lout_styles =~ s/.$//; print LOUT "}}";
106
}
107
 
108
sub lout_italic { $lout_styles .= 'f'; print LOUT "{Slope \@Font {"; }
109
sub lout_enditalic { $lout_styles =~ s/.$//; print LOUT "}}"; }
110
 
111
sub lout_startindent { $lout_styles .= 'i'; print LOUT "\@IndentedDisplay {\n"; }
112
 
113
sub lout_endindent {
114
    &lout_endpara;
115
    $lout_styles =~ s/.$//; print LOUT "}\n\@LP\n";
116
}
117
 
118
sub lout_startpackedlist { $lout_plc=-1; }
119
sub lout_endpackedlist { &lout_newline if !$lout_plc; }
120
sub lout_packeditem {
121
    &lout_newline if !$lout_plc;
122
    &lout_tab(($lout_plc>0)*40+5);
123
    $lout_plc= !$lout_plc;
124
}
125
 
126
sub lout_startlist {
127
    &lout_endpara;
128
    print LOUT "\@RawIndentedList style {\@Bullet} indent {0.5i} gap {1.1vx}\n";
129
    $lout_styles .= 'l';
130
    $lout_status= '';
131
}
132
 
133
sub lout_endlist {
134
    &lout_endpara;
135
    print LOUT "\@EndList\n\n";
136
    $lout_styles =~ s/.$//;
137
}
138
 
139
sub lout_item {
140
    &lout_endpara;
141
    print LOUT "\@ListItem{";
142
    $lout_styles.= 'I';
143
}
144
 
145
sub lout_startindex {
146
    print LOUT "//0.0fe\n";
147
}
148
 
149
sub lout_endindex {
150
    $lout_status='p';
151
}
152
 
153
sub lout_startindexmainitem {
154
    $lout_marker= $_[0];
155
    $lout_status= '';
156
    print LOUT "//0.3vx Bold \@Font \@HAdjust { \@HContract { { $_[1] } |3cx {";
157
    $lout_iiendheight= '1.00';
158
    $lout_styles .= 'X';
159
}
160
 
161
sub lout_startindexitem {
162
    $lout_marker= $_[0];
163
    print LOUT "\@HAdjust { \@HContract { { $_[1] } |3cx {";
164
    $lout_iiendheight= '0.95';
165
    $lout_styles .= 'X';
166
}
167
 
168
sub lout_endindexitem {
169
    print LOUT "} } |0c \@PageOf { $lout_marker } } //${lout_iiendheight}vx\n";
170
    $lout_styles =~ s/.$//;
171
}
172
 
173
sub lout_email { &lout_courier; &lout_text('<'); }
174
sub lout_endemail { &lout_text('>'); &lout_endcourier; }
175
 
176
sub lout_ftpon { &lout_courier; }  sub lout_endftpon { &lout_endcourier; }
177
sub lout_ftpin { &lout_courier; }  sub lout_endftpin { &lout_endcourier; }
178
sub lout_docref { }  sub lout_enddocref { }
179
sub lout_ftpsilent { $lout_ignore++; }
180
sub lout_endftpsilent { $lout_ignore--; }
181
 
182
sub lout_newsgroup { &lout_courier; }
183
sub lout_endnewsgroup { &lout_endcourier; }
184
 
185
sub lout_text {
186
    return if $lout_ignore;
187
    $lout_status= 'p';
188
    $_= &lout_sanitise($_[0]);
189
    s/ $/\n/ unless $lout_styles =~ m/[fhX]/;
190
    print LOUT $_;
191
}
192
 
193
sub lout_tab {
194
    local ($size) = $_[0]*0.5;
195
    print LOUT " |${size}ft ";
196
}
197
 
198
sub lout_newline {
199
    print LOUT " //1.0vx\n";
200
}
201
 
202
sub lout_sanitise {
203
    local ($in) = @_;
204
    local ($out);
205
    $in= ' '.$in.' ';
206
    $out='';
207
    while ($in =~ m/(\s)(\S*[\@\/|\\\"\^\&\{\}\#]\S*)(\s)/) {
208
        $out .= $`.$1;
209
        $in = $3.$';
210
        $_= $2;
211
        s/[\\\"]/\\$&/g;
212
        $out .= '"'.$_.'"';
213
    }
214
    $out .= $in;
215
    $out =~ s/^ //;  $out =~ s/ $//;
216
    $out;
217
}
218
 
219
sub lout_endpara {
220
    return if $lout_status eq '';
221
    if ($lout_styles eq '') {
222
        print LOUT "\@LP\n\n";
223
    } elsif ($lout_styles =~ s/I$//) {
224
        print LOUT "}\n";
225
    }
226
    $lout_status= '';
227
}
228
 
229
sub lout_startverbatim {
230
    print LOUT "//0.4f\n\@RawIndentedDisplay lines \@Break".
231
               " { {0.7 1.0} \@Scale {Courier Bold} \@Font {\n";
232
}
233
 
234
sub lout_verbatim {
235
    $_= $_[0];
236
    s/^\s*//;
237
    print LOUT &lout_sanitise($_),"\n";
238
}
239
 
240
sub lout_endverbatim { print LOUT "}\n}\n//0.4f\n"; }
241
 
242
1;