ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Verbatim with linebreaks sillyness
@ 2005-07-29 13:33 Taco Hoekwater
  2005-08-06 16:03 ` Eugene Toporov
  0 siblings, 1 reply; 4+ messages in thread
From: Taco Hoekwater @ 2005-07-29 13:33 UTC (permalink / raw)



Hi,

I saw this on the wiki:

   http://contextgarden.net/Verbatim_with_line_breaks

and it seemed like a fun idea to play with for a bit.
How's this?

Cheers, Taco


%
% BREAK is a special pretty handler that auto-wraps lines
% to fit the current hsize.

\gdef\BREAKsetspecials%
   {\dorecurse{256}{\setpretty\numexpr \recurselevel-1\relax=10 }}

\gdef\BREAKsethandlers%
   {\installprettyhandler 10 \BREAKtypeone  }

\newcount\BREAKcharcounter
\newcount\BREAKmaxcharcount

\def\BREAKtypeone#1%
   {\advance\BREAKcharcounter 1
    \ifnum\BREAKcharcounter > \BREAKmaxcharcount
       \hfil\break
       \BREAKcharcounter=1
    \fi
    \getpretty{#1}}

\def\BREAKsetcounters%
   {\setbox\scratchbox=\hbox{0}%
    \BREAKmaxcharcount=\hsize
    \divide\BREAKmaxcharcount \wd\scratchbox
    \def\flushrestofverbatimline{\BREAKcharcounter=0 }%
    \BREAKcharcounter=0 }

\gdef\setupprettyBREAKtype%
   {\def\prettyidentifier{BREAK}%
    \BREAKsetcounters
    \BREAKsethandlers
    \BREAKsetspecials}

\installprettytype [BREAK] [BREAK]

\starttext
\framed
    [width=8cm,
     align=flushleft]{%
\setuptyping[option=BREAK]
\starttyping
hööah:aloh/aa?lha llol!loh%lloh#allhal\lohhll;ohohal~loll ohalölo
\stoptyping
}
\stoptext

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-07 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-29 13:33 Verbatim with linebreaks sillyness Taco Hoekwater
2005-08-06 16:03 ` Eugene Toporov
2005-08-06 21:03   ` Taco Hoekwater
2005-08-07 20:41   ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).