diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-lst.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-lst.mkiv | 315 |
1 files changed, 216 insertions, 99 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-lst.mkiv b/Master/texmf-dist/tex/context/base/strc-lst.mkiv index 413052882e5..c2be8338a45 100644 --- a/Master/texmf-dist/tex/context/base/strc-lst.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-lst.mkiv @@ -70,31 +70,55 @@ \def\structurelistinject{\dotripleempty\dostructurelistinject} -\def\dostructurelistinject[#1][#2][#3]% +\def\dostructurelistinject[#1]% [#2][#3]% no check on nofarguments here {\begingroup - \edef\currentlistname{#1}% + \edef\currentlist{#1}% + \doifelse{\listparameter\c!state}\v!start\dodostructurelistinject\nonostructurelistinject} + +\def\dodostructurelistinject[#1][#2]% + {\endgroup} + +\def\dodostructurelistinject[#1][#2]% + {\getparameters[\??li\??li][\c!type=userdata,\c!location=\v!none,#1]% + \edef\currentlisttype {\@@li@@litype}% + \edef\currentlistlocation{\@@li@@lilocation}% \setnextinternalreference - \edef\currentlistnumber{\ctxlua{structure.lists.push{ + \edef\currentlistnumber{\ctxlua{structures.lists.push{ references = { internal = \nextinternalreference, - section = structure.sections.currentid(), + block = "\currentstructureblock", % handy for lists, like bibl + section = structures.sections.currentid(), + % location = "\currentlistlocation", }, metadata = { - kind = "#2", - name = "\currentlistname", - level = structure.sections.currentlevel(), + kind = "\currentlisttype", + name = "\currentlist", + level = structures.sections.currentlevel(), catcodes = \the\catcodetable, }, - userdata = structure.helpers.touserdata(\!!bs\detokenize{#3}\!!es) + userdata = structures.helpers.touserdata(\!!bs\detokenize{#2}\!!es) }}}% - \expanded{\ctxlatelua{structure.lists.enhance(\currentlistnumber)}}% + % we can do the enhance injection at the lua end which saves tokenization and a call + \ifx\currentlistlocation\v!here + % this injects nodes ! + \expanded{\ctxlatelua{structures.lists.enhance(\currentlistnumber)}}% + % new from here + \xdef\currentstructurelistattribute{\ctxlua{tex.write(structures.references.setinternalreference(nil,nil,\nextinternalreference))}}% + \xdef\currentdestinationattribute{\number\lastdestinationattribute}% + %begingroup\attribute\destinationattribute\currentdestinationattribute\dontleavehmode\emptyhbox\endgroup % todo + \dontleavehmode\hbox attr \destinationattribute \currentdestinationattribute{}% todo + % end of new + \else + \ctxlua{structures.lists.enhance(\currentlistnumber)}% direct injection + \fi \endgroup} \def\structurelistlocation - {\ctxlua{structure.lists.location(\currentlistindex)}} + {\ctxlua{structures.lists.location(\currentlistindex)}} \def\structurelistpagenumber - {\ctxlua{structure.lists.prefixedpage( + {\dostarttagged\t!listpage\empty + \ctxlua{structures.lists.prefixedpage( "\currentlist", \currentlistindex, { @@ -110,38 +134,57 @@ starter = \!!bs\listparameter\c!pagestarter\!!es, stopper = \!!bs\listparameter\c!pagestopper\!!es, } - )}} + )}% + \dostoptagged} \def\structurelistrealpagenumber - {\ctxlua{structure.lists.realpage("\currentlist",\currentlistindex)}} + {\ctxlua{structures.lists.realpage("\currentlist",\currentlistindex)}} \def\structurelistfirst - {\ctxlua{structure.lists.userdata("\currentlist",\currentlistindex,"first")}} + {\dostarttagged\t!listdata{first}% not always ok + \ctxlua{structures.lists.userdata("\currentlist",\currentlistindex,"first")}% + \dostoptagged} \def\structurelistsecond - {\ctxlua{structure.lists.userdata("\currentlist",\currentlistindex,"second")}} + {\dostarttagged\t!listdata{second}% + \ctxlua{structures.lists.userdata("\currentlist",\currentlistindex,"second")}% + \dostoptagged} \def\structurelistuservariable#1% - {\ctxlua{structure.lists.userdata("\currentlist",\currentlistindex,"#1")}} + {\dostarttagged\t!listdata{#1}% + \ctxlua{structures.lists.userdata("\currentlist",\currentlistindex,"#1")}% + \dostoptagged} % \appendtoks % \to \everystructurelist -\unexpanded\def\placestructurelist#1#2#3% hm ... [][][] - {\ctxlua{structure.lists.process("#1","#2","#3")}} - -\def\analysestructurelist#1#2#3% - {\ctxlua{structure.lists.analyze("#1","#2","#3")}} +\unexpanded\def\doplacestructurelist#1#2#3#4#5% beware, not a user command + {\dostarttagged\t!list\empty + \ctxlua{structures.lists.process { + names = "#1", + criterium = "#2", + number = "#3", + extras = "#4", + order = "#5" + }}% + \dostoptagged} + +\unexpanded\def\doanalyzestructurelist#1#2#3% + {\ctxlua{structures.lists.analyze { + names = "#1", + criterium = "#2", + number = "#3" + }}} \def\firststructureelementinlist#1% - {\ctxlua{commands.first_in_list("#1")}} + {\ctxcommand{firstinlist("#1")}} \def\structurelistsize - {\ctxlua{structure.lists.size()}} + {\ctxlua{structures.lists.size()}} \def\@@structurelistprocess{structurelist:process:} -\def\installstructurelistprocessor#1#2% +\unexpanded\def\installstructurelistprocessor#1#2% {\expandafter\def\csname\@@structurelistprocess#1\endcsname{#2}} \def\usestructurelistprocessor#1% @@ -158,24 +201,44 @@ % \chapter{Two} \section{First} \section{Second} % \stoptext -\def\processlistofstructure#1#2#3% name, method, n - {\ctxlua{structure.lists.pushnesting(#3)}% - \edef\currentlist {#1}% - \edef\currentlistmethod{#2}% - \edef\currentlistindex {#3}% +\def\definelistextra + {\dodoubleargument\dodefinelistextra} + +\def\dodefinelistextra[#1][#2]% + {\getparameters[\??li:\c!extras:#1:][#2]} + +% todo: more generic tracing + +\definelistextra + [\v!page] + [\c!before={\showmessage\m!system{14}{\currentlist/\currentlistindex}\page}] + +\def\processlistextrabefore{\executeifdefined{\??li:\c!extras:\currentlistextra:\c!before}\relax} +\def\processlistextraafter {\executeifdefined{\??li:\c!extras:\currentlistextra:\c!after }\relax} + +\unexpanded\def\processlistofstructure#1#2#3#4% name, method, n, extra + {\ctxlua{structures.lists.pushnesting(#3)}% + \edef\currentlist {#1}% + \edef\currentlistmethod {#2}% + \edef\currentlistindex {#3}% + \edef\currentlistextra {#4}% + \processlistextrabefore + \dostarttagged\t!listitem\currentlist \csname\@@structurelistprocess \ifcsname\@@structurelistprocess\currentlist:\currentlistmethod\endcsname\currentlist:\currentlistmethod\else \ifcsname\@@structurelistprocess\currentlistmethod \endcsname\currentlistmethod \else \ifcsname\@@structurelistprocess\currentlist \endcsname\currentlist \else \s!default \fi\fi\fi \endcsname - \ctxlua{structure.lists.popnesting()}} + \dostoptagged + \processlistextraafter + \ctxlua{structures.lists.popnesting()}} % \installstructcurelistprocessor{pubs:userdata} -% {\ctxlua{structure.lists.userdata("\currentlist",\currentlistindex,"bibref")}} +% {\ctxlua{structures.lists.userdata("\currentlist",\currentlistindex,"bibref")}} \installstructurelistprocessor{command} - {\ctxlua{structure.lists.userdata("\currentlist",\currentlistindex,"command")}} + {\ctxlua{structures.lists.userdata("\currentlist",\currentlistindex,"command")}} \installstructurelistprocessor{section} {\dodolistelement @@ -211,7 +274,8 @@ \setuplistalternative[b][\c!distance=5em,\c!width=2em,\c!stretch=10em,\c!command=\hfill] \setuplistalternative[c][\c!distance=5em,\c!width=0pt,\c!stretch=10em,\c!command=\hskip.5em\listdots\hskip.5em\relax] -\def\listdots{\leaders\hbox to .5em{\hss.\hss}\hfill} +%def\listdots{\leaders \hbox to .5em{\hss.\hss}\hfill} +\def\listdots{\gleaders\hbox to .5em{\hss.\hss}\hfill} % \setvalue{\??li\c!alternative}{\getvalue{\??li\c!alternative b}} % ? % \getvalue{\??li\c!alternative} % ? @@ -264,7 +328,7 @@ \c!pagecommand=\listpagecommand, \c!pagenumber=\v!yes, \c!headnumber=\v!yes, - \c!pageboundaries=, + \c!extras=, \c!margin=\!!zeropoint, \c!aligntitle=, \c!before=, @@ -324,21 +388,58 @@ % writing to lists -\def\writetolist[#1]{\gobbletwoarguments} \let\dowritetolist \gobblefourarguments \let\dodowritetolist\gobblefourarguments -\def\writebetweenlist[#1]#2% - {\doif{\namedlistparameter{#1}\c!state}\v!start{\structurelistinject[#1][command][command={#2}]}} -\def\writedatatolist - {\dodoubleargument\dowritedatatolist} - -\def\dowritedatatolist[#1][#2]% - {\doif{\namedlistparameter{#1}\c!state}\v!start{\structurelistinject[#1][userdata][#2]}} - -\def\writetolist[#1]#2#3% - {\doif{\namedlistparameter{#1}\c!state}\v!start{\structurelistinject[#1][simple][first={#2},second={#3}]}} +%D Regular list entries are bound to a specific location in order to +%D get the right pagenumber etc.\ associated. When pushing something +%D inbetween (in mkiv) it ends up directtly in the list. This is the +%D default because otherwise users will wonder why spacing might get +%D messed up (due to an unseen but present node). It is possible to +%D force a location by explicitly setting \type {location} to \type +%D {here}. +%D +%D Another way to force a certain order is to set the \type {order} +%D variable when placing a list. The \type {command} option only +%D pushes commands into the right order, and \type {all} orders all +%D entries (which might be too much). In this case no specific +%D location is needed with the inbetween method. Maybe additional +%D mechanisms show up some day. See \type {inbetween-001.tex} for an +%D example. + +% command : location=none +% userdata : location=none +% simple : location=here + +\unexpanded\def\writebetweenlist{\dodoubleempty \dowritebetweenlist} +\unexpanded\def\writedatatolist {\dotripleargument\dowritedatatolist} +\unexpanded\def\writetolist {\dodoubleempty \dowritetolist} + +\def\dowritebetweenlist[#1][#2]#3% we can overload location + {\doif{\namedlistparameter{#1}\c!state}\v!start + {\ifsecondargument + \dostructurelistinject[#1][#2,\c!type=command][command={#3}]% + \else + \dostructurelistinject[#1][\c!type=command][command={#3}]% + \fi}} + +\def\dowritedatatolist[#1][#2][#3]% we can overload location + {\doif{\namedlistparameter{#1}\c!state}\v!start + {\ifthirdargument + \dostructurelistinject[#1][#2,\c!type=userdata][#3]% + \else + \dostructurelistinject[#1][\c!type=userdata][#2]% + \fi}} + + +\def\dowritetolist[#1][#2]#3#4% we can overload location + {\doif{\namedlistparameter{#1}\c!state}\v!start + {\ifsecondargument + \dostructurelistinject[#1][\c!location=\v!here,#2,\c!type=simple][first={#3},second={#4}]% + \else + \dostructurelistinject[#1][\c!location=\v!here,\c!type=simple][first={#3},second={#4}]% + \fi}} \installstructurelistprocessor{simple} {\dodolistelement @@ -357,16 +458,21 @@ \edef\currentlist{\firststructureelementinlist{#1}}% \the\everystructurelist \doif{\listparameter\c!coupling}\v!on{\startlistreferences{#1}}% - \placestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}% + \doplacestructurelist + {#1}% + {\listparameter\c!criterium}% + {\number\listparameter\c!number}% + {\listparameter\c!extras}% + {\listparameter\c!order}% \stoplistreferences \endgroup \dosetlistmode} -\def\dosetlistmode % utilitydone will disappear +\def\dosetlistmode {\ifcase\structurelistsize\relax - \utilitydonefalse \resetsystemmode\v!list + \resetsystemmode\v!list \else - \utilitydonetrue \setsystemmode \v!list + \setsystemmode \v!list \fi} \unexpanded\def\systemsuppliedchapter {\getvalue{\v!chapter}} % brrr @@ -379,7 +485,7 @@ \def\docompletelist[#1][#2]% {\dodocompletelist[#1][#1][#2]} -\def\completelist +\unexpanded\def\completelist {\dodoubleempty\docompletelist} \def\listelements {} % list of page breaks @@ -390,10 +496,10 @@ \def\doassigndimen#1#2#3% {\doifinsetelse{#2}{\v!fit,\v!broad}{#1=#3}{#1=#2}\relax} -\def\listsymbol[#1]#2% +\unexpanded\def\listsymbol[#1]#2% {\begingroup \edef\currentlist{#1}% - \edef\currentlistnumber{#2}% + \def\currentlistnumber{#2}% no edef else tag problems \currentlistsymbol \endgroup} @@ -444,28 +550,34 @@ \endgroup} \def\listsymbol@default - {% prefix = no, none, yes - \strut - \doif{\listparameter\c!label}\v!yes{\leftlabeltext\currentlist}% we can use the new command that does left and right - \listparameter\c!starter - \currentlistnumber - \listparameter\c!stopper - \doif{\listparameter\c!label}\v!yes{\rightlabeltext\currentlist}} - -\def\listsymbol@default - {% todo: - % prefix=no (first gone)|none (all gone)|yes - % number=no|yes - \strut - \doifelse{\listparameter\c!label}\v!yes - {\leftlabeltext\currentlist - \listparameter\c!starter - \currentlistnumber - \listparameter\c!stopper - \rightlabeltext\currentlist} - {\listparameter\c!starter - \currentlistnumber - \listparameter\c!stopper}} + {\strut + \begingroup + \edef\currentlistlabel{\listparameter\c!label}% + \ifx\currentlistlabel\empty % default + \listparameter\c!starter + \currentlistnumber + \listparameter\c!stopper + \else\ifx\currentlistlabel\v!no % also default + \listparameter\c!starter + \currentlistnumber + \listparameter\c!stopper + \else\ifx\currentlistlabel\v!none % real minimal (as suggested by WS) + \currentlistnumber + \else\ifx\currentlistlabel\v!yes % auto (use value stored in tuc file) + \edef\currentlistlabel{\ctxlua{structures.lists.label(\currentlistindex,"\currentlistlabel")}}% + \leftlabeltext\currentlistlabel + \listparameter\c!starter + \currentlistnumber + \listparameter\c!stopper + \rightlabeltext\currentlistlabel + \else % use whatever is set + \leftlabeltext\currentlistlabel + \listparameter\c!starter + \currentlistnumber + \listparameter\c!stopper + \rightlabeltext\currentlistlabel + \fi\fi\fi\fi + \endgroup} \def\listsymbol@unknown {\listparameter\c!symbol} @@ -527,20 +639,11 @@ \def\dodolistelement#1#2#3#4#5#6% {\edef\currentlist{#1}% - \edef\currentlistnumber{#3}% + \def\currentlistnumber{#3}% no edef else tag problem \docurrentlistalternative - %\showcomposition - \let\@@iawidth\!!zeropoint % moet boolean worden - \begingroup - \edef\listelements{\listparameter\c!pageboundaries}% - \normalexpanded{\noexpand\doifinset{#3}{\listelements}} - {\showmessage\m!systems{14}{#3}% - \page}% - \endgroup + \letinteractionparameter\c!width\zeropoint \dontcomplain - %\setfullsectionnumber{\??li\currentlist}% todo - \dosomelistelement{#1}{#2}{#3}{#4}{#5}{#6}% - \global\utilitydonetrue} % ? + \dosomelistelement{#1}{#2}{#3}{#4}{#5}{#6}} \def\dodocommandlistelement#1#2#3#4#5#6% {\doifdefinedelse{\??li#1\c!command} @@ -549,13 +652,18 @@ \def\domakelistelement#1#2#3#4% ref internal command data {\dontleavehmode - \iflocation % we cannot tewak \iflocation as we nest + \iflocation % we cannot tweak \iflocation as we nest \doifelse{\listparameter\c!interaction}{#1} - {\directgoto{\setlocationcolor\??ia#4}[internal(#2)]}% was \directgotobox - {#3{#4}}% - \else + {\begingroup + \doif{\namedstructureheadparameter\currentlist\c!interaction}\v!list + {\dosetsimplepagereference{bck:#2}% + \attribute\destinationattribute\currentdestinationattribute}% + \directgoto{\setlocationcolor\??ia#4}[internal(#2)]% we can get the attribute instead so then we don't need a goto + \endgroup}% was \directgotobox + {#3{#4}}% + \else #3{#4}% - \fi} + \fi} \def\dodofreelistelement#1#2#3#4#5#6#7#8% {\listparameter\c!before% can be \hskip @@ -637,7 +745,7 @@ \hfill}}} {\!!widtha\zeropoint \!!widthc\zeropoint - \setbox2\hbox{}}% + \setbox2\emptyhbox}% \setbox4\hbox {\doif{\listparameter\c!pagenumber}\v!yes {\doifsomething{#5} % \listwidth is new ; temp hack @@ -824,12 +932,12 @@ \dosetuplist[#1][#2]% \edef\currentlist{\firststructureelementinlist{#1}}% \the\everystructurelist - \analysestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}% + \doanalyzestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}% \xdef\utilitylistlength{\structurelistsize}% \endgroup \dosetlistmode} -\def\determinelistcharacteristics +\unexpanded\def\determinelistcharacteristics {\dodoubleempty\dodeterminelistcharacteristics} \def\combinedlistparameter#1{\csname\??ih\currentcombinedlist#1\endcsname} @@ -866,7 +974,12 @@ \doif{\combinedlistparameter\c!coupling}\v!on{\startlistreferences{#1}}% \dobeginoflist \normalexpanded{\noexpand\dosetuplist[\combinedlist][#2]}% - \placestructurelist{\combinedlist}{\combinedlistparameter\c!criterium}{\combinedlistparameter\c!number}% + \doplacestructurelist + {\combinedlist}% + {\combinedlistparameter\c!criterium}% + {\combinedlistparameter\c!number}% + {\combinedlistparameter\c!extras}% + {\combinedlistparameter\c!order}% \doendoflist \stoplistreferences \endgroup @@ -888,10 +1001,13 @@ \structurelistrealpagenumber} \def\structurelistgenerictitle - {\ctxlua{structure.lists.title("\currentlist",\currentlistindex)}} + {\dostarttagged\t!listcontent\empty + \ctxlua{structures.lists.title("\currentlist",\currentlistindex)}% + \dostoptagged} -\def\structurelistgenericnumber{\ctxlua{ - structure.lists.prefixednumber("\currentlist",\currentlistindex, { +\def\structurelistgenericnumber % tricky, we need to delay tagging as we have nested lua calls + {\dostarttagged\t!listtag\empty + \ctxlua{structures.lists.prefixednumber("\currentlist",\currentlistindex, { prefix = "\listparameter\c!prefix", separatorset = "\listparameter\c!prefixseparatorset", conversionset = "\listparameter\c!prefixconversionset", @@ -907,7 +1023,8 @@ starter = \!!bs\listparameter\c!numberstarter\!!es, stopper = \!!bs\listparameter\c!numberstopper\!!es, segments = "\listparameter\c!numbersegments", - } )}} + } )}% + \dostoptagged} % new and yet undocumented (used in cocoa qa), temporarily disabled in mkiv % |