summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/attr-ini.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/attr-ini.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/attr-ini.mkiv70
1 files changed, 40 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/context/base/attr-ini.mkiv b/Master/texmf-dist/tex/context/base/attr-ini.mkiv
index ba6ca369fc5..a1550b4be98 100644
--- a/Master/texmf-dist/tex/context/base/attr-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/attr-ini.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Initialization,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright=PRAGMA-ADE]
+%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
@@ -21,16 +21,20 @@
\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}
+\installcorenamespace{attributecount} % the counter representing the attribute (attrdef'd)
+\installcorenamespace{attributeid} % the internal number
+\installcorenamespace{attributestack} % the attribute specific stack
-\def\popattribute#1%
- {\attribute#1\csname\??ae:\string#1:\number\csname\??ae:\string#1\endcsname\endcsname
- \global\advance\csname\??ae:\string#1\endcsname\minusone}
+\unexpanded\def\pushattribute#1%
+ {\global\advance\csname\??attributestack\string#1\endcsname\plusone
+ \global\expandafter\mathchardef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\attribute#1}
-\def\installattributestack#1%
- {\expandafter\newcount\csname\??ae:\string#1\endcsname}
+\unexpanded\def\popattribute#1%
+ {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname
+ \global\advance\csname\??attributestack\string#1\endcsname\minusone}
+
+\unexpanded\def\installattributestack#1%
+ {\expandafter\newcount\csname\??attributestack\string#1\endcsname}
\newtoks \attributesresetlist
@@ -38,39 +42,43 @@
\ifdefined \s!public \else \def\s!public{public} \fi % for metatex % or hard check later
\unexpanded\def\defineattribute
- {\dodoubleempty\dodefineattribute}
+ {\dodoubleempty\attr_basics_define}
-\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}}
+\def\attr_basics_define[#1][#2]% alternatively we can let lua do the housekeeping
+ {\expandafter\newattribute\csname\??attributecount#1\endcsname
+ \expandafter\newconstant \csname\??attributeid#1\endcsname
+ \csname\??attributeid#1\endcsname\c_syst_last_allocated_attribute
+ \ctxcommand{defineattribute("#1",\number\c_syst_last_allocated_attribute)}%
+ \doifnotinset\s!global{#2}{\appendetoks\csname\??attributecount#1\endcsname\attributeunsetvalue\to\attributesresetlist}%
+ \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname\??attributeid#1\endcsname}}
\unexpanded\def\definesystemattribute
- {\dodoubleempty\dodefinesystemattribute}
+ {\dodoubleempty\attr_basics_define_system}
-\def\dodefinesystemattribute[#1][#2]% alternatively we can let lua do the housekeeping
+\def\attr_basics_define_system[#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
+ \expandafter\attributedef\csname\??attributecount#1\endcsname\scratchcounter
+ \expandafter\newconstant \csname\??attributeid#1\endcsname
+ \csname\??attributeid#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}}
+ \doifnotinset\s!global{#2}{\appendetoks\csname\??attributecount#1\endcsname\attributeunsetvalue\to\attributesresetlist}%
+ \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname\??attributeid#1\endcsname}}
% 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{\number\csname :attr:#1\endcsname}
+\def\dosetattribute#1#2{\csname\??attributecount#1\endcsname#2\relax}
+\def\doresetattribute#1{\csname\??attributecount#1\endcsname\attributeunsetvalue}
+\def\dogetattribute #1{\number\csname\??attributecount#1\endcsname}
+\def\dogetattributeid#1{\number\csname\??attributeid#1\endcsname}
\let\dompattribute\gobbletwoarguments
-\def\resetallattributes{\the\attributesresetlist}
+\unexpanded\def\resetallattributes{\the\attributesresetlist}
+
+%D Rather special.
+
+\unexpanded\def\savecurrentattributes #1{\ctxcommand{savecurrentattributes ("#1")}}
+\unexpanded\def\restorecurrentattributes#1{\ctxcommand{restorecurrentattributes("#1")}}
%D For the moment we put this here (later it will move to where it's used):
@@ -92,4 +100,6 @@
\definesystemattribute [ruled] [public]
\definesystemattribute [shifted] [public]
+\unexpanded\def\showattributes{\ctxcommand{showattributes()}}
+
\protect \endinput