Happy new (Christian++) year everybody.

Tadziu Hoffmann <hoffm...@usm.uni-muenchen.de> wrote:
 |> [...] and also supports five different builtin styles for
 |> verbatim output instead of only a silly numbered one.
 |
 |Okay, I'm curious.  What different styles apart from numbering
 |could there possibly be?  (I can't think of any, except of
 |course for variants of this, such as numbering only every
 |fifth line, or numbering only lines containing text and
 |skipping empty ones, or setting the number in a different
 |color/font/size, etc.)

No, no..  It's really just that i don't have this in roff.
And no, i was impressed from Eckel's ?Thinking in Java? style,
which was so different to all the rest.  (Unfortunately that made
me buy his ?Thinking in C++? one or two years later and that
wasn't really it.)  Everybody goes the spiral staircase, so to
say.  But on Tucholsky's "talking writing silence" i'm on two at
most.  ^.^

Whereas the styles are pretty basic, the really great thing on my
TeX package was that almost everything was hookable; builtin:

  % 5 (default) styles. The numbered (inside) ones are ok for up to 9999 lines
  \def\@verbatim@I{\hbox{}}% I = EMPTY
  \def\@verbatim@II{% II = Numbered; number inside document;
    {\smallest\it\hbox to 3em{\hfill\number\@count@verbatimno}\hbox to.84em{}}%
  }
  \def\@verbatim@III{% III = Numbered; number shifted to the left margin
    \llap{{\smallest\it\number\@count@verbatimno}\hbox to.84em{}}%
  }
  \def\@verbatim@IV{% IV = black border left; border inside document
    \vbox{\kern-3pt\vstrutbox{3}}\hbox to.84em{}%
  }
  \def\@verbatim@V{% V = black border left; border shifted to the left margin.
    \llap{\vbox{\kern-3pt\vstrutbox{3}}\hbox to.84em{}}%
  }

A default to be chosen from by simple command

  \def\setVerbatimStyle#1{%
    \def\@@value{#1}\def\@@value@{I}%
    \ifx\@@value\@@value@%
      \setHookVerbatimStyle{\@verbatim@I}%
    ..
  }
  \setVerbatimStyle{III}% Default is III

But you could adjust a lot of even those by doing some hooks

  % Hooks
  \def\setHookVerbatimPre#1{\gdef\@hook@verbatim@pre{#1}}%
  \setHookVerbatimPre{\tt}%
  \def\setHookVerbatimAfter#1{\gdef\@hook@verbatim@after{#1}}%
  \setHookVerbatimAfter{}%

  \def\setHookVerbatimStyle#1{% set in the style-section below
  \gdef\@verbatim@baseStyle{%
  \global\advance\@count@verbatimno by\TRUE\relax%
  \hSkip{\@verbatim@leftindent}{#1}%
  }%
  % one can choose "local" styles. this is used to restore the global
  \global\let\@hook@verbatim@style\@verbatim@baseStyle%
  }%
  % Dimen
  \def\setVerbatimLeftIndent#1{\gdef\@verbatim@leftindent{#1}}%
  \setVerbatimLeftIndent{0pt}%

(I was sooo proud of that stuff and even wanted to write a book.
Maybe good that the c't magazine distributed a virus on CD in
a program called Street Graphics or so and that i forgot my PGP
password to restore from backup.)

--steffen

Reply via email to