diff options
Diffstat (limited to 'tex/context/base/strc-con.mkvi')
-rw-r--r-- | tex/context/base/strc-con.mkvi | 197 |
1 files changed, 82 insertions, 115 deletions
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi index 64371579a..956acaae5 100644 --- a/tex/context/base/strc-con.mkvi +++ b/tex/context/base/strc-con.mkvi @@ -27,16 +27,17 @@ % % todo: \currentconstructionattribute : can be a counter instead -%D Constructions are just descriptions but a bit more abstract so that we can -%D conveniently build upon them. They are not really meant for users but module -%D writers might find them useful. We mention a couple of parameters but these are -%D only mentioned because in the shared code we map all resolvers to constructions. -%D -%D On top of constructions we build descriptions, enumerations, notes, labels and -%D maybe some day more. + +%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} @@ -69,9 +70,9 @@ % \c!alternative=\v!left, \c!display=\v!yes, - \c!width=7\emwidth, - \c!distance=\emwidth, - \c!titledistance=.5\emwidth, + \c!width=7em, + \c!distance=1em, + \c!titledistance=0.5em, %c!hang=, %c!sample=, \c!margin=\v!no, @@ -136,9 +137,9 @@ {\csname\??constructionstophandler\currentconstructionhandler\endcsname \endgroup} -%D As we will build on top of the generic construction mechanism we have handlers -%D as a sort of plug in mechanism. In order to have some consistency we share -%D some namespaces. +%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} @@ -153,7 +154,7 @@ \unexpanded\def\strc_constructions_initialize#1% class instance {\edef\currentconstruction{#1}% - \let\currentconstructionlistentry\!!zerocount +\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 @@ -166,16 +167,16 @@ \newconditional\c_strc_constructions_number_state \newconditional\c_strc_constructions_title_state -\unexpanded\setvalue{\??constructioninitializer\v!construction}% +\setvalue{\??constructioninitializer\v!construction}% {\setfalse\c_strc_constructions_number_state \setfalse\c_strc_constructions_title_state} -\unexpanded\setvalue{\??constructionfinalizer\v!construction}% +\setvalue{\??constructionfinalizer\v!construction}% {} -%D We keep the command variant around but rather would move to the start-stop one. -%D Also, passing the title as argument has some history so we need to keep that as -%D well. +% 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 @@ -189,10 +190,10 @@ \unexpanded\def\currentconstructionsample {\begstrut \constructionparameter\c!text - \p_strc_constructions_sample + \constructionparameter\c!sample \endstrut} -\unexpanded\setvalue{\??constructionmainhandler\v!construction}#1% +\setvalue{\??constructionmainhandler\v!construction}#1% {\iftrialtypesetting \else \begingroup \currentconstructionsynchronize % reinstated @@ -201,7 +202,7 @@ \endgroup \fi#1} -\unexpanded\setvalue{\??constructiontexthandler\v!construction}% +\setvalue{\??constructiontexthandler\v!construction}% {\begingroup \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext \the\everyconstruction @@ -223,54 +224,36 @@ \def\resetconstructions % to be used in e.g. footnotes {\c_strc_constructions_nested_state\zerocount} -\unexpanded\setvalue{\??constructioncommandhandler\v!construction}% +\setvalue{\??constructioncommandhandler\v!construction}% {\endgroup} -\let\p_strc_constructions_sample \empty -\let\p_strc_constructions_align \empty -\let\p_strc_constructions_indenting \empty -\let\p_strc_constructions_width \empty -\let\p_strc_constructions_aligntitle \empty -\let\p_strc_constructions_renderingsetup\empty -\let\p_strc_constructions_headalign \empty -\let\p_strc_constructions_hang \empty -\let\p_strc_constructions_inbetween \empty -\let\p_strc_constructions_closesymbol \empty - -\unexpanded\setvalue{\??constructionstarthandler\v!construction}% this will be redone (reorganized) .. too much boxing +\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}% % \checkconstructionalternativeparent % this catches an unknown alternative - \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}% - \doifnotsetups\p_strc_constructions_renderingsetup + \doifnotsetups{\constructionalternativeparameter\c!renderingsetup} {\letconstructionparameter\c!alternative\v!left \let\currentconstructionalternative\v!left}% \doadaptleftskip{\constructionparameter\c!margin}% \setlocalhsize % so we can use \localhsize in width assignments \constructionsheaddistance\constructionalternativeparameter\c!distance\relax - \edef\p_strc_constructions_width{\constructionalternativeparameter\c!width}% \ifdim\constructionsheaddistance=\zeropoint - \ifx\p_strc_constructions_width\v!broad - \constructionsheaddistance\emwidth - \fi + \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 some day (especially in labels this is unwanted overhead) + % per alternative \setbox\constructionheadbox\hbox {\forgetall \dontcomplain \settrialtypesetting - \edef\p_strc_constructions_sample{\constructionparameter\c!sample}% - \ifx\p_strc_constructions_sample\empty - \csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext - \else - \csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructionsample - \fi}% + \doifelsenothing{\constructionparameter\c!sample} + {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext}% + {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructionsample}}% \assignwidth - \p_strc_constructions_width + {\constructionalternativeparameter\c!width} \constructionsheadwidth {\unhcopy\constructionheadbox} \constructionsheaddistance @@ -283,24 +266,15 @@ \else \csname\??constructionmainhandler\currentconstructionhandler\endcsname{\boxedconstructionhead\currentconstructiontext}% \fi}% - \edef\p_strc_constructions_aligntitle{\constructionparameter\c!aligntitle}% - \ifx\p_strc_constructions_aligntitle\v!no - \leftconstructionskip \leftskip - \rightconstructionskip\rightskip - \else - \ifcase\c_strc_constructions_nested_state - \leftconstructionskip \leftskip - \rightconstructionskip\rightskip - \fi - \fi - \edef\p_strc_constructions_align{\constructionparameter\c!align}% - \ifx\p_strc_constructions_align\empty \else - \setupalign[\p_strc_constructions_align]% \use... - \fi - \edef\p_strc_constructions_indenting{\constructionparameter\c!indenting}% - \ifx\p_strc_constructions_indenting\empty \else - \indenting[\p_strc_constructions_indenting]% \use... - \fi + \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 @@ -308,15 +282,15 @@ \fi \strc_constructions_close_symbol_reset % - \edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}% - % - \directsetup\p_strc_constructions_renderingsetup\relax + % \doifnotsetups {\constructionalternativeparameter\c!renderingsetup} + % {\let\currentconstructionalternative\v!left}% + \directsetup{\constructionalternativeparameter\c!renderingsetup}\relax % \dostoptagged % tag \dostarttagged\t!constructioncontent\empty \ignorespaces} % args not needed -\unexpanded\setvalue{\??constructionstophandler\v!construction}% +\setvalue{\??constructionstophandler\v!construction}% {\strc_constructions_close_symbol_place \doifnot{\constructionparameter\c!display}\v!no\par \dostoptagged % content @@ -328,21 +302,16 @@ % \endgroup \dorechecknextindentation} -\unexpanded\def\boxedconstructionhead#1% +\def\boxedconstructionhead#1% {\vtop {\hsize\constructionsheadwidth - \edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}% - \ifx\p_strc_constructions_headalign\empty \else - \setupalign[\p_strc_constructions_headalign]% \use... - \fi + \doifsomething{\constructionparameter\c!headalign}{\setupalign[\constructionparameter\c!headalign]}% #1}} \installcorenamespace{constructionalternative} \installcorenamespace{constructionrenderings} % see lists: alternativemethods ... todo -% -% there will be a proper interface to variables \installcommandhandler \??constructionalternative {constructionalternative} \??constructionalternative @@ -422,15 +391,16 @@ {\setbox\constructionheadbox\vtop % \vbox gaat fout in hang {\forgetall \dontcomplain - \hsize\constructionsheadwidth\relax - \ifx\p_strc_constructions_headalign\empty + \hsize\constructionsheadwidth + \edef\p_headalign{\constructionparameter\c!headalign}% + \ifx\p_headalign\empty \setupalign[#1]% use fast one \else - \setupalign[\p_strc_constructions_headalign]% use fast one + \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}% - \setbox\constructionheadbox\hbox{\box\constructionheadbox}% needed in case of e.g. a real big head font, see descriptions-006.tex +\setbox\constructionheadbox\hbox{\box\constructionheadbox}% needed in case of e.g. a real big head font, see descriptions-006.tex \ht\constructionheadbox\strutht \dp\constructionheadbox\strutdp} @@ -438,11 +408,12 @@ {\setbox\constructionheadbox\vtop {\forgetall \dontcomplain - \hsize\constructionsheadwidth\relax - \ifx\p_strc_constructions_headalign\empty + \hsize\constructionsheadwidth + \edef\p_headalign{\constructionparameter\c!headalign}% + \ifx\p_headalign\empty \setupalign[#1]% use fast one \else - \setupalign[\p_strc_constructions_headalign]% use fast one + \setupalign[\p_headalign]% use fast one \fi \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% \setbox\constructionheadbox\hbox{\box\constructionheadbox}% needed in case of e.g. a real big head font, see descriptions-006.tex @@ -450,18 +421,18 @@ \dp\constructionheadbox\strutdp} \def\strc_constructions_set_hang#1% - {\ifx\p_strc_constructions_hang\empty - % nothing - \else\ifx\p_strc_constructions_hang\v!fit + {\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_strc_constructions_hang\v!broad + \else\ifx\p_hang\v!broad \scratchdimen\dimexpr\htdp\constructionheadbox+.5\strutht\relax \getnoflines\scratchdimen \hangafter-\noflines \else - \hangafter-\p_strc_constructions_hang + \hangafter-\p_hang \fi\fi\fi \relax \hangindent\ifx#1\v!right-\fi\constructionsheadwidth} @@ -470,18 +441,18 @@ % environment. The wrapping happens elsewhere. \startsetups[\??constructionrenderings:\v!left] - \edef\p_strc_constructions_hang{\constructionparameter\c!hang}% - \doifsetupselse{\??constructionrenderings:\v!left:\p_strc_constructions_hang} { - \directsetup{\??constructionrenderings:\v!left:\p_strc_constructions_hang} + \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_strc_constructions_hang{\constructionparameter\c!hang} - \doifsetupselse{\??constructionrenderings:\v!right:\p_strc_constructions_hang} { - \directsetup{\??constructionrenderings:\v!right:\p_strc_constructions_hang} + \edef\p_hang{\constructionparameter\c!hang} + \doifsetupselse{\??constructionrenderings:\v!right:\p_hang} { + \directsetup{\??constructionrenderings:\v!right:\p_hang} } { \directsetup{\??constructionrenderings:\v!right:\v!hanging} } @@ -491,8 +462,9 @@ \let\\=\crlf \noindent \strc_constructions_set_pure_box\v!flushleft - \leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth+\constructionsheaddistance\relax - \rightskip\rightconstructionskip\relax + \leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth\relax + \rightskip\rightconstructionskip + \advance\leftskip\constructionsheaddistance \llap { \hbox to \leftskip { \hskip\leftconstructionskip @@ -601,18 +573,13 @@ \stopsetups \startsetups[\??constructionrenderings:\v!top] - \strc_sectioning_prevent_page_break\plusone + \dohandlepagebreakX\plusone \let\\=\space \noindent - \copy\constructionheadbox % why copy ? - \par + \copy\constructionheadbox\par % copy ? + \nobreak + \doifelsenothing{\constructionparameter\c!inbetween}{\blank}{\constructionparameter\c!inbetween}% \nobreak - \edef\p_strc_constructions_inbetween{\constructionparameter\c!inbetween}% - \ifx\p_strc_constructions_inbetween\empty \else - \p_strc_constructions_inbetween - \par - \nobreak - \fi \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -672,9 +639,9 @@ \stopsetups \startsetups[\??constructionrenderings:\v!serried] - \edef\p_strc_constructions_width{\constructionparameter\c!width}% CHECK ! ! ! wrong parameter namespace - \doifsetupselse{\??constructionrenderings:\v!serried:\p_strc_constructions_width} { - \directsetup{\??constructionrenderings:\v!serried:\p_strc_constructions_width} + \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} } @@ -720,7 +687,7 @@ \noindent \advance\leftskip-\leftskipadaption\relax \ifdim\leftskipadaption=\zeropoint - \leftskipadaption1.5\emwidth\relax % just some default + \leftskipadaption1.5em\relax % just some default \ifnum\c_strc_constructions_nested_state=\plusone \ifdim\leftskip>\zeropoint \relax \leftskipadaption\leftskip @@ -732,7 +699,7 @@ \fi \hskip-\leftskipadaption\relax \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox - \kern\ifdim\constructionsheaddistance=\zeropoint .75\emwidth\else\constructionsheaddistance\fi + \kern\ifdim\constructionsheaddistance=\zeropoint .75em\else\constructionsheaddistance\fi \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -764,9 +731,9 @@ \unexpanded\def\strc_constructions_close_symbol_place {\ifconditional\csname\??constructionclosesymbol\currentconstruction\endcsname \global\expandafter\setfalse\csname\??constructionclosesymbol\currentconstruction\endcsname - \edef\p_strc_constructions_closesymbol{\constructionparameter\c!closesymbol}% - \ifx\p_strc_constructions_closesymbol\empty \else - \constructionparameter\c!closecommand{\p_strc_constructions_closesymbol}% hm why {} maybe because box expected + \edef\p_closesymbol{\constructionparameter\c!closesymbol}% + \ifx\p_closesymbol\empty \else + \constructionparameter\c!closecommand{\p_closesymbol}% hm why {} maybe because box expected \fi \fi} |