diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-08 00:43:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-08 00:43:40 +0000 |
commit | 824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch) | |
tree | abfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/strc-ref.mkvi | |
parent | 689aefb0727676ed3cddf331337b4be226495e72 (diff) |
context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip
git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-ref.mkvi')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-ref.mkvi | 378 |
1 files changed, 235 insertions, 143 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ref.mkvi b/Master/texmf-dist/tex/context/base/strc-ref.mkvi index ee45d76fafe..54f180d8e01 100644 --- a/Master/texmf-dist/tex/context/base/strc-ref.mkvi +++ b/Master/texmf-dist/tex/context/base/strc-ref.mkvi @@ -61,20 +61,42 @@ % \definespecial\dosetexecuteJScode % ... -%D This module deals with referencing. In \CONTEXT\ referencing -%D is one of the core features, although at a first glance -%D probably nobody will notice. This is good, because -%D referencing should be as hidden as possible. +%D This module deals with referencing. In \CONTEXT\ referencing is one of +%D the core features, although at a first glance probably nobody will +%D notice. This is good, because referencing should be as hidden as possible. %D -%D In paper documents, referencing comes down to cross -%D referencing, but in their interactive counterparts, is also -%D involves navigation. Many features implemented here are -%D therefore closely related to navigation. +%D Before we start implementing functionality we provide a way to set +%D up this mechanism. %D -%D Many \CONTEXT\ commands can optionally be fed with a -%D reference. Such a reference, when called upon, returns the -%D number of a figure, table, chapter etc, a piece of text, or -%D a pagenumber. +%D \showsetup{setupreferencing} +%D +%D In interactive documents verbose references don't always +%D make sense (what is a page number in an unnumbered +%D document). By setting the \type{interaction} variable, one +%D can influences the way interactive references are set. + +\installcorenamespace{referencing} + +\installdirectcommandhandler \??referencing {referencing} % \??referencing + +\newif\ifreferencing \referencingtrue + +\appendtoks + \edef\p_state{\referencingparameter\c!state}% + \ifx\p_state\v!start + \referencingtrue + \else + \referencingfalse + \fi +\to \everysetupreferencing + +%D In paper documents, referencing comes down to cross referencing, but in +%D their interactive counterparts, is also involves navigation. Many features +%D implemented here are therefore closely related to navigation. +%D +%D Many \CONTEXT\ commands can optionally be fed with a reference. Such a +%D reference, when called upon, returns the number of a figure, table, chapter +%D etc, a piece of text, or a pagenumber. %D %D There are three ways of defining a reference: %D @@ -89,17 +111,25 @@ %D \reference[here]{some text} %D \stoptyping -\unexpanded\def\textreference {\dosingleargument\strc_references_text_reference} -\unexpanded\def\pagereference {\dosingleargument\strc_references_page_reference} -\unexpanded\def\reference {\dosingleargument\strc_references_full_reference} -\unexpanded\def\setreference {\dodoubleargument\strc_references_set_reference } +\unexpanded\def\textreference {\dosingleargument\strc_references_text_reference} % no need for \dosingle +\unexpanded\def\pagereference {\dosingleargument\strc_references_page_reference} % as they're mandate and +\unexpanded\def\reference {\dosingleargument\strc_references_full_reference} % never forgotten +\unexpanded\def\setreference {\dodoubleargument\strc_references_set_reference } % %D These are implemented in a low level form as: -\def\strc_references_text_reference [#labels]{\strc_references_set_named_reference\s!text{#labels}{}} -\def\strc_references_page_reference [#labels]{\strc_references_set_named_reference\s!page{#labels}{}{}} -\def\strc_references_full_reference [#labels]{\strc_references_set_named_reference\s!full{#labels}{}} -\def\strc_references_set_reference[#labels][#settings]{\strc_references_set_named_reference\s!user{#labels}{#settings}{}} +\unexpanded\def\strc_references_text_reference [#labels]{\strc_references_set_named_reference\s!text{#labels}{}} +\unexpanded\def\strc_references_page_reference [#labels]{\strc_references_set_named_reference\s!page{#labels}{}{}} +\unexpanded\def\strc_references_full_reference [#labels]{\strc_references_set_named_reference\s!full{#labels}{}} +\unexpanded\def\strc_references_set_reference[#labels][#settings]{\strc_references_set_named_reference\s!user{#labels}{#settings}{}} + +\unexpanded\def\dosetdirectpagereference#1{\strc_references_set_named_reference\s!page{#1}{}{}} % low level, maybe use _ + +\unexpanded\def\usereferenceparameter#1% faster local variant + {\edef\m_strc_references_asked{#1\c!reference}% + \ifx\m_strc_references_asked\empty\else + \dosetdirectpagereference\m_strc_references_asked + \fi} %D Actually there is not much difference between a text and a %D full reference, but it's the concept that counts. The low @@ -108,15 +138,15 @@ \newcount\lastreferenceattribute \newcount\lastdestinationattribute -\def\dofinishfullreference#prefix#label{\normalexpanded{\ctxlatelua{structures.references.enhance("#prefix","#label")}}} -\def\dofinishtextreference#prefix#label{\normalexpanded{\ctxlatelua{structures.references.enhance("#prefix","#label",{})}}} +\def\dofinishfullreference#prefix#label{\normalexpanded{\ctxlatecommand{enhancereference("#prefix","#label")}}} +\def\dofinishtextreference#prefix#label{\normalexpanded{\ctxlatecommand{enhancereference("#prefix","#label",{})}}} \let\dofinishpagereference\dofinishfullreference \let\dofinishuserreference\dofinishfullreference \def\dofinishsomereference#kind{\executeifdefined{dofinish#{kind}reference}\gobbletwoarguments} -\def\strc_references_set_named_reference +\unexpanded\def\strc_references_set_named_reference {\ifreferencing \expandafter\strc_references_set_named_reference_indeed \else @@ -143,7 +173,7 @@ \edef\currentreferencekind {#kind}% \edef\currentreferencelabels {#labels}% \edef\currentreferenceuserdata {#userdata}% - \edef\currentreferenceexpansion{\@@rfexpansion}% {\referenceparameter\c!expansion} + \edef\currentreferenceexpansion{\referencingparameter\c!expansion}% {\referenceparameter\c!expansion} \ifx\currentreferencelabels\empty \lastdestinationattribute\attributeunsetvalue \else @@ -163,7 +193,7 @@ % beware, the structures.references.set writes a % \setnextinternalreference \strc_references_start_destination_nodes - \ctxlua{structures.references.setandgetattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels", + \ctxcommand{setreferenceattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels", { references = { % internal = \nextinternalreference, % no need for an internal as we have an explicit @@ -210,7 +240,7 @@ \lastdestinationattribute\attributeunsetvalue \else \strc_references_start_destination_nodes - \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","\currentreferencelabels", + \ctxcommand{setreferenceattribute("\s!page", "\referenceprefix","\currentreferencelabels", { references = { block = "\currentsectionblock", @@ -248,7 +278,7 @@ \def\strc_references_set_simple_page_reference#label% {\iflocation \strc_references_start_destination_nodes - \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","#label", + \ctxcommand{setreferenceattribute("\s!page", "\referenceprefix","#label", { references = { % block = "\currentsectionblock", @@ -268,13 +298,74 @@ \def\strc_references_get_simple_page_reference#label% {\iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% \xdef\currentreferenceattribute{\number\lastreferenceattribute}% \else \xdef\currentreferenceattribute{\number\attributeunsetvalue}% \fi} %D \macros +%D {contentreference} +%D +%D \starttyping +%D \setupinteraction +%D [state=start, +%D focus=standard] +%D +%D \setupheader +%D [state=stop] +%D +%D See page \goto{page 2}[page2] \page +%D +%D \contentreference +%D [page2] +%D [offset=1cm,toffset=2cm,frame=on] +%D {\externalfigure[cow.pdf][factor=fit]} +%D +%D \stoptyping + +\unexpanded\def\contentreference + {\hbox\bgroup + \dodoubleempty\strc_references_content_pickup} + +\def\strc_references_content_pickup + {\ifsecondargument + \expandafter\strc_references_content_pickup_yes + \else + \expandafter\strc_references_content_pickup_yes + \fi} + +\def\strc_references_content_pickup_yes[#1][#2]% + {\dowithnextbox{\strc_references_content_yes_finish{#1}{#2}}\hbox} + +\def\strc_references_content_pickup_nop[#1][#2]% + {\dowithnextbox{\strc_references_content_nop_finish{#1}{#2}}\hbox} + +\def\strc_references_content_yes_finish#1#2% + {\scratchwidth \wd\nextbox + \scratchheight\ht\nextbox + \scratchdepth \dp\nextbox + \setbox\nextbox\hbox + {\framed[\c!frame=\v!off,#2]{\box\nextbox}}% + \strc_references_set_simple_page_reference{#1}% + \setbox\nextbox\hbox attr \destinationattribute \currentdestinationattribute + {\strc_references_flush_destination_nodes + \box\nextbox}% + \setbox\nextbox\hbox{\box\nextbox}% + \wd\nextbox\scratchwidth + \ht\nextbox\scratchheight + \dp\nextbox\scratchdepth + \box\nextbox + \egroup} + +\def\strc_references_content_nop_finish#1#2% + {\strc_references_set_simple_page_reference{#1}% + \hbox attr \destinationattribute \currentdestinationattribute + {\strc_references_flush_destination_nodes + \box\nextbox}% + \egroup} + +%D \macros %D {everyreference} %D %D For rather tricky purposes, one can assign sanitizing @@ -437,13 +528,13 @@ {\dodoubleempty\strc_references_define_reference} \def\strc_references_define_reference[#name][#specification]% - {\ctxlua{structures.references.define("\referenceprefix","#name",\!!bs\detokenize{#specification}\!!es)}} + {\ctxcommand{definereference("\referenceprefix","#name",\!!bs\detokenize{#specification}\!!es)}} \unexpanded\def\resetreference[#name]% - {\ctxlua{structures.references.reset("\referenceprefix","#name")}} + {\ctxcommand{resetreference("\referenceprefix","#name")}} \def\setpagereference#name#specification% hm,. low level ? - {\ctxlua{structures.references.define("","#name",\!!bs\v!page(\luaescapestring{#specification})\!!es)}} + {\ctxcommand{definereference("","#name",\!!bs\v!page(\luaescapestring{#specification})\!!es)}} %D Chained references are defined as: %D @@ -473,13 +564,13 @@ \newconditional\gotonewwindow \setfalse\gotonewwindow \def\expandtexincurrentreference % will happen in lua some time - {\ifcase\referencehastexstate\else\ctxlua{structures.references.expandcurrent()}\fi} + {\ifcase\referencehastexstate\else\ctxcommand{expandcurrentreference()}\fi} \def\expandreferenceoperation#tag#content{\ctxcommand{setreferenceoperation(#tag,\!!bs#content\!!es)}} \def\expandreferencearguments#tag#content{\ctxcommand{setreferencearguments(#tag,\!!bs#content\!!es)}} \def\doifreferencefoundelse#labels#yes#nop% - {\ctxlua{structures.references.doifelse("\referenceprefix","#labels",\luaconditional\highlighthyperlinks,\luaconditional\gotonewwindow)}% + {\ctxcommand{doifelsereference("\referenceprefix",\!!bs#labels\!!es,\luaconditional\highlighthyperlinks,\luaconditional\gotonewwindow)}% {\expandtexincurrentreference #yes}% {#nop}} @@ -520,6 +611,7 @@ %D text). \def\dummyreference{{\tttf ??}} +\def\emptyreference{{\tttf !!}} %D To prevent repetitive messages concerning a reference %D being defined, we set such an unknown reference to an empty @@ -562,8 +654,8 @@ %D the special driver modules (see \type{spec-ini}). The flag %D \type{\iflocation} signals if we're in interactive mode. -\ifx\buttonheight\undefined \newdimen\buttonheight \fi -\ifx\buttonwidth \undefined \newdimen\buttonwidth \fi +\ifdefined\buttonheight \else \newdimen\buttonheight \fi +\ifdefined\buttonwidth \else \newdimen\buttonwidth \fi %D Internal references can best be set using the next few %D macros. Setting such references to unique values is @@ -588,17 +680,24 @@ {\global\advance\locationcount\plusone} \def\setnextinternalreferences#kind#name% plural - {\ctxlua{structures.references.setnextinternal("#kind","#name")}} + {\ctxcommand{setnextinternalreference("#kind","#name")}} \def\getinternalorderreference#kind#name% - {\ctxlua{structures.references.currentorder("#kind","#name")}} + {\ctxcommand{currentreferenceorder("#kind","#name")}} \def\thisissomeinternal#kind#name% only for old time sake {\begingroup - \ctxlua{structures.references.setinternalreference("","#kind:#name")}% + \ctxcommand{setinternalreference("","#kind:#name")}% \hbox attr \destinationattribute\lastdestinationattribute{}% \endgroup} +\installcorenamespace{savedinternalreference} + +\letvalue{\??savedinternalreference\s!default}\!!zerocount + +\unexpanded\def\storeinternalreference#1#2% + {\setxvalue{\??savedinternalreference\currentstructurename}{#2}} + \newconditional\preferpagereferences \def\gotosomeinternal#kind#name#target#text% @@ -630,8 +729,6 @@ %D \goto{some text}[\v!action(PreviousJump] %D \stoptyping -\newif\ifreferencing \referencingtrue - %D One can also activate an automatic prefix mechanism. By %D setting the \type{\prefix} variable to \type{+}, the prefix %D is incremented, when set to \type{-} or empty, the prefix is @@ -639,64 +736,24 @@ \newcount\prefixcounter -%D These settings are accomplished by: -%D -%D \showsetup{setupreferencing} -%D -%D In interactive documents verbose references don't always -%D make sense (what is a page number in an unnumbered -%D document). By setting the \type{interaction} variable, one -%D can influences the way interactive references are set. - -\newtoks \everysetupreferencing - -\unexpanded\def\setupreferencing - {\dosingleargument\strc_references_setup_referencing} - -\def\strc_references_setup_referencing[#settings]% - {\getparameters[\??rf][\c!prefix=\s!unknown,#settings]% - \the\everysetupreferencing} - -\appendtoks - \processaction - [\@@rfstate] - [ \v!stop=>\referencingfalse, - \v!start=>\referencingtrue]% -\to \everysetupreferencing - \newconditional\autocrossfilereferences \appendtoks - \doifelse\@@rfautofile\v!yes\settrue\setfalse\autocrossfilereferences + \edef\p_autofile{\referencingparameter\c!autofile}% + \ifx\p_autofile\v!yes + \settrue \autocrossfilereferences + \else + \setfalse\autocrossfilereferences + \fi \to \everysetupreferencing -\def\exportreferences - {\doif\@@rfexport\v!yes{\ctxlua{structures.references.export()}}} - \appendtoks - \exportreferences + \edef\p_export{\referencingparameter\c!export}% + \ifx\p_export\v!yes + \ctxcommand{exportreferences()}% + \fi \to \everygoodbye -\def\incrementreferenceprefix{+} -\def\decrementreferenceprefix{-} - -\unexpanded\def\setupreferenceprefix[#prefix]% - {\edef\@@rfprefix{#prefix}% - \ifx\@@rfprefix\empty - \let\referenceprefix\empty - \else\ifx\@@rfprefix\incrementreferenceprefix - \global\advance\prefixcounter \plusone - \edef\referenceprefix{\the\prefixcounter}% - \let\@@rfprefix\s!unknown - \else\ifx\@@rfprefix\decrementreferenceprefix - \let\referenceprefix\empty - \let\@@rfprefix\s!unknown - \else\ifx\@@rfprefix\s!unknown - % forget about it - \else - \edef\referenceprefix{\@@rfprefix}% expanded ! - \fi\fi\fi\fi} - \unexpanded\def\setupglobalreferenceprefix[#prefix]% {\xdef\referenceprefix{#prefix}} @@ -707,8 +764,28 @@ \unexpanded\def\popreferenceprefix {\popmacro\referenceprefix} +\def\m_strc_references_prefix_yes{+} +\def\m_strc_references_prefix_nop{-} + +\unexpanded\def\setupreferenceprefix[#prefix]% + {\edef\p_prefix{#prefix}% + \ifx\p_prefix\empty + \let\referenceprefix\empty + \else\ifx\p_prefix\m_strc_references_prefix_yes + \letreferencingparameter\c!prefix\s!unknown + \global\advance\prefixcounter\plusone + \edef\referenceprefix{\the\prefixcounter}% + \else\ifx\p_prefix\m_strc_references_prefix_nop + \letreferencingparameter\c!prefix\s!unknown + \let\referenceprefix\empty + \else\ifx\p_prefix\s!unknown + % forget about it + \else + \let\referenceprefix\p_prefix + \fi\fi\fi\fi} + \appendtoks - \setupreferenceprefix[\@@rfprefix] + \setupreferenceprefix[\referencingparameter\c!prefix] \to \everysetupreferencing %D We can typeset a reference using \type{\in}, \type{\at} and @@ -808,11 +885,11 @@ \let\crlf\space \let\\\space \postponenotes - \@@rfleft + \referencingparameter\c!left \doifreferencefoundelse{#label} - {\goto{\limitatetext\currentreferencetitle\@@rfwidth\unknown}[#label]}% not so efficient (dup lookup) + {\goto{\limitatetext\currentreferencetitle{\referencingparameter\c!width}\unknown}[#label]}% not so efficient (dup lookup) {}% todo - \@@rfright + \referencingparameter\c!right \endgroup} %D The previously discussed setup macro lets us specify the @@ -883,7 +960,9 @@ \let\leftofreference \empty \let\rightofreference \empty -\setvalue{\??rf\c!interaction\v!all}% +\installcorenamespace{referencinginteraction} + +\setvalue{\??referencinginteraction\v!all}% {\the\leftreferencetoks \doifsometokselse\leftreferencetoks \leftofreferencecontent \donothing \leftofreference @@ -892,24 +971,24 @@ \doifsometokselse\rightreferencetoks\rightofreferencecontent\donothing \the\rightreferencetoks} -\setvalue{\??rf\c!interaction\v!label}% +\setvalue{\??referencinginteraction\v!label}% {\leftofreference \the\leftreferencetoks \the\rightreferencetoks \rightofreference} -\setvalue{\??rf\c!interaction\v!text}% +\setvalue{\??referencinginteraction\v!text}% {\leftofreference \currentreferencecontent \rightofreference} -\setvalue{\??rf\c!interaction\v!symbol}% +\setvalue{\??referencinginteraction\v!symbol}% {\referencesymbol} \def\referencesequence - {\csname \??rf\c!interaction - \ifcsname\??rf\c!interaction\@@rfinteraction\endcsname - \@@rfinteraction + {\csname\??referencinginteraction + \ifcsname\??referencinginteraction\referencingparameter\c!interaction\endcsname + \referencingparameter\c!interaction \else \v!all \fi @@ -1067,7 +1146,7 @@ \def\autoreferencelabeltextflag{*} % a proper key like 'auto' or 'name' can clash with a label key \unexpanded\def\autoreferencelabeltext - {\ctxlua{structures.references.getcurrentmetadata("name")}} + {\ctxcommand{getcurrentreferencemetadata("name")}} % \starttext % \definereferenceformat[inxx] [left=(,right=),text=txt] @@ -1144,7 +1223,7 @@ \attribute\referenceattribute\attributeunsetvalue \global\lastsavedreferenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% \setlocationattributes \setstrut % can be option \global\lastsavedreferenceattribute\lastreferenceattribute @@ -1163,7 +1242,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax,\extrareferencearguments)}% \setlocationattributes \attribute\referenceattribute\lastreferenceattribute \global\lastsavedreferenceattribute\lastreferenceattribute @@ -1182,9 +1261,9 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% {\expandtexincurrentreference - \ctxlua{structures.references.injectcurrentset(\number\ht\strutbox,\number\dp\strutbox)}% + \ctxcommand{injectcurrentreference(\number\ht\strutbox,\number\dp\strutbox)}% \setlocationattributes \setstrut % can be option \global\lastsavedreferenceattribute\lastreferenceattribute @@ -1205,9 +1284,9 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% {\expandtexincurrentreference - \ctxlua{structures.references.injectcurrentset(\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax)}% + \ctxcommand{injectcurrentreference(\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax)}% \setlocationattributes \global\lastsavedreferenceattribute\lastreferenceattribute \attribute\referenceattribute\lastreferenceattribute @@ -1226,7 +1305,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% \setlocationattributes \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty @@ -1243,7 +1322,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% \setlocationcolorspec{#resolver}% no consequence for strut \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty @@ -1260,7 +1339,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty \hbox attr \referenceattribute \lastreferenceattribute {#content}% @@ -1276,9 +1355,9 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% {\expandtexincurrentreference - \ctxlua{structures.references.injectcurrentset(nil,nil)}% + \ctxcommand{injectcurrentreference(nil,nil)}% \setlocationattributes \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty @@ -1298,8 +1377,8 @@ \ht\scratchbox#height% \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% - {\ctxlua{structures.references.injectcurrentset(nil,nil)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% + {\ctxcommand{injectcurrentreference(nil,nil)}% \global\lastsavedreferenceattribute\lastreferenceattribute \hbox attr \referenceattribute \lastreferenceattribute {\box\scratchbox}} {\box\scratchbox}% @@ -1386,14 +1465,18 @@ %D %D \showsetup{setupurl} -\unexpanded\def\setupurl - {\dodoubleargument\getparameters[\??ur]} +\installcorenamespace{url} + +\installdirectcommandhandler \??url {url} + +\setupurl + [\c!style=\v!type, + \c!color=] \unexpanded\def\url[#label]% move \hyphenatedurl to lua end (is already lua) {\dontleavehmode \begingroup - \dousestyleparameter\@@urstyle - \dousecolorparameter\@@urcolor + \useurlstyleandcolor\c!style\c!color \hyphenatedurl{\ctxcommand{geturl("#label")}}% \endgroup} @@ -1425,14 +1508,13 @@ \def\strc_references_do_special_from[#label]% {\dontleavehmode - \goto{\ctxlua{structures.references.from("#label")}}[fileorurl(#label)]} + \goto{\ctxcommand{from("#label")}}[fileorurl(#label)]} \def\dofromurldescription#content% called at the lua end {#content} \def\dofromurlliteral#content% called at the lua end - {\dousestyleparameter\@@urstyle - \dousecolorparameter\@@urcolor + {\useurlstyleandcolor\c!style\c!color \hyphenatedurl{#content}} \let\dofromfiledescription\dofromurldescription @@ -1463,21 +1545,21 @@ % also lua, like urls and files -\unexpanded\def\setupprograms - {\dodoubleargument\getparameters[\??pr]} +\installcorenamespace{programs} + +\installdirectcommandhandler \??programs {programs} \unexpanded\def\defineprogram {\dotripleargument\strc_references_define_program} \def\strc_references_define_program[#name][#program][#description]% - {\ctxlua{structures.references.programs.define("#name","#program","#description")}} + {\ctxcommand{defineprogram("#name",\!!bs#program\!!es,\!!bs#description\!!es)}} \def\program[#name]% incompatible, more consistent, hardy used anyway {\dontleavehmode \begingroup - \dousestyleparameter\@@prstyle - \dousecolorparameter\@@prcolor - \ctxlua{structures.references.programs.get("#name","\@@pralternative","\@@prspace")}% + \useprogramsstyleandcolor\c!style\c!color + \ctxcommand{getprogram("#name","\directprogramsparameter\c!alternative","\directprogramsparameter\c!space")}% \endgroup} %D As we can see, we directly use the special reference @@ -1571,7 +1653,11 @@ \setbox\scratchbox\hbox{#text}% to be solved some day \ifdim\wd\scratchbox>\zeropoint \unhbox\scratchbox - \doifsomething\@@rfseparator{\removeunwantedspaces\@@rfseparator}% remove is new + \edef\p_separator{\referencingparameter\c!separator}% + \ifx\p_separator\empty \else + \removeunwantedspaces % remove is new + \p_separator + \fi \else \unhbox\scratchbox \fi @@ -1598,10 +1684,6 @@ \c!separator=\nonbreakablespace, \c!export=\v!no] -\setupurl - [\c!style=\v!type, - \c!color=] - \setupprograms [\c!directory=, \c!style=\v!type, @@ -1699,7 +1781,9 @@ % todo: parameterhandler -\def\getreferencestructureprefix#kind#name#category% +\installcorenamespace{referencingprefix} + +\def\getreferencestructureprefix#kind#name#category% name will change {{ prefix = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefix", separatorset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixseparatorset", @@ -1715,22 +1799,30 @@ \def\strc_references_setup_reference_structure_prefix[#kind][#category][#settings]% {\ifthirdargument - \getparameters[\??rf:\c!prefix:#kind:#category][#settings]% + \getparameters[\??referencingprefix#kind:#category][#settings]% \else\ifsecondargument - \getparameters[\??rf:\c!prefix::#kind][#category]% + \getparameters[\??referencingprefix:#kind][#category]% \fi\fi} \def\referencestructureprefixparameter#kind#name#category#parameter% - {\ifcsname\??rf:\c!prefix:#name:#category#parameter\endcsname - \csname\??rf:\c!prefix:#name:#category#parameter\endcsname - \else\ifcsname\??rf:\c!prefix:#kind:#category#parameter\endcsname - \csname \??rf:\c!prefix:#kind:#category#parameter\endcsname - \else\ifcsname\??rf:\c!prefix::#category#parameter\endcsname - \csname \??rf:\c!prefix::#category#parameter\endcsname + {\ifcsname\??referencingprefix#name:#category#parameter\endcsname + \csname\??referencingprefix#name:#category#parameter\endcsname + \else\ifcsname\??referencingprefix#kind:#category#parameter\endcsname + \csname \??referencingprefix#kind:#category#parameter\endcsname + \else\ifcsname\??referencingprefix:#category#parameter\endcsname + \csname \??referencingprefix:#category#parameter\endcsname \fi\fi\fi} +% \def\currentreferencedefault +% {\ctxcommand{filterdefaultreference()}} + \def\currentreferencedefault - {\ctxlua{structures.references.filter("default",\ctxlua{structures.references.getcurrentprefixspec("\v!default")})}} + {\ctxcommand{filterreference("\s!default",\ctxcommand{getcurrentprefixspec("\s!default")})}} + +% needs testing +% +% \def\currentreferencedefault +% {\ctxcommand{currentreferencedefault()}} %D Not all support is visible by looking at the \TEX\ code; here is one of those:^ %D |