diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/cont-new.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/cont-new.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/cont-new.mkiv | 580 |
1 files changed, 564 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/context/base/cont-new.mkiv b/Master/texmf-dist/tex/context/base/cont-new.mkiv index 6269e5a6160..3bda269efef 100644 --- a/Master/texmf-dist/tex/context/base/cont-new.mkiv +++ b/Master/texmf-dist/tex/context/base/cont-new.mkiv @@ -1,6 +1,6 @@ %D \module %D [ file=cont-new, -%D version=2006.10.04, +%D version=1995.10.10, %D title=\CONTEXT\ Miscellaneous Macros, %D subtitle=New Macros, %D author=Hans Hagen, @@ -11,29 +11,577 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -% potential new defaults: -% -% \setbreakpoints[compound] +\newcontextversion{2011.05.18 18:04} + +%D This file is loaded at runtime, thereby providing an +%D excellent place for hacks, patches, extensions and new +%D features. \unprotect -\ctxlua{logs.report = commands.report} % this will become default +\writestatus\m!system{beware: some patches loaded from cont-new.mkiv} + + +\def\fastscale#1% + {\begingroup + \ifnum#1=1000\relax + \setfalse\scaleboxdone + \else + \settrue\scaleboxdone + \edef\finalscaleboxxscale{\withoutpt\the\dimexpr#1pt/1000\relax}% + \let\finalscaleboxyscale\finalscaleboxxscale + \fi + \dowithnextbox{\doscaleboxindeed\flushnextbox\endgroup}\hbox} + +% \setupcaption [figure] [align=flushleft] +% \setupcaption [figure-1] [align=flushleft,leftmargin=10mm] +% \setupcaption [figure-2] [align=flushleft,leftmargin=10mm,rightmargin=-10mm,width=\textwidth] +% +% \startsetups somefigure +% \ifdim\floatsetupwidth>\textwidth +% \placesetupfloat[figure-2] +% \else +% \placesetupfloat[figure-1] +% \fi +% \stopsetups +% +% \placefloatwithsetups[somefigure]{}{\externalfigure[dummy][width=5cm,height=2cm]} + +\def\placefloatwithsetups + {\dotripleempty\doplacefloatwithsetups} + +\long\def\doplacefloatwithsetups[#1][#2][#3]#4% + {\def\floatsetupcaption {#4}% + \def\floatsetupcontent {\copy\nextbox}% + \def\floatsetupwidth {\wd\nextbox}% + \def\floatsetupheight {\ht\nextbox}% + \def\placesetupfloat[##1]{\placefloat[##1][#2][#3]{#4}{\floatsetupcontent}}% #4 and not \floatsetupcaption (unexpanded) + \dowithnextbox{\setups[#1]}\vbox} + +\def\dividedsize#1#2#3% size gap n + {\dimexpr + \ifnum\dimexpr#1\relax>\plusone + (\dimexpr#1\relax-\numexpr#3-1\relax\dimexpr#2\relax)/#3\else#1% + \fi + \relax} + +\def\singlewidened #1{\hbox spread 1em{\hss#1\hss}} +\def\complexwidened[#1]#2{\hbox spread #1{\hss#2\hss}} + +\definecomplexorsimple\widened + +% todo +% +% \def\definelocation{\dodoubleargument\dodefinelocation} +% \def\dodefinelocation[#1][#2]{\setvalue{loc:#1}{#2}} +% +% \definelocation[lt] [\v!left\v!top] +% \definelocation[tl] [\v!left\v!top] +% \definelocation[\v!top\v!left][\v!left\v!top] +% +% \def\getlocation#1{\executeifdefined{loc:#1}{#1}} + +% \let\cs\getvalue % no, we want \cs to be czech + +% experimental so this may change + +\def\startdescriptions + {\dosingleempty\dostartdescriptions} + +\def\dostartdescriptions[#1]% + {\begingroup + \def\item{\getvalue{#1}}% + \let\dostoppairdescription \donothing + \let\@@description \dostartpairdescription + \let\@@startsomedescription\dostartsomedescription} + +\def\stopdescriptions + {\dostoppairdescription + \endgroup} + +\def\dostartpairdescription[#1][#2]% + {\dostoppairdescription + \def\dostoppairdescription{\@@stopdescription{#1}}% + \bgroup + \def\currentdescription{#1}% + \doifelse{\descriptionparameter{\s!do\c!state}}\v!start + {\@@makedescription{#1}[#2]{}} + {\@@makedescription{#1}[#2]}} + +\def\dostartsomedescription% #1[#2]#3% + {\bgroup + \@@makedescription} % {#1}[#2]{#3}} + +% \starttext +% +% \definedescription[test] +% +% \startdescriptions +% \test{Foo} Bar bar bar +% \test{Foo} Bar bar bar +% \test{Foo} Bar bar bar +% \stopdescriptions +% +% \startdescriptions[test] +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \stopdescriptions +% +% \startdescriptions +% \starttest{Foo} Bar bar bar \stoptest +% \starttest{Foo} Bar bar bar \stoptest +% \starttest{Foo} Bar bar bar \stoptest +% \stopdescriptions +% +% \startdescriptions[test] +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \stopdescriptions +% +% \stoptext + +% this will be activated when +% +% \newinsert\thispageinsert % <- installinsertion +% +% \def\flushatthispage +% {\bgroup +% \dowithnextbox{\insert\thispageinsert{\box\nextbox}\egroup}% +% \hbox} +% +% \appendtoks +% \ifvoid\thispageinsert\else\hbox{\smashedbox\thispageinsert}\fi +% \to \everyshipout + +% \definemarkedpage[nobackgrounds] +% \markpage[nobackgrounds] +% \doifmarkedpageelse{nobackgrounds} + +% Just a simple and fast hanger, for usage in macros. + +\def\setuphanging + {\dodoubleempty\getparameters[\??ha]} + +\setuphanging + [\c!distance=.5em] + +\def\starthanging + {\noindent\bgroup + \dowithnextbox + {\setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}% + \hangindent\nextboxwd + \hangafter\plusone + \flushnextbox\ignorespaces} + \hbox} + +\def\stophanging + {\endgraf + \egroup} + +% experimental + +\def\stophangaround + {\endgraf + \egroup} + +\def\starthangaround + {\noindent\bgroup + \dowithnextbox + {\ifdim\nextboxht>\strutht\setbox\nextbox\tbox{\flushnextbox}\fi + \setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}% + \getboxheight\scratchdimen\of\box\nextbox + \getnoflines\scratchdimen + \nextboxht\strutht + \nextboxdp\strutdp + \hangindent\nextboxwd + \hangafter-\noflines + \llap{\flushnextbox}\ignorespaces} + \hbox} + +\def\modevalue#1#2#3% + {\@EA\ifx\csname\@mode@\systemmodeprefix#1\endcsname\endcsname\enabledmode#2\else#2\fi} + +\def\systemmodevalue#1% + {\modevalue{\systemmodeprefix#1}} + +% new, still to be improved +% +% \dorecurse{10} +% {\input thuan +% \placefigure{}{\framed[height=1.5cm]{test}} +% \placefloatplaceholder} + +\def\placefloatplaceholder + {\ifroomforfloat \else + \scratchdimen\pagegoal + \advance\scratchdimen-\pagetotal + \advance\scratchdimen-3\lineheight + \ifdim\scratchdimen>\zeropoint + \startlinecorrection[blank] + \mhbox{\inframed{\labeltexts{placeholder}{\lastcaptiontag}}}% + \stoplinecorrection + \else + \allowbreak + \fi + \fi} + +\setuplabeltext + [placeholder={, moved}] + +\startluacode + function commands.percentageof(str,dim) + local n = str:match("^(.*)%%$") + tex.sprint(tex.ctxcatcodes,(n and (tonumber(n)/100)*dim .. "sp") or str) + end +\stopluacode + +\gdef\setpercentdimen#1#2% + {#1=\ctxcommand{percentageof("#2",\number#1)}\relax} + +% \scratchdimen=100pt \setpercentdimen\scratchdimen{10\letterpercent} \the\scratchdimen +% \scratchdimen=100pt \setpercentdimen\scratchdimen{5pt} \the\scratchdimen + +\bgroup \permitcircumflexescape -\def\immediatemessage#1{\ctxlua{commands.writestatus("message","#1")}} +\obeylines % don't remove %'s ! -% we need to figure this out (to be discussed) +\gdef\collapsedspace#1% + {\ifx#1^^M% + \expandafter\collapsedspace + \else + \space + \expandafter#1% + \fi} -\unexpanded\def\textminus - {\char \iffontchar\font"2012 "2012 % figuredash - \else\iffontchar\font"2013 "2013 % endash - \else\iffontchar\font"2212 "2212 % math minus - "002D % hyphen - \fi\fi\fi} +\gdef\collapsespaces + {\prependtoksonce\relax\to\everyeof% + \ignorelines% + \ignoretabs% + \let\obeyedspace\collapsedspace% + \obeyspaces} -\unexpanded\def\textplus - {\char"002B } % plus +\egroup + +\def\inlinedbox + {\bgroup + \dowithnextbox + {\scratchdimen\nextboxht + \advance\scratchdimen\nextboxdp + \advance\scratchdimen-\lineheight + \divide\scratchdimen\plustwo + \advance\scratchdimen\strutdepth + \setbox\nextbox\hbox{\lower\scratchdimen\flushnextbox}% + \nextboxht\strutht + \nextboxdp\strutdp + \flushnextbox + \egroup}% + \hbox} + +\def\dimenratio#1#2% etex only + {\withoutpt\the\dimexpr2\dimexpr(#1)/\dimexpr(#2)/32768\relax\relax} + +\def\doxprecurse#1#2% + {\ifnum#1=\zerocount % no \ifcase + \expandafter\gobblethreearguments + \else + #2\expandafter\expandafter\expandafter\doxprecurse\expandafter + \fi\expandafter{\the\numexpr#1-1\relax}{#2}} + +\def\buttonframed{\dodoubleempty\localframed[\??bt]} % goodie + +\unexpanded\def\asciistr#1{\dontleavehmode{\defconvertedargument\ascii{#1}\verbatimfont\ascii}} + +\def\shapefill{\vskip\zeropoint\!!plus\lineheight\!!minus\lineheight\relax} + +% \ruledhbox +% {\startignorespaces +% \def\oeps{a} +% \startignorespaces +% \def\oeps{a} +% \stopignorespaces +% \def\oeps{a} +% \stopignorespaces +% \oeps} + +\newsignal\boissignal +\newcount \boislevel + +\long\def\startignorespaces + {\advance\boislevel\plusone + \ifcase\boislevel\or \ifhmode + \hskip\boissignal + \fi \fi + \ignorespaces} + +\long\def\stopignorespaces + {\ifcase\boislevel\or \ifhmode + \doloop + {\ifdim\lastskip=\zeropoint + \exitloop + \else\ifdim\lastskip=\boissignal + \unskip + \exitloop + \else + \unskip + \fi\fi}% + \fi \fi + \advance\boislevel\minusone} + +\def\minimalhbox#1#% + {\dowithnextbox + {\bgroup + \setbox\scratchbox\hbox#1{\hss}% + \ifdim\nextboxwd<\wd\scratchbox\nextboxwd\wd\scratchbox\fi + \flushnextbox + \egroup} + \hbox} + +\def\gobbleuntilempty#1\empty{} + +\def\dodimchoice#1#2#3% + {\ifdim#1#2% + #3\@EA\gobbleuntilempty + \else + \@EA\dodimchoice + \fi{#1}} + +\def\donumchoice#1#2#3% + {\ifnum#1#2% + #3\@EA\gobbleuntilempty + \else + \@EA\dodimchoice + \fi{#1}} + +\def\dimchoice#1#2{\dodimchoice{#1}#2{=#1}{#1}\empty} +\def\numchoice#1#2{\donumchoice{#1}#2{=#1}{#1}\empty} + +% \the\dimexpr(\dimchoice {7pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) +% \the\dimexpr(\dimchoice{11pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) +% \the\dimexpr(\dimchoice{14pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) + +\def\showsetupsdefinition[#1]{\showvalue{\??su:#1}} % temp hack for debugging + +\def\tabulaterule % to be redone, not correct + {\dotabulaterule + {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax + \doifvalue{\??tt\currenttabulate\c!distance}\v!grid + {\kern-\scratchdimen}}} % experimental tm-prikkels +% so far + +% between alignment lines certain rules apply, and even a +% simple test can mess up a table, which is why we have a +% special test facility +% +% \ruledvbox +% {\starttabulate[|l|p|] +% \NC 1test \NC test \NC \NR +% \tableifelse{\doifelse{a}{a}}{\NC Xtest \NC test \NC \NR}{}% +% \stoptabulate} + +\long\def\tableifelse#1% + {\tablenoalign + {#1% + {\aftergroup \firstoftwoarguments}% + {\aftergroup\secondoftwoarguments}}} + +\long \def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}} + +\def\tightvbox{\dowithnextbox{\nextboxdp\zeropoint\flushnextbox}\vbox} +\def\tightvtop{\dowithnextbox{\nextboxht\zeropoint\flushnextbox}\vtop} + +% what is this stupid macro meant for: + +\def\hyphenationpoint + {\hskip\zeropoint} + +\def\hyphenated#1% + {\bgroup + \!!counta\zerocount + \def\hyphenated##1{\advance\!!counta\plusone}% + \handletokens#1\with\hyphenated + \!!countb\plusone + \def\hyphenated##1% + {##1% + \advance\!!countb\plusone\relax + \ifnum\!!countb>2 \ifnum\!!countb<\!!counta + \hyphenationpoint + \fi\fi}% + \handletokens#1\with\hyphenated + \egroup} + +\def\obeysupersubletters + {\let\super\normalsuper + \let\suber\normalsuber + \let\normalsuper\letterhat + \let\normalsuber\letterunderscore + \enablesupersub} + +\def\obeysupersubmath + {\let\normalsuper\letterhat + \let\normalsuber\letterunderscore + \enablesupersub} + +\def\startgridcorrection + {\dosingleempty\dostartgridcorrection} + +\def\dostartgridcorrection[#1]% + {\ifgridsnapping + \iffirstargument\doifsomething{#1}{\moveongrid[#1]}\fi + \snaptogrid\vbox\bgroup + \else + \startbaselinecorrection + \fi} + +\def\stopgridcorrection + {\ifgridsnapping + \egroup + \else + \stopbaselinecorrection + \fi} + +\def\checkgridsnapping + {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi} + +\def\startplaatsen + {\dosingleempty\dostartplaatsen} + +\def\dostartplaatsen[#1]% tzt n*links etc + {\endgraf + \noindent\bgroup + \setlocalhsize + \hbox to \localhsize\bgroup + \doifnot{#1}\v!left\hss + \def\stopplaatsen + {\unskip\unskip\unskip + \doifnot{#1}\v!right\hss + \egroup + \egroup + \endgraf}% + \gobblespacetokens} + +% \startplaatsen[links] bla \stopplaatsen + +% we don't register the paragraph characteristics, only the +% width + +\appendtoks + \setinnerparpositions % see "techniek" for application +\to \everytabulate + +\def\fontclassname#1#2% + {\ifcsname\??ff#1#2\endcsname + \fontclassname{#1}{\csname\??ff#1#2\endcsname}% + \else\ifcsname\??ff#2\endcsname + \fontclassname{#1}{\csname\??ff#2\endcsname}% + \else + #2% + \fi\fi} + +\def\defineclassfontsynonym + {\dotripleargument\dodefineclassfontsynonym} + +\def\dodefineclassfontsynonym[#1][#2][#3]% + {\definefontsynonym[#1][\fontclassname{#2}{#3}]} + +%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}] +% +%\defineclassfontsynonym [KopFont] [officina] [SerifBold] + +\def\startcolumnmakeup % don't change + {\bgroup + \getrawnoflines\textheight % teksthoogte kan topskip hebben, dus raw + \scratchdimen\noflines\lineheight + \advance\scratchdimen-\lineheight + \advance\scratchdimen\topskip + \setbox\scratchbox + \ifcase\showgridstate\vbox\else\ruledvbox\fi to \scratchdimen\bgroup + \forgetall} % ! don't change + +\def\stopcolumnmakeup + {\egroup + \dp\scratchbox\zeropoint + \wd\scratchbox\textwidth + \box\scratchbox + \egroup + \synchronizehsize} + +\long\def\startexternalfigure + {\dotripleempty\dostartexternalfigure} + +\long\def\dostartexternalfigure[#1][#2][#3]#4\stopexternalfigure + {\gdef\figuredescription{#4}% + \externalfigure[#1][#2][#3]% + \globallet\figuredescription\empty} + +\let\figuredescription\empty + +% incomplete, will be a special case of float placement + +\def\startfixed{\dosingleempty\dostartfixed} + +\def\dostartfixed[#1]% + {\expanded{\dowithnextbox{\noexpand\dodofixed{\ifhmode0\else1\fi}{#1}}}% + \vbox\bgroup + \setlocalhsize} + +\def\stopfixed + {\egroup} + +\def\dodofixed#1#2% + {\ifcase#1\relax + \processaction + [#2] + [ \v!high=>\bbox {\flushnextbox}, + \v!low=>\tbox {\flushnextbox}, + \v!middle=>\vcenter{\flushnextbox}, + \v!lohi=>\vcenter{\flushnextbox}, + \s!unknown=>\tbox {\flushnextbox}, + \s!default=>\tbox {\flushnextbox}]% + \else + \startbaselinecorrection + \noindent\flushnextbox + \stopbaselinecorrection + \fi} + +% \startitemize +% +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% +% \page +% +% \item \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \page +% +% \item test \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \page +% +% \item test \par \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \stopitemize + +\def\obeyfollowingtoken{{}} % end \cs scanning + +% potential new defaults: +% +% \setbreakpoints[compound] -% till we fixed all styles +% till we fixed all styles: \let\\=\crlf |