diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-itm.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-itm.mkiv | 163 |
1 files changed, 103 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-itm.mkiv b/Master/texmf-dist/tex/context/base/strc-itm.mkiv index 7207494ed49..67f42f86672 100644 --- a/Master/texmf-dist/tex/context/base/strc-itm.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-itm.mkiv @@ -15,6 +15,9 @@ \registerctxluafile{strc-itm}{1.001} +% this will be reimplemented: \startitem ... \stopitem will be the main macros and +% \item will then call them + \unprotect \newconditional\sublistitem \setfalse\sublistitem @@ -43,7 +46,7 @@ \newcount\noflistelements \newcount\itemcolumndepth \newcount\itemdepth -\newcount\maxitemdepth \maxitemdepth=6 +% \newcount\maxitemdepth \maxitemdepth=6 \newdimen\itemgrouplistwidth \newdimen\itemgroupaskedwidth @@ -59,19 +62,20 @@ \def\dolistreference {\iftrialtypesetting \else % no need for different treatment of \continuelistitems - \ctxlua{structure.itemgroups.register("\currentitemgroup",\number\noflistelements,"\getitemparameter\currentitemlevel\c!maxwidth")}% + \ctxlua{structures.itemgroups.register("\currentitemgroup",\number\noflistelements,"\getitemparameter\currentitemlevel\c!maxwidth")}% \fi} \def\checkcurrentnofitems % we could do this at the lua end and save a call - {\edef\currentnofitems {\ctxlua{structure.itemgroups.nofitems("\currentitemgroup",\number\currentnoflists)}}% - \edef\currentitemmaxwidth{\ctxlua{structure.itemgroups.maxwidth("\currentitemgroup",\number\currentnoflists)}\scaledpoint}} + {\edef\currentnofitems {\ctxlua{structures.itemgroups.nofitems("\currentitemgroup",\number\currentnoflists)}}% + \edef\currentitemmaxwidth{\ctxlua{structures.itemgroups.maxwidth("\currentitemgroup",\number\currentnoflists)}\scaledpoint}} % todo: \dodosetreference -> \dostructurecountercomponent (to be checked) \def\dohandleitemreference % we will make a decent number helper {\ifx\currentitemreference \empty \else +\iftrialtypesetting \else \setnextinternalreference - \ctxlua { jobreferences.setandgetattribute("\s!full", "\referenceprefix","\currentitemreference", + \ctxlua {structures.references.setandgetattribute("\s!full", "\referenceprefix","\currentitemreference", { metadata = { kind = "item",% ? @@ -80,9 +84,9 @@ }, references = { internal = \nextinternalreference, - section = structure.sections.currentid(), + section = structures.sections.currentid(), }, - prefixdata = structure.helpers.simplify { + prefixdata = structures.helpers.simplify { prefix = "\structurecounterparameter\currentitemgroupcounter\c!prefix", separatorset = "\structurecounterparameter\currentitemgroupcounter\c!prefixseparatorset", conversion = \!!bs\structurecounterparameter\currentitemgroupcounter\c!prefixconversion\!!es, @@ -92,8 +96,8 @@ % segments = "\askedprefixsegments", connector = \!!bs\structurecounterparameter\currentitemgroupcounter\c!prefixconnector\!!es, }, - numberdata = structure.helpers.simplify { - numbers = structure.counters.compact("\currentitemgroupcounter",nil,true), + numberdata = structures.helpers.simplify { + numbers = structures.counters.compact("\currentitemgroupcounter",nil,true), separatorset = "\structurecounterparameter\currentitemgroupcounter\c!numberseparatorset", conversion = "\structurecounterparameter\currentitemgroupcounter\c!numberconversion", conversionset = "\structurecounterparameter\currentitemgroupcounter\c!numberconversionset", @@ -104,10 +108,10 @@ }) }% \xdef\currentitemattribute{\number\lastdestinationattribute}% - \begingroup\attribute\destinationattribute\currentitemattribute\kern\zeropoint\endgroup % todo + \begingroup\attribute\destinationattribute\currentitemattribute\kern\zeropoint\endgroup % todo, apply attribute to symbol +\fi \fi} - % \startitemize[n,packed] % \item test \item test \item test % \stopitemize @@ -198,10 +202,11 @@ % so we have: \def\initializeitemgrouplevel#1% - {\ifcsname\??op\currentitemgroup#1\s!parent\endcsname + {\ifcsname\??op\currentitemgroup\number#1\s!parent\endcsname % ok \else - \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup}% + \setxvalue{\??op\currentitemgroup \c!levels}{\number#1}% + \setxvalue{\??op\currentitemgroup\number#1\s!parent}{\??op\currentitemgroup}% \fi} \unexpanded\def\defineitemgroup @@ -211,15 +216,15 @@ {\doifsomething{#1} {\pushmacro\currentitemgroup \def\currentitemgroup{#1}% - \setvalue{\e!start#1}{\startitemgroup[#1]}% - \setvalue{\e!stop#1}{\stopitemgroup}% - \setvalue{\e!setup#1\e!endsetup}{\setupitemgroup[#1]}% for old times sake + \setuvalue{\e!start#1}{\startitemgroup[#1]}% + \setuvalue{\e!stop#1}{\stopitemgroup}% + \setuvalue{\e!setup#1\e!endsetup}{\setupitemgroup[#1]}% for old times sake \doifelsenothing{#2} {\getparameters[\??op#1][\s!parent=\??oo,#3]}% {\doifassignmentelse{#2} {\getparameters[\??op#1][\s!parent=\??oo,#2]}% {\getparameters[\??op#1][\s!parent=\??op#2,#3]}}% - \dorecurse\maxitemdepth{\initializeitemgrouplevel\recurselevel}% + \dorecurse{\itemparameter\empty\c!levels}{\initializeitemgrouplevel\recurselevel}% \definestructurecounter[itemgroup:#1]% \popmacro\currentitemgroup}} @@ -310,10 +315,13 @@ % \empty \else \getitemparameter\currentitemlevel\c!before - \fi\fi} + \fi\fi + \dostarttagged\t!itemgroup\currentitemgroup + \dotagsetitemize} \def\itemaftercommand - {\ifconditional\nowhitelistitem + {\dostoptagged + \ifconditional\nowhitelistitem \ifconditional\afterlistitem \ifcase\currentitemlevel\or\getitemparameter\currentitemlevel\c!after\fi \else @@ -352,7 +360,7 @@ \getitemparameter\currentitemlevel\c!afterhead \fi\fi} -\def\dododododosetupitemgroup[#1][#2]% +\unexpanded\def\dododododosetupitemgroup[#1][#2]% prevent expansion below {\doifassignmentelse{#2}% {\dosetupitemgroupvariable[#1][#2]}% {\setitemparameter{#1}\c!option{#2}}}% @@ -360,19 +368,8 @@ \def\dodododosetupitemgroup[#1][#2]% {\doifsomething{#2} {\doifelse{#1}\v!each - {\dorecurse\maxitemdepth{\normalexpanded{\noexpand\dododododosetupitemgroup[\recurselevel]}[#2]}} - {\normalexpanded{\noexpand\dododododosetupitemgroup[#1]}[#2]}}} - -% \def\dododosetupitemgroup[#1][#2]% -% {\doifelsenothing{#2} -% {\doifelsenothing{#1} -% {\dodododosetupitemgroup[\currentitemlevel][#2]} -% {\dodododosetupitemgroup[#1][#2]}} -% {\ifcase\currentitemlevel\relax -% \dodododosetupitemgroup[\v!each][#1]% -% \else -% \dodododosetupitemgroup[\currentitemlevel][#1]% -% \fi}} + {\dorecurse{\itemparameter\empty\c!levels}{\normalexpanded{\dododododosetupitemgroup[\recurselevel]}[#2]}} + {\normalexpanded{\dododododosetupitemgroup[#1]}[#2]}}} \def\dododosetupitemgroup[#1][#2]% {\doifelsenothing{#2} @@ -531,13 +528,8 @@ \def\dodostartitemgroup[#1]% [#2]% {\relax % prevents lookahead - \ifnum\currentitemlevel=\maxitemdepth\relax - \showmessage\m!layouts9{\number\maxitemdepth}% - \let\itemincrement\zerocount - \else - \let\itemincrement\plusone - \fi - \global\advance\itemdepth\itemincrement + \global\advance\itemdepth\plusone + \initializeitemgrouplevel\itemdepth \xdef\currentitemlevel{\number\itemdepth}% \edef\itemgroupoptions{\getitemparameter\currentitemlevel\c!option}% \ifx\itemgroupoptions\empty @@ -575,7 +567,7 @@ \@EA\long\@EA\def\@EA\collectitemgroupitem\@EA#\@EA1\csname\e!stop\v!item\endcsname {\increment\itemcollectcounter - \long\setvalue{\v!item*\itemcollectcounter}{\item#1\par}} + \long\setvalue{\v!item*\itemcollectcounter}{\startitemgroupitem#1\stopitemgroupitem}} \def\flushcollecteditems {\ifconditional\randomizeitems @@ -622,6 +614,8 @@ \let\currentitemindenting\empty +\let\dotagsetitemize\relax + \def\redostartitemgroup[#1][#2]% {\setfalse\inlinelistitem % new, no indent (leftskip) \setfalse\concatnextitem % new, concat @@ -649,6 +643,9 @@ \doifinsetelse\v!random {#1}{\settrue\randomizeitems }{\setfalse\randomizeitems }% \doifinsetelse\v!continue{#1}{\settrue\continuelistitems}{\setfalse\continuelistitems}% % == \doifinsetelse\v!intro{#1}\settrue\setfalse\introlistitem +\iftrialtypesetting + \savestructurecounter[\currentitemgroupcounter]%[\currentitemlevel]% todo: per level +\fi \global\advance\noflists\plusone \currentnoflists\noflists \noflistelements\zerocount @@ -761,6 +758,11 @@ % \item \input ward \item \input ward \item \input ward % \stopitemize \blank +\def\dorestoreitemgroup + {\restorestructurecounter[\currentitemgroupcounter]% [\currentitemlevel]% todo: per level + \global\advance\noflists\minusone + \currentnoflists\noflists} + \unexpanded\def\stopitemgroup {\stopcollectitems \ifconditional\textlistitem @@ -769,7 +771,12 @@ \par \fi \dolistreference - \ifconditional\firstlistitem \else \endgroup \fi % toegevoegd, eerste \som opent groep + \ifconditional\firstlistitem + \else + \dostoptagged + \dostoptagged + \endgroup + \fi % toegevoegd, eerste \som opent groep \ifnum\itemcolumndepth=\currentitemlevel\relax \stopcolumns \global\itemcolumndepth\zerocount @@ -791,14 +798,17 @@ \fi \fi % new test, needed in sidefloats (surfaced in volker's proceedings) +\iftrialtypesetting + \dorestoreitemgroup +\fi \ifconditional\textlistitem % else forgotten \endgroup - \global\advance\itemdepth-\itemincrement + \global\advance\itemdepth-\plusone \xdef\currentitemlevel{\number\itemdepth}% \egroup \else \endgroup - \global\advance\itemdepth-\itemincrement + \global\advance\itemdepth-\plusone \xdef\currentitemlevel{\number\itemdepth}% \egroup \par @@ -889,14 +899,33 @@ % % so we need to keep that property +\let\startitemgroupitem\itemgroupitem + +\def\stopitemgroupitem + {\ifconditional\textlistitem + % nothing + \else + \endgraf + \fi} + +\def\startitemgroupitemhead#1% + {\itemgrouphead#1\par} + +\def\stopitemgroupitemhead + {\ifconditional\textlistitem + % to be tested + \else + \endgraf + \fi} + \appendtoks - \letvalue{\e!start\v!item}\itemgroupitem - \letvalue{\e!stop \v!item}\endgraf + \letvalue{\e!start\v!item}\startitemgroupitem + \letvalue{\e!stop \v!item}\stopitemgroupitem \to \itemgroupcommands \appendtoks - \setvalue{\e!start\v!head}#1{\itemgrouphead#1\par}% - \letvalue{\e!stop \v!head}\endgraf + \letvalue{\e!start\v!head}\startitemgroupitemhead + \letvalue{\e!stop \v!head}\stopitemgroupitemhead \to \itemgroupcommands % \startitemize @@ -1043,15 +1072,15 @@ \fi \ifdim\currentitemmaxwidth>\zeropoint \setbox\itemgroupitembox\simplealignedbox - {\getitemparameter\currentitemlevel\c!itemalign} {\dimexpr\currentitemmaxwidth+\getitemparameter\currentitemlevel\c!distance\relax} + {\getitemparameter\currentitemlevel\c!itemalign} {\box\itemgroupitembox\hskip\getitemparameter\currentitemlevel\c!distance}% \fi \else\ifdim\itemgroupaskedwidth>\zeropoint \doifsomething{\getitemparameter\currentitemlevel\c!itemalign} {\setbox\itemgroupitembox\simplealignedbox - {\getitemparameter\currentitemlevel\c!itemalign} {\dimexpr\itemgroupaskedwidth+\getitemparameter\currentitemlevel\c!distance\relax} + {\getitemparameter\currentitemlevel\c!itemalign} {\box\itemgroupitembox\hskip\getitemparameter\currentitemlevel\c!distance}}% \fi\fi \globallet\doitemdestination\empty @@ -1140,7 +1169,10 @@ % \setupitemize[each][atmargin][width=3em] % \startitemize[n,repeat,packed] \getbuffer \stopitemize -\chardef\autoitemgroupspacing=2 % 0 = voor/na, 1=tussen als geen voor 2=(prev)tussen=old/normal +\setnewconstant\autoitemgroupspacing\plustwo % 0 = voor/na, 1=tussen als geen voor 2=(prev)tussen=old/normal + +% todo: assume startitem ... stopitem and do an autostopitem .. cleaner for +% elements \def\complexdoitemgroupitem[#1]% {\def\currentitemreference{#1}% @@ -1176,6 +1208,8 @@ \fi \fi \else +\dostoptagged +\dostoptagged \ifconditional\textlistitem % was bugged: \inlinelistitem \ifhmode % WS: make the distance between items customizable, think about better default values -> see itemize-1.tex @@ -1190,7 +1224,10 @@ \vskip-\dimexpr\lastskip+\lineheight\relax \nobreak \fi +\dostarttagged\t!item\empty +\dostarttagged\t!itemtag\empty \dolistitem +\dostoptagged \relax \ifconditional\packlistitem \setupwhitespace[\v!none]% @@ -1198,6 +1235,7 @@ \getitemparameter\currentitemlevel\c!inner \marsymbol \let\marsymbol\relax +\dostarttagged\t!itemcontent\empty \strut % added 11-08-99 \setfalse\concatnextitem % new, concat \nobreak % else problems with intext items @@ -1242,19 +1280,23 @@ % \item {test} is this okay? % \stopitemize -\def\complexitem[#1]#2\par % todo: no two pass data - {\startitemgroup[#1]% - \complexdoitemgroupitem[]\begstrut#2\endstrut\par +% \def\complexitem[#1]#2\par % todo: no two pass data +% {\startitemgroup[#1]% +% \complexdoitemgroupitem[]\begstrut#2\endstrut\par +% \stopitemgroup} + +\def\complexitem[#1]#2\par + {\doifsomethingelse{#1}{\startitemgroup[#1]}{\startitemgroup[\v!itemize]}% + \startitem#2\stopitem \stopitemgroup} +\setvalue{\e!start\v!item}% + {\startitemgroup[\v!itemize]\startitem + \setvalue{\e!stop \v!item}{\endgraf\stopitemgroup}} % inside, else overloaded + \definecomplexorsimpleempty\item \definecomplexorsimpleempty\doitemgroupitem -\def\complexhead[#1]#2\par#3\par - {\startitemgroup[#1]% - \complexdoitemgrouphead[]\begstrut#2\endstrut\par\begstrut#3\endstrut\par - \stopitemgroup} - % the next solution accepts \head test \type{x{x}x} test ... \let\doenditemhead\relax @@ -1291,7 +1333,7 @@ \def\sym#1% {\noindent \begingroup - \setbox\scratchbox\hbox{\trialtypesettingtrue#1}% + \setbox\scratchbox\hbox{\settrialtypesetting#1}% \setbox\scratchbox\hbox \ifdim\wd\scratchbox<1em to 1.5\else spread 1\fi em{#1\hfil}% \normalexpanded{\box\scratchbox\endgroup\hangindent\the\wd\scratchbox}% @@ -1328,6 +1370,7 @@ %\c!inner=, \c!n=2, \c!items=4, + \c!levels=10, \c!lefttext=(, \c!righttext=), \c!start=1, |