diff options
Diffstat (limited to 'tex/context/base/trac-vis.mkiv')
-rw-r--r-- | tex/context/base/trac-vis.mkiv | 810 |
1 files changed, 701 insertions, 109 deletions
diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv index 0e4993853..e906bb50d 100644 --- a/tex/context/base/trac-vis.mkiv +++ b/tex/context/base/trac-vis.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=trac-vis, % replaces supp-vis plus some s-* modules -%D version=2112.06.23, % 1996.10.21, -%D title=\CONTEXT\ Tracing Macros, +%D [ file=trac-vis, % was core-vis, +%D version=1996.06.01, +%D title=\CONTEXT\ Tracking Macros, %D subtitle=Visualization, %D author=Hans Hagen, %D date=\currentdate, @@ -11,119 +11,711 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D The old visual debugger dates from 1996 and started out as joke. In practice -%D it's not used that often although the \type {\ruledhbox} cum suis macros come -%D in handy when writing code. In the process of luafication some additional -%D tracing options were tested, for instance showing font kerns. As part of the -%D \MKIV\ cleanup the decision was made to reimplement, reintegrate and reconsider -%D all these features. The old code is gone and the new code will get extended -%D when needed. We still provide placeholders for some old visualization commands -%D but they might go away. +%D This module adds some more visualization cues to the ones +%D supplied in the support module. %D -%D Control over what gets visualized happens with the tracker command: +%D %\everypar dual character, \the\everypar and \everypar= +%D %\hrule cannot be grabbed in advance, switches mode +%D %\vrule cannot be grabbed in advance, switches mode +%D % +%D %\indent only explicit ones +%D %\noindent only explicit ones +%D %\par only explicit ones %D -%D \enabletrackers[visualizer.*] +%D %\leftskip only if explicit one +%D %\rightskip only if explicit one + +\writestatus{loading}{ConTeXt Tracking Macros / Visualization} + +\unprotect + +%D \macros +%D {indent, noindent, par} %D -%D Possible values are: \type {fontkern}, \type {kern}, \type {glue}, \type -%D {penalty}, \type {hbox}, \type {vbox}, \type {all}, \type {reset}, \type -%D {makeup}, \type {whatsit}, \type{glyph}. +%D \TeX\ acts upon paragraphs. In mosts documents paragraphs +%D are separated by empty lines, which internally are handled as +%D \type{\par}. Paragraphs can be indented or not, depending on +%D the setting of \type{\parindent}, the first token of a +%D paragraph and/or user suppressed or forced indentation. %D -%D In due time some special visualzation of math will move here as well. +%D Because the actual typesetting is based on both explicit +%D user and implicit system actions, visualization is only +%D possible for the user supplied \type{\indent}, +%D \type{\noindent}, and \type{\par}. Other +%D 'clever' tricks will quite certainly lead to more failures +%D than successes, so we only support these three explicit +%D primitives and one macro: -\writestatus{loading}{ConTeXt Tracing Macros / Visualization} +\def\showparagraphcue#1#2#3#4#5% + {\bgroup + \scratchdimen#1\relax + \dontinterfere + \dontcomplain + \boxrulewidth5\testrulewidth + #3#4\relax + \setbox\scratchbox\normalhbox to \scratchdimen + {#2{\ruledhbox to \scratchdimen + {\vrule #5 20\testrulewidth \!!width \zeropoint + \normalhss}}}% + \smashbox\scratchbox + \normalpenalty\plustenthousand + \box\scratchbox + \egroup} -\registerctxluafile{trac-vis}{1.001} +\def\ruledhanging + {\ifdim\hangindent>\zeropoint + \ifnum\hangafter<\zerocount + \normalhbox + {\boxrulewidth5\testrulewidth + \setbox\scratchbox\ruledhbox to \hangindent + {\scratchdimen\strutht + \advance\scratchdimen \strutdp + \vrule + \!!width \zeropoint + \!!height \zeropoint + \!!depth -\hangafter\scratchdimen}% + \normalhskip-\hangindent + \smashbox\scratchbox + \raise\strutht\box\scratchbox}% + \fi + \fi} -\unprotect +\def\ruledparagraphcues + {\bgroup + \dontcomplain + \normalhbox to \zeropoint + {\ifdim\leftskip>\zeropoint\relax + \showparagraphcue\leftskip\llap\relax\relax\!!depth + \normalhskip-\leftskip + \fi + \ruledhanging + \normalhskip\hsize + \ifdim\rightskip>\zeropoint\relax + \normalhskip-\rightskip + \showparagraphcue\rightskip\relax\relax\relax\!!depth + \fi}% + \egroup} + +\def\ruledpar + {\relax + \ifhmode + \showparagraphcue{40\testrulewidth}\relax\rightrulefalse\relax\!!height + \fi + \normalpar} + +\def\rulednoindent + {\relax + \normalnoindent + \ruledparagraphcues + \showparagraphcue{40\testrulewidth}\llap\leftrulefalse\relax\!!height} + +\def\ruledindent + {\relax + \normalnoindent + \ruledparagraphcues + \ifdim\parindent>\zeropoint + \showparagraphcue\parindent\relax\relax\relax\!!height + \else + \showparagraphcue{40\testrulewidth}\llap\relax\relax\!!height + \fi + \normalhskip\parindent} + +\def\dontshowimplicits + {\let\noindent \normalnoindent + \let\indent \normalindent + \let\par \normalpar} + +\def\showimplicits + {\testrulewidth \defaulttestrulewidth + \let\noindent \rulednoindent + \let\indent \ruledindent + \let\par \ruledpar} + +%D The next few||line examples show the four cues. Keep in +%D mind that we only see them when we explicitly open or close +%D a paragraph. +%D +%D \bgroup +%D \def\voorbeeld#1% +%D {#1Visualizing some \TeX\ primitives and Plain \TeX\ +%D macros can be very instructive, at least it is to me. +%D Here we see {\tt\string#1} and {\tt\string\ruledpar} in +%D action, while {\tt\string\parindent} equals +%D {\tt\the\parindent}.\ruledpar} +%D +%D \showimplicits +%D +%D \voorbeeld \indent +%D \voorbeeld \noindent +%D +%D \parindent=60pt +%D +%D \voorbeeld \indent +%D \voorbeeld \noindent +%D +%D \startnarrower +%D \voorbeeld \indent +%D \voorbeeld \noindent +%D \stopnarrower +%D \egroup +%D +%D These examples also demonstrate the visualization of +%D \type {\leftskip} and \type {\rightskip}. The macro +%D \type {\nofruledbaselines} determines the number of lines +%D shown. + +\newcounter\ruledbaselines + +\def\nofruledbaselines{3} + +\def\debuggertext#1% + {\ifx\ttxx\undefined + $\scriptscriptstyle#1$% + \else + {\ttxx#1}% + \fi} + +\def\ruledbaseline + {\vrule \!!width \zeropoint + \bgroup + \dontinterfere + \doglobal\increment\ruledbaselines + \scratchdimen\nofruledbaselines\baselineskip + \setbox\scratchbox\normalvbox to 2\scratchdimen + {\leaders + \normalhbox + {\strut + \vrule + \!!height \testrulewidth + \!!depth \testrulewidth + \!!width 120\points} + \normalvfill}% + \smashbox\scratchbox + \advance\scratchdimen \strutheightfactor\baselineskip + \setbox\scratchbox\normalhbox + {\normalhskip -48\points + \normalhbox to 24\points + {\normalhss\debuggertext\ruledbaselines\normalhskip6\points}% + \raise\scratchdimen\box\scratchbox}% + \smashbox\scratchbox + \box\scratchbox + \egroup} + +\def\showbaselines + {\testrulewidth\defaulttestrulewidth + \EveryPar{\ruledbaseline}} + +%D \macros +%D {showpagebuilder} +%D +%D The next tracing option probaly is only of use to me and a +%D few \CONTEXT\ hackers. + +\def\showpagebuilder + {\EveryPar{\doshowpagebuilder}} + +\def\doshowpagebuilder + {\strut\llap + {\startcolor[blue]\vl + \high{\infofont v:\the\vsize }\vl + \high{\infofont g:\the\pagegoal }\vl + \high{\infofont t:\the\pagetotal}\vl + \stopcolor}} + +%D \macros +%D {makecutbox, cuthbox, cutvbox, cutvtop} +%D +%D Although mainly used for marking the page, these macros can +%D also serve local use. +%D +%D \startbuffer +%D \setbox0=\vbox{a real \crlf vertical box} \makecutbox0 +%D \stopbuffer +%D +%D \typebuffer +%D +%D This marked \type{\vbox} shows up as: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D The alternative macros are used as: +%D +%D \startbuffer +%D \cuthbox{a made cut box} +%D \stopbuffer +%D +%D \typebuffer +%D +%D This is typeset as: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D By setting the next macros one can influence the length of +%D the marks as well as the horizontal and vertical divisions. + +\newdimen\tractempwidth +\newdimen\tractempheight +\newdimen\tractempdepth + +\def \cutmarklength {2\bodyfontsize} + +\newcount\horizontalcutmarks \horizontalcutmarks = 2 +\newcount\verticalcutmarks \verticalcutmarks = 2 +\newcount\cutmarkoffset \cutmarkoffset = 1 + +\let \cutmarksymbol \relax +\let \cutmarktoptext \empty +\let \cutmarkbottomtext \empty +\let \cutmarkhoffset \empty +\let \cutmarkvoffset \empty + +\def\horizontalcuts + {\normalhbox to \tractempwidth + {\dorecurse\horizontalcutmarks{\vrule\!!width\boxrulewidth\!!height\cutmarklength\normalhfill}% + \unskip}} + +\def\verticalcuts + {\normalvbox to \dimexpr\tractempheight+\tractempdepth\relax + {\hsize\cutmarklength + \dorecurse\verticalcutmarks{\vrule\!!height\boxrulewidth\!!width\hsize\normalvfill}% + \unskip}} + +\def\baselinecuts + {\ifdim\tractempdepth>\zeropoint + \normalvbox to \dimexpr\tractempheight+\tractempdepth\relax + {\hsize\dimexpr\cutmarklength/2\relax + \normalvskip\zeropoint\!!plus\tractempheight + \vrule\!!height\boxrulewidth\!!width\hsize + \normalvskip\zeropoint\!!plus\tractempdepth}% + \fi} + +\def\cutmarksymbols#1% + {\normalhbox to \tractempwidth + {\setbox\scratchbox\normalhbox to \cutmarklength + {\normalhss\infofont\cutmarksymbol\normalhss}% + \normalhss + \normalvbox to \cutmarklength + {\scratchdimen\dimexpr\cutmarklength/2\relax + \scratchskip \ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi + \normalvss + \hbox to \tractempwidth + {\llap{\copy\scratchbox\normalhskip\scratchskip}% + \normalhskip\scratchdimen\hss\infofont#1\hss\normalhskip\scratchdimen + \rlap{\normalhskip\scratchskip\copy\scratchbox}}% + \normalvss}% + \normalhss}} + +\def\makecutbox#1% simplier with layers, todo + {\tractempheight\ht#1% + \tractempdepth \dp#1% + \tractempwidth \wd#1% + \setbox#1\normalhbox + {\dontcomplain + \forgetall + \boxmaxdepth\maxdimen + \offinterlineskip + \scratchdimen\dimexpr\cutmarklength/2\relax + \hsize\tractempwidth + \setbox\scratchbox\normalvbox + {\setbox\scratchbox\normalhbox{\horizontalcuts}% + \scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi +% \normalvskip\dimexpr-\scratchskip-2\scratchdimen\relax +% \copy\scratchbox +% \normalvskip\scratchskip + \tlap{\copy\scratchbox\normalvskip\scratchskip}% + \hbox to \tractempwidth + {\scratchskip\ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi + \setbox\scratchbox\normalhbox{\verticalcuts}% + \llap{\copy\scratchbox\normalhskip\scratchskip}% + \ifdim\tractempdepth=\zeropoint + \normalhfill + \else + \bgroup + \setbox\scratchbox\normalhbox{\baselinecuts}% + \llap{\copy\scratchbox\normalhskip\scratchskip}% + \normalhfill + \rlap{\normalhskip\scratchskip\copy\scratchbox}% + \egroup + \fi + \rlap{\normalhskip\scratchskip\copy\scratchbox}}% +% \normalvskip\scratchskip +% \copy\scratchbox}% + \blap{\normalvskip\scratchskip\copy\scratchbox}}% + \ht\scratchbox\tractempheight + \dp\scratchbox\tractempdepth + \wd\scratchbox\zeropoint + \startcolor[\defaulttextcolor]% + \box\scratchbox + \ifx\cutmarksymbol\relax \else + \setbox\scratchbox\normalvbox + {\scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi + \vskip-\scratchskip + \vskip-\cutmarklength + \normalhbox{\cutmarksymbols\cutmarktoptext}% + \vskip\scratchskip + \vskip\tractempheight + \vskip\tractempdepth + \vskip\scratchskip + \normalhbox{\cutmarksymbols\cutmarkbottomtext}}% + \ht\scratchbox\tractempheight + \dp\scratchbox\tractempdepth + \wd\scratchbox\zeropoint + \box\scratchbox + \fi + \stopcolor + \box#1}% + \wd#1\tractempwidth + \ht#1\tractempheight + \dp#1\tractempdepth} + +\def\cuthbox{\normalhbox\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalhbox} +\def\cutvbox{\normalvbox\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvbox} +\def\cutvtop{\normalvtop\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvtop} + +%D \macros +%D {colormarkbox,rastermarkbox} +%D +%D This macro is used in the pagebody routine. No other use +%D is advocated here. +%D +%D \starttyping +%D \colormarkbox0 +%D \stoptyping + +\def\colormarkoffset{\cutmarkoffset} +\def\colormarklength{\cutmarklength} + +\def\dodocolorrangeA#1% + {\fastcolored[#1]{\hrule\!!width3em\!!height\scratchdimen\!!depth\zeropoint}} + +\def\docolorrangeA#1 #2 % + {\vbox + {\hsize3em % \scratchdimen + \ifcase#1\or + \dodocolorrangeA{c=#2}\or + \dodocolorrangeA{m=#2}\or + \dodocolorrangeA{y=#2}\or + \dodocolorrangeA{m=#2,y=#2}\or + \dodocolorrangeA{c=#2,y=#2}\or + \dodocolorrangeA{c=#2,m=#2}\fi + \ifdim\scratchdimen>1ex + \vskip-\scratchdimen + \vbox to \scratchdimen + {\vss\hbox to 3em{\hss#2\hss}\vss}% + \fi}} + +\def\colorrangeA#1% + {\vbox + {\startcolor[\s!white]% + \scratchdimen\dimexpr(-\colormarklength*4+\tractempheight+\tractempdepth)/21\relax + \offinterlineskip + \docolorrangeA #1 1.00 \docolorrangeA #1 0.95 + \docolorrangeA #1 0.75 + \docolorrangeA #1 0.50 + \docolorrangeA #1 0.25 \docolorrangeA #1 0.05 + \docolorrangeA #1 0.00 + \stopcolor}} + +\def\docolorrangeB #1 #2 #3 #4 #5 % + {\fastcolored + [\c!c=#2,\c!m=#3,\c!y=#4,\c!k=#5] + {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}% + \ifdim\scratchdimen>2em + \hskip-\scratchdimen + \vbox to \colormarklength + {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}% + \fi} + +\def\colorrangeB + {\hbox + {\startcolor[\s!white]% + \scratchdimen\dimexpr(-\colormarklength*\plustwo+\tractempwidth)/11\relax + \docolorrangeB .5~C .5 0 0 0 + \docolorrangeB .5~M 0 .5 0 0 + \docolorrangeB .5~Y 0 0 .5 0 + \docolorrangeB .5~K 0 0 0 .5 + \docolorrangeB C 1 0 0 0 + \docolorrangeB G 1 0 1 0 + \docolorrangeB Y 0 0 1 0 + \docolorrangeB R 0 1 1 0 + \docolorrangeB M 0 1 0 0 + \docolorrangeB B 1 1 0 0 + \docolorrangeB K 0 0 0 1 + \stopcolor}} + +\def\docolorrangeC#1 % + {\fastcolored + [\c!s=#1]% + {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}% + \ifdim\scratchdimen>2em + \hskip-\scratchdimen + \vbox to \colormarklength + {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}% + \fi} + +\def\colorrangeC + {\hbox + {\startcolor[\s!white]% + \scratchdimen\dimexpr(-\colormarklength*2+\tractempwidth)/14\relax + \docolorrangeC 1 \docolorrangeC .95 + \docolorrangeC .9 \docolorrangeC .85 + \docolorrangeC .8 \docolorrangeC .75 + \docolorrangeC .7 + \docolorrangeC .6 + \docolorrangeC .5 + \docolorrangeC .4 + \docolorrangeC .3 + \docolorrangeC .2 + \docolorrangeC .1 + \docolorrangeC 0 + \stopcolor}} + +\def\docolormarkbox#1#2% + {\tractempheight\ht#2% + \tractempdepth \dp#2% + \tractempwidth \wd#2% + \setbox#2\hbox + {\scratchdimen\dimexpr\colormarklength/2\relax + \forgetall + \ssxx + \setbox\scratchbox\vbox + {\offinterlineskip + \vskip\dimexpr-\colormarkoffset\scratchdimen-2\scratchdimen\relax + \ifcase#1\relax + \vskip\dimexpr\colormarklength+\scratchdimen+\tractempheight\relax + \else + \hbox to \tractempwidth{\hss\hbox{\colorrangeB}\hss}% + \vskip\colormarkoffset\scratchdimen + \vbox to \tractempheight + {\vss + \hbox to \tractempwidth + {\llap{\colorrangeA1\hskip\colormarkoffset\scratchdimen}\hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA4}}% + \vss + \hbox to \tractempwidth + {\llap{\colorrangeA2\hskip\colormarkoffset\scratchdimen}\hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA5}}% + \vss + \hbox to \tractempwidth + {\llap{\colorrangeA3\hskip\colormarkoffset\scratchdimen}\hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA6}}% + \vss}% + \fi + \vskip\colormarkoffset\scratchdimen + \hbox to \tractempwidth + {\hss\lower\tractempdepth\hbox{\colorrangeC}\hss}}% + \ht\scratchbox\tractempheight + \dp\scratchbox\tractempdepth + \wd\scratchbox\zeropoint + \box\scratchbox + \box#2}% + \wd#2\tractempwidth + \ht#2\tractempheight + \dp#2\tractempdepth} + +\def\colormarkbox {\docolormarkbox\plusone } % #1 +\def\rastermarkbox{\docolormarkbox\zerocount} % #1 + +%D \macros +%D {showwhatsits, dontshowwhatsits} +%D +%D \TEX\ has three so called whatsits: \type {\mark}, \type +%D {\write} and \type {\special}. The first one keeps track of +%D the current state at page boundaries, the last two are used +%D to communicate to the outside world. Due to fact that +%D especially \type {\write} is often used in conjunction with +%D \type {\edef}, we can only savely support that one in \ETEX. +%D +%D \bgroup \showwhatsits \setupcolors[state=start] +%D +%D Whatsits show up \color[blue]{in color} and are +%D characterized bij their first character.\footnote [some note] +%D {So we may encounter \type {w}, \type {m} and \type{s}.} +%D They are \writestatus{dummy}{demo}\color[yellow]{stacked}. +%D +%D \egroup + +\newif\ifimmediatewrite + +\ifx\eTeXversion\undefined + + \let\showwhatsits \relax + \let\dontshowwhatsits\relax + +\else + + \let\supernormalmark \normalmark % mark may already been superseded + \let\supernormalmarks \normalmarks % mark may already been superseded + + \def\showwhatsits + {\protected\def\normalmark {\visualwhatsit100+m\supernormalmark }% + \protected\def\normalmarks{\visualwhatsit100+m\supernormalmarks}% + \protected\def\special {\visualwhatsit0100s\normalspecial }% + \protected\def\write {\visualwhatsit001-w\normalwrite }% + \let\immediate\immediatewhatsit + \appendtoks\dontshowwhatsits\to\everystoptext} + + \def\immediatewhatsit + {\bgroup\futurelet\next\doimmediatewhatsit} + + \def\doimmediatewhatsit + {\ifx\next\write + \egroup\immediatewritetrue + \else + \egroup\expandafter\normalimmediate + \fi} + + \def\dontshowwhatsits + {\let\immediate \normalimmediate + \let\normalmark\supernormalmark + \let\special \normalspecial + \let\write \normalwrite} + + \def\visualwhatsit#1#2#3#4#5% + {\bgroup + \pushwhatsit + \dontinterfere + \dontcomplain + \dontshowcomposition + \dontshowwhatsits + \ttx + \ifvmode\donetrue\else\donefalse\fi + \setbox\scratchbox\hbox + {\ifdone + \colored[r=#1,g=#2,b=#3]{#5}% temp hack + \else + \colored[s=0]{#5}% temp hack + \fi}% + \setbox\scratchbox\hbox + {\ifdone + \colored[r=#1,g=#2,b=#3]{\vrule\!!width\wd\scratchbox}% temp hack + \else + \colored[s=0]{\vrule\!!width\wd\scratchbox}% temp hack + \fi + \hskip-\wd\scratchbox\box\scratchbox}% + \scratchdimen1ex + \setbox\scratchbox\hbox + {\ifdone\hskip\else\raise#4\fi\scratchdimen\box\scratchbox}% + \smashbox\scratchbox + \ifdone\nointerlineskip\fi + \box\scratchbox + \ifvmode\nointerlineskip\fi + \popwhatsit + \egroup + \ifimmediatewrite + \immediatewritefalse + \expandafter\normalimmediate + \fi} + + \def\pushwhatsit + {\ifzeropt\lastskip + \ifcase\lastpenalty + \ifzeropt\lastkern + \ifhmode + \let\popwhatsit\relax + \else + \edef\popwhatsit{\prevdepth\the\prevdepth}% + \fi + \else + \ifhmode + \edef\popwhatsit{\kern\the\lastkern}\unkern + \else + \edef\popwhatsit{\kern\the\lastkern\prevdepth\the\prevdepth}% + \kern-\lastkern + \fi + \fi + \else + \ifhmode + \edef\popwhatsit{\the\lastpenalty}% + \unpenalty + \else + \edef\popwhatsit{\penalty\the\lastpenalty\prevdepth\the\prevdepth}% + %\nobreak + \fi + \fi + \else + \ifhmode + \edef\popwhatsit{\hskip\the\lastskip}\unskip + \else + \edef\popwhatsit{\vskip\the\lastskip\prevdepth\the\prevdepth}% + \vskip-\lastskip + \fi + \fi} + +\fi + +%D The next macro can be used to keep track of classes of +%D boxes (handy for development cq.\ tracing). + +\def\dodotagbox#1#2#3% can be reimplemented + {\def\next##1##2##3##4% + {\vbox to \ht#2{##3\hbox to \wd#2{##1#3##2}##4}}% + \processaction + [#1] + [ l=>\next\relax\hfill\vfill\vfill, + r=>\next\hfill\relax\vfill\vfill, + t=>\next\hfill\hfill\relax\vfill, + b=>\next\hfill\hfill\vfill\relax, + lt=>\next\relax\hfill\relax\vfill, + lb=>\next\relax\hfill\vfill\relax, + rt=>\next\hfill\relax\relax\vfill, + rb=>\next\hfill\relax\vfill\relax, + tl=>\next\relax\hfill\relax\vfill, + bl=>\next\relax\hfill\vfill\relax, + tr=>\next\hfill\relax\relax\vfill, + br=>\next\hfill\relax\vfill\relax, + \s!default=>\next\hfill\hfill\vfill\vfill, + \s!unknown=>\next\hfill\hfill\vfill\vfill]} + +\def\dotagbox[#1]#2% + {\bgroup + \dowithnextbox + {\setbox\scratchbox\flushnextbox + \setbox\nextbox\ifhbox\nextbox\hbox\else\vbox\fi + \bgroup + \startoverlay + {\copy\scratchbox} + {\dodotagbox{#1}\scratchbox{\framed + [\c!background=\v!screen,\c!backgroundscreen=1]{#2}}} + \stopoverlay + \egroup + \nextboxwd\the\wd\scratchbox + \nextboxht\the\ht\scratchbox + \nextboxdp\the\dp\scratchbox + \flushnextbox + \egroup}} + +\def\tagbox + {\dosingleempty\dotagbox} + +%D \macros +%D {coloredhbox,coloredvbox,coloredvtop, +%D coloredstrut} +%D +%D The following visualizations are used in some of the manuals: + +\definecolor[boxcolor:ht][r=.5,g=.75,b=.5] +\definecolor[boxcolor:dp][r=.5,g=.5,b=.75] +\definecolor[boxcolor:wd][r=.75,g=.5,b=.5] +\definecolor[strutcolor] [r=.5,g=.25,b=.25] + +\def\coloredbox#1% + {\dowithnextbox{#1{\hbox + {\blackrule[\c!width=\nextboxwd,\c!height=\nextboxht,\c!depth=\zeropoint,\c!color=boxcolor:ht]% + \hskip-\nextboxwd + \blackrule[\c!width=\nextboxwd,\c!height=\zeropoint,\c!depth=\nextboxdp,\c!color=boxcolor:dp]% + \hskip-\nextboxwd + \box\nextbox}}}#1} + +\def\coloredhbox{\coloredbox\hbox} +\def\coloredvbox{\coloredbox\vbox} +\def\coloredvtop{\coloredbox\vtop} -\definesystemattribute[visual][public,global] - -%D We only provide box visualizers as they can come in handy for testing -%D macros. In due time we will move some of the m-visual code here too. - -\let\syst_visualizers_hbox\hbox -\let\syst_visualizers_vbox\vbox -\let\syst_visualizers_vtop\vtop - -\unexpanded\def\ruledhbox{\syst_visualizers_hbox attr \visualattribute \ctxcommand{visual("simplehbox")} } -\unexpanded\def\ruledvbox{\syst_visualizers_vbox attr \visualattribute \ctxcommand{visual("simplevbox")} } -\unexpanded\def\ruledvtop{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("simplevtop")} } % special case -\unexpanded\def\ruledtopv{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("vtop")} } - -\unexpanded\def\showmakeup - {\ctxcommand{setvisual("makeup")}% - \let\normalvtop\ruledtopv - \let\vtop \ruledtopv} - -\unexpanded\def\showallmakeup - {\ctxcommand{setvisual("all")}% - \let\normalvtop\ruledtopv - \let\vtop \ruledtopv - \showstruts} - -\unexpanded\def\showboxes - {\ctxcommand{setvisual("boxes")}% - \let\normalvtop\ruledtopv - \let\vtop \ruledtopv} - -\unexpanded\def\showglyphs - {\ctxcommand{setvisual("glyph")}} - -\unexpanded\def\showfontkerns - {\ctxcommand{setvisual("fontkern")}} - -\unexpanded\def\setvisualizerfont - {\dosingleempty\syst_visualizers_setfont} - -\def\syst_visualizers_setfont[#1]% somename at 4pt - {\begingroup - \doifelsenothing{#1}{\definedfont[Mono at 4pt]}{\definedfont[#1]}% - \ctxlua{nodes.visualizers.setfont()}% - \endgroup} - -%D Overload: - -% \def\spac_struts_vide_hbox -% {\hbox attr \visualattribute \ctxcommand{visual("strut")} } - -\def\spac_struts_vide_hbox - {\edef\spac_struts_vide_hbox{\hbox attr \visualattribute \ctxcommand{visual("strut")} }% - \spac_struts_vide_hbox} - -%D We keep this one: - -\unexpanded\def\dontinterfere - {\reseteverypar - \parindent\zeropoint - \parskip \zeropoint - \leftskip \zeropoint - \rightskip\zeropoint - \relax} - -%D We keep these for a while: - -\let\ruledvcenter \vcenter -\let\ruledhss \hss -\let\ruledhfil \hfil -\let\ruledhfill \hfill -\let\ruledhfilll \hfilll -\let\ruledhfilneg \hfilneg -\let\ruledhfillneg \hfillneg -\let\ruledhfilllneg \hfilllneg -\let\ruledvss \vss -\let\ruledvfil \vfil -\let\ruledvfill \vfill -\let\ruledvfilll \vfilll -\let\ruledvfilneg \vfilneg -\let\ruledvfillneg \vfillneg -\let\ruledvfilllneg \vfilllneg -\let\ruledhskip \hskip -\let\ruledvskip \vskip -\let\ruledkern \kern -\let\ruledhglue \hglue -\let\ruledvglue \vglue -\let\ruledmkern \mkern -\let\ruledmskip \mskip -\let\ruledpenalty \penalty +\def\coloredstrut + {\color[strutcolor]{\def\strutwidth{2\points}\setstrut\strut}} \protect \endinput |