diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/attr-ini.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/attr-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/attr-ini.mkiv | 175 |
1 files changed, 50 insertions, 125 deletions
diff --git a/Master/texmf-dist/tex/context/base/attr-ini.mkiv b/Master/texmf-dist/tex/context/base/attr-ini.mkiv index 87d06c48a44..ba6ca369fc5 100644 --- a/Master/texmf-dist/tex/context/base/attr-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/attr-ini.mkiv @@ -14,14 +14,13 @@ \writestatus{loading}{ConTeXt Attribute Macros / Initialization} %D Although it's still somewhat experimental, here we introduce code -%D related to attributes. +%D related to attributes. Housekeeping will move completely to Lua +%D and \newattribute will go away. \unprotect \registerctxluafile{attr-ini}{1.001} -%D This might move: - \def\pushattribute#1% {\global\advance\csname\??ae:\string#1\endcsname\plusone \global\expandafter\mathchardef\csname\??ae:\string#1:\number\csname\??ae:\string#1\endcsname\endcsname\attribute#1} @@ -33,138 +32,64 @@ \def\installattributestack#1% {\expandafter\newcount\csname\??ae:\string#1\endcsname} -%D For the moment we put this here (later it will move to where it's used): - -\definesystemattribute[state] -\definesystemattribute[skip] -\definesystemattribute[penalty] -\definesystemattribute[colormodel][global] \chardef\colormodelattribute \dogetattributeid{colormodel} -\definesystemattribute[color] \chardef\colorattribute \dogetattributeid{color} -\definesystemattribute[transparency] \chardef\transparencyattribute \dogetattributeid{transparency} -\definesystemattribute[background] \chardef\backgroundattribute \dogetattributeid{background} -\definesystemattribute[colorintent] \chardef\colorintentattribute \dogetattributeid{colorintent} -\definesystemattribute[negative] \chardef\negativeattribute \dogetattributeid{negative} -\definesystemattribute[effect] \chardef\effectattribute \dogetattributeid{effect} -\definesystemattribute[viewerlayer] \chardef\viewerlayerattribute \dogetattributeid{viewerlayer} -\definesystemattribute[layoutcomponent] \chardef\layoutcomponentattribute\dogetattributeid{layoutcomponent} -\definesystemattribute[reference] \chardef\referenceattribute \dogetattributeid{reference} -\definesystemattribute[destination] \chardef\destinationattribute \dogetattributeid{destination} -\definesystemattribute[graphicvadjust] \chardef\graphicvadjustattribute \dogetattributeid{graphicvadjust} -\definesystemattribute[ruled] \chardef\ruledattribute \dogetattributeid{ruled} -\definesystemattribute[shifted] \chardef\shiftedattribute \dogetattributeid{shifted} - -% \definesystemattribute[ignore] -% -% \edef\startignorecontent{\dosetattribute{ignore}\plusone} -% \edef\stopignorecontent {\doresetattribute{ignore}} - -% todo: no need for 'color' argument, we can set that once at startup; currently -% a bit inconsistent - -% 1=off 2=gray 3=spot 4=rgb 5=cmyk 6=cmy % only 1/2/4/5 are supported -% -% We could combine this in one attribute but this is not faster and also -% less flexible because sometimes we want to freeze the attribute bit. -% -% Watch out: real color support will be implemented later. - -\newcount\currentcolormodel - -\def\dosetcolormodel#1% - {\currentcolormodel\ctxlua{tex.print(colors.setmodel('#1'))}% - \attribute\colormodelattribute\currentcolormodel} - -\dosetcolormodel{all} - -\appendtoks - \dosetcolormodel{all}% redundant? -\to \everyjob - -\def\registerrgbcolor #1#2#3#4{\ctxlua{colors.register('#1','rgb' ,#2,#3,#4)}} -\def\registercmykcolor#1#2#3#4#5{\ctxlua{colors.register('#1','cmyk',#2,#3,#4,#5)}} -\def\registergraycolor #1#2{\ctxlua{colors.register('#1','gray',#2)}} - -% transparency - -\def\registertransparency#1#2#3% - {\setevalue{(ts:#1)}{\attribute\transparencyattribute\ctxlua{tex.write(transparencies.register(#2,#3))} }} +\newtoks \attributesresetlist -\def\sometransparencyswitch#1{\csname(ts:#1)\endcsname} +\ifdefined \s!global \else \def\s!global{global} \fi % for metatex % or hard check later +\ifdefined \s!public \else \def\s!public{public} \fi % for metatex % or hard check later -\def\sometransparencyswitch - {\ctxlua{transparencies.enable()}% - \gdef\sometransparencyswitch##1{\csname(ts:##1)\endcsname}% - \sometransparencyswitch} +\unexpanded\def\defineattribute + {\dodoubleempty\dodefineattribute} -% \registertransparency {one} {1} {.5} -% \registertransparency {two} {1} {.6} +\def\dodefineattribute[#1][#2]% alternatively we can let lua do the housekeeping + {\expandafter\newattribute\csname @attr@#1\endcsname + \expandafter\newconstant \csname :attr:#1\endcsname + \csname :attr:#1\endcsname\lastallocatedattribute + \ctxcommand{defineattribute("#1",\number\lastallocatedattribute)}% + %\writestatus\m!system{defining attribute #1 with number \number\lastallocatedattribute}% + \doifnotinset\s!global{#2}{\appendetoks\csname @attr@#1\endcsname\attributeunsetvalue\to\attributesresetlist}% + \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname :attr:#1\endcsname}} -% overprint +\unexpanded\def\definesystemattribute + {\dodoubleempty\dodefinesystemattribute} -\def\registercolorintent#1#2% - {\setevalue{(os:#1)}{\attribute\colorintentattribute\ctxlua{tex.write(colorintents.register('#2'))} }} +\def\dodefinesystemattribute[#1][#2]% alternatively we can let lua do the housekeeping + {\scratchcounter\ctxcommand{getprivateattribute("#1")}\relax + \expandafter\attributedef\csname @attr@#1\endcsname\scratchcounter + \expandafter\newconstant \csname :attr:#1\endcsname + \csname :attr:#1\endcsname\scratchcounter + %\writestatus\m!system{defining system attribute #1 with number \number\scratchcounter}% + \doifnotinset\s!global{#2}{\appendetoks\csname @attr@#1\endcsname\attributeunsetvalue\to\attributesresetlist}% + \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname :attr:#1\endcsname}} -\def\dotriggercolorintent - {\ctxlua{colorintents.enable()}% - \gdef\dotriggercolorintent##1{\csname(os:##1)\endcsname}% - \dotriggercolorintent} +% expandable so we can \edef them for speed -\registercolorintent{knockout} {knockout} -\registercolorintent{overprint}{overprint} +\def\dosetattribute#1#2{\csname @attr@#1\endcsname#2\relax} +\def\doresetattribute#1{\csname @attr@#1\endcsname\attributeunsetvalue} +\def\dogetattribute #1{\number\csname @attr@#1\endcsname} +\def\dogetattributeid#1{\number\csname :attr:#1\endcsname} -\installattributestack\colorintentattribute +\let\dompattribute\gobbletwoarguments -\setevalue{(os:#\v!none}{\attribute\colorintentattribute\attributeunsetvalue} % does this work out ok? +\def\resetallattributes{\the\attributesresetlist} -% negative - -\def\registernegative#1#2% - {\setevalue{(ns:#1)}{\attribute\negativeattribute\ctxlua{tex.write(negatives.register('#2'))} }} - -\def\dotriggernegative - {\ctxlua{negatives.enable()}% - \gdef\dotriggernegative##1{\csname(ns:##1)\endcsname}% - \dotriggernegative} - -\registernegative{positive}{positive} -\registernegative{negative}{negative} - -% effect - -\def\registereffect#1#2#3% #2=stretch #3=rulethickness - {\setxvalue{(es:#1:#2:\number\dimexpr#3\relax)}% - {\attribute\effectattribute\ctxlua{tex.write(effects.register('#1',#2,\number\dimexpr#3\relax))} }} - -\def\dotriggereffect - {\ctxlua{effects.enable()}% - \gdef\dotriggereffect##1##2##3% - {\ifcsname(es:##1:##2:\number\dimexpr##3\relax)\endcsname\else\registereffect{##1}{##2}{##3}\fi - \csname(es:##1:##2:\number\dimexpr##3\relax)\endcsname}% - \dotriggereffect} - -% \registereffect{normal} -% \registereffect{inner} -% \registereffect{outer} -% \registereffect{both} -% \registereffect{hidden} - -% viewerlayers (will probably change a bit) - -% needs to work over stopitemize grouping etc - -\def\registerviewerlayer#1#2% global ! - {\setxvalue{(vl:#1)}{\global\attribute\viewerlayerattribute\ctxlua{tex.write(viewerlayers.register('#2'))} }} - -\setevalue{(vl:)}{\global\attribute\viewerlayerattribute\attributeunsetvalue} +%D For the moment we put this here (later it will move to where it's used): -\def\dotriggerviewerlayer - {\ctxlua{viewerlayers.enable()}% - \gdef\dotriggerviewerlayer##1{\csname(vl:##1)\endcsname}% - \dotriggerviewerlayer} +\definesystemattribute [state] +\definesystemattribute [skip] +\definesystemattribute [penalty] +\definesystemattribute [colormodel] [public,global] +\definesystemattribute [color] [public] +\definesystemattribute [transparency] [public] +\definesystemattribute [background] [public] +\definesystemattribute [colorintent] [public] +\definesystemattribute [negative] [public] +\definesystemattribute [effect] [public] +\definesystemattribute [viewerlayer] [public] +\definesystemattribute [layoutcomponent] [public] +\definesystemattribute [reference] [public] +\definesystemattribute [destination] [public] +\definesystemattribute [internal] [public] +\definesystemattribute [ruled] [public] +\definesystemattribute [shifted] [public] \protect \endinput - -% test case -% -% {\green \hbox to \hsize{\leaders\hrule \hfill a}\par} -% {\red \hbox to \hsize{\leaders\hbox{x}\hfill a}\par} |