\writestatus{loading}{Context Core Macros / Itemgroups}
\startmessages dutch library: layouts
9: momenteel maximaal -- niveaus in opsommingen
\stopmessages
\startmessages english library: layouts
9: currently no more than -- levels in itemizations
\stopmessages
\startmessages german library: layouts
9: z.Z. nicht mehr als -- Ebenen in Aufzaehlungen
\stopmessages
\startmessages czech library: layouts
9: aktualne ne vice nez -- urovne/urovni vyctu
\stopmessages
\startmessages italian library: layouts
9: attualmente non più di -- livelli di elencazione
\stopmessages
\startmessages norwegian library: layouts
9: for øyeblikket maksimalt -- nivåer i opplisting
\stopmessages
\startmessages romanian library: layouts
9: acum nu se supota mai mult de -- nivele de adancime la iteratii
\stopmessages
\startmessages french library: layouts
9: pas plus de -- niveaux pour l'instant dans les élémentarisations
\stopmessages
\unprotect
\newconditional\sublistitem \setfalse\sublistitem
\newconditional\symbollistitem \setfalse\symbollistitem
\newconditional\headlistitem \setfalse\headlistitem
\newconditional\introlistitem \setfalse\introlistitem
\newconditional\randomizeitems \setfalse\randomizeitems
\newconditional\autointrolistitem \setfalse\autointrolistitem
\newconditional\optimizelistitem \settrue \optimizelistitem
\newconditional\packlistitem \setfalse\packlistitem
\newconditional\paragraphlistitem \setfalse\paragraphlistitem
\newconditional\textlistitem \setfalse\textlistitem
\newconditional\firstlistitem \setfalse\firstlistitem
\newconditional\beforelistitem \setfalse\beforelistitem
\newconditional\afterlistitem \setfalse\afterlistitem
\newconditional\nowhitelistitem \setfalse\nowhitelistitem
\newconditional\joinedlistitem \setfalse\joinedwhitelistitem
\newconditional\reverselistitem \setfalse\reverselistitem
\newconditional\continuelistitems \setfalse\continuelistitems
\newconditional\fittinglistitems \setfalse\fittinglistitems
\newcount\noflists
\newcount\currentnoflists
\newcount\itemcolumndepth
\newcount\itemdepth
\newcount\maxitemdepth
\definetwopasslist\s!list
\let\currentitemlevel \!!zerocount
\let\currentitemgroup \empty
\let\currentnofitems \!!zerocount
\let\currentmaxnofitems\!!zerocount
\let\currentminnofitems\!!zerocount
\let\currentitemoffset \!!zerocount
\def\currentitemnumber{\countervalue{\@@itemcounter\currentitemlevel}}
\def\dolistreference
{\ifconditional\continuelistitems
\savetaggedtwopassdata\s!list{\number\currentnoflists}{\number\currentnoflists}
{\currentitemlevel:\noflistelements:c:\getitemparameter\currentitemlevel\c!maxwidth}
\else
\savetaggedtwopassdata\s!list{\number\currentnoflists}{\number\currentnoflists}
{\currentitemlevel:\noflistelements:n:\getitemparameter\currentitemlevel\c!maxwidth}
\fi}
\def\splititemtwopassdata#1
{\expanded{\findtwopassdata{\s!list}{\number#1}}
\expandafter\dosplititemtwopassdata\twopassdata:0:0:0:0:0\relax}
\def\dosplititemtwopassdata#1:#2:#3:#4:#5\relax
{\edef\itemdatal{#1}\edef\itemdatan{#2}\edef\itemdatat{#3}\edef\itemdataw{#4}}
\def\checkcurrentnofitems
{\splititemtwopassdata\currentnoflists
\iftwopassdatafound
\ifcase\itemdatan\relax
\let\currentnofitems \!!zerocount
\let\currentminnofitems\!!plusone
\let\currentmaxnofitems\!!zerocount
\else
\scratchcounter\itemdatan\relax
\edef\currentnofitems{\the\scratchcounter}
\let\currentitemtag\itemdatat
\doloop
{\splititemtwopassdata{\numexpr\currentnoflists+\recurselevel\relax}
\iftwopassdatafound
\ifnum\itemdatal=\currentitemlevel\relax
\doifelse{c}\itemdatat
{\advance\scratchcounter\itemdatan\relax}
{\exitloop}
\fi
\else
\exitloop
\fi}
\edef\currentmaxnofitems{\the\scratchcounter}
\scratchcounter\zerocount
\doif{c}\currentitemtag
{\doloop
{\splititemtwopassdata{\numexpr\currentnoflists-\recurselevel\relax}
\iftwopassdatafound
\ifnum\itemdatal=\currentitemlevel\relax
\doifelse{c}\itemdatat
{\advance\scratchcounter\itemdatan\relax}
{\advance\scratchcounter\itemdatan\exitloop}
\fi
\else
\exitloop
\fi}}
\advance\scratchcounter\plusone
\edef\currentminnofitems{\the\scratchcounter}
\fi
\else
\let\currentnofitems \!!zerocount
\let\currentminnofitems\!!plusone
\let\currentmaxnofitems\!!zerocount
\fi}
\def\unknownitemreference{0} \let\itemreferences\unknownitemreference
\def\getitemparameter #1#2{\csname\??op\currentitemgroup#1#2\endcsname}
\def\setitemparameter #1#2{\@EA\def\csname\??op\currentitemgroup#1#2\endcsname}
\def\letitemparameter #1#2{\@EA\let\csname\??op\currentitemgroup#1#2\endcsname}
\def\getitemparameter#1#2
{\executeifdefined{\??op\currentitemgroup#1#2}
{\executeifdefined{\??op\currentitemgroup #2}
{\executeifdefined{\??oo #2}
{}}}}
\def\doitemattributes #1{\doattributes{\??op\currentitemgroup#1}}
\def\@@globalitemsymbol #1{\??op\currentitemgroup\c!symbol\s!global#1}
\def\@@localitemsymbol #1{\??op\currentitemgroup\c!symbol\s!local #1}
\def\@@currentitemsymbol#1{\??op\currentitemgroup\c!symbol #1}
\def\@@itemcounter{\s!itemcount\currentitemgroup}
\def\doitembreak#1{\ifconditional\optimizelistitem\ifconditional\textlistitem\else\dosomebreak#1\fi\fi}
\def\initializeitemgroupslevel#1
{\ifundefined{\@@globalitemsymbol{#1}}
\edef\itemreferences{\itemreferences,#1}
\makecounter{\@@itemcounter#1}
\setevalue{\@@globalitemsymbol{#1}}{#1}
\fi}
\def\initializeitemgrouplevel#1
{\ifundefined{\??op\currentitemgroup#1\c!width}
\doinitializeitemgrouplevel{#1}
\fi}
\def\doinitializeitemgrouplevel#1
{\copyparameters
[\??op\currentitemgroup#1][\??oo]
[\c!width,\c!factor,\c!distance,\c!align,\c!symalign,\c!option,
\c!style,\c!marstyle,\c!symstyle,\c!headstyle,
\c!color,\c!marcolor,\c!symcolor,\c!headcolor,
\c!beforehead,\c!afterhead,\c!before,\c!inbetween,\c!after,
\c!stopper,\c!placestopper,\c!indenting,
\c!n,\c!inner,\c!symbol,\c!margin,\c!items,
\c!leftmargin,\c!rightmargin,\c!indentnext,
\c!command,
\c!start,\c!lefttext,\c!righttext]}
\def\setupitemgroups
{\dosingleargument\dosetupitemgroups}
\def\dosetupitemgroups[#1]
{\getparameters[\??oo][\c!levels=4,#1]
\ifnum\@@oolevels>\maxitemdepth
\maxitemdepth\@@oolevels\relax
\dorecurse\maxitemdepth{\initializeitemgroupslevel\recurselevel}
\fi}
\def\doitemreference#1,#2,#3\\
{\ifnum\currentitemlevel>#1\relax
\ifnum#1>\zerocount \tempsymbol \fi
\getvalue{\@@currentitemsymbol{#2}}
\doitemreference#2,#3\\
\fi}
\def\itemreference
{\expandafter\doitemreference\itemreferences,,\\}
\def\packitems
{\ifcase\currentitemlevel \else \settrue\packlistitem \fi}
\def\dosetupitemgroupvariable[#1]
{\doifelsenothing{#1}
{\getparameters[\??op\currentitemgroup\currentitemlevel]}
{\getparameters[\??op\currentitemgroup#1]}}
\newconditional\inlinelistitem \setfalse\inlinelistitem
\def\dododosetupitemgroupconstant[#1][#2#3#4]
{\global\setitemparameter\currentitemlevel\c!maxwidth{0}
\processaction
[#2#3#4]
[ \v!packed*=>\packitems,
\v!intro*=>\settrue\introlistitem,
\v!autointro*=>\settrue\autointrolistitem,
\v!broad*=>\setitemparameter{#1}\c!factor{1},
#2#3*\v!broad*=>\setitemparameter{#1}\c!factor{#2#3},
#2*\v!broad*=>\setitemparameter{#1}\c!factor{#2},
\v!text*=>\settrue\textlistitem
\settrue\inlinelistitem
\settrue\joinedlistitem
\packitems,
\v!columns*=>\packitems,
\v!before*=>\settrue\beforelistitem,
\v!after*=>\settrue\afterlistitem,
\v!nowhite*=>\settrue\nowhitelistitem,
\v!margin*=>\setitemparameter{#1}\c!width{-2em},
\v!inmargin*=>\setitemparameter{#1}\c!width{-2em},
\v!atmargin*=>\doifnot{#1}{1}{\setitemparameter{#1}\c!width{0em}},
\v!intext*=>\settrue\inlinelistitem,
\v!loose*=>\setfalse\optimizelistitem,
\v!fit*=>\settrue\fittinglistitems,
\v!nofit*=>\setfalse\fittinglistitems,
\v!paragraph*=>\settrue\paragraphlistitem
\packitems,
\v!joinedup*=>\settrue\joinedlistitem
\packitems,
\v!serried*=>\setitemparameter{#1}\c!factor{-1},
#2#3*\v!serried*=>\setitemparameter{#1}\c!factor{-#2#3},
#2*\v!serried*=>\setitemparameter{#1}\c!factor{-#2},
\v!stopper*=>\setitemparameter{#1}\c!placestopper{\v!yes},
\v!unpacked*=>\setfalse\packlistitem,
\v!repeat*=>\settrue\repeatlistitem,
\v!reverse*=>\settrue\reverselistitem,
\v!standard*=>\dosetupstandarditemgroup{#1}]}
\def\dosetupstandarditemgroup#1
{\getparameters
[\??op\currentitemgroup#1]
[\c!width=1.5em,
\c!factor=0,
\c!distance=.5em,
\c!beforehead=,
\c!afterhead=\blank,
\c!before=\blank,
\c!inbetween=\blank,
\c!after=\blank,
\c!inner=]}
\def\itembeforecommand
{\ifconditional\nowhitelistitem
\ifconditional\beforelistitem
\ifcase\currentitemlevel\or\getitemparameter\currentitemlevel\c!before\fi
\else
\nowhitespace
\fi
\else\ifconditional\joinedlistitem
\else
\getitemparameter\currentitemlevel\c!before
\fi\fi}
\def\itemaftercommand
{\ifconditional\nowhitelistitem
\ifconditional\afterlistitem
\ifcase\currentitemlevel\or\getitemparameter\currentitemlevel\c!after\fi
\else
\nowhitespace
\fi
\else\ifconditional\joinedlistitem
\else
\getitemparameter\currentitemlevel\c!after
\fi\fi}
\def\iteminbetweencommand
{\ifconditional\nowhitelistitem
\nowhitespace
\else\ifconditional\joinedlistitem
\else
\getitemparameter\currentitemlevel\c!inbetween
\fi\fi}
\def\itembeforeheadcommand
{\ifconditional\nowhitelistitem
\nowhitespace
\else\ifconditional\joinedlistitem
\else
\getitemparameter\currentitemlevel\c!beforehead
\fi\fi}
\def\itemafterheadcommand
{\ifconditional\nowhitelistitem
\nowhitespace
\else\ifconditional\joinedlistitem
\else
\getitemparameter\currentitemlevel\c!afterhead
\fi\fi}
\def\dosetupitemgroupconstant[#1][#2]
{\def\dodosetupitemgroupconstant##1
{\doifsomething{##1}{\dododosetupitemgroupconstant[#1][##1*]}}
\processcommacommand[#2]\dodosetupitemgroupconstant}
\def\dododododosetupitemgroup[#1][#2]
{\doifassignmentelse{#2}
{\dosetupitemgroupvariable[#1][#2]}
{\setitemparameter{#1}\c!option{#2}}}
\def\dodododosetupitemgroup[#1][#2]
{\ConvertToConstant\doifnot{#2}{}
{\doifelse{#1}\v!each
{\dorecurse\maxitemdepth{\ExpandFirstAfter\dododododosetupitemgroup[\recurselevel][#2]}}
{\ExpandFirstAfter\dododododosetupitemgroup[#1][#2]}}}
\def\dododosetupitemgroup[#1][#2]
{\ConvertToConstant\doifelse{#2}{}
{\ifcase\currentitemlevel\relax
\dodododosetupitemgroup[\v!each][#1]
\else
\dodododosetupitemgroup[\currentitemlevel][#1]
\fi}
{\doifelsenothing{#1}
{\dodododosetupitemgroup[\currentitemlevel][#2]}
{\dodododosetupitemgroup[#1][#2]}}}
\def\dodosetupitemgroup[#1][#2][#3][#4]
{\pushmacro\currentitemgroup
\def\currentitemgroup{#1}
\dododosetupitemgroup[#2][#3]
\ConvertToConstant\doifnot{#4}{}
{\dododosetupitemgroup[#2][#4]}
\popmacro\currentitemgroup}
\def\dosetupitemgroup[#1][#2][#3][#4]
{\def\docommand##1{\dodosetupitemgroup[##1][#2][#3][#4]}
\processcommalist[#1]\docommand}
\def\setupitemgroup
{\doquadrupleempty\dosetupitemgroup}
\def\doadvanceitem
{\ifconditional\sublistitem\else\ifconditional\symbollistitem\else
\pluscounter{\@@itemcounter\currentitemlevel}
\fi\fi}
\def\setitemlevel#1
{\ifnum\currentitemlevel>\zerocount
\settrue\firstlistitem
\expanded{\setitemparameter{\currentitemlevel}{\c!start}{1}}
\doifinset{0}{#1}{\setitemparameter\currentitemlevel\c!start{0}}
\setcounter{\@@itemcounter\currentitemlevel}{0}
\doifelsenothing{\getitemparameter\currentitemlevel\c!start}
{\def\currentitemoffset{1}}
{\def\currentitemoffset{\getitemparameter\currentitemlevel\c!start}
\letitemparameter\currentitemlevel\c!start\empty}
\def\tempnumber
{\countervalue{\@@itemcounter\currentitemlevel}}
\doifelse{\getitemparameter\currentitemlevel\c!placestopper}\v!yes
{\def\tempsymbol{\getitemparameter\currentitemlevel\c!stopper}}
{\let\tempsymbol\empty}
\fi}
\def\actualitemnumber
{\ifconditional\reverselistitem
\convertnumber\currentitemsymbol{\numexpr\currentmaxnofitems+\currentitemoffset-\currentitemnumber+1\relax}
\else
\convertnumber\currentitemsymbol{\numexpr\currentminnofitems+\currentitemoffset+\currentitemnumber-1\relax}
\fi}
\def\unknownitemsymbol{?}
\def\setitemmark#1
{\doifsymboldefinedelse{#1}
{\edef\currentitemsymbol{#1}
\setxvalue{\@@globalitemsymbol\currentitemlevel}{\currentitemsymbol}
\setgvalue{\@@localitemsymbol \currentitemlevel}{\unknownitemsymbol}
\def\listitem{\symbol[\currentitemsymbol]}
\let\@@opsymbol\empty}
{\doifconversiondefinedelse{#1}
{\edef\currentitemsymbol{#1}
\setxvalue{\@@globalitemsymbol\currentitemlevel}{\currentitemsymbol}
\setgvalue{\@@localitemsymbol\currentitemlevel }{\actualitemnumber }
\ifconditional\textlistitem
\doifsomething{\getitemparameter\currentitemlevel\c!lefttext}
{\let\tempsymbol\empty}
\fi
\def\listitem
{\getitemparameter\currentitemlevel
{\ifconditional\textlistitem\c!lefttext\else\c!left\fi}
\getvalue{\@@localitemsymbol\currentitemlevel}\tempsymbol
\getitemparameter\currentitemlevel
{\ifconditional\textlistitem\c!righttext\else\c!right\fi}}
\let\@@opsymbol\empty}
{}}}
\def\calculatelistwidth#1#2
{#2=\getitemparameter{#1}\c!distance\relax
\ifnum\getitemparameter{#1}\c!factor>\zerocount
\ifdim#2=\zeropoint #2=.5em\fi
\fi
\multiply#2 \getitemparameter{#1}\c!factor
\advance #2 \getitemparameter{#1}\c!width\relax}
\newconditional\concatnextitem \setfalse\concatnextitem
\newconditional\autoconcatnextitem \settrue \autoconcatnextitem
\newsignal \itemsignal
\def\startitemgroup
{\dotripleempty\dostartitemgroup}
\def\dostartitemgroup[#1][#2][#3]
{\bgroup
\ifnum\currentitemlevel=\zerocount
\def\currentitemgroup{#1}
\fi
\ifthirdargument
\dodostartitemgroup[#2][#3]
\else
\doifassignmentelse{#2}
{\dodostartitemgroup[][#2]}
{\dodostartitemgroup[#2][]}
\fi}
\def\dodostartitemgroup[#1]
{\relax
\ifnum\currentitemlevel=\maxitemdepth\relax
\showmessage\m!layouts9{\number\maxitemdepth}
\let\itemincrement\zerocount
\else
\let\itemincrement\plusone
\fi
\global\advance\itemdepth\itemincrement
\xdef\currentitemlevel{\number\itemdepth}
\initializeitemgrouplevel\currentitemlevel
\edef\itemgroupoptions{\getitemparameter\currentitemlevel\c!option}
\ifx\itemgroupoptions\empty
\edef\itemgroupoptions{#1}
\else
\doifsomething{#1}{\edef\itemgroupoptions{\itemgroupoptions,#1}}
\fi
\expanded{\redostartitemgroup[\itemgroupoptions]}}
\let\startcollectitems\relax
\let\stopcollectitems \relax
\@EA\long\@EA\def\@EA\collectitemgroupitem\@EA#\@EA1\csname\e!stop\v!item\endcsname
{\increment\itemcollectcounter
\long\setvalue{\v!item*\itemcollectcounter}{\item#1\par}}
\def\flushcollecteditems
{\ifconditional\randomizeitems
\getrandomnumber\itemcollectcounternow\plusone\itemcollectcounter
\else
\increment\itemcollectcounternow
\fi
\doifdefined{\v!item*\itemcollectcounternow}
{\getvalue{\v!item*\itemcollectcounternow}
\letbeundefined{\v!item*\itemcollectcounternow}
\increment\itemcollectcounterdone}
\ifnum\itemcollectcounterdone<\itemcollectcounter\relax
\expandafter\flushcollecteditems
\fi}
\def\stopcollectitems
{\ifconditional\randomizeitems
\newcounter\itemcollectcounterdone
\ifnum\itemcollectcounter>\zerocount
\@EAEAEA\flushcollecteditems
\fi
\fi}
\def\startcollectitems
{\ifconditional\randomizeitems
\newcounter\itemcollectcounter
\letvalue{\e!start\v!item}\collectitemgroupitem
\fi}
\ifx\startcolumns\undefined \def\startcolumns[#1]{} \fi
\ifx\stopcolumns \undefined \let\stopcolumns\relax \fi
\def\dosetsymalign#1
{\processaction
[#1]
[ \v!flushleft=>\let\symalignleft\relax,
\v!right=>\let\symalignleft\relax,
\v!flushright=>\let\symalignleft\hfill,
\v!left=>\let\symalignleft\hfill,
\v!middle=>\let\symalignleft\hfil,
\v!center=>\let\symalignleft\hfil]}
\def\redostartitemgroup[#1][#2]
{\setfalse\inlinelistitem
\setfalse\concatnextitem
\setfalse\txtlistitem
\ifhmode
\ifconditional\autoconcatnextitem
\ifdim\lastskip=\itemsignal
\settrue\concatnextitem
\fi
\fi