summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-con.mkvi
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/strc-con.mkvi')
-rw-r--r--tex/context/base/strc-con.mkvi197
1 files changed, 115 insertions, 82 deletions
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi
index 956acaae5..64371579a 100644
--- a/tex/context/base/strc-con.mkvi
+++ b/tex/context/base/strc-con.mkvi
@@ -27,17 +27,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 +69,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 +136,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 +153,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 +166,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 +189,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 +201,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 +223,54 @@
\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
+
+\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}
+ \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}%
+ \doifnotsetups\p_strc_constructions_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
- \doif{\constructionalternativeparameter\c!width}\v!broad{\constructionsheaddistance\emwidth}%
+ \ifx\p_strc_constructions_width\v!broad
+ \constructionsheaddistance\emwidth
+ \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 +283,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 +308,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 +328,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 +422,15 @@
{\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
\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 +438,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 +450,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 +470,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 +491,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 +601,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 +672,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}
}
@@ -687,7 +720,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
@@ -699,7 +732,7 @@
\fi
\hskip-\leftskipadaption\relax
\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
- \kern\ifdim\constructionsheaddistance=\zeropoint .75em\else\constructionsheaddistance\fi
+ \kern\ifdim\constructionsheaddistance=\zeropoint .75\emwidth\else\constructionsheaddistance\fi
\useconstructionstyleandcolor\c!style\c!color
\ignorespaces
\stopsetups
@@ -731,9 +764,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}