summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/pack-com.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/pack-com.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/pack-com.mkiv88
1 files changed, 79 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/context/base/pack-com.mkiv b/Master/texmf-dist/tex/context/base/pack-com.mkiv
index d12c0d90aef..6c1363148b9 100644
--- a/Master/texmf-dist/tex/context/base/pack-com.mkiv
+++ b/Master/texmf-dist/tex/context/base/pack-com.mkiv
@@ -88,6 +88,15 @@
\installcommandhandler \??combination {combination} \??combination
+\setfalse\c_strc_constructions_define_commands
+
+\definelabel
+ [\v!combination] % handy for configuring
+ [\c!numberconversion=\v!character,
+ \c!text=]
+
+\settrue\c_strc_constructions_define_commands
+
\setupcombination
[\c!width=\v!fit,
\c!height=\v!fit,
@@ -105,6 +114,17 @@
\let\setupcombinations\setupcombination % for the moment (we might distinguish)
\installcorenamespace{combinationlocation}
+\installcorenamespace{combinationalternative}
+
+\appendtoks
+ \setfalse\c_strc_constructions_define_commands
+ \normalexpanded
+ {\definelabel
+ [\v!combination:\currentcombination]%
+ [\v!combination\ifx\currentcombinationparent\empty\else:\currentcombinationparent\fi]}%
+ [\s!counter=\currentcombination,\c!levels=1]%
+ \settrue\c_strc_constructions_define_commands
+\to \everydefinecombination
\setvalue{\??combinationlocation\v!left }{\let\m_pack_combinations_leftfiller\relax}
\setvalue{\??combinationlocation\v!right }{\let\m_pack_combinations_rightfiller\relax}
@@ -158,30 +178,41 @@
\unexpanded\def\pack_common_caption_stop {\removeunwantedspaces\egroup}
\unexpanded\def\stopcombination
- {\bgroup\normalexpanded{\egroup{}\ctxcommand{ntimes("{}{}",\number\c_pack_combinations_n)}}%
+ {\bgroup\normalexpanded{\egroup{}\ctxcommand{ntimes("{}{}",\number\c_pack_combinations_n)}}% brr
\dostoptagged
\egroup
\egroup}
+\newtoks\everycombination
+
\def\pack_combinations_start[#1][#2]% needs a cleanup, also nx ny (pretty old, this one)
{\global\setsystemmode{combination}%
%
\edef\currentcombination{#1}%
\edef\currentcombinationspec{#2}%
\ifx\currentcombinationspec\empty
- \doifinstringelse{*}\currentcombination
- {\edef\currentcombinationspec{\currentcombination*\plusone*}%
- \let\currentcombination\empty}
- {\doifnumberelse\currentcombination
+ \doifassignmentelse{#1}%
+ {\let\currentcombination\empty
+ \setupcurrentcombination[#1]%
+ \edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}
+ {\doifinstringelse{*}\currentcombination
{\edef\currentcombinationspec{\currentcombination*\plusone*}%
\let\currentcombination\empty}
- {\edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}%
+ {\doifnumberelse\currentcombination
+ {\edef\currentcombinationspec{\currentcombination*\plusone*}%
+ \let\currentcombination\empty}
+ {\edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}}%
\else
- \edef\currentcombinationspec{\currentcombinationspec*\plusone*}%
+ \doifassignmentelse{#2}%
+ {\setupcurrentcombination[#2]%
+ \edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}
+ {\edef\currentcombinationspec{\currentcombinationspec*\plusone*}}%
\fi
%
\forgetall
%
+ \the\everycombination
+ %
\let\startcontent\pack_common_content_start
\let\stopcontent \pack_common_content_stop
\let\startcaption\pack_common_caption_start
@@ -220,6 +251,22 @@
\cr
\pack_combinations_pickup}
+% \def\pack_combinations_pickup_content % we want to add struts but still ignore an empty box
+% {\dostoptagged
+% \setbox\b_pack_combinations_content\box\nextbox
+% \dostarttagged\t!combinationcaption\empty
+% \dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
+% \afterassignment\pack_combinations_caption_first
+% \let\nexttoken=}
+
+% I've first considered using a constructor directly but it's more overhead
+% and some settings conflict with already used combination settings so instead
+% we plug in labels. This also permits extensions later on.
+
+\appendtoks
+ \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}%
+\to \everydefinecombination
+
\def\pack_combinations_pickup % we want to add struts but still ignore an empty box
{\dostarttagged\t!combinationpair\empty
\dostarttagged\t!combinationcontent\empty
@@ -229,10 +276,33 @@
{\dostoptagged
\setbox\b_pack_combinations_content\box\nextbox
\dostarttagged\t!combinationcaption\empty
- \dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
+ \expandnamespacemacro\??combinationalternative\p_pack_combinations_alternative\v!text}
+
+\setvalue{\??combinationalternative\v!text}%
+ {\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
\afterassignment\pack_combinations_caption_first
\let\nexttoken=}
+\setvalue{\??combinationalternative\v!label}%
+ {\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
+ \hsize\wd\b_pack_combinations_content
+ \ifx\p_align\empty\else\setupalign[\p_align]\fi
+ \usecombinationstyleandcolor\c!style\c!color % but label style wins, so independent configuration
+ \begstrut
+ \normalexpanded{\strc_labels_command{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}}%
+ \endstrut
+ \egroup}
+
+\appendtoks
+ \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}%
+ \ifx\p_pack_combinations_alternative\v!label
+ \edef\p_continue{\combinationparameter\c!continue}%
+ \ifx\p_continue\v!yes \else
+ \normalexpanded{\strc_labels_reset{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}{1}}%
+ \fi
+ \fi
+\to \everycombination
+
\def\pack_combinations_pickup_caption
{\dostoptagged
\dostoptagged
@@ -795,7 +865,7 @@
\usepairedboxstyleandcolor\c!style\c!color
\tolerantTABLEbreaktrue % hm.
\blank[\v!disable]% use fast one
- \everypar{\begstrut}}
+ \everypar{\begstrut}} % also flushers here (see bTABLE)
\definepairedbox[\v!legend]