summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/page-mar.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-mar.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/page-mar.mkiv104
1 files changed, 44 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-mar.mkiv b/Master/texmf-dist/tex/context/base/page-mar.mkiv
index 464b4f9bb09..433364a0638 100644
--- a/Master/texmf-dist/tex/context/base/page-mar.mkiv
+++ b/Master/texmf-dist/tex/context/base/page-mar.mkiv
@@ -11,12 +11,16 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\endinput % obsolete, also commented code in anch-pgr.mkiv
+
%D Support for margin words is one of the reasons for writing
%D \CONTEXT. Over time support for marginal content has been
%D extended en enhanced. Therefore it's always good to watch
%D out for unexpected side effects.
-\writestatus{loading}{ConTeXt Page Macros / Maginal Things}
+%D TODO: use parents etc
+
+\writestatus{loading}{ConTeXt Page Macros / Marginal Things}
\unprotect
@@ -60,12 +64,16 @@
#2]%
\setuvalue{#1}{\dohandlemarginline{#1}}}
-\def\marginlineparameter #1{\csname\??im\??im\currentmarginline#1\endcsname}
-\def\marginlineexecuter #1#2{\executeifdefined{\??im\??im\currentmarginline#1}{#2}}
+\def\marginlineparameter#1{\csname\??im\??im\currentmarginline#1\endcsname}
+
+\def\marginlineexecuter#1#2%
+ {\dostarttagged\t!margintext\currentmarginline
+ \executeifdefined{\??im\??im\currentmarginline#1}{#2}%
+ \dostoptagged}
-\def\dohandlemarginline#1% #2
+\def\dohandlemarginline#1%#2%
{\def\currentmarginline{#1}%
- \csname\s!do\??im\??im\executeifdefined{\??im\??im#1\c!location}\v!left\endcsname{#1}} % {#2}
+ \csname\s!do\??im\??im\executeifdefined{\??im\??im#1\c!location}\v!left\endcsname{#1}}% {#2}
\def\doleftmarginline#1#2% #1 is redundant (we can remove it when we group dohandlemarginline; maybe ...
{\pushindentation
@@ -182,17 +190,20 @@
%D The next bunch of macros looks messy which is due to its
%D multi-purpose character.
-\chardef\margincontentdisplacement \zerocount
-\let \margincontentdistance \!!zeropoint
-\let \margincontenthoffset \!!zeropoint
-\def \margincontentlines {1}
-\def \margincontenttag {0}
-\let \margincontentseparator \empty
-\def \margincontentstrutheight {\strutht}
+\setnewconstant\margincontentdisplacement \zerocount
+\let \margincontentdistance \!!zeropoint
+\let \margincontenthoffset \!!zeropoint
+\def \margincontentlines {1}
+\def \margincontenttag {0}
+\let \margincontentseparator \empty
+\def \margincontentstrutheight {\strutht}
\newcount\margincontentlevel
\newdimen\margincontentheight
+% \installparameterhandler \??im{inmargin}
+% \installparameterhashhandler\??im{inmargin}
+
\unexpanded\def\setupinmargin
{\dodoubleempty\dosetupinmargin}
@@ -203,10 +214,6 @@
\getparameters[\??im][#1]%
\fi}
-% \def\dodosetupinmargin[#1]#2% [settings]{class}
-% {\checkinmargin[#2]%
-% \getparameters[\??im#2][#1]}
-
\def\dodosetupinmargin[#1]#2% [settings]{class}
{\checkinmargin[#2]%
\getparameters[\??im#2][#1]%
@@ -255,7 +262,7 @@
\donothing
\doifnumberelse\margincontenttag
{\ifnum\margincontenttag>25 % to be translated
- \writestatus\m!systems{potential margin stack overflow (\margincontenttag)}%
+ \writestatus\m!system{potential margin stack overflow (\margincontenttag)}%
\fi}
\donothing
% we need to preserve {a,b,c} kind of settings
@@ -266,8 +273,10 @@
\v!no=>\let\margincontentalign\v!normal,
\v!inner=>\let\margincontentalign#1,
\v!outer=>\let\margincontentalign#2,
+ \v!flushright=>\let\margincontentalign\v!left,
\v!left=>\let\margincontentalign\v!left,
\v!middle=>\let\margincontentalign\v!middle,
+ \v!flushleft=>\let\margincontentalign\v!right,
\v!right=>\let\margincontentalign\v!right]%
\doifvaluesomething{\??im\margincontenttag\c!align} % watch {} around set
{\edef\margincontentalign{{\getvalue{\??im\margincontenttag\c!align},\margincontentalign}}}%
@@ -284,7 +293,9 @@
\@@imbefore
\dostartattributes{\??im\margincontenttag}\c!style\c!color\empty
\dosetupstrut[\margincontentstrut]% was: \setstrut % yes or no
+ \dostarttagged\t!margintextblock\currentmargincontent % margincontenttag
\begstrut#3\endstrut\endgraf
+ \dostoptagged
\xdef\margincontentstrutheight{\the\strutht}% so that it's known outside the framed
\dostopattributes
\@@imafter}%
@@ -349,8 +360,9 @@
% 2 only natural height
% 3 also stack height
-\chardef\margincontentmethod \plusthree % beware: 1 = old method
-\chardef\marginpagecheckmethod\plusone
+\setnewconstant\margincontentmethod \plusthree % beware: 1 = old method
+\setnewconstant\marginpagecheckmethod \plusone
+\setnewconstant\marginrepositionmethod\plusone
\def\margincontentextralines{1} % old method, play safe
\def\nofmargincontentlines {0}
@@ -401,14 +413,6 @@
%\hbox{\lower\strutdp\box\scratchbox}} % alas, wrong lapping, therefore useless
\dopositionmarginbox\scratchbox}
-% \def\domarginblockskip#1%
-% {\hskip\margincontenthoffset
-% \hskip\compensatedinnermakeupmargin\relax
-% \doifelsenothing\margincontentdistance
-% {\hskip\getvalue{\??im#1\c!distance}}
-% {\hskip\margincontentdistance}%
-% \relax}
-
\def\domarginblockskip#1%
{\doifelsenothing\margincontentdistance
{\hskip\dimexpr
@@ -416,7 +420,7 @@
+\compensatedinnermakeupmargin
+\csname\??im#1\c!distance\endcsname
\relax}
- {\dimexpr
+ {\hskip\dimexpr
+\margincontenthoffset
+\compensatedinnermakeupmargin
+\margincontentdistance
@@ -467,26 +471,6 @@
\edef\inmargintaglist{+,-,\v!low,\v!left,\v!right,\v!inner,\v!outer}
-% the old one:
-%
-% \def\doinmargin[#1][#2][#3][#4][#5]% #6 #7
-% {\doifcommonelse{+,-,\v!laag}{#4}
-% {\dodoinmargin[#1][#2][#3][#4][#5]}
-% {\dodoinmargin[#1][#2][#3][][#4]}}
-%
-% an alternative:
-%
-% \letvalue{\??im\v!laag\c!offset}\empty
-% \letvalue{\??im +\c!offset}\empty
-% \letvalue{\??im -\c!offset}\empty
-%
-% \def\doinmargin[#1][#2][#3][#4][#5]% #6 #7
-% {\doifnumberelse{#4}
-% {\dodoinmargin[#1][#2][#3][#4][#5]}
-% {\doifdefinedelse{\??im#4\c!offset}
-% {\dodoinmargin[#1][#2][#3][#4][#5]}
-% {\dodoinmargin[#1][#2][#3][][#4]}}}
-%
% the problem is that we need to keep downward compatibility
% with respect to the first argument thing a reference or a
% directive; the alternative is to force users to pass a
@@ -608,15 +592,15 @@
{\bgroup
% old stuff, a bit tricky, but now interfaced
\edef\currentmargincontent{#1}%
- \chardef\marginrepositionmethod\executeifdefined{\??im\currentmargincontent\c!sidemethod }\plusone
- \chardef\margincontentmethod \executeifdefined{\??im\currentmargincontent\c!textmethod }\plusthree
- \chardef\marginpagecheckmethod \executeifdefined{\??im\currentmargincontent\c!splitmethod}\plusone
+ \marginrepositionmethod\executeifdefined{\??im\currentmargincontent\c!sidemethod }\plusone
+ \margincontentmethod \executeifdefined{\??im\currentmargincontent\c!textmethod }\plusthree
+ \marginpagecheckmethod \executeifdefined{\??im\currentmargincontent\c!splitmethod}\plusone
% so far
\forgetall % otherwise sidefloat problems, added 2005/07/20, maybe dangerous
\postponenotes % group is (somehow) needed
\doifinsetelse\v!low{#4}
- {\chardef\margincontentdisplacement\plusone}
- {\chardef\margincontentdisplacement\zerocount}%
+ {\margincontentdisplacement\plusone}
+ {\margincontentdisplacement\zerocount}%
\doif\v!reverse{#2}
{\swapmacros\dorightmarginblock\doleftmarginblock}%
\processaction
@@ -660,10 +644,10 @@
\def\margintitle{\margintext} % txt mark as well
\newtoks\collectedmargintexts % so .. delayed!
-\chardef\margintextcollected \zerocount
+\newconditional\margintextcollected
\def\domargincontent[#1][#2]#3% we used to check for #2/#1 being number, no longer now
- {\global\chardef\margintextcollected\plusone
+ {\global\settrue\margintextcollected
\global\let\flushmargincontents\doflushmargincontents
\edef\margincontenttag{#1}%
\ifx\margincontenttag\empty
@@ -676,11 +660,11 @@
\noexpand \doinmargin[\executeifdefined{\??im\margincontenttag\c!location}\@@imlocation][\v!normal][\margincontenttag][\margincontenttag][#2]%
\to \collectedmargintexts
\doglobal \appendtoks
- {#3}%
+ {#3}% argument to previously appended \doinmargin
\to \collectedmargintexts}
\def\doflushmargincontents % plural
- {\ifcase\margintextcollected\else
+ {\ifconditional\margintextcollected
\expandafter\flushmargincontentsindeed
\fi}
@@ -758,14 +742,14 @@
\def\resetmargincontent
{\global\margincontentlevel\zerocount
- \global\chardef\margintextcollected\zerocount
+ \global\setfalse\margintextcollected
\global\collectedmargintexts\emptytoks}
\unexpanded\def\placemargincontent
- {\ifcase\margintextcollected\else % was level check
+ {\ifconditional\margintextcollected % was level check
\bgroup
\redoconvertfont % !!
- \chardef\graphicvadjustmode\zerocount
+ %\setfalse\graphicvadjustmode % not used
\flushmargincontentsindeed
\egroup
\fi}