%D \module
%D   [       file=attr-eff,
%D        version=2007.06.06,
%D          title=\CONTEXT\ Attribute Macros,
%D       subtitle=Effects,
%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 / Effects}

\registerctxluafile{attr-eff}{autosuffix}

\unprotect

\installcorenamespace{effect}

\installcommandhandler \??effect {effect} \??effect

\setupeffect
  [\c!method=\v!none, % should become command or define or so
   \c!stretch=\zerocount,
   \c!rulethickness=\zeropoint,
   \c!alternative=\v!normal]

\appendtoks
    \ifcstok{\effectparameter\c!method}\v!command
        \frozen\protected\xdefcsname\e!start\currenteffect\endcsname{\starteffect[#1]}%
        \frozen\protected\xdefcsname\e!stop \currenteffect\endcsname{\stopeffect}%
    \fi
\to \everydefineeffect

\permanent\protected\def\starteffect[#1]%
  {\clf_seteffect
     alternative   {\namedeffectparameter{#1}\c!alternative}
     stretch       {\namedeffectparameter{#1}\c!stretch}% no longer needed
     rulethickness {\namedeffectparameter{#1}\c!rulethickness}%
   \relax}

\permanent\protected\def\stopeffect % can be special
  {\clf_reseteffect} % v!normal 0 0

\permanent\protected\def\effect[#1]%
  {\groupedcommand{\starteffect[#1]}{\stopeffect}}

% yes or no grouped

\defineeffect [\v!inner]   [\c!alternative=\v!inner,\c!rulethickness=.25pt]
\defineeffect [\v!outer]   [\c!alternative=\v!outer,\c!rulethickness=.25pt]
\defineeffect [\v!both]    [\c!alternative=\v!both, \c!rulethickness=.25pt]
\defineeffect [\v!normal]  [\c!alternative=\v!normal]
\defineeffect [\v!hidden]  [\c!alternative=\v!hidden]
\defineeffect [\v!clip]    [\c!alternative=\v!clip]
\defineeffect [\v!stretch] [\c!alternative=\v!stretch,\c!stretch=1]

\protect \endinput
