diff options
Diffstat (limited to 'tex/context/base/mkiv/colo-run.mkiv')
-rw-r--r-- | tex/context/base/mkiv/colo-run.mkiv | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/colo-run.mkiv b/tex/context/base/mkiv/colo-run.mkiv new file mode 100644 index 000000000..16f54c3b5 --- /dev/null +++ b/tex/context/base/mkiv/colo-run.mkiv @@ -0,0 +1,238 @@ +%D \module +%D [ file=colo-run, +%D version=1997.04.01, +%D title=\CONTEXT\ Color Macros, +%D subtitle=Runtime loaded commands, +%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. + +\registerctxluafile{colo-run}{1.000} + +\unprotect + +%D Colors + +% These are nicer in \LUA\ code than in \TEX\ code but not more +% efficient. + +\unexpanded\gdef\showcolorbar[#1]% + {\backgroundline[#1]{\strut\enspace\color[white]{white}\enspace\color[black]{black}\enspace}} + +\unexpanded\gdef\showcolor {\dosingleempty\colo_basics_show} +\unexpanded\gdef\showcolorset {\dosingleempty\colo_basics_show_set} +\unexpanded\gdef\showcolorcomponents{\dosingleempty\colo_basics_show_components} + +\gdef\colo_basics_show_set [#1]{\ctxcommand{showcolorset("#1")}} +\gdef\colo_basics_show_components[#1]{\ctxcommand{showcolorcomponents("#1")}} + +\gdef\colo_basics_show[#1]% % we do this at the tex end as loading happens + {\usecolors [#1]% % delayed and we can only ask for the set if + \showcolorset[#1]} % loading has happened + +% The rest might also be done in \LUA\ although there is not much +% beauty to gain here (too much typesetting specific). Also, these +% macros are pretty old and hardly used so best keep them as they +% are. + +%D Palets + +\unexpanded\gdef\showpalet + {\dodoubleargument\colo_show_palet} + +\gdef\colo_show_palet[#1][#2]% + {\ifcsname\??colorpalet#1\endcsname + \doifelseinset\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal [#1][#2]% + \fi} + +\gdef\colo_palets_show_vertical[#1][#2]% + {\vbox + {\forgetall + \setlocalhsize + \hsize\localhsize + \offinterlineskip + \setuppalet[#1] + \tabskip\zeropoint + \def\colo_palets_show_palet##1% + {\doifelseinset\v!number{#2}{##1\hskip.5em}{}& + \color[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}% + \graycolor[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}& + \doifinset\v!value{#2}{\hskip.5em\colorvalue{##1}}\crcr} + \halign + {\hss##&\hss##\hss&##\cr + &\doifinset\v!name{#2}{\strut#1}&\cr% + \colo_palets_process[#1]\colo_palets_show_palet\crcr}}} + +\gdef\colo_palets_show_horizontal[#1][#2]% todo: bTABLE etc + {\vbox + {\forgetall + \setlocalhsize + \hsize\localhsize + \offinterlineskip + \setuppalet[#1] + \tabskip\zeropoint + \!!widtha\zeropoint + \doifinset\v!number{#2} + {\def\colo_palets_show_palet##1% + {\setbox0\hbox{##1}% + \ifdim\!!widtha<\wd0\!!widtha\wd0\fi}% + \colo_palets_process[#1]\colo_palets_show_palet}% + \advance\!!widtha 1em + \ifdim\!!widtha<5em + \!!widtha5em + \fi + \halign + {##&&\hbox to \!!widtha{\hss##\hss}\cr + \doifinset\v!number{#2} + {\def\colo_palets_show_palet##1{&\strut##1}% + \colo_palets_process[#1]\colo_palets_show_palet}\cr + \doifinset\v!name{#2}{#1\hskip.5em}% + \def\colo_palets_show_palet##1% + {&\strut\color[##1]{\vrule\s!width\!!widtha\s!height\strutht\s!depth\zeropoint}}% + \colo_palets_process[#1]\colo_palets_show_palet\crcr + \noalign{\vskip-\strutdepth}% + \def\colo_palets_show_palet##1% + {&\graycolor[##1]{\vrule\s!width\!!widtha\s!height\zeropoint\s!depth\strutdp}}% + \colo_palets_process[#1]\colo_palets_show_palet\crcr + \doifinset\v!value{#2} + {\def\colo_palets_show_palet##1% + {&\vbox + {\hsize\!!widtha + \vskip.25ex + \everypar{\strut} + \veryraggedcenter + \let\colorformatseparator\endgraf + \colorvalue{##1}}}% + \colo_palets_process[#1]\colo_palets_show_palet}% + \crcr}}} + +\gdef\colo_palets_process[#1]% + {\expanded{\globalprocesscommalist[\getvalue{\??colorpalet#1}]}} + +\unexpanded\gdef\comparepalet + {\dosingleargument\colo_palets_compare} + +\gdef\colo_palets_compare[#1]% + {\ifcsname\??colorpalet#1\endcsname + \hbox + {\colo_palets_compare_indeed\color[#1]% + \quad + \colo_palets_compare_indeed\graycolor[#1]}% + \fi} + +\gdef\colo_palets_compare_indeed#1[#2]% + {\vbox + {\forgetall + \setlocalhsize + \hsize\localhsize + \offinterlineskip + \setuppalet[#2] + \getcommacommandsize[\getvalue{\??colorpalet#2}] + \!!widtha2em\relax + \hsize\commalistsize\!!widtha + \def\colo_palets_compare##1% + {\hbox + {\setbox0\hbox + {#1[##1]{\vrule\s!width\hsize\s!height3ex}}% + \wd0\zeropoint + \box0 + \hbox to \hsize + {\def\colo_palets_compare####1% + {\hbox to \!!widtha + {\hss#1[####1]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}% + \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} + \endgraf} + \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} + +%D Groups + +\unexpanded\gdef\showcolorgroup + {\dodoubleargument\colo_groups_show} + +\gdef\colo_groups_show[#1][#2]% + {\doifcolor{#1:1} + {\doifelseinset\v!vertical{#2} \colo_groups_show_vertical \colo_groups_show_horizontal [#1][#2]}} + +\gdef\colo_groups_show_horizontal[#1][#2]% + {\vbox + {\forgetall + \setlocalhsize + \hsize\localhsize + \offinterlineskip + \setuppalet + \tabskip\zeropoint + \def\colorformatseparator{\strut\cr} + \def\colo_groups_show_group##1% + {\doifcolor{#1:##1}{\vbox + {\halign + {\hss####\hss\cr + \doifinset\v!number{#2}{\strut##1}\cr + \color[#1:##1]{\vrule\s!width4em\s!height\strutht\s!depth\zeropoint}\cr + \graycolor[#1:##1]{\vrule\s!width4em\s!height\zeropoint\s!depth\strutdp}\cr + \doifinset\v!value{#2}{\colorvalue{#1:##1}\strut}\crcr}}}}% + \hbox + {\doifinset\v!name{#2} + {\strut + \doifelseinset\v!value{#2} + {\raise3\lineheight\hbox{#1\hskip.5em}} + {#1}% + \hskip.5em}% + \colo_groups_show_group1\colo_groups_show_group2\colo_groups_show_group3\colo_groups_show_group4% + \colo_groups_show_group5\colo_groups_show_group6\colo_groups_show_group7\colo_groups_show_group8}}} + +\gdef\colo_groups_show_vertical[#1][#2]% + {\vbox + {\forgetall + \setlocalhsize + \hsize\localhsize + \offinterlineskip + \setuppalet + \tabskip\zeropoint + \def\colo_groups_show_group##1% + {\doifcolor{#1:##1} + {\doifinset\v!number{#2}{##1\hskip.5em}& + \color[#1:##1]{\vrule\s!width2.5em\s!height\strutht\s!depth\strutdp}% + \graycolor[#1:##1]{\vrule\s!width2.5em\s!height\strutht\s!depth\strutdp}& + \doifinset\v!value{#2}{\hskip.5em\colorvalue{#1:##1}}\crcr}}% + \halign + {\hss##&\hss##\hss&##\hss\cr + &\doifinset\v!name{#2}{\strut#1}&\crcr + \colo_groups_show_group1\colo_groups_show_group2\colo_groups_show_group3\colo_groups_show_group4% + \colo_groups_show_group5\colo_groups_show_group6\colo_groups_show_group7\colo_groups_show_group8}}} + +\unexpanded\gdef\comparecolorgroup + {\dosingleargument\colo_groups_compare} + +\gdef\colo_groups_compare[#1]% + {\doifcolor{#1:1} + {\hbox + {\colo_groups_compare_indeed\color[#1]% + \quad + \colo_groups_compare_indeed\graycolor[#1]}}} + +\gdef\colo_groups_compare_indeed#1[#2]% + {\vbox + {\forgetall + \setlocalhsize + \hsize\localhsize + \!!counta\zerocount + \dorecurse{15}{\doifcolor{#2:\recurselevel}{\advance\!!counta\plusone}} + \!!widtha2em\relax + \hsize\!!counta\!!widtha + \dorecurse\!!counta{\colo_groups_compare_step{#1}{#2}\recurselevel}}} + +\def\colo_groups_compare_step#1#2#3% + {\hbox to \hsize + {\setbox0\hbox + {#1[#2:#3]{\vrule\s!width\hsize\s!height3ex}}% + \wd0\zeropoint + \box0 + \hbox to \hsize + {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}} + \endgraf} + +\protect \endinput |