diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2009-08-23 11:11:32 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2009-08-23 11:11:32 +0000 |
commit | 8fc3039c82d48605b5ca8b2eda3f4fdd755681e1 (patch) | |
tree | 3cd9bbdd599bc4d1ac0409e167fee2136e4c0ec9 /Master/texmf-dist/tex/context/base/node-bck.mkiv | |
parent | 850fc99b7cd3ae7a20065531fe866ff7bae642ec (diff) |
this is context 2009.08.19 17:10
git-svn-id: svn://tug.org/texlive/trunk@14827 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-bck.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/node-bck.mkiv | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-bck.mkiv b/Master/texmf-dist/tex/context/base/node-bck.mkiv new file mode 100644 index 00000000000..758e598e836 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/node-bck.mkiv @@ -0,0 +1,163 @@ +%D \module +%D [ file=node-bck, +%D version=2009.06.08, +%D title=\CONTEXT\ Node Macros, +%D subtitle=Backgrounds, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=PRAGMA] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Support / Backgrounds} + +%D This is first attempt to replacing backgrounds in a few +%D tables mechanisms. + +\unprotect + +\registerctxluafile{node-bck}{1.001} + +%D Box helpers: + +\def\doaddbackgroundtobox#1[#2]% + {\begingroup\faststartcolor[#2]% + \normalexpanded{\noexpand\faststopcolor\endgroup#1 + attr \backgroundattribute \plusone + attr \colormodelattribute \the\attribute\colormodelattribute + attr \colorattribute \the\attribute\colorattribute + attr \transparencyattribute \the\attribute\transparencyattribute}} + +\def\backgroundvbox{\doaddbackgroundtobox\vbox} +\def\backgroundvtop{\doaddbackgroundtobox\vtop} +\def\backgroundhbox{\doaddbackgroundtobox\hbox} + +\def\colorattr#1% + {\ifcsname(cs:\currentpalet#1)\endcsname + \thecolorattr{\currentpalet#1}% + \else\ifcsname(cs:#1)\endcsname + \thecolorattr{#1}% + \fi\fi} + +\def\thecolorattr#1% + {attr \colormodelattribute \attribute\colormodelattribute + attr \colorattribute \csname(cs:#1)\endcsname + attr \transparencyattribute \csname(ts:#1)\endcsname} + +\def\backgroundcolorattr#1% + {\ifcsname(cs:\currentpalet#1)\endcsname + \thebackgroundcolorattr{\currentpalet#1}% + \else\ifcsname(cs:#1)\endcsname + \thebackgroundcolorattr{#1}% + \fi\fi} + +\def\thebackgroundcolorattr#1% + {attr \backgroundattribute \plusone + attr \colormodelattribute \attribute\colormodelattribute + attr \colorattribute \csname(cs:#1)\endcsname + attr \transparencyattribute \csname(ts:#1)\endcsname} + +% \def\backgroundvbox[#1]{\vbox \backgroundcolorattr{#1}} +% \def\backgroundvtop[#1]{\vtop \backgroundcolorattr{#1}} +% \def\backgroundhbox[#1]{\hbox \backgroundcolorattr{#1}} + +%D tabulate: + +\def\tabulatenormalcolumn#1% + {\doiffastoptionalcheckelse{\tabulatenormalcolumnyes#1}{\tabulatenormalcolumnnop#1}} + +\def\tabulatenormalcolumnnop#1% overloads anch-pgr + {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi&\global\chardef\tabulatetype#1&} + +\def\tabulatenormalcolumnyes#1[#2]% + {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi&\global\chardef\tabulatetype#1&% + \iftrialtypesetting\else\settabulatecolor{#2}\fi\ignorespaces} + +\newcount\maxtabularcolorcolumn + +\def\settabulatecolor#1% we could store the attributes at the cost of a lua call + {\begingroup + \global\settrue\tabulatehascolors + \ifnum\tabulatecolumn>\maxtabularcolorcolumn + \global\maxtabularcolorcolumn\tabulatecolumn + \fi + \setxvalue{\??tt:c:\the\tabulatecolumn}{#1}% + \dosetattribute{background}\plusone + \faststartcolor[#1]\strut\char0\faststopcolor + \endgroup} + +\def\repeatsettabulatecolor + {\begingroup + \ifcsname\??tt:c:\the\tabulatecolumn\endcsname + \dosetattribute{background}\plusone + \faststartcolor[\csname\??tt:c:\the\tabulatecolumn\endcsname]\strut\char0\faststopcolor + \fi + \endgroup} + +\def\resettabulatecolors + {\ifcase\maxtabularcolorcolumn\else + \doresettabulatecolors + \fi} + +\def\doresettabulatecolors + {\dorecurse\maxtabularcolorcolumn{\letgvalue{\??tt:c:\recurselevel}\undefined}} % slow + +\appendtoks + \resettabulatecolors +\to \everyaftertabulaterow + +\def\splitofftabulatebox % overloads in anch-pgr + {\dontcomplain + \global\setbox\tabulatebox % % % global ? % % % + \vsplit\tablebox\tabulatecolumn to \lineheight + \setbox\tabulatebox\normalvbox + {\unvbox\tabulatebox}% + \setbox\tabulatebox\hbox to \wd\tabulatebox + {\iftrialtypesetting\else\ifconditional\tabulatehascolors\repeatsettabulatecolor\fi\fi + \hss\dotabulatehook{\box\tabulatebox}\hss}% + \ht\tabulatebox\strutht + \dp\tabulatebox\strutdp + \box\tabulatebox + \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} + +\appendtoks + \global\setfalse\tabulatehascolors +\to \everytabulate + +\protect \endinput + +% test + +\starttext + +\backgroundvbox[green] {\input tufte } \par +\backgroundvbox[blue] {\input ward } \par +\backgroundvbox[red] {\input knuth } \par +\backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par + +\starttabulate[||p||] +\NC test \NC test \NC test \NC \NR +\NC test \NC[green] \input tufte \NC[yellow] test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC[blue] test \NC[red] test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC[gray] test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC[blue] test \NC test \NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC test \NC[magenta] test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC[cyan] \dorecurse{10}{\input ward }\NC test \NC \NR +\NC test \NC test \NC test \NC \NR +\NC test \NC[yellow] test \NC test \NC \NR +\stoptabulate + +\stoptext |