summaryrefslogtreecommitdiff
path: root/tex/context/base/node-rul.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/node-rul.mkiv')
-rw-r--r--tex/context/base/node-rul.mkiv110
1 files changed, 110 insertions, 0 deletions
diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv
index ea9f5364b..40d0014dc 100644
--- a/tex/context/base/node-rul.mkiv
+++ b/tex/context/base/node-rul.mkiv
@@ -56,6 +56,7 @@
\unprotect
\definesystemattribute[ruled]
+\definesystemattribute[shifted]
\registerctxluafile{node-rul}{1.001}
@@ -191,6 +192,115 @@
\def\setupunderbar[#1]% too incompatible for the moment
{}
+%D This will move: (a bit duplicated)
+
+\newtoks\checkalldefinedshifts
+
+\def\shiftparameter #1{\csname\doshiftparameter\currentshift#1\endcsname}
+\def\shiftparameterhash#1{\doshiftparameterhash{\??ra\currentshift}#1}
+
+\def\doshiftparameter #1#2{\ifcsname\??ra#1#2\endcsname\??ra#1#2\else\expandafter\doshiftparentparameter\csname\??ra#1\s!parent\endcsname#2\fi}
+\def\doshiftparameterhash#1#2{\ifcsname#1#2\endcsname#1\else\expandafter\doshiftparentparameterhash\csname#1\s!parent\endcsname#2\fi}
+
+\def\doshiftparentparameter #1#2{\ifx#1\relax\s!empty\else\doshiftparameter #1#2\fi}
+\def\doshiftparentparameterhash#1#2{\ifx#1\relax \else\doshiftparameterhash#1#2\fi}
+
+\def\dosetshiftattributes#1#2% style color
+ {\edef\fontattributehash {\shiftparameterhash#1}%
+ \edef\colorattributehash{\shiftparameterhash#2}%
+ \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
+ \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
+
+\def\defineshift
+ {\dotripleempty\dodefineshift}
+
+\def\dodefineshift[#1][#2][#3]%
+ {\ifthirdargument
+ \getparameters[\??ra#1][\s!parent=#2,#3]%
+ \else
+ \getparameters[\??ra#1][\s!parent=,#2]%
+ \fi
+ %
+ %\setvalue{\??ra:#1}{0}%
+ %
+ \ifcsname\??ra:#1:c\endcsname
+ \csname\??ra:#1:c\endcsname\zerocount
+ \else
+ \expandafter\newcount\csname\??ra:#1:c\endcsname
+ \fi
+ \normalexpanded{\checkalldefinedshifts{\noexpand\doredefineshift{#1}\the\checkalldefinedshifts}}%
+ \dodefineshiftindeed{#1}%
+ \unexpanded\setvalue{#1}{\doshifted{#1}}}
+
+\def\dodefineshiftindeed#1%
+ {\bgroup
+ \def\currentshift{#1}%
+ \normalexpanded
+ {\egroup
+ \scratchcounter\ctxlua{nodes.shifts.define {
+ method = \shiftparameter\c!method,
+ continue = "\shiftparameter\c!continue",
+ dy = \shiftparameter\c!dy,
+ unit = "\shiftparameter\c!unit",
+ }}}%
+ \setevalue{\??ra#1:a}{\the\scratchcounter}}
+
+\let\doredefineshift\dodefineshiftindeed
+
+\def\doshifted#1%
+ {\groupedcommand{\dodoshifted{#1}}\relax}
+
+\def\dodoshifted
+ {\ctxlua{nodes.shifts.enable()}%
+ \glet\dodoshifted\dodoshiftedindeed
+ \dodoshifted}
+
+\def\dodoshiftedindeed#1%
+ {\def\currentshift{#1}%
+ \advance\csname\??ra:#1:c\endcsname\plusone
+ \scratchcounter\csname\??ra:#1:c\endcsname
+ \dosetattribute{shifted}{\numexpr1000*\scratchcounter
+ +\csname\??ra#1\ifcsname\??ra#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname}%
+ \dosetshiftattributes\c!style\c!color}
+
+\unexpanded\def\startshift[#1]%
+ {\begingroup
+ \dodoshifted{#1}}
+
+\unexpanded\def\stopshift
+ {\endgroup}
+
+\def\setupshifts
+ {\dodoubleempty\dosetupshifts}
+
+\def\dosetupshifts[#1][#2]% not that efficient
+ {\ifsecondargument
+ \getparameters[\??ra#1][#2]%
+ \dodefineshiftindeed{#1}%
+ \else
+ \getparameters[\??ra][#1]%
+ \the\checkalldefinedshifts
+ \fi}
+
+\setupshifts
+ [\c!method=0,
+ \c!continue=\v!no,
+ \c!dy=0,
+ \c!unit=ex,
+ \c!style=,
+ \c!color=]
+
+\def\v!shiftup {shiftup}
+\def\v!shiftdown{shiftdown}
+
+\defineshift [\v!shiftup] [\c!method=0,\c!dy=-1,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
+\defineshift [\v!shiftdown] [\c!method=1,\c!dy=.3,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
+
+% we want these always so ...
+
+\expandafter\let\expandafter\shiftup \csname\v!shiftup \endcsname
+\expandafter\let\expandafter\shiftdown \csname\v!shiftdown \endcsname
+
\protect \endinput
% obsolete: