%D \module %D [ file=attr-lay, %D version=2007.06.06, %D title=\CONTEXT\ Attribute Macros, %D subtitle=Viewerlayers, %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. \writestatus{loading}{ConTeXt Attribute Macros / Viewerlayers} \unprotect \registerctxluafile{attr-lay}{1.001} % needs to work over stopitemize grouping etc % \def\registerviewerlayer#1#2% global ! % {\setxvalue{\??ql:#1}{\global\attribute\viewerlayerattribute\ctxlua{tex.write(attributes.viewerlayers.register('#2'))} }} % % \setevalue{\??ql:}{\global\attribute\viewerlayerattribute\attributeunsetvalue} \getparameters [\??lr] [\c!state=\v!start, \c!title=, \c!printable=\v!yes, \c!scope=\v!local, % maybe global but needs checking with layout \c!method=\v!none] \def\defineviewerlayer {\dodoubleargument\dodefineviewerlayer} \def\dodefineviewerlayer[#1][#2]% document wide properties {\begingroup \getparameters[\??lr][#2]% \ctxcommand{defineviewerlayer{ tag = "#1", title = "\@@lrtitle", visible = "\@@lrstate", editable = "\v!yes", printable = "\@@lrprintable", scope = "\@@lrscope" }}% \doif\@@lrmethod\v!command {\setugvalue{\e!start#1}{\startviewerlayer[#1]}% \setugvalue{\e!stop #1}{\stopviewerlayer }}% \endgroup} \unexpanded\def\startviewerlayer[#1]{\ctxcommand{startviewerlayer("#1")}} % not grouped \unexpanded\def\stopviewerlayer {\ctxcommand{stopviewerlayer()}} % not grouped \unexpanded\def\viewerlayer [#1]{\groupedcommand{\startviewerlayer[#1]}{\stopviewerlayer}} % grouped % some day we will keep this at the lua end as the info is only needed there \let\currentviewerlayer\empty \newtoks\currentviewerlayertoks % soon we can set macros at the lua end \def\currentviewerlayer{\the\currentviewerlayertoks} \appendtoks \let\currentviewerlayer\empty \to \everybeforepagebody % layout components are implemented rather directly (speed) \def\doinitializelayoutcomponent#1% {\edef\layoutcomponentboxattribute{\ctxcommand{definedviewerlayer{% tag = "#1", title = utilities.strings.nice("#1"), % only here as in steps we have step: visible = "\v!start", editable = "\v!yes", printable = "\v!yes" }}}% \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}% \expandafter\glet\csname\??lr:a:#1\endcsname\layoutcomponentboxattribute} \def\dosetlayoutcomponentattribute#1% make this faster {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??lr:a:#1\endcsname \ifx\layoutcomponentboxattribute\relax \doinitializelayoutcomponent{#1}% get rid of { } \fi} \def\doresetlayoutcomponentattribute {\let\layoutcomponentboxattribute\empty} \let\setlayoutcomponentattribute \gobbleoneargument \let\resetlayoutcomponentattribute\relax \let\layoutcomponentboxattribute \empty \def\showlayoutcomponents {\ctxlua{attributes.viewerlayers.enable()}% will go \let\setlayoutcomponentattribute \dosetlayoutcomponentattribute \let\resetlayoutcomponentattribute\doresetlayoutcomponentattribute} \protect \endinput