summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-ref.mkvi
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/strc-ref.mkvi')
-rw-r--r--tex/context/base/strc-ref.mkvi346
1 files changed, 207 insertions, 139 deletions
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index ee45d76fa..7efc967b7 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/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
@@ -96,10 +118,10 @@
%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}{}}
%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 +130,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 +165,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 +185,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 +232,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 +270,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 +290,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 +520,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 +556,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","#labels",\luaconditional\highlighthyperlinks,\luaconditional\gotonewwindow)}%
{\expandtexincurrentreference
#yes}%
{#nop}}
@@ -562,8 +645,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,14 +671,14 @@
{\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}
@@ -630,8 +713,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 +720,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 +748,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 +869,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 +944,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 +955,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 +1130,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 +1207,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 +1226,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 +1245,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 +1268,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 +1289,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 +1306,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 +1323,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 +1339,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 +1361,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 +1449,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 +1492,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 +1529,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","#program","#description")}}
\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 +1637,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 +1668,6 @@
\c!separator=\nonbreakablespace,
\c!export=\v!no]
-\setupurl
- [\c!style=\v!type,
- \c!color=]
-
\setupprograms
[\c!directory=,
\c!style=\v!type,
@@ -1699,7 +1765,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 +1783,22 @@
\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
- {\ctxlua{structures.references.filter("default",\ctxlua{structures.references.getcurrentprefixspec("\v!default")})}}
+ {\ctxcommand{filterdefaultreference()}}
%D Not all support is visible by looking at the \TEX\ code; here is one of those:^
%D