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

* Re: Verbatim with linebreaks sillyness
  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
  0 siblings, 2 replies; 4+ messages in thread
From: Eugene Toporov @ 2005-08-06 16:03 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1704 bytes --]

Taco,

Just tried this and it is really cool!
But how can I make spaces without the special space character?

Thanks

On 7/29/05, Taco Hoekwater <taco@elvenkind.com> wrote:
> 
> 
> 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
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 



-- 
Regards.
Eugene Toporov

[-- Attachment #1.2: Type: text/html, Size: 2639 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

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

* Re: Verbatim with linebreaks sillyness
  2005-08-06 16:03 ` Eugene Toporov
@ 2005-08-06 21:03   ` Taco Hoekwater
  2005-08-07 20:41   ` Hans Hagen
  1 sibling, 0 replies; 4+ messages in thread
From: Taco Hoekwater @ 2005-08-06 21:03 UTC (permalink / raw)


Eugene Toporov wrote:
> Taco,
> 
> Just tried this and it is really cool!
> But how can I make spaces without the special space character?

Like so:

   \def\BREAKtypeone#1%
    {\advance\BREAKcharcounter 1
     \ifnum\BREAKcharcounter > \BREAKmaxcharcount
        \hfil\break
        \BREAKcharcounter=1
     \fi
     \ifnum#1=32 % the character number for a space
        \setbox\scratchbox=\hbox{0}%
        \kern \wd\scratchbox
     \else
        \getpretty{#1}%
     \fi}

Cheers again, Taco

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

* Re: Verbatim with linebreaks sillyness
  2005-08-06 16:03 ` Eugene Toporov
  2005-08-06 21:03   ` Taco Hoekwater
@ 2005-08-07 20:41   ` Hans Hagen
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2005-08-07 20:41 UTC (permalink / raw)


Eugene Toporov wrote:

> Taco,
>
> Just tried this and it is really cool!
> But how can I make spaces without the special space character?

framedtext is better suited than framed here:

\defineframedtext
  [broken]
  [width=8cm,
   align=flushleft]

\definetyping[BREAK][option=BREAK]

\startbroken
\startBREAK
hööah:aloh/aa?lha llol!loh%lloh#allhal\lohhll;ohohal~loll 
ohalölohööah:aloh/aa?lha llol!loh%lloh#allhal\lohhll;ohohal~loll ohalölo
\stopBREAK
\stopbroken


>
> Thanks
>
> On 7/29/05, *Taco Hoekwater* <taco@elvenkind.com 
> <mailto:taco@elvenkind.com>> wrote:
>
>
>     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
>
>     _______________________________________________
>     ntg-context mailing list
>     ntg-context@ntg.nl <mailto:ntg-context@ntg.nl>
>     http://www.ntg.nl/mailman/listinfo/ntg-context
>
>
>
>
> -- 
> Regards.
> Eugene Toporov
>
>------------------------------------------------------------------------
>
>_______________________________________________
>ntg-context mailing list
>ntg-context@ntg.nl
>http://www.ntg.nl/mailman/listinfo/ntg-context
>  
>


-- 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ 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).