diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-con.mkvi')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-con.mkvi | 892 |
1 files changed, 892 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-con.mkvi b/Master/texmf-dist/tex/context/base/strc-con.mkvi new file mode 100644 index 00000000000..3068fda0ba7 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/strc-con.mkvi @@ -0,0 +1,892 @@ +%D \module +%D [ file=strc-con, +%D version=2008.10.20, +%D title=\CONTEXT\ Structure Macros, +%D subtitle=Constructions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Structure Macros / Constructions} + +\registerctxluafile{strc-con}{1.001} + +% todo: check if commands similar to lists +% todo: \strc_constructions_setup_counter\strc_constructions_setup_counter{#1} in setup ... synchronization +% +% ? : \def\showdnlisttext{\constructionparameter\c!listtext} % space in default +% +% maybe: pickup text and store in buffer ... +% +% \@@notemakeconstruction[##1]{}{##2}% +% \expandafter\endgroup\noteparameter\c!next}} +% +% todo: \currentconstructionattribute : can be a counter instead + + +%D Constructions are just descriptions but a bit more abstract so that +%D we can conveniently build upon them. They are not really meant for +%D users but module writers might find them useful. We mention a +%D couple of parameters but these are only mentioned because in the +%D shared code we map all resolvers to constructions. + +\unprotect + +\ifdefined\v!construction \else \def\v!construction{construction} \fi + +%D Todo: + +\installcorenamespace{construction} + +\installcommandhandler \??construction {construction} \??construction + +\let\setupconstructions\setupconstruction + +\setupconstructions[% + %c!title=, + %c!text=, + % + %c!style=, + %c!color=, + %c!command=, + %c!align=, + % + %c!headstyle=, + %c!headcolor=, + %c!headalign=, + % + %c!titlestyle=, + %c!titlecolor=, + %c!titlecommand=, + %c!titleleft=, + %c!titleright=, + % + %c!closesymbol=, + %c!closecommand=, + % + \c!alternative=\v!left, + \c!display=\v!yes, + \c!width=7em, + \c!distance=1em, + \c!titledistance=0.5em, + %c!hang=, + %c!sample=, + \c!margin=\v!no, + \c!before=\blank, + \c!inbetween=\blank, + \c!after=\blank, + %c!indentnext=, + %c!indenting=, + % + \c!expansion=\v!no, + %c!xmlsetup=, + %s!catcodes=, +] + +%D Constructions and alike uses similar structures. In order to prevent issues +%D we freeze some states. There is some overhead in the intermediate define +%D step (as we could set them directly) but this is more flexible (and looks +%D nicer). Keep in mind that descriptions, enumeration and notations are all +%D independent and that we just remap the resolvers. + +% \defineconstruction[test][handler=description,level=1] +% \defineconstruction[test][parent][handler=description,level=3] + +\installcorenamespace{constructionmain} % frozen after definition +\installcorenamespace{constructionlevel} % frozen after definition +\installcorenamespace{constructionclass} % frozen after definition + +\let\currentconstructionmain \empty +\let\currentconstructionlevel \empty +\let\currentconstructionhandler\empty + +\appendtoks + \ifx\currentconstructionparent\empty + \letvalue{\??constructionmain\currentconstruction}\currentconstruction + \definelist[\currentconstruction]% goodie + \else + \letvalue{\??constructionmain\currentconstruction}\currentconstructionparent + \definelist[\currentconstruction][\currentconstructionparent]% goodie + \fi + \setevalue{\??constructionlevel\currentconstruction}{\number\constructionparameter\c!level}% + \setevalue{\??constructionclass\currentconstruction}{\constructionparameter\s!handler}% +\to \everydefineconstruction + +\appendtoks + \setuevalue{\e!start\currentconstruction}{\strc_constructions_start{\currentconstruction}}% + \setuevalue{\e!stop \currentconstruction}{\strc_constructions_stop}% +\to \everydefineconstruction + +%D Just a basic environment (mostly for testing). We will provide a 'setup' based +%D plugin once the rest is sorted out. + +\unexpanded\def\strc_constructions_start#1% + {\begingroup + \strc_constructions_initialize{#1}% + \dodoubleempty\strc_constructions_start_regular} + +\unexpanded\def\strc_constructions_start_regular[#1][#2]% + {\strc_constructions_register[\c!label={\constructionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,#1][#2]% + \csname\??constructionstarthandler\currentconstructionhandler\endcsname} + +\unexpanded\def\strc_constructions_stop + {\csname\??constructionstophandler\currentconstructionhandler\endcsname + \endgroup} + +%D As we will build on top of the generic construction mechanism we +%D have handlers as a sort of plug in mechanism. In order to have +%D some consistency we share some namespaces. + +\installcorenamespace{constructioninitializer} +\installcorenamespace{constructionfinalizer} + +\installcorenamespace{constructionmainhandler} +\installcorenamespace{constructioncommandhandler} +\installcorenamespace{constructionstarthandler} +\installcorenamespace{constructionstophandler} + +\installcorenamespace{constructiontexthandler} +\installcorenamespace{constructionnotehandler} + +\unexpanded\def\strc_constructions_initialize#1% class instance + {\edef\currentconstruction{#1}% +\let\currentconstructionlistentry\!!zerocount + \expandafter\let\expandafter\currentconstructionmain \csname\??constructionmain \currentconstruction\endcsname + \expandafter\let\expandafter\currentconstructionlevel \csname\??constructionlevel\currentconstruction\endcsname + \expandafter\let\expandafter\currentconstructionhandler\csname\??constructionclass\currentconstruction\endcsname + \csname\??constructioninitializer\currentconstructionhandler\endcsname} + +\unexpanded\def\strc_constructions_finalize + {\csname\??constructionfinalizer\currentconstructionhandler\endcsname + \strc_constructions_discard} + +\newconditional\c_strc_constructions_number_state +\newconditional\c_strc_constructions_title_state + +\setvalue{\??constructioninitializer\v!construction}% + {\setfalse\c_strc_constructions_number_state + \setfalse\c_strc_constructions_title_state} + +\setvalue{\??constructionfinalizer\v!construction}% + {} + +% We keep the command variant around but rather would move to the +% start-stop one. Also, passing the title as argument has some +% history so we need to keep that as well. + +\ifdefined\dotagsetconstruction \else \let\dotagsetconstruction\relax \fi + +\newtoks\everyconstruction + +\unexpanded\def\currentconstructiontext + {\begstrut + \csname\??constructiontexthandler\currentconstructionhandler\endcsname + \endstrut} + +\unexpanded\def\currentconstructionsample + {\begstrut + \constructionparameter\c!text + \constructionparameter\c!sample + \endstrut} + +\setvalue{\??constructionmainhandler\v!construction}#1% + {\iftrialtypesetting \else + \begingroup + \currentconstructionsynchronize % reinstated + \attribute\destinationattribute\currentconstructionattribute\relax % todo, whole text + \signalcharacter + \endgroup + \fi#1} + +\setvalue{\??constructiontexthandler\v!construction}% + {\begingroup + \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext + \the\everyconstruction + \constructionparameter\c!headcommand + {\strut + \constructionparameter\c!text + \ctxcommand{savedlisttitle("\currentconstructionmain",\currentconstructionlistentry)}}% + \endgroup} + +\unexpanded\def\strc_constructions_stored_start + {\begingroup % brrr \endgroup elsewhere ... will be sorted out + \csname\??constructionstarthandler\currentconstructionhandler\endcsname} + +\unexpanded\def\strc_constructions_stored_stop + {\csname\??constructionstophandler\currentconstructionhandler\endcsname} + +\newconstant\c_strc_constructions_nested_state % to be redone + +\def\resetconstructions % to be used in e.g. footnotes + {\c_strc_constructions_nested_state\zerocount} + +\setvalue{\??constructioncommandhandler\v!construction}% + {\endgroup} + +\setvalue{\??constructionstarthandler\v!construction}% this will be redone (reorganized) .. too much boxing + {\dostarttagged\t!construction\currentconstruction + \dotagsetconstruction + \constructionparameter\c!before + \begingroup + \edef\currentconstructionalternative{\constructionparameter\c!alternative}% + \doadaptleftskip{\constructionparameter\c!margin}% + \setlocalhsize % so we can use \localhsize in width assignments + \constructionsheaddistance\constructionalternativeparameter\c!distance\relax + \ifdim\constructionsheaddistance=\zeropoint + \doif{\constructionalternativeparameter\c!width}\v!broad{\constructionsheaddistance\emwidth}% + \fi + % inefficient and not always needed, for instance not with margins so we will make checkers + % per alternative + \setbox\constructionheadbox\hbox + {\forgetall + \dontcomplain + \settrialtypesetting + \doifelsenothing{\constructionparameter\c!sample} + {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext}% + {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructionsample}}% + \assignwidth + {\constructionalternativeparameter\c!width} + \constructionsheadwidth + {\unhcopy\constructionheadbox} + \constructionsheaddistance + \dostarttagged\t!constructiontag\empty % todo + \setbox\constructionheadbox\hbox + {\forgetall + \dontcomplain + \doifelse{\constructionparameter\c!alternative}\v!serried % brrr, hack, will change + {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext} + {\csname\??constructionmainhandler\currentconstructionhandler\endcsname{\boxedconstructionhead\currentconstructiontext}}}% + \doifelse{\constructionparameter\c!aligntitle}\v!no + {\leftconstructionskip \leftskip + \rightconstructionskip\rightskip} + {\ifcase\c_strc_constructions_nested_state + \leftconstructionskip \leftskip + \rightconstructionskip\rightskip + \fi}% + \doifsomething{\constructionparameter\c!align}{\setupalign[\constructionparameter\c!align]}% \use... + \indenting[\constructionparameter\c!indenting]% \use... + \ifcase\c_strc_constructions_nested_state + \c_strc_constructions_nested_state\plusone + \or + \c_strc_constructions_nested_state\plustwo + \fi + \strc_constructions_close_symbol_reset + % + \doifnotsetups {\constructionalternativeparameter\c!renderingsetup} + {\let\currentconstructionalternative\v!left}% + \directsetup{\constructionalternativeparameter\c!renderingsetup}\relax + % + \dostoptagged % tag + \dostarttagged\t!constructioncontent\empty + \ignorespaces} % args not needed + +\setvalue{\??constructionstophandler\v!construction}% + {\strc_constructions_close_symbol_place + \doifnot{\constructionparameter\c!display}\v!no\par + \dostoptagged % content + \dostoptagged % construction + \endgroup + \constructionparameter\c!after + \useindentnextparameter\constructionparameter + \strc_constructions_finalize +% \endgroup + \dorechecknextindentation} + +\def\boxedconstructionhead#1% + {\vtop + {\hsize\constructionsheadwidth + \doifsomething{\constructionparameter\c!headalign}{\setupalign[\constructionparameter\c!headalign]}% + #1}} + +\installcorenamespace{constructionalternative} +\installcorenamespace{constructionrenderings} + +% see lists: alternativemethods ... todo + +\installcommandhandler \??constructionalternative {constructionalternative} \??constructionalternative + +\setupconstructionalternative + [\c!width=\constructionparameter\c!width, + \c!distance=\constructionparameter\c!distance] + +\defineconstructionalternative + [\v!left] + [%\c!width=7em, + %\c!distance=1em, + \c!renderingsetup=\??constructionrenderings:\v!left] + +\defineconstructionalternative + [\v!right] + [%\c!width=7em, + %\c!distance=1em, + \c!renderingsetup=\??constructionrenderings:\v!right] + +\defineconstructionalternative + [\v!inmargin] + [\c!renderingsetup=\??constructionrenderings:\v!inmargin] + +\defineconstructionalternative + [\v!inleft] + [\c!renderingsetup=\??constructionrenderings:\v!inleft] + +\defineconstructionalternative + [\v!inright] + [\c!renderingsetup=\??constructionrenderings:\v!inright] + +\defineconstructionalternative + [\v!margin] + [\c!renderingsetup=\??constructionrenderings:\v!margin] + +\defineconstructionalternative + [\v!leftmargin] + [\c!renderingsetup=\??constructionrenderings:\v!leftmargin] + +\defineconstructionalternative + [\v!rightmargin] + [\c!renderingsetup=\??constructionrenderings:\v!rightmargin] + +\defineconstructionalternative + [\v!innermargin] + [\c!renderingsetup=\??constructionrenderings:\v!innermargin] + +\defineconstructionalternative + [\v!outermargin] + [\c!renderingsetup=\??constructionrenderings:\v!outermargin] + +\defineconstructionalternative + [\v!serried] + [\c!renderingsetup=\??constructionrenderings:\v!serried] + +\defineconstructionalternative + [\v!hanging] + [%\c!width=\v!fit, + \c!renderingsetup=\??constructionrenderings:\v!hanging] + +\defineconstructionalternative + [\v!top] + [\c!renderingsetup=\??constructionrenderings:\v!top, + \c!width=\localhsize] + +\defineconstructionalternative + [\v!command] + [\c!renderingsetup=\??constructionrenderings:\v!command] + +\newbox \constructionheadbox +\newskip \leftconstructionskip +\newskip \rightconstructionskip +\newdimen \constructionsheadwidth % replaces \!!widtha % TODO: proper namespace dimens +\newdimen \constructionsheaddistance % replaces \!!widthb % TODO: proper namespace dimens + +\def\strc_constructions_set_hang_box#1% messy left/rightskip + {\setbox\constructionheadbox\vtop % \vbox gaat fout in hang + {\forgetall + \dontcomplain + \hsize\constructionsheadwidth + \edef\p_headalign{\constructionparameter\c!headalign}% + \ifx\p_headalign\empty + \setupalign[#1]% use fast one + \else + \setupalign[\p_headalign]% use fast one + \fi + \advance\ifx#1\v!flushleft\rightskip\else\leftskip\fi\constructionsheaddistance % only difference and wrong anyway + \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \ht\constructionheadbox\strutht + \dp\constructionheadbox\strutdp} + +\def\strc_constructions_set_pure_box#1% default ... better set up differently + {\setbox\constructionheadbox\vtop + {\forgetall + \dontcomplain + \hsize\constructionsheadwidth + \edef\p_headalign{\constructionparameter\c!headalign}% + \ifx\p_headalign\empty + \setupalign[#1]% use fast one + \else + \setupalign[\p_headalign]% use fast one + \fi + \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \ht\constructionheadbox\strutht + \dp\constructionheadbox\strutdp} + +\def\strc_constructions_set_hang#1% + {\edef\p_hang{\constructionparameter\c!hang}% + \ifx\p_hang\empty + \else\ifx\p_hang\v!fit + \scratchdimen\htdp\constructionheadbox + \getnoflines\scratchdimen + \hangafter-\noflines + \else\ifx\p_hang\v!broad + \scratchdimen\dimexpr\htdp\constructionheadbox+.5\strutht\relax + \getnoflines\scratchdimen + \hangafter-\noflines + \else + \hangafter-\p_hang + \fi\fi\fi + \relax + \hangindent\ifx#1\v!right-\fi\constructionsheadwidth} + +% The setups. These only deal with placement of the descriptor and initializing the +% environment. The wrapping happens elsewhere. + +\startsetups[\??constructionrenderings:\v!left] + \edef\p_hang{\constructionparameter\c!hang} + \doifsetupselse{\??constructionrenderings:\v!left:\p_hang} { + \directsetup{\??constructionrenderings:\v!left:\p_hang} + } { + \directsetup{\??constructionrenderings:\v!left:\v!hanging} + } +\stopsetups + +\startsetups[\??constructionrenderings:\v!right] + \edef\p_hang{\constructionparameter\c!hang} + \doifsetupselse{\??constructionrenderings:\v!right:\p_hang} { + \directsetup{\??constructionrenderings:\v!right:\p_hang} + } { + \directsetup{\??constructionrenderings:\v!right:\v!hanging} + } +\stopsetups + +\startsetups[\??constructionrenderings:\v!left:\v!none] + \let\\=\crlf + \noindent + \strc_constructions_set_pure_box\v!flushleft + \leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth\relax + \rightskip\rightconstructionskip + \advance\leftskip\constructionsheaddistance + \llap { + \hbox to \leftskip { + \hskip\leftconstructionskip + \copy\constructionheadbox\hss + } + } + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!left:0] + \directsetup{\??constructionrenderings:\v!left:\v!none} +\stopsetups + +\startsetups[\??constructionrenderings:\v!left:] + \directsetup{\??constructionrenderings:\v!left:\v!none} +\stopsetups + +\startsetups[\??constructionrenderings:\v!right:\v!none] + \let\\=\crlf + \noindent + \leftskip\leftconstructionskip + \rightskip\dimexpr\rightconstructionskip+\constructionsheadwidth\relax + %\strc_constructions_pure_hang_box\raggedleft + \strc_constructions_set_pure_box\v!flushright + \rlap { + \hskip\dimexpr\hsize-\leftskip-\rightskip\relax + \copy\constructionheadbox + \hskip\rightconstructionskip + } + \advance\rightskip \constructionsheaddistance + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!right:0] + \directsetup{\??constructionrenderings:\v!right:\v!none} +\stopsetups + +\startsetups[\??constructionrenderings:\v!right:] + \directsetup{\??constructionrenderings:\v!right:\v!none} +\stopsetups + +\startsetups[\??constructionrenderings:\v!left:\v!margin]% + \let\\=\crlf + \noindent + \strc_constructions_set_pure_box\v!flushleft + \llap { + \hbox to \constructionsheadwidth { + \copy\constructionheadbox + \hss + } + \hskip\constructionsheaddistance + } + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!right:\v!margin]% + \let\\=\crlf + \noindent + \strc_constructions_set_pure_box\v!flushright + \rlap { + \hskip\constructionsheaddistance + \hbox to \constructionsheadwidth { + \copy\constructionheadbox\hss + } + } + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!left:\v!hanging]% + \let\\=\crlf + \dontcomplain + \advance\constructionsheadwidth \constructionsheaddistance + \strc_constructions_set_hang_box\v!flushleft + \strc_constructions_set_hang\v!left + \noindent + \llap { + \vtop to \zeropoint { + \box\constructionheadbox + } + } + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!right:\v!hanging]% + \let\\=\crlf + \dontcomplain + \advance\constructionsheadwidth \constructionsheaddistance + \strc_constructions_set_hang_box\v!flushright + \strc_constructions_set_hang\v!right + \noindent + \rlap { + \hbox to \dimexpr\hsize-\leftskip-\rightskip\relax { + \hss + \vtop to \zeropoint { + \box\constructionheadbox + } + } + } + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!top] + \dohandlepagebreakX\plusone + \let\\=\space + \noindent + \copy\constructionheadbox\par % copy ? + \nobreak + \doifelsenothing{\constructionparameter\c!inbetween}{\blank}{\constructionparameter\c!inbetween}% + \nobreak + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +% why copy? historic reason? + +\startsetups[\??constructionrenderings:\v!margin] + \let\\=\crlf + \noindent + \inmargin[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!leftmargin] + \let\\=\crlf + \noindent + \inleft[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!rightmargin] + \let\\=\crlf + \noindent + \inright[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!innermargin] + \let\\=\crlf + \noindent + \ininner[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!outermargin] + \let\\=\crlf + \noindent + \inouter[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!inmargin] + \directsetup{\??constructionrenderings:\v!margin} +\stopsetups + +\startsetups[\??constructionrenderings:\v!inleft] + \directsetup{\??constructionrenderings:\v!leftmargin} +\stopsetups + +\startsetups[\??constructionrenderings:\v!inright] + \directsetup{\??constructionrenderings:\v!rightmargin} +\stopsetups + +\startsetups[\??constructionrenderings:\v!serried] + \edef\p_width{\constructionparameter\c!width}% CHECK ! ! ! wrong parameter namespace + \doifsetupselse{\??constructionrenderings:\v!serried:\p_width} { + \directsetup{\??constructionrenderings:\v!serried:\p_width} + } { + \directsetup{\??constructionrenderings:\v!serried:\v!wide} + } +\stopsetups + +\startsetups[\??constructionrenderings:\v!serried:\v!fit] + \let\\=\crlf + \noindent + \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox + \hskip\constructionsheaddistance\relax + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!serried:\v!broad] + \let\\=\crlf + \noindent + \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox + \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!serried:] + \directsetup{\??constructionrenderings:\v!serried:\v!broad} +\stopsetups + +\startsetups[\??constructionrenderings:\v!serried:\v!wide] + \let\\=\crlf + \noindent + \hbox to \constructionsheadwidth { + \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox + \hss + } + \hskip\constructionsheaddistance\relax + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +\startsetups[\??constructionrenderings:\v!hanging] + % tricky: leftskipadaption is somewhat unpredictable + \let\\=\crlf + \noindent + \advance\leftskip-\leftskipadaption\relax + \ifdim\leftskipadaption=\zeropoint + \leftskipadaption1.5em\relax % just some default + \ifnum\c_strc_constructions_nested_state=\plusone + \ifdim\leftskip>\zeropoint \relax + \leftskipadaption\leftskip + \fi + \fi + \fi + \ifnum\c_strc_constructions_nested_state>\zerocount % was \ifnum\c_strc_constructions_nested_state=\plusone + \advance\leftskip\leftskipadaption % but we're already further on + \fi + \hskip-\leftskipadaption\relax + \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox + \kern\ifdim\constructionsheaddistance=\zeropoint .75em\else\constructionsheaddistance\fi + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +%D \starttyping +%D \setupfootnotation[location=command,headcommand=\llap] +%D \stoptyping + +\startsetups[\??constructionrenderings:\v!command] + \noindent + \constructionparameter\c!headcommand{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox} + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +% you can use \placeclosesymbol or \qed to place a symbol at the end of a +% construction + +\installcorenamespace{constructionclosesymbol} + +\let\placeclosesymbol\donothing +\let\qed \donothing + +\def\strc_constructions_close_symbol_reset % no need for global + {\global\expandafter\settrue\csname\??constructionclosesymbol\currentconstruction\endcsname + \let\placeclosesymbol\strc_constructions_close_symbol_place + \let\qed \strc_constructions_close_symbol_place} + +\unexpanded\def\strc_constructions_close_symbol_place + {\ifconditional\csname\??constructionclosesymbol\currentconstruction\endcsname + \global\expandafter\setfalse\csname\??constructionclosesymbol\currentconstruction\endcsname + \edef\p_closesymbol{\constructionparameter\c!closesymbol}% + \ifx\p_closesymbol\empty \else + \constructionparameter\c!closecommand{\p_closesymbol}% hm why {} maybe because box expected + \fi + \fi} + +\newif\ifnoconstructioncaption + +%D The storage macros: + +\let\currentconstructionlistentry\!!zerocount + +\def\strc_constructions_register + {\ctxcommand{doiflisthasentry(\currentconstructionlistentry)}% + \strc_constructions_register_nop + \strc_constructions_register_yes} + +% \def\strc_constructions_register{\strc_constructions_register_yes} + +\def\strc_constructions_register_nop[#1][#2]% #1=interfaced-settings, #2=optional user data + %{\writestatus{constructions}{reusing \currentconstruction: \number\currentconstructionlistentry}} + {} + +\def\strc_constructions_discard + {\iftrialtypesetting + % \writestatus{constructions}{discarding \currentconstruction: \number\currentconstructionlistentry}% + \ctxcommand{discardfromlist(\currentconstructionlistentry)}% + \fi} + +\let\currentconstructionlistnumber \!!zerocount +\let\currentconstructionsynchronize\relax +\let\currentconstructionattribute \attributeunsetvalue + +\def\strc_constructions_register_yes[#1][#2]% #1=interfaced-settings, #2=optional user data + {\begingroup % similar to structure so we might generalize this + \setupcurrentconstruction[#1]% % xdef's will become edef's + \xdef\currentconstructionexpansion {\constructionparameter\c!expansion}% + \xdef\currentconstructionxmlsetup {\constructionparameter\c!xmlsetup}% + \xdef\currentconstructioncatcodes {\constructionparameter\s!catcodes}% + \xdef\currentconstructionlabel {\constructionparameter\c!label}% + \xdef\currentconstructionreference {\constructionparameter\c!reference}% + \xdef\currentconstructionreferenceprefix{\constructionparameter\c!referenceprefix}% + %xdef\currentconstructionshownumber {\constructionparameter\c!number}% + \xdef\currentconstructionincrementnumber{\constructionparameter\c!incrementnumber}% + % + \ifx\currentconstructionexpansion\empty + \global\let\currentconstructionexpansion\v!no + \fi + % + \ifx\currentconstructionexpansion\s!xml + \xmlstartraw + \xdef\currentconstructiontitle {\constructionparameter\c!title}% + \xdef\currentconstructionbookmark{\constructionparameter\c!bookmark}% + \xdef\currentconstructionmarking {\constructionparameter\c!marking}% + \xdef\currentconstructionlist {\constructionparameter\c!list}% + \xmlstopraw + \ifx\currentconstructionlist\empty + \global\let\currentconstructionlist\currentconstructiontitle + \fi + \global\let\currentconstructioncoding\s!xml + \else + \ifx\currentconstructionexpansion\v!yes + \xdef\currentconstructiontitle {\constructionparameter\c!title}% + \xdef\currentconstructionbookmark{\constructionparameter\c!bookmark}% + \xdef\currentconstructionmarking {\constructionparameter\c!marking}% + \xdef\currentconstructionlist {\constructionparameter\c!list}% + \else + \xdef\currentconstructiontitle {\detokenizedconstructionparameter\c!title}% + \xdef\currentconstructionbookmark{\detokenizedconstructionparameter\c!bookmark}% + \xdef\currentconstructionmarking {\detokenizedconstructionparameter\c!marking}% + \xdef\currentconstructionlist {\detokenizedconstructionparameter\c!list}% + \iflocation \ifx\currentconstructionbookmark\empty + \begingroup + \simplifycommands + \xdef\currentconstructionbookmark{\detokenize\expandafter{\normalexpanded{\constructionparameter\c!title}}}% + \endgroup + \fi \fi + \fi + \ifx\currentconstructionlist\empty + \globallet\currentconstructionlist\currentconstructiontitle + \fi + \globallet\currentconstructioncoding\s!tex + \fi + % + \ifx\currentconstructiontitle\v!none % will become obsolete + \global\noconstructioncaptiontrue\global\noconstructionnumbertrue + \fi + % + \ifnoconstructioncaption % then why analyze anyway? + \endgroup + \let\currentconstructionlistnumber \relax + \let\currentconstructionsynchronize\relax + \let\currentconstructionattribute \relax + \else + \setnextinternalreferences{construction}\currentconstructionmain % plural + \relax + \scratchcounter\ctxcommand{addtolist{ % we can set a counter at the lua end + metadata = { + kind = "construction", + name = "\currentconstructionmain", + level = structures.sections.currentlevel(), + catcodes = \the\catcodetable, + % \currentdirectionparameters + }, + references = { + internal = \nextinternalreference, + order = \nextinternalorderreference, + reference = "\currentconstructionreference", + referenceprefix = "\referenceprefix", + block = "\currentsectionblock", + section = structures.sections.currentid(), + }, + titledata = { + label = \!!bs\detokenize\expandafter{\currentconstructionlabel }\!!es, + title = \!!bs\detokenize\expandafter{\currentconstructiontitle }\!!es, + \ifx\currentconstructionbookmark\currentconstructiontitle \else + bookmark = \!!bs\detokenize\expandafter{\currentconstructionbookmark}\!!es, + \fi + \ifx\currentconstructionlist\currentconstructiontitle \else + list = \!!bs\detokenize\expandafter{\currentconstructionlist }\!!es, + \fi + }, + \ifconditional\c_strc_constructions_number_state + prefixdata = { + prefix = "\constructionparameter\c!prefix", + separatorset = "\constructionparameter\c!prefixseparatorset", + conversion = \!!bs\constructionparameter\c!prefixconversion\!!es, + conversionset = "\constructionparameter\c!prefixconversionset", + set = "\constructionparameter\c!prefixset", + segments = "\constructionparameter\c!prefixsegments", + connector = \!!bs\constructionparameter\c!prefixconnector\!!es, + }, + numberdata = { + numbers = structures.counters.compact("\currentconstructionnumber",nil,true), % ! number can be cloned + separatorset = "\constructionparameter\c!numberseparatorset", + conversion = "\constructionparameter\c!numberconversion", + conversionset = "\constructionparameter\c!numberconversionset", + starter = \!!bs\constructionparameter\c!numberstarter\!!es, + stopper = \!!bs\constructionparameter\c!numberstopper\!!es, + segments = "\constructionparameter\c!numbersegments", + }, + \or + % symbol + \fi + userdata = \!!bs\detokenize{#2}\!!es % will be converted to table at the lua end + } + }\relax + % \writestatus{constructions}{registering \currentconstruction: \number\scratchcounter}% + \normalexpanded{% + \endgroup + \edef\noexpand\currentconstructionlistentry {\the\scratchcounter}% + \edef\noexpand\currentconstructionattribute {\ctxcommand {setinternalreference("\referenceprefix","\currentconstructionreference",\nextinternalreference,"\interactionparameter\c!focus")}}% + \edef\noexpand\currentconstructionsynchronize{\ctxlatecommand{enhancelist(\the\scratchcounter)}}% + }% + \fi} + +% This is not so nice, some day I'll just store the number with the entry +% and deal with all at the Lua end, but first we need to be able to set +% macros. + +\def\reinstateconstructionnumberentry#1% was xdef + {\edef\currentconstructionattribute {\ctxcommand {getinternalreference(#1)}}% + \edef\currentconstructionsynchronize{\ctxlatecommand{enhancelist(#1)}}} + +\installstructurelistprocessor{construction}{\usestructurelistprocessor{number+title}} + +\protect \endinput |