%D \module %D [ file=attr-ini, %D version=2007.06.06, %D title=\CONTEXT\ Attribute Macros, %D subtitle=Initialization, %D author=Hans Hagen, %D date=\currentdate, %D copyright=PRAGMA-ADE] %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 Attribute Macros / Initialization} %D Although it's still somewhat experimental, here we introduce code %D related to attributes. \unprotect \registerctxluafile{attr-ini}{1.001} \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} \def\popattribute#1% {\attribute#1\csname\??ae:\string#1:\number\csname\??ae:\string#1\endcsname\endcsname \global\advance\csname\??ae:\string#1\endcsname\minusone} \def\installattributestack#1% {\expandafter\newcount\csname\??ae:\string#1\endcsname} \newtoks \attributesresetlist \ifdefined \v!global \else \def\v!global{global} \fi % for metatex \unexpanded\def\defineattribute {\dodoubleempty\dodefineattribute} \def\dodefineattribute[#1][#2]% alternatively we can let lua do the housekeeping {\expandafter\newattribute\csname @attr@#1\endcsname \expandafter \xdef\csname :attr:#1\endcsname{\number\lastallocatedattribute}% \ctxlua{attributes.define("#1",\number\lastallocatedattribute)}% %\writestatus\m!systems{defining attribute #1 with number \number\lastallocatedattribute}% \doifnotinset\v!global{#2}{\appendetoks\csname @attr@#1\endcsname\attributeunsetvalue\to\attributesresetlist}} \unexpanded\def\definesystemattribute {\dodoubleempty\dodefinesystemattribute} \def\dodefinesystemattribute[#1][#2]% alternatively we can let lua do the housekeeping {\scratchcounter\ctxlua{tex.print(attributes.private("#1"))}\relax \global\expandafter\attributedef\csname @attr@#1\endcsname\scratchcounter \expandafter \xdef\csname :attr:#1\endcsname{\number\scratchcounter}% %\writestatus\m!systems{defining system attribute #1 with number \number\scratchcounter}% \doifnotinset\v!global{#2}{\appendetoks\csname @attr@#1\endcsname\attributeunsetvalue\to\attributesresetlist}} % expandable so we can \edef them for speed \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{\csname :attr:#1\endcsname} \let\dompattribute\gobbletwoarguments \def\resetallattributes{\the\attributesresetlist} %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} \protect \endinput