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 | 244 |
1 files changed, 154 insertions, 90 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-con.mkvi b/Master/texmf-dist/tex/context/base/strc-con.mkvi index 956acaae506..0f5b202b9c8 100644 --- a/Master/texmf-dist/tex/context/base/strc-con.mkvi +++ b/Master/texmf-dist/tex/context/base/strc-con.mkvi @@ -15,6 +15,8 @@ \registerctxluafile{strc-con}{1.001} +% todo: check why \copy .. probably mkii leftover +% % todo: check if commands similar to lists % todo: \strc_constructions_setup_counter\strc_constructions_setup_counter{#1} in setup ... synchronization % @@ -27,17 +29,16 @@ % % 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. +%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. \unprotect -\ifdefined\v!construction \else \def\v!construction{construction} \fi - %D Todo: \installcorenamespace{construction} @@ -70,9 +71,9 @@ % \c!alternative=\v!left, \c!display=\v!yes, - \c!width=7em, - \c!distance=1em, - \c!titledistance=0.5em, + \c!width=7\emwidth, + \c!distance=\emwidth, + \c!titledistance=.5\emwidth, %c!hang=, %c!sample=, \c!margin=\v!no, @@ -137,9 +138,9 @@ {\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. +%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. \installcorenamespace{constructioninitializer} \installcorenamespace{constructionfinalizer} @@ -154,7 +155,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 @@ -167,16 +168,16 @@ \newconditional\c_strc_constructions_number_state \newconditional\c_strc_constructions_title_state -\setvalue{\??constructioninitializer\v!construction}% +\unexpanded\setvalue{\??constructioninitializer\v!construction}% {\setfalse\c_strc_constructions_number_state \setfalse\c_strc_constructions_title_state} -\setvalue{\??constructionfinalizer\v!construction}% +\unexpanded\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. +%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. \ifdefined\dotagsetconstruction \else \let\dotagsetconstruction\relax \fi @@ -190,10 +191,10 @@ \unexpanded\def\currentconstructionsample {\begstrut \constructionparameter\c!text - \constructionparameter\c!sample + \p_strc_constructions_sample \endstrut} -\setvalue{\??constructionmainhandler\v!construction}#1% +\unexpanded\setvalue{\??constructionmainhandler\v!construction}#1% {\iftrialtypesetting \else \begingroup \currentconstructionsynchronize % reinstated @@ -202,7 +203,7 @@ \endgroup \fi#1} -\setvalue{\??constructiontexthandler\v!construction}% +\unexpanded\setvalue{\??constructiontexthandler\v!construction}% {\begingroup \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext \the\everyconstruction @@ -224,36 +225,72 @@ \def\resetconstructions % to be used in e.g. footnotes {\c_strc_constructions_nested_state\zerocount} -\setvalue{\??constructioncommandhandler\v!construction}% +\unexpanded\setvalue{\??constructioncommandhandler\v!construction}% {\endgroup} -\setvalue{\??constructionstarthandler\v!construction}% this will be redone (reorganized) .. too much boxing +\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 +\let\p_strc_constructions_distance \empty + +\newconditional\c_strc_constructions_distance_none + +\unexpanded\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 - \doifnotsetups{\constructionalternativeparameter\c!renderingsetup} - {\letconstructionparameter\c!alternative\v!left - \let\currentconstructionalternative\v!left}% + \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}% + % catch fuzzyness + \ifx\p_strc_constructions_renderingsetup\empty + \letconstructionparameter\c!alternative\v!left + \let\currentconstructionalternative\v!left + \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}% + \else + \doifnotsetups\p_strc_constructions_renderingsetup + {\letconstructionparameter\c!alternative\v!left + \let\currentconstructionalternative\v!left + \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}}% + \fi + % \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}% + \edef\p_strc_constructions_distance{\constructionalternativeparameter\c!distance}% + \edef\p_strc_constructions_width{\constructionalternativeparameter\c!width}% + \ifx\p_strc_constructions_distance\v!none + \settrue\c_strc_constructions_distance_none + \constructionsheaddistance\zeropoint + \else + \setfalse\c_strc_constructions_distance_none + \constructionsheaddistance\p_strc_constructions_distance\relax + \ifdim\constructionsheaddistance=\zeropoint + \ifx\p_strc_constructions_width\v!broad + \constructionsheaddistance\emwidth + \fi + \fi \fi % inefficient and not always needed, for instance not with margins so we will make checkers - % per alternative + % per alternative some day (especially in labels this is unwanted overhead) \setbox\constructionheadbox\hbox {\forgetall \dontcomplain \settrialtypesetting - \doifelsenothing{\constructionparameter\c!sample} - {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext}% - {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructionsample}}% + \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}% \assignwidth - {\constructionalternativeparameter\c!width} + \p_strc_constructions_width \constructionsheadwidth {\unhcopy\constructionheadbox} \constructionsheaddistance @@ -266,15 +303,24 @@ \else \csname\??constructionmainhandler\currentconstructionhandler\endcsname{\boxedconstructionhead\currentconstructiontext}% \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... + \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 \ifcase\c_strc_constructions_nested_state \c_strc_constructions_nested_state\plusone \or @@ -282,15 +328,15 @@ \fi \strc_constructions_close_symbol_reset % - % \doifnotsetups {\constructionalternativeparameter\c!renderingsetup} - % {\let\currentconstructionalternative\v!left}% - \directsetup{\constructionalternativeparameter\c!renderingsetup}\relax + \edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}% + % + \directsetup\p_strc_constructions_renderingsetup\relax % \dostoptagged % tag \dostarttagged\t!constructioncontent\empty \ignorespaces} % args not needed -\setvalue{\??constructionstophandler\v!construction}% +\unexpanded\setvalue{\??constructionstophandler\v!construction}% {\strc_constructions_close_symbol_place \doifnot{\constructionparameter\c!display}\v!no\par \dostoptagged % content @@ -302,16 +348,21 @@ % \endgroup \dorechecknextindentation} -\def\boxedconstructionhead#1% +\unexpanded\def\boxedconstructionhead#1% {\vtop {\hsize\constructionsheadwidth - \doifsomething{\constructionparameter\c!headalign}{\setupalign[\constructionparameter\c!headalign]}% + \edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}% + \ifx\p_strc_constructions_headalign\empty \else + \setupalign[\p_strc_constructions_headalign]% \use... + \fi #1}} \installcorenamespace{constructionalternative} \installcorenamespace{constructionrenderings} % see lists: alternativemethods ... todo +% +% there will be a proper interface to variables \installcommandhandler \??constructionalternative {constructionalternative} \??constructionalternative @@ -391,16 +442,17 @@ {\setbox\constructionheadbox\vtop % \vbox gaat fout in hang {\forgetall \dontcomplain - \hsize\constructionsheadwidth - \edef\p_headalign{\constructionparameter\c!headalign}% - \ifx\p_headalign\empty + \hsize\constructionsheadwidth\relax + \ifx\p_strc_constructions_headalign\empty \setupalign[#1]% use fast one \else - \setupalign[\p_headalign]% use fast one + \setupalign[\p_strc_constructions_headalign]% use fast one + \fi + \ifconditional\c_strc_constructions_distance_none \else + \advance\ifx#1\v!flushleft\rightskip\else\leftskip\fi\constructionsheaddistance % only difference and wrong anyway \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} @@ -408,12 +460,11 @@ {\setbox\constructionheadbox\vtop {\forgetall \dontcomplain - \hsize\constructionsheadwidth - \edef\p_headalign{\constructionparameter\c!headalign}% - \ifx\p_headalign\empty + \hsize\constructionsheadwidth\relax + \ifx\p_strc_constructions_headalign\empty \setupalign[#1]% use fast one \else - \setupalign[\p_headalign]% use fast one + \setupalign[\p_strc_constructions_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 @@ -421,18 +472,18 @@ \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 + {\ifx\p_strc_constructions_hang\empty + % nothing + \else\ifx\p_strc_constructions_hang\v!fit \scratchdimen\htdp\constructionheadbox \getnoflines\scratchdimen \hangafter-\noflines - \else\ifx\p_hang\v!broad + \else\ifx\p_strc_constructions_hang\v!broad \scratchdimen\dimexpr\htdp\constructionheadbox+.5\strutht\relax \getnoflines\scratchdimen \hangafter-\noflines \else - \hangafter-\p_hang + \hangafter-\p_strc_constructions_hang \fi\fi\fi \relax \hangindent\ifx#1\v!right-\fi\constructionsheadwidth} @@ -441,18 +492,18 @@ % 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} + \edef\p_strc_constructions_hang{\constructionparameter\c!hang}% + \doifsetupselse{\??constructionrenderings:\v!left:\p_strc_constructions_hang} { + \directsetup{\??constructionrenderings:\v!left:\p_strc_constructions_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} + \edef\p_strc_constructions_hang{\constructionparameter\c!hang} + \doifsetupselse{\??constructionrenderings:\v!right:\p_strc_constructions_hang} { + \directsetup{\??constructionrenderings:\v!right:\p_strc_constructions_hang} } { \directsetup{\??constructionrenderings:\v!right:\v!hanging} } @@ -462,9 +513,8 @@ \let\\=\crlf \noindent \strc_constructions_set_pure_box\v!flushleft - \leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth\relax - \rightskip\rightconstructionskip - \advance\leftskip\constructionsheaddistance + \leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth+\constructionsheaddistance\relax + \rightskip\rightconstructionskip\relax \llap { \hbox to \leftskip { \hskip\leftconstructionskip @@ -573,13 +623,18 @@ \stopsetups \startsetups[\??constructionrenderings:\v!top] - \dohandlepagebreakX\plusone + \strc_sectioning_prevent_page_break\plusone \let\\=\space \noindent - \copy\constructionheadbox\par % copy ? - \nobreak - \doifelsenothing{\constructionparameter\c!inbetween}{\blank}{\constructionparameter\c!inbetween}% + \copy\constructionheadbox % why copy ? + \par \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 @@ -639,9 +694,9 @@ \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} + \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} } { \directsetup{\??constructionrenderings:\v!serried:\v!wide} } @@ -660,7 +715,9 @@ \let\\=\crlf \noindent \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox - \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax + \ifconditional\c_strc_constructions_distance_none \else + \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax + \fi \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -687,7 +744,7 @@ \noindent \advance\leftskip-\leftskipadaption\relax \ifdim\leftskipadaption=\zeropoint - \leftskipadaption1.5em\relax % just some default + \leftskipadaption1.5\emwidth\relax % just some default \ifnum\c_strc_constructions_nested_state=\plusone \ifdim\leftskip>\zeropoint \relax \leftskipadaption\leftskip @@ -698,8 +755,15 @@ \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 + \ifhbox\constructionheadbox \unhbox\else\box\fi\constructionheadbox + \ifconditional\c_strc_constructions_distance_none \else + % we used to have just a kern, but long lines look bad then + \scratchdistance\ifdim\constructionsheaddistance=\zeropoint .75\emwidth\else\constructionsheaddistance\fi + \hskip \scratchdistance + \s!plus .25\scratchdistance + \s!minus.25\scratchdistance + \fi + \allowbreak % new \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -731,9 +795,9 @@ \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 + \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 \fi \fi} |