| 1 |
% Makes a landscape listing of one or more files |
| 2 |
% Extended to allow the Latin-1 accented characters in UTF-8 encoding |
| 3 |
% Typical usage: |
| 4 |
% tex llist-latin *.txt \\end |
| 5 |
|
| 6 |
\def\grabfile#1 {\setbox0=\lastbox\endgraf\doit{#1}} |
| 7 |
\everypar{\grabfile} |
| 8 |
|
| 9 |
\font\filenamefont= cmtt8 scaled\magstep3 |
| 10 |
\font\headlinefont= cmr8 |
| 11 |
\font\listingfont= cmtex8 |
| 12 |
\font\ttfont= cmtt8 |
| 13 |
\font\syttfont= cmsytt10 at 8pt |
| 14 |
\font\eoffont= cmti8 |
| 15 |
|
| 16 |
\def\today{\ifcase\month\or |
| 17 |
January\or February\or March\or April\or May\or June\or |
| 18 |
July\or August\or September\or October\or November\or December\fi |
| 19 |
\space\number\day, \number\year} |
| 20 |
\newcount\m \newcount\n |
| 21 |
\n=\time \divide\n 60 \m=-\n \multiply\m 60 \advance\m \time |
| 22 |
\def\hours{\twodigits\n\twodigits\m} |
| 23 |
\def\twodigits#1{\ifnum #1<10 0\fi \number#1} |
| 24 |
|
| 25 |
\newlinechar=`@ |
| 26 |
\message{@\today\space at \hours} |
| 27 |
|
| 28 |
\baselineskip=9pt |
| 29 |
\medskipamount=4pt minus 1pt |
| 30 |
\raggedbottom |
| 31 |
\nopagenumbers |
| 32 |
|
| 33 |
\newcount\n |
| 34 |
\catcode`\^^c3=\active |
| 35 |
\def\missing{{\syttfont\char15}} |
| 36 |
\def^^c3#1{\n=`#1\advance\n by-128 |
| 37 |
{\ttfont\ifcase\n |
| 38 |
\`A\or\'A\or\^A\or\~A\or\"A\or\AA\or\AE\or\c C\or |
| 39 |
\`E\or\'E\or\^E\or\"E\or\`I\or\'I\or\^I\or\"I\or |
| 40 |
\missing\or\~N\or\`O\or\'O\or\^O\or\~O\or\"O\or{\syttfont\char2}\or |
| 41 |
\O\or\`U\or\'U\or\^U\or\"U\or\'Y\or\missing\or\ss\or |
| 42 |
\`a\or\'a\or\^a\or\~a\or\"a\or\aa\or\ae\or\c c\or |
| 43 |
\`e\or\'e\or\^e\or\"e\or\`\i\or\'\i\or\^\i\or\"\i\or |
| 44 |
\missing\or\~n\or\`o\or\'o\or\^o\or\~o\or\"o\or{\syttfont\char4}\or |
| 45 |
\o\or\`u\or\'u\or\^u\or\"u\or\'y\or\missing\or\"y\fi}} |
| 46 |
|
| 47 |
\chardef\other=12 |
| 48 |
\def\doit#1{\message{@Listing #1@} |
| 49 |
\begingroup \everypar{} \frenchspacing |
| 50 |
\headline{\ifright \headlinefont \hfill Page \folio |
| 51 |
\else\filenamefont#1\quad\headlinefont \today\ at \hours\hss \fi} |
| 52 |
\def\do##1{\catcode`##1=\other}\dospecials |
| 53 |
\catcode127=\other \catcode9=\other \catcode12=\other |
| 54 |
\parindent 0pt \parfillskip=0pt plus 1fil minus .8in |
| 55 |
\everypar{\hangindent 1in} \rightskip=0pt plus 2in |
| 56 |
\def\par{\ifvmode\penalty-50\medskip\else\endgraf\fi} |
| 57 |
\listingfont \obeylines \obeyspaces \global\pageno=1 |
| 58 |
\input #1 {\eoffont(end of\/ file)}\endgraf\vfill\eject |
| 59 |
\ifright\null\vfill\eject\fi\endgroup} |
| 60 |
{\obeyspaces\global\let =\ } |
| 61 |
\catcode`\_=\other % allow _ in file names |
| 62 |
|
| 63 |
\hsize=4.6truein |
| 64 |
\vsize=7truein |
| 65 |
\hoffset=-.5truein |
| 66 |
\voffset=-.2truein |
| 67 |
\newif\ifright |
| 68 |
\newbox\lefthalf |
| 69 |
\output{\ifright |
| 70 |
\shipout\hbox{\hbox to5.5in{\box\lefthalf\hss}% |
| 71 |
\vbox{\makeheadline\pagebody\makefootline}} |
| 72 |
\advancepageno\global\rightfalse |
| 73 |
\else\global\setbox\lefthalf\vbox{\makeheadline\pagebody\makefootline} |
| 74 |
\global\righttrue\fi} |
| 75 |
|
| 76 |
\special{landscape} |
| 77 |
|
| 78 |
% A tab (^^I) prints as lowercase gamma. |
| 79 |
% Character ^^M could be made visible, with a bit of work; |
| 80 |
% at present, it's indistinguishable from newline (^^J). |
| 81 |
|
| 82 |
% You can get up to 91 characters on a line without an overfull box. |
| 83 |
% (But lines with more than 84 characters will be clipped, if they |
| 84 |
% appear on a righthand halfpage.) |