From 3edfc2fc3e569201a16c63871aae121e57673539 Mon Sep 17 00:00:00 2001
From: Hans Hagen
Date: Thu, 23 Jul 2009 20:11:00 +0200
Subject: stable 2009.07.23 20:11
---
tex/context/base/anch-bar.mkii | 194 +++++++++++++++
tex/context/base/anch-bar.mkiv | 194 +++++++++++++++
tex/context/base/anch-bar.tex | 194 ---------------
tex/context/base/anch-pgr.mkii | 3 +-
tex/context/base/anch-pgr.mkiv | 34 +--
tex/context/base/anch-pos.mkii | 14 +-
tex/context/base/anch-pos.mkiv | 145 +++++-------
tex/context/base/anch-snc.mkii | 177 ++++++++++++++
tex/context/base/anch-snc.mkiv | 185 +++++++++++++++
tex/context/base/anch-snc.tex | 177 --------------
tex/context/base/attr-ini.lua | 83 ++-----
tex/context/base/attr-ini.mkiv | 25 +-
tex/context/base/back-ini.mkiv | 36 +--
tex/context/base/back-pdf.mkiv | 3 -
tex/context/base/buff-ini.lua | 93 +++++---
tex/context/base/buff-ver.mkiv | 133 +++++++----
tex/context/base/catc-act.tex | 4 +-
tex/context/base/catc-ini.mkii | 30 ++-
tex/context/base/catc-ini.mkiv | 43 +++-
tex/context/base/catc-sym.tex | 22 +-
tex/context/base/char-ini.mkiv | 4 +-
tex/context/base/chem-ini.mkiv | 5 +
tex/context/base/colo-ext.mkiv | 6 +-
tex/context/base/colo-ini.lua | 14 +-
tex/context/base/colo-ini.mkiv | 146 +++---------
tex/context/base/cont-new.tex | 6 +-
tex/context/base/context.mkii | 7 +-
tex/context/base/context.mkiv | 15 +-
tex/context/base/context.tex | 2 +-
tex/context/base/core-con.lua | 71 ++++--
tex/context/base/core-con.mkiv | 16 ++
tex/context/base/core-env.mkiv | 16 --
tex/context/base/core-fnt.mkiv | 34 +--
tex/context/base/core-ini.mkiv | 3 +-
tex/context/base/core-mis.mkii | 2 +-
tex/context/base/core-mis.mkiv | 67 +-----
tex/context/base/core-spa.lua | 154 ++++++------
tex/context/base/core-spa.mkiv | 118 ++++++----
tex/context/base/core-var.mkiv | 10 +-
tex/context/base/font-ini.mkiv | 24 +-
tex/context/base/font-run.mkiv | 2 +-
tex/context/base/font-syn.lua | 48 +++-
tex/context/base/grph-inc.mkiv | 29 +--
tex/context/base/l-set.lua | 27 ++-
tex/context/base/lang-url.lua | 10 +-
tex/context/base/lang-url.mkiv | 8 +-
tex/context/base/lpdf-ano.lua | 12 +-
tex/context/base/lpdf-col.lua | 8 +-
tex/context/base/lpdf-ini.lua | 6 +-
tex/context/base/lpdf-mis.lua | 29 ++-
tex/context/base/lpdf-ren.lua | 1 -
tex/context/base/m-visual.tex | 46 ++--
tex/context/base/math-pln.mkiv | 2 +-
tex/context/base/meta-ini.mkiv | 4 +-
tex/context/base/mlib-ctx.lua | 7 +-
tex/context/base/mlib-pps.lua | 22 +-
tex/context/base/mlib-run.lua | 57 ++---
tex/context/base/mult-sys.tex | 2 +
tex/context/base/node-dum.lua | 5 -
tex/context/base/node-fin.lua | 98 ++++++--
tex/context/base/node-ref.lua | 8 +-
tex/context/base/node-shp.lua | 36 ++-
tex/context/base/norm-ltx.tex | 2 +-
tex/context/base/norm-ptx.tex | 8 +-
tex/context/base/pack-box.mkiv | 4 +-
tex/context/base/pack-lyr.mkiv | 3 +-
tex/context/base/pack-obj.mkiv | 2 +-
tex/context/base/page-ini.mkiv | 97 +++++---
tex/context/base/page-lay.mkiv | 2 +
tex/context/base/page-mar.mkii | 2 +-
tex/context/base/page-mar.mkiv | 31 +--
tex/context/base/page-set.mkiv | 8 +-
tex/context/base/page-sid.mkiv | 201 ++++------------
tex/context/base/ppchtex.mkiv | 2 +-
tex/context/base/pret-lua.lua | 23 +-
tex/context/base/pret-mp.lua | 19 +-
tex/context/base/pret-tex.lua | 4 +-
tex/context/base/prop-lay.mkiv | 6 +-
tex/context/base/s-pre-67.tex | 140 +++++++++++
tex/context/base/scrn-int.mkiv | 14 +-
tex/context/base/strc-doc.lua | 94 +++++---
tex/context/base/strc-doc.mkiv | 29 ++-
tex/context/base/strc-flt.mkiv | 20 +-
tex/context/base/strc-itm.mkiv | 5 +
tex/context/base/strc-lst.lua | 28 ++-
tex/context/base/strc-lst.mkiv | 20 +-
tex/context/base/strc-not.mkiv | 23 +-
tex/context/base/strc-num.lua | 11 +-
tex/context/base/strc-num.mkiv | 1 +
tex/context/base/strc-ref.mkiv | 102 ++++++--
tex/context/base/strc-sec.mkiv | 71 ++++--
tex/context/base/strc-xml.mkiv | 47 ++++
tex/context/base/supp-box.tex | 8 +-
tex/context/base/supp-dir.mkiv | 3 -
tex/context/base/supp-fil.mkiv | 21 --
tex/context/base/syst-aux.mkiv | 67 +++---
tex/context/base/syst-ext.mkii | 13 +
tex/context/base/syst-gen.mkii | 17 ++
tex/context/base/syst-ini.tex | 2 +
tex/context/base/trac-inf.lua | 35 ++-
tex/context/base/trac-tex.mkiv | 36 +++
tex/context/base/trac-vis.mkiv | 353 +++++++++++++---------------
tex/context/base/type-ini.mkiv | 116 ++++-----
tex/context/base/type-siz.mkiv | 20 +-
tex/context/base/typo-brk.lua | 11 +-
tex/context/base/typo-cap.lua | 7 +-
tex/context/base/typo-krn.lua | 7 +-
tex/context/base/typo-mir.lua | 1 +
tex/context/base/typo-spa.lua | 7 +-
tex/context/base/unic-ini.mkiv | 8 +-
tex/context/base/x-fo.tex | 2 +-
tex/context/interface/cont-cs.xml | 3 +
tex/context/interface/cont-de.xml | 3 +
tex/context/interface/cont-en.xml | 3 +
tex/context/interface/cont-fr.xml | 3 +
tex/context/interface/cont-it.xml | 3 +
tex/context/interface/cont-nl.xml | 3 +
tex/context/interface/cont-pe.xml | 3 +
tex/context/interface/cont-ro.xml | 3 +
tex/generic/context/luatex-fonts-merged.lua | 7 +-
tex/generic/context/luatex-fonts.lua | 6 +-
121 files changed, 2710 insertions(+), 2056 deletions(-)
create mode 100644 tex/context/base/anch-bar.mkii
create mode 100644 tex/context/base/anch-bar.mkiv
delete mode 100644 tex/context/base/anch-bar.tex
create mode 100644 tex/context/base/anch-snc.mkii
create mode 100644 tex/context/base/anch-snc.mkiv
delete mode 100644 tex/context/base/anch-snc.tex
create mode 100644 tex/context/base/s-pre-67.tex
create mode 100644 tex/context/base/trac-tex.mkiv
diff --git a/tex/context/base/anch-bar.mkii b/tex/context/base/anch-bar.mkii
new file mode 100644
index 000000000..d08573c0f
--- /dev/null
+++ b/tex/context/base/anch-bar.mkii
@@ -0,0 +1,194 @@
+%D \module
+%D [ file=anch-bar,
+%D version=2003.03.16,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Margin Bars and alike,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA-ADE]
+%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 Anchoring Macros / Margin Bars}
+
+\unprotect
+
+%D We will implement a sidebar mechanism using the
+%D functionality from \type {core-pos}.
+%D
+%D \starttyping
+%D \definesidebar[whow][rulecolor=green,distance=]
+%D
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar[whow]
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \stopsidebar
+%D \stoptyping
+
+\newcount\currentsidebar
+\newdimen\sidebardistance
+
+\def\setupsidebars
+ {\dodoubleargument\dosetupsidebars}
+
+\def\dosetupsidebars[#1][#2]%
+ {\ifsecondargument
+ \getparameters[\??br#1][#2]%
+ \else
+ \getparameters[\??br][#1]%
+ \fi}
+
+% \setupMPvariables
+% [mpos:bar]
+% [linecolor=red,
+% linewidth=2pt,
+% distance=5pt]
+
+\setupsidebars
+ [\c!rulethickness=2pt,
+ \c!rulecolor=red,
+ \c!distance=.5\bodyfontsize]
+
+\def\definesidebar
+ {\dodoubleempty\dodefinesidebar}
+
+\def\dodefinesidebar[#1][#2]%
+ {\copyparameters
+ [\??br#1][\??br]
+ [\c!rulethickness,\c!rulecolor,\c!distance]%
+ \getparameters
+ [\??br#1][#2]}
+
+\def\startsidebar
+ {\dosingleempty\dostartsidebar}
+
+\def\dostartsidebar[#1]%
+ {\bgroup
+ \dontleavehmode
+ \checktextbackgrounds
+ \global\advance\currentsidebar\plusone
+ \doifelsenothing{#1}
+ {\advance\sidebardistance\@@brdistance}
+ {\doifelsevaluenothing{\??br#1\c!distance}
+ {\advance\sidebardistance\@@brdistance}
+ {\sidebardistance\getvalue{\??br#1\c!distance}}}%
+ \startpositionoverlay{text-1}%
+ \expanded{\setMPpositiongraphicrange
+ {b:side:\the\currentsidebar}%
+ {e:side:\the\currentsidebar}%
+ {mpos:bar}%
+ {self=side:\the\currentsidebar,
+ linewidth=\getvalue{\??br#1\c!rulethickness},
+ linecolor=\getvalue{\??br#1\c!rulecolor},
+ distance=\the\sidebardistance}}%
+ \stoppositionoverlay
+ \bpos{side:\the\currentsidebar}\ignorespaces}
+
+% \def\dostopsidebar#1%
+% {\removelastspace\tpos{side:#1}\carryoverpar\egroup}
+
+\def\stopsidebar
+ {\removelastspace\tpos{side:\the\currentsidebar}\carryoverpar\egroup}
+
+\startMPpositionmethod{mpos:bar}
+ \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}%
+ StartPage ;
+ path p ; p :=
+ if \MPp\MPbself=\MPp\MPeself :
+ (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
+ (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
+ elseif RealPageNumber=\MPp\MPbself :
+ (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
+ (llcorner Field[Text][Text]) ;
+ elseif RealPageNumber=\MPp\MPeself :
+ (ulcorner Field[Text][Text]) --
+ (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
+ else :
+ (ulcorner Field[Text][Text]) --
+ (llcorner Field[Text][Text]) ;
+ fi ;
+ p := p shifted (-llcorner Field[Text][Text]-(\MPvar{distance},0)) ;
+ interim linecap := butt ;
+ draw p
+ withpen pencircle scaled \MPvar{linewidth}
+ withcolor \MPvar{linecolor} ;
+ StopPage ;
+ \stopMPpositiongraphic
+ \MPpositiongraphic{mpos:bar}{}%
+\stopMPpositionmethod
+
+%D We now reimplement the margin rules handler defined in
+%D \type {core-rul}:
+%D
+%D \setupmarginrules[level=5]
+%D
+%D \startmarginrule[1]
+%D First we set the level at~5. Next we typeset this first
+%D paragraph as a level~1 one. As expected no rule show up.
+%D \stopmarginrule
+%D
+%D \startmarginrule[5]
+%D The second paragraph is a level~5 one. As we can see here,
+%D the marginal rule gets a width according to its level.
+%D \stopmarginrule
+%D
+%D \startmarginrule[8]
+%D It will of course be no surprise that this third paragraph
+%D has a even thicker margin rule. This behavior can be
+%D overruled by specifying the width explictly.
+%D \stopmarginrule
+
+\definesidebar
+ [\v!margin]
+ [\c!rulecolor=\s!black,
+ \c!rulethickness=\@@karulethickness,
+ \c!distance=\dimexpr\leftmargindistance-\@@karulethickness/2\relax]
+
+\definecomplexorsimple\startmarginrule
+
+\def\simplestartmarginrule
+ {\complexstartmarginrule[1]}
+
+\def\complexstartmarginrule[#1]%
+ {\bgroup
+ \ifnum#1<\@@kalevel\relax
+ \let\stopmarginrule\egroup
+ \else
+ \def\@@kadefaultwidth{#1}%
+ \let\stopmarginrule\dostopmarginrule
+ \@EA\startsidebar\@EA[\@EA\v!margin\@EA]%
+ \fi}
+
+\def\dostopmarginrule
+ {\stopsidebar
+ \egroup}
+
+\protect \endinput
diff --git a/tex/context/base/anch-bar.mkiv b/tex/context/base/anch-bar.mkiv
new file mode 100644
index 000000000..d08573c0f
--- /dev/null
+++ b/tex/context/base/anch-bar.mkiv
@@ -0,0 +1,194 @@
+%D \module
+%D [ file=anch-bar,
+%D version=2003.03.16,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Margin Bars and alike,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA-ADE]
+%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 Anchoring Macros / Margin Bars}
+
+\unprotect
+
+%D We will implement a sidebar mechanism using the
+%D functionality from \type {core-pos}.
+%D
+%D \starttyping
+%D \definesidebar[whow][rulecolor=green,distance=]
+%D
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar[whow]
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \stopsidebar
+%D \stoptyping
+
+\newcount\currentsidebar
+\newdimen\sidebardistance
+
+\def\setupsidebars
+ {\dodoubleargument\dosetupsidebars}
+
+\def\dosetupsidebars[#1][#2]%
+ {\ifsecondargument
+ \getparameters[\??br#1][#2]%
+ \else
+ \getparameters[\??br][#1]%
+ \fi}
+
+% \setupMPvariables
+% [mpos:bar]
+% [linecolor=red,
+% linewidth=2pt,
+% distance=5pt]
+
+\setupsidebars
+ [\c!rulethickness=2pt,
+ \c!rulecolor=red,
+ \c!distance=.5\bodyfontsize]
+
+\def\definesidebar
+ {\dodoubleempty\dodefinesidebar}
+
+\def\dodefinesidebar[#1][#2]%
+ {\copyparameters
+ [\??br#1][\??br]
+ [\c!rulethickness,\c!rulecolor,\c!distance]%
+ \getparameters
+ [\??br#1][#2]}
+
+\def\startsidebar
+ {\dosingleempty\dostartsidebar}
+
+\def\dostartsidebar[#1]%
+ {\bgroup
+ \dontleavehmode
+ \checktextbackgrounds
+ \global\advance\currentsidebar\plusone
+ \doifelsenothing{#1}
+ {\advance\sidebardistance\@@brdistance}
+ {\doifelsevaluenothing{\??br#1\c!distance}
+ {\advance\sidebardistance\@@brdistance}
+ {\sidebardistance\getvalue{\??br#1\c!distance}}}%
+ \startpositionoverlay{text-1}%
+ \expanded{\setMPpositiongraphicrange
+ {b:side:\the\currentsidebar}%
+ {e:side:\the\currentsidebar}%
+ {mpos:bar}%
+ {self=side:\the\currentsidebar,
+ linewidth=\getvalue{\??br#1\c!rulethickness},
+ linecolor=\getvalue{\??br#1\c!rulecolor},
+ distance=\the\sidebardistance}}%
+ \stoppositionoverlay
+ \bpos{side:\the\currentsidebar}\ignorespaces}
+
+% \def\dostopsidebar#1%
+% {\removelastspace\tpos{side:#1}\carryoverpar\egroup}
+
+\def\stopsidebar
+ {\removelastspace\tpos{side:\the\currentsidebar}\carryoverpar\egroup}
+
+\startMPpositionmethod{mpos:bar}
+ \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}%
+ StartPage ;
+ path p ; p :=
+ if \MPp\MPbself=\MPp\MPeself :
+ (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
+ (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
+ elseif RealPageNumber=\MPp\MPbself :
+ (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
+ (llcorner Field[Text][Text]) ;
+ elseif RealPageNumber=\MPp\MPeself :
+ (ulcorner Field[Text][Text]) --
+ (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
+ else :
+ (ulcorner Field[Text][Text]) --
+ (llcorner Field[Text][Text]) ;
+ fi ;
+ p := p shifted (-llcorner Field[Text][Text]-(\MPvar{distance},0)) ;
+ interim linecap := butt ;
+ draw p
+ withpen pencircle scaled \MPvar{linewidth}
+ withcolor \MPvar{linecolor} ;
+ StopPage ;
+ \stopMPpositiongraphic
+ \MPpositiongraphic{mpos:bar}{}%
+\stopMPpositionmethod
+
+%D We now reimplement the margin rules handler defined in
+%D \type {core-rul}:
+%D
+%D \setupmarginrules[level=5]
+%D
+%D \startmarginrule[1]
+%D First we set the level at~5. Next we typeset this first
+%D paragraph as a level~1 one. As expected no rule show up.
+%D \stopmarginrule
+%D
+%D \startmarginrule[5]
+%D The second paragraph is a level~5 one. As we can see here,
+%D the marginal rule gets a width according to its level.
+%D \stopmarginrule
+%D
+%D \startmarginrule[8]
+%D It will of course be no surprise that this third paragraph
+%D has a even thicker margin rule. This behavior can be
+%D overruled by specifying the width explictly.
+%D \stopmarginrule
+
+\definesidebar
+ [\v!margin]
+ [\c!rulecolor=\s!black,
+ \c!rulethickness=\@@karulethickness,
+ \c!distance=\dimexpr\leftmargindistance-\@@karulethickness/2\relax]
+
+\definecomplexorsimple\startmarginrule
+
+\def\simplestartmarginrule
+ {\complexstartmarginrule[1]}
+
+\def\complexstartmarginrule[#1]%
+ {\bgroup
+ \ifnum#1<\@@kalevel\relax
+ \let\stopmarginrule\egroup
+ \else
+ \def\@@kadefaultwidth{#1}%
+ \let\stopmarginrule\dostopmarginrule
+ \@EA\startsidebar\@EA[\@EA\v!margin\@EA]%
+ \fi}
+
+\def\dostopmarginrule
+ {\stopsidebar
+ \egroup}
+
+\protect \endinput
diff --git a/tex/context/base/anch-bar.tex b/tex/context/base/anch-bar.tex
deleted file mode 100644
index d08573c0f..000000000
--- a/tex/context/base/anch-bar.tex
+++ /dev/null
@@ -1,194 +0,0 @@
-%D \module
-%D [ file=anch-bar,
-%D version=2003.03.16,
-%D title=\CONTEXT\ Anchoring Macros,
-%D subtitle=Margin Bars and alike,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright=PRAGMA-ADE]
-%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 Anchoring Macros / Margin Bars}
-
-\unprotect
-
-%D We will implement a sidebar mechanism using the
-%D functionality from \type {core-pos}.
-%D
-%D \starttyping
-%D \definesidebar[whow][rulecolor=green,distance=]
-%D
-%D \input tufte \par
-%D \startsidebar
-%D \input tufte \par
-%D \input tufte \par
-%D \startsidebar[whow]
-%D \input tufte \par
-%D \input tufte \par
-%D \input tufte
-%D \stopsidebar \par
-%D \input tufte \par
-%D \input tufte
-%D \stopsidebar \par
-%D \input tufte \par
-%D \input tufte \par
-%D \startsidebar
-%D \input tufte \par
-%D \input tufte \par
-%D \input tufte \par
-%D \input tufte \par
-%D \input tufte
-%D \stopsidebar \par
-%D \input tufte \par
-%D \input tufte \par
-%D \startsidebar
-%D \input tufte
-%D \input tufte
-%D \input tufte
-%D \input tufte
-%D \input tufte
-%D \stopsidebar
-%D \stoptyping
-
-\newcount\currentsidebar
-\newdimen\sidebardistance
-
-\def\setupsidebars
- {\dodoubleargument\dosetupsidebars}
-
-\def\dosetupsidebars[#1][#2]%
- {\ifsecondargument
- \getparameters[\??br#1][#2]%
- \else
- \getparameters[\??br][#1]%
- \fi}
-
-% \setupMPvariables
-% [mpos:bar]
-% [linecolor=red,
-% linewidth=2pt,
-% distance=5pt]
-
-\setupsidebars
- [\c!rulethickness=2pt,
- \c!rulecolor=red,
- \c!distance=.5\bodyfontsize]
-
-\def\definesidebar
- {\dodoubleempty\dodefinesidebar}
-
-\def\dodefinesidebar[#1][#2]%
- {\copyparameters
- [\??br#1][\??br]
- [\c!rulethickness,\c!rulecolor,\c!distance]%
- \getparameters
- [\??br#1][#2]}
-
-\def\startsidebar
- {\dosingleempty\dostartsidebar}
-
-\def\dostartsidebar[#1]%
- {\bgroup
- \dontleavehmode
- \checktextbackgrounds
- \global\advance\currentsidebar\plusone
- \doifelsenothing{#1}
- {\advance\sidebardistance\@@brdistance}
- {\doifelsevaluenothing{\??br#1\c!distance}
- {\advance\sidebardistance\@@brdistance}
- {\sidebardistance\getvalue{\??br#1\c!distance}}}%
- \startpositionoverlay{text-1}%
- \expanded{\setMPpositiongraphicrange
- {b:side:\the\currentsidebar}%
- {e:side:\the\currentsidebar}%
- {mpos:bar}%
- {self=side:\the\currentsidebar,
- linewidth=\getvalue{\??br#1\c!rulethickness},
- linecolor=\getvalue{\??br#1\c!rulecolor},
- distance=\the\sidebardistance}}%
- \stoppositionoverlay
- \bpos{side:\the\currentsidebar}\ignorespaces}
-
-% \def\dostopsidebar#1%
-% {\removelastspace\tpos{side:#1}\carryoverpar\egroup}
-
-\def\stopsidebar
- {\removelastspace\tpos{side:\the\currentsidebar}\carryoverpar\egroup}
-
-\startMPpositionmethod{mpos:bar}
- \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}%
- StartPage ;
- path p ; p :=
- if \MPp\MPbself=\MPp\MPeself :
- (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
- (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
- elseif RealPageNumber=\MPp\MPbself :
- (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) --
- (llcorner Field[Text][Text]) ;
- elseif RealPageNumber=\MPp\MPeself :
- (ulcorner Field[Text][Text]) --
- (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ;
- else :
- (ulcorner Field[Text][Text]) --
- (llcorner Field[Text][Text]) ;
- fi ;
- p := p shifted (-llcorner Field[Text][Text]-(\MPvar{distance},0)) ;
- interim linecap := butt ;
- draw p
- withpen pencircle scaled \MPvar{linewidth}
- withcolor \MPvar{linecolor} ;
- StopPage ;
- \stopMPpositiongraphic
- \MPpositiongraphic{mpos:bar}{}%
-\stopMPpositionmethod
-
-%D We now reimplement the margin rules handler defined in
-%D \type {core-rul}:
-%D
-%D \setupmarginrules[level=5]
-%D
-%D \startmarginrule[1]
-%D First we set the level at~5. Next we typeset this first
-%D paragraph as a level~1 one. As expected no rule show up.
-%D \stopmarginrule
-%D
-%D \startmarginrule[5]
-%D The second paragraph is a level~5 one. As we can see here,
-%D the marginal rule gets a width according to its level.
-%D \stopmarginrule
-%D
-%D \startmarginrule[8]
-%D It will of course be no surprise that this third paragraph
-%D has a even thicker margin rule. This behavior can be
-%D overruled by specifying the width explictly.
-%D \stopmarginrule
-
-\definesidebar
- [\v!margin]
- [\c!rulecolor=\s!black,
- \c!rulethickness=\@@karulethickness,
- \c!distance=\dimexpr\leftmargindistance-\@@karulethickness/2\relax]
-
-\definecomplexorsimple\startmarginrule
-
-\def\simplestartmarginrule
- {\complexstartmarginrule[1]}
-
-\def\complexstartmarginrule[#1]%
- {\bgroup
- \ifnum#1<\@@kalevel\relax
- \let\stopmarginrule\egroup
- \else
- \def\@@kadefaultwidth{#1}%
- \let\stopmarginrule\dostopmarginrule
- \@EA\startsidebar\@EA[\@EA\v!margin\@EA]%
- \fi}
-
-\def\dostopmarginrule
- {\stopsidebar
- \egroup}
-
-\protect \endinput
diff --git a/tex/context/base/anch-pgr.mkii b/tex/context/base/anch-pgr.mkii
index fde8755c2..bd5d7d3b9 100644
--- a/tex/context/base/anch-pgr.mkii
+++ b/tex/context/base/anch-pgr.mkii
@@ -651,8 +651,7 @@
\def\initializeparbackgrounds
{\ifcase\totalnofparbackgrounds\else
- \global\positioningtrue
- \global\positioningpartrue
+ \enableparposition
\fi}
\unexpanded\def\starttextbackground
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 8e719e0d7..c558bb04f 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -615,23 +615,25 @@
\newcount\textbackgrounddepth
-\ifx\nofparbackgrounds \undefined \newcount \nofparbackgrounds \fi
+\ifdefined\nofparbackgrounds\else \newcount\nofparbackgrounds \fi
-% \ifx\totalnofparbackgrounds\undefined \newcounter\totalnofparbackgrounds \fi
-%
-% \appendtoks
-% \expanded{\savecurrentvalue\noexpand\totalnofparbackgrounds{\number\nofparbackgrounds}}%
-% \to \everybye
-%
-% \appendtoks
-% \initializeparbackgrounds
-% \to \everystarttext
-%
-% \def\initializeparbackgrounds
-% {\ifcase\totalnofparbackgrounds\else
-% \global\positioningtrue
-% \global\positioningpartrue
-% \fi}
+\ifx\totalnofparbackgrounds\undefined \newcounter\totalnofparbackgrounds \fi
+
+\appendtoks
+ \expanded{\savecurrentvalue\noexpand\totalnofparbackgrounds{\number\nofparbackgrounds}}%
+\to \everybye
+
+% actually we can just ask lua to give us the nofpositions (or a least n<>0)
+
+\appendtoks
+ % a position can be mid paragraph in which case we're behind
+ \initializeparbackgrounds
+\to \everystarttext
+
+\def\initializeparbackgrounds
+ {\ifcase\totalnofparbackgrounds\else
+ \enableparpositions
+ \fi}
\unexpanded\def\starttextbackground
{\bgroup
diff --git a/tex/context/base/anch-pos.mkii b/tex/context/base/anch-pos.mkii
index eaf9886b4..589c4aa26 100644
--- a/tex/context/base/anch-pos.mkii
+++ b/tex/context/base/anch-pos.mkii
@@ -583,6 +583,13 @@
% we can check for used entries, and if not, then not add one
+\def\enableparpositions % global
+ {\global\positioningtrue
+ \global\positioningpartrue}
+
+\def\disableparpositions % local
+ {\positioningparfalse}
+
\def\registerparoptions
{\ifpositioningpar \ifpositioning \iftrialtypesetting \else
\ifinpagebody \else \ifmmode \else \ifinformula \else
@@ -854,11 +861,8 @@
\rawprocesscommalist[#2]\docommand
\ifdone\egroup#3\else\egroup#4\fi}
-\def\doifpositionsonsamepageelse
- {\dodoifpositionsonsamepageelse{0}}
-
-\def\doifpositionsonthispageelse#1#2#3%
- {\dodoifpositionsonsamepageelse\realfolio}
+\def\doifpositionsonsamepageelse{\dodoifpositionsonsamepageelse\!!zerocount}
+\def\doifpositionsonthispageelse{\dodoifpositionsonsamepageelse\realfolio }
%D Plugins:
diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv
index 88f492fb8..0ddda9af4 100644
--- a/tex/context/base/anch-pos.mkiv
+++ b/tex/context/base/anch-pos.mkiv
@@ -106,28 +106,6 @@
%D method is implemented in a special driver. If needed, the
%D driver can fall back on the following macros.
-% TO BE MERGED
-
-% \def\setpospxy#1#2#3#4%
-% {\@EA\xdef\csname\POSprefix#1\endcsname
-% {\number#2,%
-% \the\dimexpr#3\ifnum\positionanchormode=\plusone-\MPx\pageanchor\fi\relax,%
-% \the\dimexpr#4\ifnum\positionanchormode=\plusone-\MPy\pageanchor\fi\relax}}
-
-% \def\setpospxywhd#1#2#3#4#5#6#7%
-% {\@EA\xdef\csname\POSprefix#1\endcsname
-% {\number#2,%
-% \the\dimexpr#3\ifnum\positionanchormode=\plusone-\MPx\pageanchor\fi\relax,%
-% \the\dimexpr#4\ifnum\positionanchormode=\plusone-\MPy\pageanchor\fi\relax,%
-% \the\dimexpr#5\relax,\the\dimexpr#6\relax,\the\dimexpr#7\relax}}
-
-% \def\setpospxyplus#1#2#3#4#5#6#7#8%
-% {\@EA\xdef\csname\POSprefix#1\endcsname
-% {\number#2,%
-% \the\dimexpr#3\ifnum\positionanchormode=\plusone-\MPx\pageanchor\fi\relax,%
-% \the\dimexpr#4\ifnum\positionanchormode=\plusone-\MPy\pageanchor\fi\relax,%
-% \the\dimexpr#5\relax,\the\dimexpr#6\relax,\the\dimexpr#7\relax,#8}}
-
% are the next 6 still used?
\def\dolazysaveposition #1#2#3#4{\normalexpanded{\ctxlatelua{ptbs['#1']={#2,"#3","#4"}}}}
@@ -520,47 +498,34 @@
%D based on information collected in the previous pass.
\newcount\parposcounter
-
-\newif\ifpositioningpar
+\newif \ifpositioningpar
+\chardef \parposstrut = 1 % 0 => no strut data, so fall backs used
+\newif \iftracepositions
% we can check for used entries, and if not, then not add one
-\def\registerparoptions
+\def\enableparpositions % global
+ {\global\let\registerparoptions\doregisterparoptions
+ \global\positioningtrue
+ \global\positioningpartrue}
+
+\def\disableparpositions % local
+ {\positioningparfalse}
+
+\let\registerparoptions\relax
+
+\def\doregisterparoptions
{\ifpositioningpar \ifpositioning \iftrialtypesetting \else
\ifinpagebody \else \ifmmode \else \ifinformula \else
\ifprocessingverbatim
- \iflinepar \doregisterparoptions \fi
+ \iflinepar \dodoregisterparoptions \fi
\else
- \doregisterparoptions
+ \dodoregisterparoptions
\fi
\fi \fi \fi
\fi \fi \fi}
-\chardef\parposstrut=1 % 0 => no strut data, so fall backs used
-
-\newif\iftracepositions
-
-% \def\doregisterparoptions
-% {\global\advance\parposcounter\plusone
-% \begingroup
-% \leftskip 1\leftskip
-% \rightskip1\rightskip
-% \setpositiondataplus
-% {p:\number\parposcounter}% identifier
-% {\the\zeropoint}%
-% {\the\strutht}%
-% {\the\strutdp}%
-% {\the\hsize ,% 1
-% \the\leftskip ,% 2
-% \the\rightskip ,% 3
-% \the\hangindent,% 4
-% \the\hangafter ,% 5 (num)
-% \the\parindent }% 6
-% %\normalhbox{\registerparsymbol}%
-% \registerparsymbol
-% \endgroup}
-
-\def\doregisterparoptions
+\def\dodoregisterparoptions
{\global\advance\parposcounter\plusone
\setpositiondataplus
{p:\number\parposcounter}% identifier
@@ -717,7 +682,21 @@
\def\overlappingmargin{-2\scaledpoint}
-\def\doifoverlappingelse#1#2%
+\def\overlappingcheckone#1#2%
+ {\ifdim#1<\!!dimena \else \ifdim#1>\!!dimenb \else
+ \ifdim#2<\!!dimenc \else \ifdim#2>\!!dimend \else
+ \donetrue
+ \fi\fi
+ \fi\fi}
+
+\def\overlappingchecktwo#1#2%
+ {\ifdim#1<\!!dimene \else \ifdim#1>\!!dimenf \else
+ \ifdim#2<\!!dimeng \else \ifdim#2>\!!dimenh \else
+ \donetrue
+ \fi\fi
+ \fi\fi}
+
+\def\doifoverlappingelse#1#2% maybe do this in lua
{\begingroup
\donefalse
\edef\!!stringa{#1}\edef\!!stringb{#2}%
@@ -741,26 +720,14 @@
\advance\!!dimenh+\overlappingmargin
\fi
% more often eh fb eg fg
- \def\checkone##1##2%
- {\ifdim##1<\!!dimena \else \ifdim##1>\!!dimenb \else
- \ifdim##2<\!!dimenc \else \ifdim##2>\!!dimend \else
- \donetrue
- \fi\fi
- \fi\fi}%
- \def\checktwo##1##2%
- {\ifdim##1<\!!dimene \else \ifdim##1>\!!dimenf \else
- \ifdim##2<\!!dimeng \else \ifdim##2>\!!dimenh \else
- \donetrue
- \fi\fi
- \fi\fi}%
- \checkone\!!dimene\!!dimeng \ifdone \else
- \checkone\!!dimene\!!dimenh \ifdone \else
- \checkone\!!dimenf\!!dimeng \ifdone \else
- \checkone\!!dimenf\!!dimenh \ifdone \else
- \checktwo\!!dimena\!!dimenc \ifdone \else
- \checktwo\!!dimena\!!dimend \ifdone \else
- \checktwo\!!dimenb\!!dimene \ifdone \else
- \checktwo\!!dimenb\!!dimenc \fi \fi \fi \fi \fi \fi \fi
+ \overlappingcheckone\!!dimene\!!dimeng \ifdone \else
+ \overlappingcheckone\!!dimene\!!dimenh \ifdone \else
+ \overlappingcheckone\!!dimenf\!!dimeng \ifdone \else
+ \overlappingcheckone\!!dimenf\!!dimenh \ifdone \else
+ \overlappingchecktwo\!!dimena\!!dimenc \ifdone \else
+ \overlappingchecktwo\!!dimena\!!dimend \ifdone \else
+ \overlappingchecktwo\!!dimenb\!!dimene \ifdone \else
+ \overlappingchecktwo\!!dimenb\!!dimenc \fi \fi \fi \fi \fi \fi \fi
\fi
\ifdone
\endgroup\expandafter\firstoftwoarguments
@@ -784,23 +751,25 @@
%D {action when not on this page}
%D \stoptyping
-\def\dodoifpositionsonsamepageelse#1#2#3#4%
- {\bgroup
- \scratchcounter#1\donefalse
- \def\docommand##1%
- {\ifcase\scratchcounter
- \scratchcounter\MPp{##1}\donetrue
- \else
- \ifnum\scratchcounter=\MPp{##1}\relax\else\donefalse\fi
- \fi}%
- \rawprocesscommalist[#2]\docommand
- \ifdone\egroup#3\else\egroup#4\fi}
+\def\dododoifpositionsonsamepageelse#1%
+ {\ifcase\scratchcounter
+ \scratchcounter\MPp{##}\donetrue
+ \else
+ \ifnum\scratchcounter=\MPp{#1}\relax\else\donefalse\fi
+ \fi}%
-\def\doifpositionsonsamepageelse
- {\dodoifpositionsonsamepageelse{0}}
+\def\dodoifpositionsonsamepageelse#1#2%
+ {\begingroup
+ \scratchcounter#1\donefalse
+ \rawprocesscommalist[#2]\dododoifpositionsonsamepageelse
+ \ifdone
+ \endgroup\expandafter\firstoftwoarguments
+ \else
+ \endgroup\expandafter\secondoftwoarguments
+ \fi}
-\def\doifpositionsonthispageelse#1#2#3%
- {\dodoifpositionsonsamepageelse\realfolio}
+\def\doifpositionsonsamepageelse{\dodoifpositionsonsamepageelse\!!zerocount}
+\def\doifpositionsonthispageelse{\dodoifpositionsonsamepageelse\realfolio }
%D Plugins:
diff --git a/tex/context/base/anch-snc.mkii b/tex/context/base/anch-snc.mkii
new file mode 100644
index 000000000..cf5b35d69
--- /dev/null
+++ b/tex/context/base/anch-snc.mkii
@@ -0,0 +1,177 @@
+%D \module
+%D [ file=anch-snc,
+%D version=2003.12.01,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Synchronization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%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 Anchoring Macros / Synchronization}
+
+\unprotect
+
+\ifx\s!set \undefined \def\s!set {set} \fi
+\ifx\s!reset \undefined \def\s!reset {reset} \fi
+\ifx\s!preset \undefined \def\s!preset {preset} \fi
+\ifx\s!syncpos\undefined \def\s!syncpos{syncpos} \fi
+
+\def\definesyncpositions[#1]%
+ {\setcounter{\s!num:\s!syncpos:#1}{0}%
+ \doglobal\appendtoksonce\getvalue {\s!reset:\s!syncpos:#1}\to\resetsyncpositions
+ \doglobal\appendtoksonce\getvalue{\s!preset:\s!syncpos:#1}\to\presetsyncpositions
+ \setgvalue{\s!syncpos:#1}{sync_n[#1] := 0 ;}%
+ \setgvalue{\s!set:\s!syncpos:#1}{\dosetsyncpositions{#1}}}
+
+\def\syncposition
+ {\dodoubleempty\dosyncposition}
+
+\def\dosyncposition[#1][#2]%
+ {\letgvalue{\s!reset:\s!syncpos:#1}\relax
+ \letgvalue{\s!preset:\s!syncpos:#1}\relax
+ \dontleavehmode
+ \dodosyncposition{#1}{#2}\s!set
+ \ignorespaces}
+
+\def\doifelselastsyncposition#1#2%
+ {\doifelse{\lastsyncclass\lastsyncposition}{#1#2}}
+
+\def\dodosyncposition#1#2#3%
+ {\letgvalue{\s!reset:\s!syncpos:#1}\relax
+ \letgvalue{\s!preset:\s!syncpos:#1}\relax
+ \ifundefined{\s!syncpos:#1}%
+ \strut
+ \else
+ \pluscounter{\s!num:\s!syncpos:#1}%
+ \setsyncpositions{#1}%
+ % option: geen w/h, alleen p 0 0 0 data
+ \setpositionplus
+ {\s!syncpos:#1:\countervalue{\s!num:\s!syncpos:#1}}%
+ {#2}%
+ \hbox{\strut\traceposstring\llap\green{#3/\countervalue{\s!num:\s!syncpos:#1}/#1/#2>>}}%
+ \fi}
+
+\def\setsyncpositions#1%
+ {\enabletextarearegistration
+ \getvalue {\s!set:\s!syncpos:#1}%
+ \letgvalue{\s!set:\s!syncpos:#1}\relax}
+
+\def\dosetsyncpositions#1%
+ {\startnointerference % removing out of sync can best be done in mp
+ \!!dimena\maxdimen
+ \!!counta\zerocount
+ \!!countc\zerocount
+ \doloop
+ {\doifpositionelse{\s!syncpos:#1:\recurselevel}
+ {\!!dimenb\MPy{\s!syncpos:#1:\recurselevel}\relax
+ \!!countb\MPp{\s!syncpos:#1:\recurselevel}\relax
+ \ifnum\!!countb=\!!counta % same page
+ \ifdim\!!dimenb>\!!dimena
+ \donefalse % out of order nodes
+ \else
+ \donetrue % nodes in order
+ \fi
+ \else
+ \donetrue % different page
+ \fi
+ \ifdone
+ \!!counta\!!countb
+ \!!dimena\!!dimenb
+ \advance\!!countc\plusone
+ \edef\!!stringa{[#1][\the\!!countc]:=}%
+ \edef\!!stringc{\s!syncpos:#1:\the\!!countc}%
+ \edef\!!stringd{\MPplus\!!stringc{1}{0}}%
+ \setxvalue{\s!syncpos:#1}%
+ {\getsyncpositions{#1}%
+ sync_p \!!stringa \MPp \!!stringc ;
+ sync_xy\!!stringa \MPxy\!!stringc ;
+ sync_w \!!stringa \MPw \!!stringc ;
+ sync_h \!!stringa \MPh \!!stringc ;
+ sync_d \!!stringa \MPd \!!stringc ;
+ \ifx\!!stringd\empty \else sync_t \!!stringa \MPplus\!!stringc{1}{0} ; \fi}%
+ \fi}
+ {\setxvalue{\s!syncpos:#1}%
+ {\getsyncpositions{#1}%
+ sync_n[#1] := \the\!!countc ;}
+ \exitloop}}%
+ \stopnointerference}
+
+\def\getsyncpositions#1%
+ {\getvalue{\s!syncpos:#1}}
+
+\newtoks\resetsyncpositions
+\newtoks\presetsyncpositions
+
+\def\resyncposition {\dodoubleargument\doresyncposition}
+\def\presyncposition{\dodoubleargument\dopresyncposition}
+
+\def\dodoresyncposition #1#2{\dodosyncposition{#1}{#2}\s!reset}
+\def\dodopresyncposition#1#2{\dodosyncposition{#1}{#2}\s!preset}
+
+\def\doresyncposition [#1][#2]{\setxvalue{\s!reset :\s!syncpos:#1}{\noexpand\dodoresyncposition{#1}{#2}}}
+\def\dopresyncposition[#1][#2]{\setxvalue{\s!preset:\s!syncpos:#1}{\noexpand\dodopresyncposition{#1}{#2}}}
+
+\def\flushsyncpositions % this order !
+ {\begingroup
+ \the\presetsyncpositions
+ \the\resetsyncpositions
+ \endgroup}
+
+\def\flushsyncxxsets#1%
+ {\setbox\scratchbox\hbox{\the#1}%
+ \ifvoid\scratchbox\else
+ \prewordbreak \let\prewordbreak\relax % only once
+ \smashbox\scratchbox
+ \box\scratchbox
+ \fi}
+
+\def\flushsyncresets {\flushsyncxxsets\resetsyncpositions }
+\def\flushsyncpresets{\flushsyncxxsets\presetsyncpositions}
+
+% \appendtoks \flushsyncpositions \to \everypar
+% \appendtoks \flushsyncpositions \to \everyheadstart
+
+% \explicitneverypar -> in grid snapper, eerst testen
+%
+% \appendtoks \flushsyncpositions \to \neverypar
+
+\protect \endinput
+
+\starttext
+
+\definesyncpositions[1]
+
+\startuseMPgraphic{sync}
+ StartPage ;
+ \getsyncpositions{1} ;
+ SyncThreshold := 2LineHeight ;
+ SyncLeftOffset := -.5LeftMarginDistance ;
+ % SetSyncThreshold(1,3,3LineHeight) ;
+ SyncWidth := - (BackSpace + SyncLeftOffset) ;
+ SetSyncColor(1,1,\MPcolor{red}) ;
+ SetSyncColor(1,2,\MPcolor{green}) ;
+ SetSyncColor(1,3,\MPcolor{blue}) ;
+ SetSyncColor(1,4,\MPcolor{yellow}) ;
+ PrepareSyncTasks(1,true,true,false) ;
+ for i = 1 upto NOfSyncPaths :
+ fill SyncPaths[i]
+ withcolor TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]]) ;
+ endfor ;
+ setbounds currentpicture to Page ;
+ StopPage ;
+\stopuseMPgraphic
+
+\defineoverlay[tempoverlay][\useMPgraphic{sync}]
+
+\setupbackgrounds[page][background=tempoverlay]
+
+\syncposition[1][1] \input ward \endgraf
+\syncposition[1][2] \input ward \endgraf
+\syncposition[1][3] \input ward \endgraf
+\syncposition[1][4] \input ward \endgraf
+
+\stoptext
diff --git a/tex/context/base/anch-snc.mkiv b/tex/context/base/anch-snc.mkiv
new file mode 100644
index 000000000..1f3610111
--- /dev/null
+++ b/tex/context/base/anch-snc.mkiv
@@ -0,0 +1,185 @@
+%D \module
+%D [ file=anch-snc,
+%D version=2003.12.01,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Synchronization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% this can be optimized (will do when used again)
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Synchronization}
+
+\unprotect
+
+\ifx\s!set \undefined \def\s!set {set} \fi
+\ifx\s!reset \undefined \def\s!reset {reset} \fi
+\ifx\s!preset \undefined \def\s!preset {preset} \fi
+\ifx\s!syncpos\undefined \def\s!syncpos{syncpos} \fi
+
+\def\definesyncpositions[#1]%
+ {\global\let\flushsyncpositions\doflushsyncpositions % only when used
+ \setcounter{\s!num:\s!syncpos:#1}{0}%
+ \doglobal\appendtoksonce\csname\s!reset :\s!syncpos:#1\endcsname\to\resetsyncpositions
+ \doglobal\appendtoksonce\csname\s!preset:\s!syncpos:#1\endcsname\to\presetsyncpositions
+% to be tested:
+% \doglobal\expandafter\appendtoksonce\csname\s!reset :\s!syncpos:#1\endcsname\to\resetsyncpositions
+% \doglobal\expandafter\appendtoksonce\csname\s!preset:\s!syncpos:#1\endcsname\to\presetsyncpositions
+ \setgvalue{\s!syncpos:#1}{sync_n[#1] := 0 ;}%
+ \setgvalue{\s!set:\s!syncpos:#1}{\dosetsyncpositions{#1}}}
+
+\def\syncposition
+ {\dodoubleempty\dosyncposition}
+
+\def\dosyncposition[#1][#2]%
+ {\letgvalue{\s!reset :\s!syncpos:#1}\relax
+ \letgvalue{\s!preset:\s!syncpos:#1}\relax
+ \dontleavehmode
+ \dodosyncposition{#1}{#2}\s!set
+ \ignorespaces}
+
+\def\doifelselastsyncposition#1#2%
+ {\doifelse{\lastsyncclass\lastsyncposition}{#1#2}}
+
+\def\dodosyncposition#1#2#3%
+ {\letgvalue{\s!reset:\s!syncpos:#1}\relax
+ \letgvalue{\s!preset:\s!syncpos:#1}\relax
+ \ifcsname\s!syncpos:#1\endcsname
+ \pluscounter{\s!num:\s!syncpos:#1}%
+ \setsyncpositions{#1}%
+ % option: geen w/h, alleen p 0 0 0 data
+ \setpositionplus
+ {\s!syncpos:#1:\countervalue{\s!num:\s!syncpos:#1}}%
+ {#2}%
+ \hbox{\strut\traceposstring\llap\green{#3/\countervalue{\s!num:\s!syncpos:#1}/#1/#2>>}}%
+ \else
+ \strut
+ \fi}
+
+\def\setsyncpositions#1%
+ {\enabletextarearegistration
+ \getvalue {\s!set:\s!syncpos:#1}%
+ \letgvalue{\s!set:\s!syncpos:#1}\relax}
+
+\def\dosetsyncpositions#1%
+ {\startnointerference % removing out of sync can best be done in mp
+ \!!dimena\maxdimen
+ \!!counta\zerocount
+ \!!countc\zerocount
+ \doloop
+ {\doifpositionelse{\s!syncpos:#1:\recurselevel}
+ {\!!dimenb\MPy{\s!syncpos:#1:\recurselevel}\relax
+ \!!countb\MPp{\s!syncpos:#1:\recurselevel}\relax
+ \ifnum\!!countb=\!!counta % same page
+ \ifdim\!!dimenb>\!!dimena
+ \donefalse % out of order nodes
+ \else
+ \donetrue % nodes in order
+ \fi
+ \else
+ \donetrue % different page
+ \fi
+ \ifdone
+ \!!counta\!!countb
+ \!!dimena\!!dimenb
+ \advance\!!countc\plusone
+ \edef\!!stringa{[#1][\the\!!countc]:=}%
+ \edef\!!stringc{\s!syncpos:#1:\the\!!countc}%
+ \edef\!!stringd{\MPplus\!!stringc{1}{0}}%
+ \setxvalue{\s!syncpos:#1}%
+ {\getsyncpositions{#1}%
+ sync_p \!!stringa \MPp \!!stringc ;
+ sync_xy\!!stringa \MPxy\!!stringc ;
+ sync_w \!!stringa \MPw \!!stringc ;
+ sync_h \!!stringa \MPh \!!stringc ;
+ sync_d \!!stringa \MPd \!!stringc ;
+ \ifx\!!stringd\empty \else sync_t \!!stringa \MPplus\!!stringc{1}{0} ; \fi}%
+ \fi}
+ {\setxvalue{\s!syncpos:#1}%
+ {\getsyncpositions{#1}%
+ sync_n[#1] := \the\!!countc ;}
+ \exitloop}}%
+ \stopnointerference}
+
+\def\getsyncpositions#1%
+ {\getvalue{\s!syncpos:#1}}
+
+\newtoks\resetsyncpositions
+\newtoks\presetsyncpositions
+
+\def\resyncposition {\dodoubleargument\doresyncposition}
+\def\presyncposition{\dodoubleargument\dopresyncposition}
+
+\def\dodoresyncposition #1#2{\dodosyncposition{#1}{#2}\s!reset}
+\def\dodopresyncposition#1#2{\dodosyncposition{#1}{#2}\s!preset}
+
+\def\doresyncposition [#1][#2]{\setxvalue{\s!reset :\s!syncpos:#1}{\noexpand\dodoresyncposition{#1}{#2}}}
+\def\dopresyncposition[#1][#2]{\setxvalue{\s!preset:\s!syncpos:#1}{\noexpand\dodopresyncposition{#1}{#2}}}
+
+\let\flushsyncpositions\relax
+
+\def\doflushsyncpositions % this order !
+ {\begingroup
+ \the\presetsyncpositions
+ \the\resetsyncpositions
+ \endgroup}
+
+\def\flushsyncxxsets#1%
+ {\setbox\scratchbox\hbox{\the#1}%
+ \ifvoid\scratchbox\else
+ \prewordbreak \let\prewordbreak\relax % only once
+ \smashbox\scratchbox
+ \box\scratchbox
+ \fi}
+
+\def\flushsyncresets {\flushsyncxxsets\resetsyncpositions }
+\def\flushsyncpresets{\flushsyncxxsets\presetsyncpositions}
+
+% \appendtoks \flushsyncpositions \to \everypar
+% \appendtoks \flushsyncpositions \to \everyheadstart
+
+% \explicitneverypar -> in grid snapper, eerst testen
+%
+% \appendtoks \flushsyncpositions \to \neverypar
+
+\protect \endinput
+
+\starttext
+
+\definesyncpositions[1]
+
+\startuseMPgraphic{sync}
+ StartPage ;
+ \getsyncpositions{1} ;
+ SyncThreshold := 2LineHeight ;
+ SyncLeftOffset := -.5LeftMarginDistance ;
+ % SetSyncThreshold(1,3,3LineHeight) ;
+ SyncWidth := - (BackSpace + SyncLeftOffset) ;
+ SetSyncColor(1,1,\MPcolor{red}) ;
+ SetSyncColor(1,2,\MPcolor{green}) ;
+ SetSyncColor(1,3,\MPcolor{blue}) ;
+ SetSyncColor(1,4,\MPcolor{yellow}) ;
+ PrepareSyncTasks(1,true,true,false) ;
+ for i = 1 upto NOfSyncPaths :
+ fill SyncPaths[i]
+ withcolor TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]]) ;
+ endfor ;
+ setbounds currentpicture to Page ;
+ StopPage ;
+\stopuseMPgraphic
+
+\defineoverlay[tempoverlay][\useMPgraphic{sync}]
+
+\setupbackgrounds[page][background=tempoverlay]
+
+\syncposition[1][1] \input ward \endgraf
+\syncposition[1][2] \input ward \endgraf
+\syncposition[1][3] \input ward \endgraf
+\syncposition[1][4] \input ward \endgraf
+
+\stoptext
diff --git a/tex/context/base/anch-snc.tex b/tex/context/base/anch-snc.tex
deleted file mode 100644
index cf5b35d69..000000000
--- a/tex/context/base/anch-snc.tex
+++ /dev/null
@@ -1,177 +0,0 @@
-%D \module
-%D [ file=anch-snc,
-%D version=2003.12.01,
-%D title=\CONTEXT\ Anchoring Macros,
-%D subtitle=Synchronization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
-%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 Anchoring Macros / Synchronization}
-
-\unprotect
-
-\ifx\s!set \undefined \def\s!set {set} \fi
-\ifx\s!reset \undefined \def\s!reset {reset} \fi
-\ifx\s!preset \undefined \def\s!preset {preset} \fi
-\ifx\s!syncpos\undefined \def\s!syncpos{syncpos} \fi
-
-\def\definesyncpositions[#1]%
- {\setcounter{\s!num:\s!syncpos:#1}{0}%
- \doglobal\appendtoksonce\getvalue {\s!reset:\s!syncpos:#1}\to\resetsyncpositions
- \doglobal\appendtoksonce\getvalue{\s!preset:\s!syncpos:#1}\to\presetsyncpositions
- \setgvalue{\s!syncpos:#1}{sync_n[#1] := 0 ;}%
- \setgvalue{\s!set:\s!syncpos:#1}{\dosetsyncpositions{#1}}}
-
-\def\syncposition
- {\dodoubleempty\dosyncposition}
-
-\def\dosyncposition[#1][#2]%
- {\letgvalue{\s!reset:\s!syncpos:#1}\relax
- \letgvalue{\s!preset:\s!syncpos:#1}\relax
- \dontleavehmode
- \dodosyncposition{#1}{#2}\s!set
- \ignorespaces}
-
-\def\doifelselastsyncposition#1#2%
- {\doifelse{\lastsyncclass\lastsyncposition}{#1#2}}
-
-\def\dodosyncposition#1#2#3%
- {\letgvalue{\s!reset:\s!syncpos:#1}\relax
- \letgvalue{\s!preset:\s!syncpos:#1}\relax
- \ifundefined{\s!syncpos:#1}%
- \strut
- \else
- \pluscounter{\s!num:\s!syncpos:#1}%
- \setsyncpositions{#1}%
- % option: geen w/h, alleen p 0 0 0 data
- \setpositionplus
- {\s!syncpos:#1:\countervalue{\s!num:\s!syncpos:#1}}%
- {#2}%
- \hbox{\strut\traceposstring\llap\green{#3/\countervalue{\s!num:\s!syncpos:#1}/#1/#2>>}}%
- \fi}
-
-\def\setsyncpositions#1%
- {\enabletextarearegistration
- \getvalue {\s!set:\s!syncpos:#1}%
- \letgvalue{\s!set:\s!syncpos:#1}\relax}
-
-\def\dosetsyncpositions#1%
- {\startnointerference % removing out of sync can best be done in mp
- \!!dimena\maxdimen
- \!!counta\zerocount
- \!!countc\zerocount
- \doloop
- {\doifpositionelse{\s!syncpos:#1:\recurselevel}
- {\!!dimenb\MPy{\s!syncpos:#1:\recurselevel}\relax
- \!!countb\MPp{\s!syncpos:#1:\recurselevel}\relax
- \ifnum\!!countb=\!!counta % same page
- \ifdim\!!dimenb>\!!dimena
- \donefalse % out of order nodes
- \else
- \donetrue % nodes in order
- \fi
- \else
- \donetrue % different page
- \fi
- \ifdone
- \!!counta\!!countb
- \!!dimena\!!dimenb
- \advance\!!countc\plusone
- \edef\!!stringa{[#1][\the\!!countc]:=}%
- \edef\!!stringc{\s!syncpos:#1:\the\!!countc}%
- \edef\!!stringd{\MPplus\!!stringc{1}{0}}%
- \setxvalue{\s!syncpos:#1}%
- {\getsyncpositions{#1}%
- sync_p \!!stringa \MPp \!!stringc ;
- sync_xy\!!stringa \MPxy\!!stringc ;
- sync_w \!!stringa \MPw \!!stringc ;
- sync_h \!!stringa \MPh \!!stringc ;
- sync_d \!!stringa \MPd \!!stringc ;
- \ifx\!!stringd\empty \else sync_t \!!stringa \MPplus\!!stringc{1}{0} ; \fi}%
- \fi}
- {\setxvalue{\s!syncpos:#1}%
- {\getsyncpositions{#1}%
- sync_n[#1] := \the\!!countc ;}
- \exitloop}}%
- \stopnointerference}
-
-\def\getsyncpositions#1%
- {\getvalue{\s!syncpos:#1}}
-
-\newtoks\resetsyncpositions
-\newtoks\presetsyncpositions
-
-\def\resyncposition {\dodoubleargument\doresyncposition}
-\def\presyncposition{\dodoubleargument\dopresyncposition}
-
-\def\dodoresyncposition #1#2{\dodosyncposition{#1}{#2}\s!reset}
-\def\dodopresyncposition#1#2{\dodosyncposition{#1}{#2}\s!preset}
-
-\def\doresyncposition [#1][#2]{\setxvalue{\s!reset :\s!syncpos:#1}{\noexpand\dodoresyncposition{#1}{#2}}}
-\def\dopresyncposition[#1][#2]{\setxvalue{\s!preset:\s!syncpos:#1}{\noexpand\dodopresyncposition{#1}{#2}}}
-
-\def\flushsyncpositions % this order !
- {\begingroup
- \the\presetsyncpositions
- \the\resetsyncpositions
- \endgroup}
-
-\def\flushsyncxxsets#1%
- {\setbox\scratchbox\hbox{\the#1}%
- \ifvoid\scratchbox\else
- \prewordbreak \let\prewordbreak\relax % only once
- \smashbox\scratchbox
- \box\scratchbox
- \fi}
-
-\def\flushsyncresets {\flushsyncxxsets\resetsyncpositions }
-\def\flushsyncpresets{\flushsyncxxsets\presetsyncpositions}
-
-% \appendtoks \flushsyncpositions \to \everypar
-% \appendtoks \flushsyncpositions \to \everyheadstart
-
-% \explicitneverypar -> in grid snapper, eerst testen
-%
-% \appendtoks \flushsyncpositions \to \neverypar
-
-\protect \endinput
-
-\starttext
-
-\definesyncpositions[1]
-
-\startuseMPgraphic{sync}
- StartPage ;
- \getsyncpositions{1} ;
- SyncThreshold := 2LineHeight ;
- SyncLeftOffset := -.5LeftMarginDistance ;
- % SetSyncThreshold(1,3,3LineHeight) ;
- SyncWidth := - (BackSpace + SyncLeftOffset) ;
- SetSyncColor(1,1,\MPcolor{red}) ;
- SetSyncColor(1,2,\MPcolor{green}) ;
- SetSyncColor(1,3,\MPcolor{blue}) ;
- SetSyncColor(1,4,\MPcolor{yellow}) ;
- PrepareSyncTasks(1,true,true,false) ;
- for i = 1 upto NOfSyncPaths :
- fill SyncPaths[i]
- withcolor TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]]) ;
- endfor ;
- setbounds currentpicture to Page ;
- StopPage ;
-\stopuseMPgraphic
-
-\defineoverlay[tempoverlay][\useMPgraphic{sync}]
-
-\setupbackgrounds[page][background=tempoverlay]
-
-\syncposition[1][1] \input ward \endgraf
-\syncposition[1][2] \input ward \endgraf
-\syncposition[1][3] \input ward \endgraf
-\syncposition[1][4] \input ward \endgraf
-
-\stoptext
diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua
index afd69f1f5..9a8cadcf0 100644
--- a/tex/context/base/attr-ini.lua
+++ b/tex/context/base/attr-ini.lua
@@ -62,8 +62,8 @@ colors.registered = colors.registered or { }
colors.enabled = true
colors.weightgray = true
-colors.attribute = 0
-colors.selector = 0
+colors.attribute = attributes.private('color')
+colors.selector = attributes.private('colormodel')
colors.default = 1
colors.main = nil
colors.triggering = true
@@ -186,6 +186,7 @@ end
local function reviver(data,n)
local v = values[n]
+ local d
if not v then
local gray = graycolor(0)
d = { gray, gray, gray, gray }
@@ -214,15 +215,14 @@ function colors.filter(n)
return concat(data[n],":",5)
end
-function colors.setmodel(attribute,name,weightgray)
+function colors.setmodel(name,weightgray)
colors.model = name
- colors.selector = numbers[attribute]
colors.default = models[name] or 1
colors.weightgray = weightgray ~= false
return colors.default
end
-function colors.register(attribute, name, colorspace, ...) -- passing 9 vars is faster (but not called that often)
+function colors.register(name, colorspace, ...) -- passing 9 vars is faster (but not called that often)
local stamp = format(templates[colorspace],...)
local color = registered[stamp]
if not color then
@@ -232,7 +232,7 @@ function colors.register(attribute, name, colorspace, ...) -- passing 9 vars is
-- colors.reviver(color)
end
if name then
- list[numbers[attribute]][name] = color -- not grouped, so only global colors
+ list[colors.attribute][name] = color -- not grouped, so only global colors
end
return registered[stamp]
end
@@ -258,6 +258,7 @@ transparencies.data = transparencies.data or { }
transparencies.values = transparencies.values or { }
transparencies.enabled = false
transparencies.triggering = true
+transparencies.attribute = attributes.private('transparency')
storage.register("transparencies/registered", transparencies.registered, "transparencies.registered")
storage.register("transparencies/values", transparencies.values, "transparencies.values")
@@ -292,6 +293,7 @@ end
local function reviver(data,n)
local v = values[n]
+ local d
if not v then
d = inject_transparency(0)
else
@@ -321,9 +323,10 @@ shipouts.handle_transparency = nodes.install_attribute_handler {
--- overprint / knockout
-overprints = overprints or { }
-overprints.data = overprints.data or { }
-overprints.enabled = false
+overprints = overprints or { }
+overprints.data = overprints.data or { }
+overprints.enabled = false
+overprints.attribute = attributes.private('overprint')
overprints.registered = {
overprint = 1,
@@ -369,9 +372,10 @@ shipouts.handle_overprint = nodes.install_attribute_handler {
--- negative / positive
-negatives = negatives or { }
-negatives.data = negatives.data or { }
-negatives.enabled = false
+negatives = negatives or { }
+negatives.data = negatives.data or { }
+negatives.enabled = false
+negatives.attribute = attributes.private("negative")
negatives.registered = {
positive = 1,
@@ -423,6 +427,7 @@ effects.values = effects.values or { }
effects.registered = effects.registered or { }
effects.enabled = false
effects.stamp = "%s:%s:%s"
+effects.attribute = attributes.private("effect")
storage.register("effects/registered", effects.registered, "effects.registered")
storage.register("effects/values", effects.values, "effects.values")
@@ -478,64 +483,19 @@ viewerlayers = viewerlayers or { }
viewerlayers.data = viewerlayers.data or { }
viewerlayers.registered = viewerlayers.registered or { }
viewerlayers.values = viewerlayers.values or { }
+viewerlayers.listwise = viewerlayers.listwise or { }
viewerlayers.enabled = false
+viewerlayers.attribute = attributes.private("viewerlayer")
storage.register("viewerlayers/registered", viewerlayers.registered, "viewerlayers.registered")
storage.register("viewerlayers/values", viewerlayers.values, "viewerlayers.values")
local data = viewerlayers.data
local values = viewerlayers.values
+local listwise = viewerlayers.listwise
local registered = viewerlayers.registered
local template = "%s"
--- interwoven
-
---~ local somedone = false
---~ local somedata = { }
---~ local nonedata = nodeinjections.stoplayer()
---~
---~ function viewerlayers.none() -- no local
---~ if somedone then
---~ somedone = false
---~ return nonedata
---~ else
---~ return nil
---~ end
---~ end
---~
---~ local function some(name)
---~ local sd = somedata[name]
---~ if not sd then
---~ sd = {
---~ nodeinjections.switchlayer(name),
---~ nodeinjections.startlayer(name),
---~ }
---~ somedata[name] = sd
---~ end
---~ if somedone then
---~ return sd[1]
---~ else
---~ somedone = true
---~ return sd[2]
---~ end
---~ end
---~
---~ local function initializer(...)
---~ somedone = false
---~ return states.initialize(...)
---~ end
---~
---~ viewerlayers.register = function(name) -- if not inimode redefine data[n] in first call
---~ local stamp = format(template,name)
---~ local n = registered[stamp]
---~ if not n then
---~ n = #data + 1
---~ data[n] = function() return some(name) end -- slow but for the moment we don't store things in the format
---~ registered[stamp] = n
---~ end
---~ return registered[stamp] -- == n
---~ end
-
-- stacked
local function extender(viewerlayers,key)
@@ -559,13 +519,14 @@ local function initializer(...)
return states.initialize(...)
end
-viewerlayers.register = function(name) -- if not inimode redefine data[n] in first call
+viewerlayers.register = function(name,lw) -- if not inimode redefine data[n] in first call
local stamp = format(template,name)
local n = registered[stamp]
if not n then
n = #values + 1
values[n] = name
registered[stamp] = n
+ listwise[n] = lw or false
end
return registered[stamp] -- == n
end
diff --git a/tex/context/base/attr-ini.mkiv b/tex/context/base/attr-ini.mkiv
index f653e8c75..7d9cb100e 100644
--- a/tex/context/base/attr-ini.mkiv
+++ b/tex/context/base/attr-ini.mkiv
@@ -23,17 +23,18 @@
\definesystemattribute[state]
\definesystemattribute[skip]
\definesystemattribute[penalty]
-\definesystemattribute[colormodel][global] % no reset \chardef\colormodelattribute \dogetattributeid{colormodel}
-\definesystemattribute[color] \chardef\colorattribute \dogetattributeid{color}
-\definesystemattribute[transparency] \chardef\transparencyattribute \dogetattributeid{transparency}
-\definesystemattribute[background] \chardef\backgroundattribute \dogetattributeid{background}
+\definesystemattribute[colormodel][global] % no reset \chardef\colormodelattribute \dogetattributeid{colormodel}
+\definesystemattribute[color] \chardef\colorattribute \dogetattributeid{color}
+\definesystemattribute[transparency] \chardef\transparencyattribute \dogetattributeid{transparency}
+\definesystemattribute[background] \chardef\backgroundattribute \dogetattributeid{background}
\definesystemattribute[overprint]
\definesystemattribute[negative]
\definesystemattribute[effect]
-\definesystemattribute[viewerlayer] \chardef\viewerlayerattribute \dogetattributeid{viewerlayer}
-\definesystemattribute[reference] \chardef\referenceattribute \dogetattributeid{reference}
-\definesystemattribute[destination] \chardef\destinationattribute \dogetattributeid{destination}
-\definesystemattribute[graphicvadjust] \chardef\graphicvadjustattribute\dogetattributeid{graphicvadjust}
+\definesystemattribute[viewerlayer] \chardef\viewerlayerattribute \dogetattributeid{viewerlayer}
+\definesystemattribute[layoutcomponent] \chardef\layoutcomponentattribute\dogetattributeid{layoutcomponent}
+\definesystemattribute[reference] \chardef\referenceattribute \dogetattributeid{reference}
+\definesystemattribute[destination] \chardef\destinationattribute \dogetattributeid{destination}
+\definesystemattribute[graphicvadjust] \chardef\graphicvadjustattribute \dogetattributeid{graphicvadjust}
% \definesystemattribute[ignore]
%
@@ -53,7 +54,7 @@
\newcount\currentcolormodel
\def\setcolormodel#1%
- {\currentcolormodel\ctxlua{tex.print(colors.setmodel('colormodel','#1'))}%
+ {\currentcolormodel\ctxlua{tex.print(colors.setmodel('#1'))}%
\dosetattribute{colormodel}{\the\currentcolormodel}}
\setcolormodel{all}
@@ -62,9 +63,9 @@
\setcolormodel{all}% redundant?
\to \everyjob
-\def\registerrgbcolor #1#2#3#4{\ctxlua{colors.register('color','#1','rgb' ,#2,#3,#4)}}
-\def\registercmykcolor#1#2#3#4#5{\ctxlua{colors.register('color','#1','cmyk',#2,#3,#4,#5)}}
-\def\registergraycolor #1#2{\ctxlua{colors.register('color','#1','gray',#2)}}
+\def\registerrgbcolor #1#2#3#4{\ctxlua{colors.register('#1','rgb' ,#2,#3,#4)}}
+\def\registercmykcolor#1#2#3#4#5{\ctxlua{colors.register('#1','cmyk',#2,#3,#4,#5)}}
+\def\registergraycolor #1#2{\ctxlua{colors.register('#1','gray',#2)}}
% transparency
diff --git a/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv
index b074d04fe..07e9147f2 100644
--- a/tex/context/base/back-ini.mkiv
+++ b/tex/context/base/back-ini.mkiv
@@ -50,31 +50,12 @@
%D Not everything here makes sense and the content of this file will
%D definitely change.
-\let \dostartgraymode \gobbleoneargument
-\let \dostopgraymode \donothing
-\let \dostartrgbcolormode \gobblethreearguments
-\let \dostartcmykcolormode \gobblefourarguments
-\let \dostartgraycolormode \gobbleoneargument
-\let \dostopcolormode \donothing
-\let \dostartspotcolormode \gobbletwoarguments
-\let \doregisterspotcolorname \gobbletwoarguments
-\let \dostartnonecolormode \donothing
-\let \doregisternonecolor \donothing
-
-\let \doinsertsoundtrack \gobblethreearguments
-
-\let \dostartrotation \gobbleoneargument
-\let \dostoprotation \donothing
-\let \dostartscaling \gobbletwoarguments
-\let \dostopscaling \donothing
-\let \dostartmirroring \donothing
-\let \dostopmirroring \donothing
-\let \dostartnegative \donothing
-\let \dostopnegative \donothing
-\let \dostartoverprint \donothing
-\let \dostopoverprint \donothing
-\let \dostartgraphicgroup \donothing
-\let \dostopgraphicgroup \donothing
+\let \dostartrotation \gobbleoneargument
+\let \dostoprotation \donothing
+\let \dostartscaling \gobbletwoarguments
+\let \dostopscaling \donothing
+\let \dostartmirroring \donothing
+\let \dostopmirroring \donothing
%D \macros
%D {doovalbox}
@@ -107,9 +88,6 @@
\let \dostartclipping \gobblethreearguments
\let \dostopclipping \donothing
-\let \dosetuprenderingopenpageaction \donothing
-\let \dosetuprenderingclosepageaction \donothing
-
%D \macros
%D {dostartobject,
%D dostopobject,
@@ -163,7 +141,7 @@
%D version 3.0 (\PDF\ version 1.2) viewers proved to be too
%D bugged to support named destinations.
-\newif\ifusepagedestinations
+\newif\ifusepagedestinations % not yet interfaced in mkiv
%D \macros
%D {jobsuffix}
diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv
index aaba4554f..c635f1c3b 100644
--- a/tex/context/base/back-pdf.mkiv
+++ b/tex/context/base/back-pdf.mkiv
@@ -83,9 +83,6 @@
%D Transformations. Some day we will use primitives (once they're fixed).
-\def\dostartgraphicgroup{\pdfliteral{q}}
-\def\dostopgraphicgroup {\pdfliteral{Q}}
-
\def\dostartrotation#1% grouped
{\forcecolorhack
\pdfliteral{q \ctxlua{lpdf.rotationcm(#1)}}}
diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua
index 5b13f669a..53598f03a 100644
--- a/tex/context/base/buff-ini.lua
+++ b/tex/context/base/buff-ini.lua
@@ -89,18 +89,20 @@ end
flags.optimize_verbatim = true
flags.count_empty_lines = false
-commands.no_break = "\\doverbatimnobreak"
-commands.do_break = "\\doverbatimgoodbreak"
-commands.begin_of_line_command = "\\doverbatimbeginofline"
-commands.end_of_line_command = "\\doverbatimendofline"
-commands.empty_line_command = "\\doverbatimemptyline"
+local no_break_command = "\\doverbatimnobreak"
+local do_break_command = "\\doverbatimgoodbreak"
+local begin_of_line_command = "\\doverbatimbeginofline"
+local end_of_line_command = "\\doverbatimendofline"
+local empty_line_command = "\\doverbatimemptyline"
+local begin_of_buffer_command = "\\doverbatimbeginofbuffer"
+local end_of_buffer_command = "\\doverbatimendofbuffer"
function buffers.verbatimbreak(n,m)
if flags.optimize_verbatim then
if n == 2 or n == m then
- texsprint(commands.no_break)
+ texsprint(no_break_command)
else
- texsprint(commands.do_break)
+ texsprint(do_break_command)
end
end
end
@@ -280,58 +282,75 @@ end
-- maybe just line(n,str) empty(n,str)
-visualizers.default = visualizers.default or { }
-visualizers.tex = visualizers.tex or { }
-visualizers.mp = visualizers.mp or { }
-
+visualizers.handlers = visualizers.handlers or { }
visualizers.escapetoken = nil
visualizers.tablength = 7
-
visualizers.enabletab = true -- false
visualizers.enableescape = false
visualizers.obeyspace = true
-local default = visualizers.default
+local handlers = visualizers.handlers
-function visualizers.reset()
---~ visualizers.enabletab = false
---~ visualizers.enableescape = false
---~ buffers.currentvisualizer = 'default'
+function buffers.newvisualizer(name)
+ local handler = { }
+ handlers[name] = handler
+ return handler
+end
+
+function buffers.getvisualizer(name)
+ return handlers[name]
end
-buffers.currentvisualizer = 'default' -- could become a local
+local default = buffers.newvisualizer("default")
+
+local currentvisualizer, currenthandler
function buffers.setvisualizer(str)
- buffers.currentvisualizer = lower(str)
- local v = visualizers[buffers.currentvisualizer]
- if not v then
- buffers.currentvisualizer = 'default'
- elseif v.reset then
- v.reset()
+ currentvisualizer = lower(str)
+ currenthandler = handlers[currentvisualizer]
+ if not currenthandler then
+ currentvisualizer = 'default'
+ currenthandler = handlers.default
+ end
+ if currenthandler.reset then
+ currenthandler.reset()
end
end
+buffers.setvisualizer("default")
+
+function visualizers.reset()
+end
+
function buffers.doifelsevisualizer(str)
- cs.testcase((str ~= "") and (visualizers[lower(str)] ~= nil))
+ cs.testcase((str ~= "") and (handlers[lower(str)] ~= nil))
end
-- calling routines, don't change
+function hooks.begin_of_buffer()
+ (currenthandler.begin_of_buffer or default.begin_of_buffer)(currentvisualizer)
+end
+
+function hooks.end_of_buffer()
+ (currenthandler.end_of_buffer or default.end_of_buffer)()
+end
+
function hooks.flush_line(str,nesting)
str = gsub(str," *[\n\r]+ *"," ") ; -- semi colon needed
- (visualizers[buffers.currentvisualizer].flush_line or default.flush_line)(str,nesting)
+ (currenthandler.flush_line or default.flush_line)(str,nesting)
end
function hooks.begin_of_line(n)
- (visualizers[buffers.currentvisualizer].begin_of_line or default.begin_of_line)(n)
+ (currenthandler.begin_of_line or default.begin_of_line)(n)
end
function hooks.end_of_line()
- (visualizers[buffers.currentvisualizer].end_of_line or default.end_of_line)()
+ (currenthandler.end_of_line or default.end_of_line)()
end
function hooks.empty_line()
- (visualizers[buffers.currentvisualizer].empty_line or default.empty_line)()
+ (currenthandler.empty_line or default.empty_line)()
end
function hooks.line(str)
@@ -340,21 +359,29 @@ function hooks.line(str)
else
str = gsub(str,"\t"," ")
end
- return (visualizers[buffers.currentvisualizer].line or default.line)(str)
+ return (currenthandler.line or default.line)(str)
end
-- defaults
+function default.begin_of_buffer(currentvisualizer)
+ texsprint(ctxcatcodes,begin_of_buffer_command,"{",currentvisualizer,"}")
+end
+
+function default.end_of_buffer()
+ texsprint(ctxcatcodes,end_of_buffer_command)
+end
+
function default.begin_of_line(n)
- texsprint(ctxcatcodes, commands.begin_of_line_command,"{",n,"}")
+ texsprint(ctxcatcodes, begin_of_line_command,"{",n,"}")
end
function default.end_of_line()
- texsprint(ctxcatcodes,commands.end_of_line_command)
+ texsprint(ctxcatcodes,end_of_line_command)
end
function default.empty_line()
- texsprint(ctxcatcodes,commands.empty_line_command)
+ texsprint(ctxcatcodes,empty_line_command)
end
function default.line(str)
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 53ad235fe..6275b13d3 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -13,6 +13,8 @@
\writestatus{loading}{ConTeXt Buffer Macros / Verbatim}
+%D We can optimize esp the initializations a bit.
+
\unprotect
\ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi
@@ -103,10 +105,12 @@
\let\obeycharacters\setupprettytype
\let\obeytabs\ignoretabs}
+\def\dosetverbatimfont
+ {\redoconvertfont\dosetfontattribute{\currenttypingclass\currenttyping}\c!style
+ \normalnoligatures\font}
+
\def\setupcommonverbatim
- {\recatcodeuppercharactersfalse % obey regime / encoding
- %
- \let\prettyidentifier\s!default
+ {\let\prettyidentifier\s!default
%
% \doifelse{\typingparameter\c!text}\v!yes
% \naturaltextexttrue
@@ -120,9 +124,6 @@
\doif{\typingparameter\c!page }\v!no
{\def\obeypages {\ignorepages}}%
%
-% \doifelse{\typingparameter\c!tab}\v!yes
-% {}% todo
- %
\ignorehyphens % default
\getvalue{\??tp:\c!lines:\typingparameter\c!lines}%
\getvalue{\??tp:\c!empty:\typingparameter\c!empty}%
@@ -130,9 +131,6 @@
\doifnumberelse{\typingparameter\c!tab}
{\def\obeytabs{\setfixedtabskips{\typingparameter\c!tab}}}%
\donothing
- %\def\verbatimfont{\typingparameter\c!style\normalnoligatures\font}%
- % more generic, but beware of the \redoconvertfont (else no typing in titles and such)
- \def\verbatimfont{\redoconvertfont\dosetfontattribute{\currenttypingclass\currenttyping}\c!style\normalnoligatures\font}%
\setupverbatimcolor}
\newtoks \everyinitializeverbatim
@@ -148,7 +146,6 @@
{\let\bop\donothing
\let\eop\donothing
\let\sop\donothing}%
- \verbatimfont
\relax\the\everyinitializeverbatim\relax}
\appendtoks
@@ -265,26 +262,43 @@
\unexpanded\def\type{\dotype\empty}
\def\dotype#1% was \dotype
- {\bgroup
- \begstrut % new, enables leading space in \type { abc } at par start / begstrut else no hyphenation
+ {\dontleavehmode \bgroup
+ % new, \strut enables leading space in \type { abc } at par start / begstrut
+ % else no hyphenation (replaced by \dontleavehmode which saves unboxing)
+ % \begstrut
\let\currenttypingclass\??ty
\edef\currenttyping{#1}%
\catcode`\<=\@@other
\catcode`\>=\@@other
\futurelet\next\dodotype}
+% \def\dodotype
+% {\ifx\next\bgroup
+% \@EA\dodotypeA
+% \else\if\next<%
+% \doifelse{\typingparameter\c!option}\v!none{\@EAEAEA\dodotypeB}{\@EAEAEA\dodotypeC}%
+% \else
+% \@EAEAEA\dodotypeD
+% \fi\fi}
+
\def\dodotype
{\ifx\next\bgroup
\@EA\dodotypeA
- \else\if\next<%
- \doifelse{\typingparameter\c!option}\v!none{\@EAEAEA\dodotypeB}{\@EAEAEA\dodotypeC}%
\else
- \@EAEAEA\dodotypeD
- \fi\fi}
+ \@EA\dodotypeAD
+ \fi}
+
+\def\dodotypeAD
+ {\if\next<%
+ \doifelse{\typingparameter\c!option}\v!none{\@EA\dodotypeB}{\@EA\dodotypeC}%
+ \else
+ \@EA\dodotypeD
+ \fi}
\def\dodotypeA
{\initializetype % probably too much
\verbatimcolor
+ \dosetverbatimfont
\setcatcodetable \typcatcodesa
\dodotypeAA}
@@ -297,6 +311,7 @@
\def\dodotypeB#1%
{\initializetype
\verbatimcolor
+ \dosetverbatimfont
\setcatcodetable \typcatcodesb
\dodotypeBB}
@@ -309,6 +324,7 @@
\def\dodotypeC#1%
{\initializetype
\verbatimcolor
+ \dosetverbatimfont
\setcatcodetable \typcatcodesb
\dodotypeCC}
@@ -326,6 +342,7 @@
\def\dodotypeD#1%
{\initializetype
\verbatimcolor
+ \dosetverbatimfont
\setcatcodetable \typcatcodesa
\def\dodotypeDD##1#1{\dodotypeAA{##1}}%
\dodotypeDD}
@@ -343,7 +360,7 @@
\def\initializetype
{\let\obeylines\ignorelines
\setupcommonverbatim
- \verbatimfont % needed for \tex
+ %\dosetverbatimfont
%\setverbatimspaceskip
%\let\obeytabs \ignoretabs % probably not needed
%\let\obeylines\ignorelines % probably not needed
@@ -377,9 +394,12 @@
%D works all right, but a decent hyphenation support of
%D \type{\tt} text will be implemented soon.
+\def\specialobeyedspace {\hskip\interwordspace\relax} % better than spaceskip
+\def\specialcontrolspace{\hskip\zeropoint\hbox{\normalcontrolspace}\hskip\zeropoint\relax}
+
\def\obeyhyphens
- {\def\obeyedspace {\hskip\interwordspace\relax}% better than spaceskip
- \def\controlspace{\hskip\zeropoint\hbox{\normalcontrolspace}\hskip\zeropoint\relax}%
+ {\let\obeyedspace \specialobeyedspace
+ \let\controlspace\specialcontrolspace
\spaceskip.25em\relax} % hm a bit of stretch !
\def\obeybreakpoints
@@ -388,8 +408,8 @@
\def\ignorehyphens
{% \language\minusone % extra bonus, the \null should do the job too
- \def\obeyedspace {\hskip\interwordspace\relax}% better than spaceskip
- \def\controlspace{\hskip\zeropoint\hbox{\normalcontrolspace}\hskip\zeropoint\relax}%
+ \let\obeyedspace \specialobeyedspace
+ \let\controlspace\specialcontrolspace
\spaceskip.5em\relax}
\unexpanded\def\typ
@@ -435,6 +455,7 @@
{\let\currenttypingclass\??ty
\initializetype
\verbatimcolor
+ \dosetverbatimfont
%\setcatcodetable \typcatcodesa
\catcode`\{=\@@begingroup
\catcode`\}=\@@endgroup}
@@ -477,6 +498,14 @@
\setvalue{\??tp:\c!blank:\v!line }{\baselineskip}
\setvalue{\??tp:\c!blank:\v!none }{\zeropoint}
+\def\doopenupverbatimlineindeed
+ {\getpagestatus
+ \ifrightpage
+ \hskip\typingparameter\c!oddmargin\relax
+ \else
+ \hskip\typingparameter\c!evenmargin\relax
+ \fi}
+
\def\initializetyping
{%\donefalse
\switchtobodyfont[\typingparameter\c!bodyfont]%
@@ -486,13 +515,7 @@
\scratchskip\typingparameter\c!evenmargin\relax
\ifzeropt\scratchskip\else\donetrue\fi
\ifdone
- \def\doopenupverbatimline
- {\getpagestatus
- \ifrightpage
- \hskip\typingparameter\c!oddmargin\relax
- \else
- \hskip\typingparameter\c!evenmargin\relax
- \fi}%
+ \let\doopenupverbatimline\doopenupverbatimlineindeed
\else
\doadaptleftskip{\typingparameter\c!margin}%
\fi
@@ -518,6 +541,9 @@
\let \beginofverbatimlines \relax
\let \endofverbatimlines \relax
+\let \doverbatimbeginofbuffer\gobbleoneargument
+\let \doverbatimbeginofbuffer\relax
+
\def\doverbatimnobreak
{\ifoptimizeverbatim\penalty500 \fi}
@@ -581,6 +607,7 @@
\startpacked % includes \bgroup
\dosetuptypelinenumbering{#1}%
\initializetyping
+ \dosetverbatimfont
\startverbatimcolor
\normalexpanded{\dotypeblockverbatim{\e!start\currenttyping}{\e!stop\currenttyping}}} % was s!start
@@ -690,18 +717,41 @@
%D Since we support a global color too, the folowing
%D definition is better:
+\def\normalbeginofpretty [#1]{\startcolor[\prettypalet:#1]}%
+\def\normalendofpretty {\stopcolor}
+\def\normalstartverbatimcolor{\startcolor[\typingparameter\c!color]}%
+\def\normalstopverbatimcolor {\stopcolor}
+\def\normalverbatimcolor {\getvalue{\typingparameter\c!color}}% command !
+
+\def\ignorebeginofpretty [#1]{}
+\def\ignoreendofpretty {}
+
+\def\setupnormalprettyverbatim
+ {\edef\prettypalet{\prettyidentifier\prettypalet}%
+ \let\beginofpretty \normalbeginofpretty
+ \let\endofpretty \normalendofpretty
+ \let\startverbatimcolor\normalstartverbatimcolor
+ \let\stopverbatimcolor \normalstopverbatimcolor
+ \let\verbatimcolor \normalverbatimcolor}
+
+\def\setupignoreprettyverbatim
+ {\let\prettypalet \empty
+ \let\beginofpretty \ignorebeginofpretty
+ \let\endofpretty \ignoreendofpretty
+ \let\startverbatimcolor\normalstartverbatimcolor
+ \let\stopverbatimcolor \normalstopverbatimcolor
+ \let\verbatimcolor \normalverbatimcolor}
+
\def\setupverbatimcolor
- {\def\beginofpretty[##1]{\startcolor[\prettypalet:##1]}%
- \let\endofpretty \stopcolor
- \def\startverbatimcolor{\startcolor[\typingparameter\c!color]}%
- \let\stopverbatimcolor \stopcolor
- \def\verbatimcolor {\getvalue{\typingparameter\c!color}}% command !
- \doifelsenothing{\typingparameter\c!palet}
- {\let\prettypalet\empty
- \let\endofpretty\relax
- \def\beginofpretty[##1]{}}
- {\edef\prettypalet{\prettyidentifier\typingparameter\c!palet}}}
+ {\edef\prettypalet{\typingparameter\c!palet}%
+ \ifx\prettypalet\empty
+ \setupignoreprettyverbatim
+ \else
+ \setupnormalprettyverbatim
+ \fi}
+\let\beginofpretty \ignorebeginofpretty
+\let\endofpretty \ignoreendofpretty
\let\prettypalet \empty
\let\startverbatimcolor\relax
\let\stopverbatimcolor \relax
@@ -769,9 +819,9 @@
\doifnothing{\typingparameter\c!step}{\settypingparameter\c!step{1}}%
\setuplinenumbering
[\c!method=\v!type,
- \c!start=\typingparameter\c!start,
- \c!stop=\typingparameter\c!stop,
- \c!step=\typingparameter\c!step]%
+ \c!start=\typingparameter\c!start,
+ \c!stop=\typingparameter\c!stop,
+ \c!step=\typingparameter\c!step]%
\donetrue}
{\donefalse}}%
\ifdone
@@ -803,6 +853,7 @@
{\expandafter\aftersplitstring#3\at.\to\prettyidentifier
\settypingparameter\c!option{\prettyidentifier}}%
\initializetyping
+ \dosetverbatimfont
\startverbatimcolor
\scratchcounter
\ifcsname\currenttypingclass#3\v!global\c!start\endcsname
diff --git a/tex/context/base/catc-act.tex b/tex/context/base/catc-act.tex
index 5aecb2493..bc24562d7 100644
--- a/tex/context/base/catc-act.tex
+++ b/tex/context/base/catc-act.tex
@@ -21,7 +21,7 @@
{\edef\temp{\detokenize{#1}}%
\cctcounterc\expandafter`\temp\relax % relax needed
\expandafter\startextendcatcodetable
- \expandafter\ctxcatcodes\expandafter\catcode\the\cctcounterc=13
+ \expandafter\ctxcatcodes\expandafter\catcode\the\cctcounterc\activecatcode
\stopextendcatcodetable
\letcatcodecommand \ctxcatcodes \cctcounterc \temp \relax
\ifnum\currentcatcodetable=\ctxcatcodes \setcatcodetable\ctxcatcodes \fi}
@@ -38,7 +38,7 @@
{\cctcounterc\uccode\activehackcode
\if#1"\uccode\activehackcode\expandafter\doifnumberelse\expandafter{\string#1#2}\empty #1#2\else
\uccode\activehackcode\expandafter\doifnumberelse\expandafter{\string#1#2}\empty`#1#2\fi
- \catcode\uccode\activehackcode13
+ \catcode\uccode\activehackcode\activecatcode
\uppercase{\def\next{~}}%
\uccode\activehackcode\cctcounterc
\expandafter\expandafter\expandafter\def\expandafter\next\expandafter
diff --git a/tex/context/base/catc-ini.mkii b/tex/context/base/catc-ini.mkii
index 60b7528dd..dee15290a 100644
--- a/tex/context/base/catc-ini.mkii
+++ b/tex/context/base/catc-ini.mkii
@@ -22,6 +22,22 @@
\ifx\plusone \undefined \chardef \plusone = 1 \fi
\ifx\minusone \undefined \newcount\minusone \minusone =-1 \fi
+\chardef\escapecatcode = 0
+\chardef\begingroupcatcode = 1
+\chardef\endgroupcatcode = 2
+\chardef\mathshiftcatcode = 3
+\chardef\alignmentcatcode = 4
+\chardef\endoflinecatcode = 5
+\chardef\parametercatcode = 6
+\chardef\superscriptcatcode = 7
+\chardef\subscriptcatcode = 8
+\chardef\ignorecatcode = 9
+\chardef\spacecatcode = 10
+\chardef\lettercatcode = 11
+\chardef\othercatcode = 12 \chardef\other = 12
+\chardef\activecatcode = 13 \chardef\active = 13
+\chardef\commentcatcode = 14
+
\newif \ifrecatcodeuppercharacters % only used in good old tex
% \newcount\cctdefcounter \cctdefcounter\plusone % 0 = signal
@@ -43,7 +59,8 @@
\newtoks \setdefaultuppercatcodes
\def\next#1% we don't have a proper loop defined yet
- {\edef\nextnext{#1{\the#1\catcode\the\cctcountera\space\ifnum\catcode\cctcountera=11 11\else12\fi}}%
+ {\edef\nextnext{#1{\the#1\catcode\the\cctcountera\space
+ \ifnum\catcode\cctcountera=\lettercatcode \lettercatcode\else\othercatcode\fi}}%
\nextnext\ifnum\cctcountera<\cctcounterb \advance\cctcountera\plusone \expandafter\next\expandafter#1\fi}
\cctcountera 0 \cctcounterb 127 \next\setdefaultlowercatcodes
@@ -132,7 +149,7 @@
\def\reinstatecatcodecommanda % can be used when a direct definition has been done
{\bgroup % and the selector has been lost
\uccode\activehackcode\cctcounterb
- \catcode\uccode\activehackcode13
+ \catcode\uccode\activehackcode\activecatcode
\uppercase{\xdef~{\noexpand\catcodecommand{\number\cctcounterb}}}%
\egroup}
@@ -170,15 +187,18 @@
\def\popcatcodetable
{\ifcase\catcoderestorelevel
- \immediate\write16{}%
- \immediate\write16{Fatal error: catcode push/pop mismatch. Fix this!}\wait\end
- \immediate\write16{}%
+ \showcatcodenestingerror
\else
\expandafter\catcodetable\csname scct:\number\catcoderestorelevel\endcsname
\tracepopcatcodetable
\advance\catcoderestorelevel\minusone
\fi}
+\def\showcatcodenestingerror % can be overloaded
+ {\immediate\write16{}%
+ \immediate\write16{Fatal error: catcode push/pop mismatch. Fix this!}\wait\end
+ \immediate\write16{}}
+
\def\restorecatcodes % takes previous level
{\ifnum\catcoderestorelevel>\plusone
\expandafter\catcodetable\csname scct:\number\numexpr\catcoderestorelevel-1\relax\endcsname
diff --git a/tex/context/base/catc-ini.mkiv b/tex/context/base/catc-ini.mkiv
index 085b82005..668a55d3b 100644
--- a/tex/context/base/catc-ini.mkiv
+++ b/tex/context/base/catc-ini.mkiv
@@ -25,6 +25,22 @@
\ifx\plusone \undefined \chardef \plusone = 1 \fi
\ifx\minusone \undefined \newcount\minusone \minusone =-1 \fi
+\chardef\escapecatcode = 0
+\chardef\begingroupcatcode = 1
+\chardef\endgroupcatcode = 2
+\chardef\mathshiftcatcode = 3
+\chardef\alignmentcatcode = 4
+\chardef\endoflinecatcode = 5
+\chardef\parametercatcode = 6
+\chardef\superscriptcatcode = 7
+\chardef\subscriptcatcode = 8
+\chardef\ignorecatcode = 9
+\chardef\spacecatcode = 10
+\chardef\lettercatcode = 11
+\chardef\othercatcode = 12 \chardef\other = 12
+\chardef\activecatcode = 13 \chardef\active = 13
+\chardef\commentcatcode = 14
+
\ifx\gobbleoneargument\undefined \long\def\gobbleoneargument#1{} \fi
\newif \ifrecatcodeuppercharacters % only used in good old tex
@@ -38,7 +54,7 @@
\def\newcatcodetable#1%
{\global\advance\cctdefcounter\plusone
\expandafter\xdef\csname @@ccn:\number\cctdefcounter\endcsname{\string#1}% logging
- \global\mathchardef#1\cctdefcounter
+ \global\chardef#1\cctdefcounter
\ctxlua{catcodes.register("\expandafter\gobbleoneargument\string#1",\number#1)}%
% we have two ways to access catcodetable numbers
\startruntimectxluacode tex.\expandafter\gobbleoneargument\string#1 = \number#1 ;\stopruntimectxluacode}
@@ -48,11 +64,11 @@
\newtoks \setdefaultcatcodes
\setdefaultcatcodes
- {\catcode`\\ 12
- \catcode`\^^M 12
- \catcode`\ 12
- \catcode`\% 12
- \catcode127 12 }
+ {\catcode`\\ \othercatcode
+ \catcode`\^^M \othercatcode
+ \catcode`\ \othercatcode
+ \catcode`\% \othercatcode
+ \catcode127 \othercatcode}
\long\def\startcatcodetable#1#2\stopcatcodetable
{\bgroup
@@ -127,7 +143,7 @@
\expandafter\defcatcodecommandc
\fi}
-\def\defcatcodecommandc % only first time
+\def\defcatcodecommandc % only first time (we could use \normalexpanded here)
{\expandafter\gdef\csname CCD:\number\cctcountera:\number\cctcounterb\expandafter\endcsname
\expandafter##\expandafter1\expandafter
{\expandafter\def\csname CCC:\number\cctcountera:\number\cctcounterb\endcsname{##1}}%
@@ -158,7 +174,7 @@
\def\reinstatecatcodecommanda % can be used when a direct definition has been done
{\bgroup % and the selector has been lost
\uccode\activehackcode\cctcounterb
- \catcode\uccode\activehackcode13
+ \catcode\uccode\activehackcode\activecatcode
\uppercase{\xdef~{\noexpand\catcodecommand{\number\cctcounterb}}}%
\egroup}
@@ -192,19 +208,22 @@
\def\pushcatcodetable
{\advance\catcoderestorelevel\plusone
\tracepushcatcodetable
- \expandafter\mathchardef\csname scct:\number\catcoderestorelevel\endcsname\currentcatcodetable}
+ \expandafter\chardef\csname scct:\number\catcoderestorelevel\endcsname\currentcatcodetable}
\def\popcatcodetable
{\ifcase\catcoderestorelevel
- \immediate\write16{}%
- \immediate\write16{Fatal error: catcode push/pop mismatch. Fix this!}\wait\end
- \immediate\write16{}%
+ \showcatcodenestingerror
\else
\expandafter\catcodetable\csname scct:\number\catcoderestorelevel\endcsname
\tracepopcatcodetable
\advance\catcoderestorelevel\minusone
\fi}
+\def\showcatcodenestingerror % can be overloaded
+ {\immediate\write16{}%
+ \immediate\write16{Fatal error: catcode push/pop mismatch. Fix this!}\wait\end
+ \immediate\write16{}}
+
\def\restorecatcodes % takes previous level
{\ifnum\catcoderestorelevel>\plusone
\expandafter\catcodetable\csname scct:\number\numexpr\catcoderestorelevel-1\relax\endcsname
diff --git a/tex/context/base/catc-sym.tex b/tex/context/base/catc-sym.tex
index da6c9c068..067e192c8 100644
--- a/tex/context/base/catc-sym.tex
+++ b/tex/context/base/catc-sym.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\unprotect
+% we now have loaded syst-* so we have all @@catcode constants
%D We want to have access to the raw alternatives of the
%D special characters. We use a \type {\xdef} instead of
@@ -20,9 +20,9 @@
\bgroup
-\catcode`B=\@@begingroup
-\catcode`E=\@@endgroup
-\catcode`.=\@@escape
+\catcode`B=\begingroupcatcode
+\catcode`E=\endgroupcatcode
+\catcode`.=\escapecatcode
.catcode `.{ 12 .xdef .letteropenbrace B.string{E
.catcode `.} 12 .xdef .letterclosebrace B.string}E
@@ -70,10 +70,10 @@
\def\uncatcodeallcharacters{\setcatcodetable\nilcatcodes} % was slow one, with restore
\def\uncatcodespacetokens
- {\catcode`\ =\@@space
- \catcode`\^^L=\@@ignore
- \catcode`\^^M=\@@endofline
- \catcode`\^^?=\@@ignore}
+ {\catcode`\ =\spacecatcode
+ \catcode`\^^L=\ignorecatcode
+ \catcode`\^^M=\endoflinecatcode
+ \catcode`\^^?=\ignorecatcode}
%D \macros
%D {setverbosecharacter,setverbosecscharacters}
@@ -94,8 +94,8 @@
% if used often we can move the code inline
- \catcode`\|=\@@active
- \catcode`\~=\@@active
+ \catcode`\|=\activecatcode
+ \catcode`\~=\activecatcode
\global \everyverbosechacters =
{\setverbosecscharacter |\setverbosecscharacter ~% context specific
@@ -184,4 +184,4 @@
\long\def\rescanwithsetup#1#2{\begingroup\directsetup{#1}\scantextokens{#2}\endgroup}
\fi
-\protect \endinput
+\endinput
diff --git a/tex/context/base/char-ini.mkiv b/tex/context/base/char-ini.mkiv
index b79e44857..daa20e728 100644
--- a/tex/context/base/char-ini.mkiv
+++ b/tex/context/base/char-ini.mkiv
@@ -34,8 +34,8 @@
%D them (unless of course we have adapted the table). It is on the agenda
%D to do this with \type {tex.lccode} cum suis once they're available.
-\def\setcclcuc#1#2#3{\global\catcode#1=11 \global\lccode #1=#2 \global\uccode #1=#3 }
-\def\setcclcucself#1{\global\catcode#1=11 \global\lccode #1=#1 \global\uccode #1=#1 }
+\def\setcclcuc#1#2#3{\global\catcode#1=\@@letter\global\lccode#1=#2\global\uccode#1=#3\relax}
+\def\setcclcucself#1{\global\catcode#1=\@@letter\global\lccode#1=#1\global\uccode#1=#1\relax }
\ctxlua{characters.setcodes()}
diff --git a/tex/context/base/chem-ini.mkiv b/tex/context/base/chem-ini.mkiv
index b28e73e42..da240dbac 100644
--- a/tex/context/base/chem-ini.mkiv
+++ b/tex/context/base/chem-ini.mkiv
@@ -37,6 +37,11 @@
\def\molecule#1{\ctxlua{commands.molecule(\!!bs#1\!!es)}}
+%D For old times sake:
+
+\def\chem#1#2#3%
+ {\dontleavehmode\begingroup#1\lohi{#2}{#3}\endgroup}
+
\protect \endinput
diff --git a/tex/context/base/colo-ext.mkiv b/tex/context/base/colo-ext.mkiv
index 274086bb6..1c1f0d1af 100644
--- a/tex/context/base/colo-ext.mkiv
+++ b/tex/context/base/colo-ext.mkiv
@@ -31,11 +31,11 @@
\def\negatecolorbox#1%
{\setbox#1\hbox
- {\dostartnegative
+ {\startnegativeproperty % might change
\startcolor[white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor
\hskip-\wd#1%
\box#1%
- \dostopnegative}}
+ \stopnegativeproperty}}
%D There are in principle two ways to handle overprint: bound to colors
%D or independent. For the moment we only support independent overprint
@@ -46,7 +46,7 @@
\def\starttextoverprint
{\doifelse\@@cloverprint\v!yes
- {\let\stoptextoverprint\dostopoverprint\dostartoverprint}
+ {\let\stoptextoverprint\stopoverprintproperty\startoverprintproperty}
{\let\stoptextoverprint\donothing}}
\let\stoptextoverprint\donothing
diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua
index befac2452..a67df6a77 100644
--- a/tex/context/base/colo-ini.lua
+++ b/tex/context/base/colo-ini.lua
@@ -178,7 +178,7 @@ local function do_registermultitonecolor(parent,name,parentnumber,e,f,d,p) -- sa
end
function colors.definesimplegray(name,s)
- return colors.register('color',name,'gray',s) -- we still need to get rid of 'color'
+ return colors.register(name,'gray',s) -- we still need to get rid of 'color'
end
function colors.defineprocesscolor(name,str,global,freeze) -- still inconsistent color vs transparent
@@ -187,13 +187,13 @@ function colors.defineprocesscolor(name,str,global,freeze) -- still inconsistent
if t then
if t.h then
local r, g, b = match(t.h .. "000000","(..)(..)(..)") -- watch the 255
- definecolor(name, colors.register('color',name,'rgb',(tonumber(r,16) or 0)/255,(tonumber(g,16) or 0)/255,(tonumber(b,16) or 0)/255 ), global)
+ definecolor(name, colors.register(name,'rgb',(tonumber(r,16) or 0)/255,(tonumber(g,16) or 0)/255,(tonumber(b,16) or 0)/255 ), global)
elseif t.r or t.g or t.b then
- definecolor(name, colors.register('color',name,'rgb', tonumber(t.r) or 0, tonumber(t.g) or 0, tonumber(t.b) or 0 ), global)
+ definecolor(name, colors.register(name,'rgb', tonumber(t.r) or 0, tonumber(t.g) or 0, tonumber(t.b) or 0 ), global)
elseif t.c or t.m or t.y or t.k then
- definecolor(name, colors.register('color',name,'cmyk',tonumber(t.c) or 0, tonumber(t.m) or 0, tonumber(t.y) or 0, tonumber(t.k) or 0), global)
+ definecolor(name, colors.register(name,'cmyk',tonumber(t.c) or 0, tonumber(t.m) or 0, tonumber(t.y) or 0, tonumber(t.k) or 0), global)
else
- definecolor(name, colors.register('color',name,'gray',tonumber(t.s) or 0), global)
+ definecolor(name, colors.register(name,'gray',tonumber(t.s) or 0), global)
end
if t.a and t.t then
definetransparent(name, transparencies.register(name,transparent[t.a] or tonumber(t.a) or 1,tonumber(t.t) or 1), global)
@@ -236,7 +236,7 @@ function colors.definespotcolor(name,parent,str,global)
t.p = tonumber(t.p) or 1
do_registerspotcolor(parent, name, cp, t.e, 1, "", t.p) -- p not really needed, only diagnostics
if name and name ~= "" then
- definecolor(name, colors.register('color',name,'spot', parent, 1, "", t.p), true)
+ definecolor(name, colors.register(name,'spot', parent, 1, "", t.p), true)
if t.a and t.t then
definetransparent(name, transparencies.register(name,transparent[t.a] or tonumber(t.a) or 1,tonumber(t.t) or 1), global)
elseif colors.couple then
@@ -279,7 +279,7 @@ function colors.definemultitonecolor(name,multispec,colorspec,selfspec)
if cp then
do_registerspotcolor(parent, name, cp, "", nof, dd, pp)
do_registermultitonecolor(parent, name, cp, "", nof, dd, pp)
- definecolor(name, colors.register('color', name, 'spot', parent, nof, dd, pp), true)
+ definecolor(name, colors.register(name, 'spot', parent, nof, dd, pp), true)
local t = settings_to_hash_strict(selfspec)
if t and t.a and t.t then
definetransparent(name, transparencies.register(name,transparent[t.a] or tonumber(t.a) or 1,tonumber(t.t) or 1), global)
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv
index 197cbcdca..e7a849805 100644
--- a/tex/context/base/colo-ini.mkiv
+++ b/tex/context/base/colo-ini.mkiv
@@ -24,8 +24,6 @@
\unprotect
-\chardef\colorversion=1 % temp, needed for tracing purposes, mkiv transition
-
%D We use a couple of local registers. That way we don't have
%D to group when converting colors. By the way, this is not
%D really faster. We can sqeeze half a second runtime for 50K
@@ -33,7 +31,6 @@
%D ugly then. To mention one such improvement: no colon
%D after the key character (.25 sec).
-\newdimen\colordimen
\newcount\colorcount
%D When typesetting for paper, we prefer using the \cap{CMYK}
@@ -86,7 +83,6 @@
\let\currentspotcolor \empty
\let\allspotcolors \empty
\let\usedspotcolors \empty
-\let\usedcolorchannels\empty
\let\currentpalet \empty
%D \macros
@@ -149,6 +145,7 @@
\unexpanded\def\stopcolor {\endgroup}
\unexpanded\def\graycolor [#1]{\groupedcommand{\setcolormodel{gray}\getvalue{#1}}{}}
\unexpanded\def\colored [#1]{\groupedcommand{\definecolor[@colored@][#1]\doactivatecolor{@colored@}}{}}
+\unexpanded\def\fastcolored [#1]#2{\begingroup\dodefinefastcolor[@colored@][#1]\doactivatecolor{@colored@}#2\endgroup}
\def\predefinecolor [#1]{\flushatshipout{\hbox{\color[#1]{}}}}
\def\predefineindexcolor[#1]{\flushatshipout{\hbox{\color[#1]{}}}}
\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]}
@@ -209,11 +206,7 @@
\let\usecolors\setupcolor
-% check: \chardef\currentcolorchannel=0
% check: \startcolormode
-% check: \newif\iffilterspotcolor \filterspotcolorfalse
-% check: \newif\ifdoingspotcolor \doingspotcolorfalse
-% check: \registercolorchannel
%D \macros
%D {definetransparency}
@@ -226,34 +219,6 @@
\unexpanded\def\setupcolors
{\dosingleargument\dosetupcolors}
-\def\resetcolorsplitting
- {\chardef\currentcolorchannel\zerocount
- \let\currentspotcolor\empty
- \filterspotcolorfalse}
-
-\def\colorsplitsuffix{\ifcase\currentcolorchannel\else-\@@clsplit\fi}
-\def\colorsplitprefix{\ifcase\currentcolorchannel\else\@@clsplit-\fi}
-
-\def\setcolorsplitting
- {\resetsystemmode{\v!color\colorsplitsuffix}%
- \resetcolorsplitting
- \processaction
- [\@@clsplit]
- [ c=>\chardef\currentcolorchannel1,%
- m=>\chardef\currentcolorchannel2,%
- y=>\chardef\currentcolorchannel3,%
- k=>\chardef\currentcolorchannel4,%
- r=>\chardef\currentcolorchannel5,%
- g=>\chardef\currentcolorchannel6,%
- b=>\chardef\currentcolorchannel7,%
- s=>\chardef\currentcolorchannel8,%
- \v!no=>,% \currentcolorchannel0,% all colors
- \s!default=>,% \currentcolorchannel0,% all colors
- \s!unknown=>\filterspotcolortrue
- \edef\currentspotcolor{\commalistelement}]%
- \setsystemmode{\v!color\colorsplitsuffix}%
- \iffilterspotcolor \let\@@clrgb\v!no \fi}
-
\let\showcolormessage\gobblethreearguments
\def\dosetupcolors[#1]% some no longer make sense in MkIV
@@ -261,18 +226,12 @@
\doifelse\@@clspot\v!yes
\SPOTsupportedtrue
\SPOTsupportedfalse
- \doifelsenothing\@@clsplit
- \resetcolorsplitting
- \setcolorsplitting
\doifelse\@@clreduction\v!yes
\reduceCMYKtrue
\reduceCMYKfalse
\doifelse\@@clexpansion\v!yes
\freezecolorstrue
\freezecolorsfalse
- \doifelse\@@clcriterium\v!all
- \hidesplitcolortrue
- \hidesplitcolorfalse
\doifelse\@@clfactor\v!no
\weightGRAYfalse
\weightGRAYtrue
@@ -436,7 +395,8 @@
\else
\showcolormessage\m!colors7\currentpalet
\let\currentpalet\empty
- \fi\fi}
+ \fi\fi
+ \initializemaintextcolor}
%D \macros
%D {showpalet}
@@ -508,9 +468,11 @@
\doifinstringelse{:}{#2}
{\definecolorgroup[#1][\v!rgb][#2]}
{\doloop
- {\doifdefinedelse{\??cr#2:\recurselevel}
- {\setevalue{\??cr#1:\recurselevel}{\csname\??cr#2:\recurselevel\endcsname}}
- {\exitloop}}}%
+ {\ifcsname\??cr#2:\recurselevel\endcsname
+ \setevalue{\??cr#1:\recurselevel}{\csname\??cr#2:\recurselevel\endcsname}%
+ \else
+ \exitloop
+ \fi}}%
\fi}
%D \macros
@@ -693,72 +655,28 @@
%D predefined in RGB color space, so a redefinition in CMYK
%D coordinates before RGB mode is disabled, would give
%D unexpected results due to the already frozen color spec.)
-%D
-%D So, from now on, colors are not frozen any more!
-
-\chardef\currentcolorchannel=0
-
-\newif\iffilterspotcolor \filterspotcolorfalse
-\newif\ifdoingspotcolor \doingspotcolorfalse
-
-\def\registercolorchannel#1%
- {\ifdoingspotcolor \else
- \global\expandafter\chardef\csname\??cs#1\endcsname\zerocount
- \fi}
-
-\newif\ifhidesplitcolor \hidesplitcolortrue
-
-%D The next macro is for instance used in figure splitting:
-
-\def\doifseparatingcolorselse
- {\iffilterspotcolor
- \@EA\firstoftwoarguments
- \else\ifcase\currentcolorchannel
- \@EAEAEA\secondoftwoarguments
- \else
- \@EAEAEA\firstoftwoarguments
- \fi\fi}
-
-\def\doifcolorchannelelse#1%
- {\doifseparatingcolorselse
- {\doifelsenothing{#1}
- \secondoftwoarguments
- {\doifelse{#1}\@@clsplit
- \firstoftwoarguments
- \secondoftwoarguments}}
- \secondoftwoarguments}
-\def\resetcolorseparation
- {\filterspotcolorfalse
- \chardef\currentcolorchannel\zerocount}
+%D In \MKIV\ we don't support color separation as we might now assume
+%D that printing houses have the right programs to do it themselves.
+%D The \MKII\ color separator was implemented as part of a project
+%D that needed. If it's ever needed in \MKIV\ i'll do it in the
+%D backend.
-%D These can be used in selecting specific files (like
-%D figuredatabases).
-
-% we already have:
-%
-% \def\colorsplitsuffix{\ifcase\currentcolorchannel\else-\@@clsplitsen\fi}
-% \def\colorsplitprefix{\ifcase\currentcolorchannel\else\@@clsplitsen-\fi}
-
-\def\colorchannelprefix{\doifseparatingcolorselse\@@clsplit\empty-}
-\def\colorchannelsuffix{-\doifseparatingcolorselse\@@clsplit\empty}
+\let\doifseparatingcolorselse\secondoftwoarguments
+\let\doifcolorchannelelse \secondofthreearguments
+\let\resetcolorseparation \relax
+\let\colorchannelprefix \empty
+\let\colorchannelsuffix \empty
%D We now define the low level macros:
-\chardef\colorversion=2
-
% todo: palets in definecolor
% todo: {\red xx} vs \red{xx}
% check: registerusedspotcolors
-% check: registerusedcolorchannels
% check: \currentcolorname
% check: \outercolorname
-% check: \chardef\currentcolorchannel=0
% check: \startcolormode
-% check: \newif\iffilterspotcolor \filterspotcolorfalse
-% check: \newif\ifdoingspotcolor \doingspotcolorfalse
-% check: \registercolorchannel
% \def\mptexcolor#1{"\dogetattributeid\s!color \somecolorattribute{#1} A"}
%
@@ -773,7 +691,7 @@
\def\setcolormodel#1%
{\showcolormessage\m!colors1{#1}%
- \currentcolormodel\ctxlua{tex.print(colors.setmodel('colormodel','#1',\ifweightGRAY true\else false\fi))}%
+ \currentcolormodel\ctxlua{tex.print(colors.setmodel('#1',\ifweightGRAY true\else false\fi))}%
\dosetattribute{colormodel}{\the\currentcolormodel}}
\setcolormodel{all}
@@ -886,6 +804,10 @@
\fi
\dosetattribute\s!color{\ctxlua{tex.sprint(colors.definesimplegray("_raster_",\@@rastervalue))}}}
+\def\dodefinefastcolor[#1][#2]% still not fast but ok
+ {\ctxlua{colors.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}%
+ \dodefinecolorcommand\setvalue{#1}}
+
%D \macros
%D {doifcolorelse, doifcolor}
%D
@@ -1091,16 +1013,8 @@
\definetransparency [difference] [11]
\definetransparency [exclusion] [12]
-\appendtoks
- \setupcolors[\c!state=\v!start]% later direct
-\to \everyjob
-
-\appendtoks
- \let\showcolormessage\showmessage
-\to \everyjob
-
\setupcolors
- [\c!state=\v!stop, % in mkii: \v!stop
+ [\c!state=\v!stop, % will be enabled later on
\c!conversion=\v!yes,
\c!reduction=\v!no,
\c!rgb=\v!yes,
@@ -1110,9 +1024,17 @@
\c!mp\c!spot=\@@clspot,
\c!expansion=\v!no,
\c!textcolor=,
- \c!split=\v!no,
+ \c!split=\v!no, % obsolete
\c!factor=\v!yes,
- \c!criterium=\v!all]
+ \c!criterium=\v!all] % obsolete
+
+\appendtoks
+ \setupcolors[\c!state=\v!start]% later direct
+\to \everyjob
+
+\appendtoks
+ \let\showcolormessage\showmessage
+\to \everyjob
\setupcolor
[\v!rgb]
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 9c729629c..777401a8d 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2009.07.17 13:16}
+\newcontextversion{2009.07.23 20:11}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
@@ -263,10 +263,6 @@
% \getmulticolumnlines -> now in cont-loc, to be tested and really needed
-\long\def\startprocesscommalist[#1]#2\stopprocesscommalist
- {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}%
- \processcommalist[#1]\currentcommalistcommand}
-
% \tracefonthandlingtrue
% new, still to be improved
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 24a4d6514..4f8f16163 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -16,12 +16,13 @@
%D minimal as possible.
\loadcorefile{syst-ini}
+\loadcorefile{syst-pln}
+
\loadcorefile{norm-tex}
\loadcorefile{norm-etx}
\loadcorefile{norm-ptx}
\loadcorefile{norm-xtx}
\loadcorefile{norm-ctx}
-\loadcorefile{syst-pln}
\loadmarkfile{catc-ini}
\loadcorefile{catc-act}
@@ -300,8 +301,8 @@
%D Anchoring graphics:
\loadmarkfile{anch-pgr}
-\loadcorefile{anch-bar}
-\loadcorefile{anch-snc}
+\loadmarkfile{anch-bar}
+\loadmarkfile{anch-snc}
%D Math.
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 735d1c780..fdba7661a 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -80,6 +80,7 @@
\loadmarkfile{core-env}
+\loadmarkfile{trac-tex}
\loadmarkfile{trac-lmx}
\loadmarkfile{trac-deb}
@@ -267,11 +268,11 @@
\loadmarkfile{page-str}
\loadmarkfile{anch-pgr} % overloads tabl-tbl
-\loadcorefile{anch-bar}
-\loadcorefile{anch-snc}
+\loadmarkfile{anch-bar}
+\loadmarkfile{anch-snc}
-\loadmarkfile{math-pln}
\loadmarkfile{math-ini}
+\loadmarkfile{math-pln}
\loadmarkfile{math-for}
\loadmarkfile{math-def}
\loadmarkfile{math-ali}
@@ -326,23 +327,25 @@
%usemodule[x][res-04] % xml resource libraries
%usemodule[x][res-08] % rlx runtime conversion
-% \usemodule[x][res-12] % rli external indentification
+%usemodule[x][res-12] % rli external indentification
\unprotect
+\setupcurrentlanguage[\s!en]
+
\prependtoks
\ctxlua{statistics.starttiming(ctx)}%
\to \everyjob
+
\appendtoks
\ctxlua{statistics.stoptiming(ctx)}%
\to \everyjob
+
\appendtoks
\writestatus\m!lua{used config path - \ctxlua{tex.print(caches.configpath())}}%
\writestatus\m!lua{used cache path - \ctxlua{tex.print(caches.path)}}%
\to \everydump
-\setupcurrentlanguage[\s!en]
-
\appendtoks
\ctxlua {
statistics.report_storage("log")
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 95c528f32..6a5612f5a 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2009.07.17 13:16}
+\edef\contextversion{2009.07.23 20:11}
%D For those who want to use this:
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index 1b1657957..e13f68456 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -16,8 +16,10 @@ slower but look nicer this way.
local utf = unicode.utf8
-local floor, mod, date, time, concat, format = math.floor, math.mod, os.date, os.time, table.concat, string.format
+local floor, mod, date, time, concat = math.floor, math.mod, os.date, os.time, table.concat
+local lower, format, rep = string.lower, string.format, string.rep
local texsprint, utfchar = tex.sprint, utf.char
+local tonumber, tostring = tonumber, tostring
local ctxcatcodes = tex.ctxcatcodes
@@ -121,26 +123,29 @@ counters['kr-c'] = counters['korean-circle']
local fallback = utf.byte('0')
-function converters.chr(n,m)
+local function chr(n,m)
if n > 0 and n < 27 then
texsprint(utfchar(n+m))
end
end
-
-function converters.maxchrs(n,m,cmd)
- if n > m then
- converters.maxchrs(floor((n-1)/m),m,cmd)
- n = (n-1)%m + 1
- end
- texsprint(ctxcatcodes, format("%s{%s}",cmd,n))
-end
-function converters.chrs(n,m)
+local function chrs(n,m)
if n > 26 then
- converters.chrs(floor((n-1)/26),m)
+ chrs(floor((n-1)/26),m)
n = (n-1)%26 + 1
end
texsprint(utfchar(n+m))
end
+local function maxchrs(n,m,cmd)
+ if n > m then
+ maxchrs(floor((n-1)/m),m,cmd)
+ n = (n-1)%m + 1
+ end
+ texsprint(ctxcatcodes, format("%s{%s}",cmd,n))
+end
+
+converters.chr = chr
+converters.chrs = chrs
+converters.maxchrs = maxchrs
local function do_alphabetic(n,max,chr)
if n > max then
@@ -150,20 +155,38 @@ local function do_alphabetic(n,max,chr)
characters.flush(chr(n))
end
+--~ more efficient but needs testing
+--~
+--~ local escapes = utffilters.private.escapes
+--~
+--~ local function do_alphabetic(n,max,chr)
+--~ if n > max then
+--~ do_alphabetic(floor((n-1)/max),max,chr)
+--~ n = (n-1)%max+1
+--~ end
+--~ n = chr(n)
+--~ texsprint(ctxcatcodes,escapes[n] or utfchar(n))
+--~ end
+
+--~ local lccodes, uccodes = characters.lccode, characters.uccode
+
+local function lowercased(n) return characters.lccode(code[n] or fallback) end
+local function uppercased(n) return characters.uccode(code[n] or fallback) end
+
function converters.alphabetic(n,code)
local code = counters[code] or counters['**']
- do_alphabetic(n,#code,function(n) return characters.lccode(code[n] or fallback) end) -- lccode catches wrong tables
+ do_alphabetic(n,#code,lowercased) -- lccode catches wrong tables
end
function converters.Alphabetic(n,code)
local code = counters[code] or counters['**']
- do_alphabetic(n,#code,function(n) return characters.uccode(code[n] or fallback) end)
+ do_alphabetic(n,#code,uppercased)
end
-function converters.character(n) converters.chr (n,96) end
-function converters.Character(n) converters.chr (n,64) end
-function converters.characters(n) converters.chrs(n,96) end
-function converters.Characters(n) converters.chrs(n,64) end
+function converters.character (n) chr (n,96) end
+function converters.Character (n) chr (n,64) end
+function converters.characters(n) chrs(n,96) end
+function converters.Characters(n) chrs(n,64) end
function converters.weekday(day,month,year)
texsprint(date("%w",time{year=year,month=month,day=day})+1)
@@ -199,17 +222,19 @@ local roman = {
{ [0] = '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM' },
}
-function converters.toroman(n)
+local function toroman(n)
if n >= 4000 then
- return converters.toroman(floor(n/1000)) .. " " .. converters.toroman(n%1000)
+ return toroman(floor(n/1000)) .. " " .. toroman(n%1000)
else
- return string.rep("M",floor(n/1000)) .. roman[3][floor((n%1000)/100)] ..
+ return rep("M",floor(n/1000)) .. roman[3][floor((n%1000)/100)] ..
roman[2][floor((n%100)/10)] .. roman[1][floor((n% 10)/1)]
end
end
-function converters.romannumerals(n) return texsprint(string.lower(converters.toroman(n))) end
-function converters.Romannumerals(n) return texsprint( converters.toroman(n) ) end
+function converters.romannumerals(n) return texsprint(lower(toroman(n))) end
+function converters.Romannumerals(n) return texsprint( toroman(n) ) end
+
+converters.toroman = toroman
--~ local small = {
--~ 0x0627, 0x066E, 0x062D, 0x062F, 0x0647, 0x0648, 0x0631
diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv
index 5568fc78c..b9dc0b449 100644
--- a/tex/context/base/core-con.mkiv
+++ b/tex/context/base/core-con.mkiv
@@ -690,6 +690,22 @@
%
% \doloop{\doifelseconversionnumber{ctx}{\recurselevel}{[\recurselevel]}{\exitloop}}
+%D \macros
+%D {ordinaldaynumber, highordinalstr, ordinalstr}
+%D
+%D Efficient general ordinal number converters are sometimes
+%D difficult to implement. Fortunately dates never exceed the
+%D number~31.
+
+\ifx\high \undefined \let\high \firstofoneargument \fi
+\ifx\notsmallcapped\undefined \let\notsmallcapped\firstofoneargument \fi
+
+\def\highordinalstr#1{\high{\notsmallcapped{#1}}}
+\def\ordinalstr #1{\notsmallcapped{#1}}
+
+\def\ordinaldaynumber#1% \strippedcsname\ordinaldaynumber
+ {\expanded{\executeifdefined{\currentlanguage ordinaldaynumber}\noexpand\firstofoneargument{\number#1}}}
+
%D As longs as symbols are linked to levels or numbers, we can
%D also use the conversion mechanism, but in for instance the
%D itemization macros, we prefer symbols because they can more
diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv
index 47bd7549d..c97987268 100644
--- a/tex/context/base/core-env.mkiv
+++ b/tex/context/base/core-env.mkiv
@@ -15,22 +15,6 @@
\unprotect
-%D Clean labels (no longer needed in \MKIV\ but we keep the grouping
-%D till we hav ea full separation of code.):
-
-\def\cleanuplabel#1%
- {\xdef\cleanlabel{#1}}
-
-\def\cleanupprefixedlabel#1#2%
- {\xdef\cleanprefix{#1}%
- \xdef\cleanlabel {#2}}
-
-\let\protectlabels\donothing
-\let\blabelgroup \begingroup % obsolete
-\let\elabelgroup \endgroup % obsolete
-\let\labelcsname \csname
-\let\labelvalue \getvalue
-
%D Modes:
%D
%D \starttyping
diff --git a/tex/context/base/core-fnt.mkiv b/tex/context/base/core-fnt.mkiv
index 323183712..e65739858 100644
--- a/tex/context/base/core-fnt.mkiv
+++ b/tex/context/base/core-fnt.mkiv
@@ -95,26 +95,6 @@
%D
%D The default skip can be set with:
-% \def\stretchedspacefactor{4}
-% \def\stretchedspaceamount{.25em}
-%
-% \unexpanded\def\stretcheduppercase#1%
-% {\bgroup
-% \the\everyuppercase
-% \uppercase{\def\textstring{#1}}%
-% \ifdim\stretchedspaceamount>\zeropoint
-% \def\textkern%
-% {\kern\stretchedspaceamount}%
-% \def\textskip%
-% {\scratchdimen=\stretchedspaceamount
-% \hskip\stretchedspacefactor\scratchdimen}%
-% \@EA\processtokens\@EA\relax\@EA\textkern\@EA\relax\@EA
-% \textskip\@EA{\textstring}%
-% \else
-% \textstring
-% \fi
-% \egroup}
-
%D Given the following settings, the space is 1em by default:
\def\stretchedspacefactor{4}
@@ -255,13 +235,11 @@
\unexpanded\def\dodounderbar#1%
{\bgroup
- \dimen0=\@@onbottomoffset
- \dimen0=\underbarlevel\dimen0
+ \dimen0=\underbarlevel\dimexpr\@@onbottomoffset\relax
\ifdone \else
\advance\dimen0 -\strutht
\fi
- \dimen2\dimen0
- \advance\dimen2 \@@onrulethickness
+ \dimen2\dimexpr\dimen0+\@@onrulethickness\relax
\dododounderbar{-\dimen0}{\dimen2}{#1}%
\egroup}
@@ -276,11 +254,6 @@
\def\betweenunderbarspaces
{\hskip\currentspaceskip}
-% \unexpanded\def\dounderbar#1#2%
-% {\let\betweenisolatedwords#1%
-% \processisolatedwords{#2}\dodounderbar
-% \egroup}
-
\unexpanded\def\underbar
{\bgroup
\advance\underbarlevel\plusone
@@ -317,8 +290,7 @@
\def\dooverstrike#1%
{\bgroup
\dimen0=\@@ontopoffset
- \dimen2=\dimen0
- \advance\dimen2 \@@onrulethickness
+ \dimen2=\dimexpr\dimen0+\@@onrulethickness\relax
\dododounderbar{\dimen2}{-\dimen0}{#1}%
\egroup}
diff --git a/tex/context/base/core-ini.mkiv b/tex/context/base/core-ini.mkiv
index 69edf9735..a01abdd11 100644
--- a/tex/context/base/core-ini.mkiv
+++ b/tex/context/base/core-ini.mkiv
@@ -24,10 +24,9 @@
\appendtoks \flushnotes \to \everypar
\appendtoks \synchronizesidefloats \to \everypar
-\appendtoks \checkinlinedirection \to \everypar
-
\appendtoks \checkindentation \to \everypar
\appendtoks \showparagraphnumber \to \everypar
+\appendtoks \restoreinterlinepenalty \to \everypar
\appendtoks \flushmargincontents \to \everypar
\appendtoks \flushcommentanchors \to \everypar
\appendtoks \synchronizenotes \to \everypar
diff --git a/tex/context/base/core-mis.mkii b/tex/context/base/core-mis.mkii
index e61adee25..98079830d 100644
--- a/tex/context/base/core-mis.mkii
+++ b/tex/context/base/core-mis.mkii
@@ -237,7 +237,7 @@
\getparameters[#1][#2]%
\getvalue{#1\c!before}%
\begingroup
- \positioningparfalse
+ \disableparpositions
\setbox\nextbox\hbox to \localhsize
{\getvalue{#1\c!left}%
\flushnextbox
diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv
index 88a027c02..efea8694c 100644
--- a/tex/context/base/core-mis.mkiv
+++ b/tex/context/base/core-mis.mkiv
@@ -237,7 +237,7 @@
\getparameters[#1][#2]%
\getvalue{#1\c!before}%
\begingroup
- \positioningparfalse
+ \disableparpositions
\setbox\nextbox\hbox to \localhsize
{\getvalue{#1\c!left}%
\flushnextbox
@@ -376,9 +376,7 @@
\def\doparagraphrule
{\doifelse{\paragraphcellmeter\alcounter\c!rule}\v!on
{\linewidth\paragraphcellmeter\alcounter\c!rulethickness
- \scratchdimen\paragraphcellmeter\alcounter\c!distance
- \advance\scratchdimen-\linewidth
- \divide\scratchdimen \plustwo
+ \scratchdimen\dimexpr(\paragraphcellmeter\alcounter\c!distance-\linewidth)/2\relax
\hskip\scratchdimen
\color[\paragraphcellmeter\alcounter\c!rulecolor]{\vrule\!!width\linewidth}%
\hskip\scratchdimen}
@@ -510,67 +508,6 @@
\setuptab
[\c!location=\v!left]
-% The following macro's are derived from PPCHTEX and
-% therefore take some LaTeX font-switching into account.
-
-\newif\ifloweredsubscripts
-
-% Due to some upward incompatibality of LaTeX to LaTeX2.09
-% and/or LaTeX2e we had to force \@@chemieletter. Otherwise
-% some weird \nullfont error comes up.
-
-\doifundefined{@@chemieletter}{\def\@@chemieletter{\rm}}
-
-\def\beginlatexmathmodehack
- {\ifmmode
- \let\endlatexmathmodehack\relax
- \else
- \def\endlatexmathmodehack{$}$\@@chemieletter
- \fi}
-
-\def\setsubscripts
- {\beginlatexmathmodehack
- \def\dosetsubscript##1##2##3%
- {\dimen0=##3\fontexheight##2%
- \setxvalue{@@\string##1\string##2}{\the##1##2\relax}%
- ##1##2=\dimen0\relax}%
- \def\dodosetsubscript##1##2%
- {\dosetsubscript{##1}{\textfont2}{##2}%
- \dosetsubscript{##1}{\scriptfont2}{##2}%
- \dosetsubscript{##1}{\scriptscriptfont2}{##2}}%
- %dodosetsubscript\mathsupnormal {?}%
- \dodosetsubscript\mathsubnormal {.7}%
- \dodosetsubscript\mathsubcombined{.7}%
- \global\loweredsubscriptstrue
- \endlatexmathmodehack}
-
-\def\resetsubscripts
- {\ifloweredsubscripts
- \beginlatexmathmodehack
- \def\doresetsubscript##1##2%
- {\dimen0=\getvalue{@@\string##1\string##2}\relax
- ##1##2=\dimen0}%
- \def\dodoresetsubscript##1%
- {\doresetsubscript{##1}{\textfont2}%
- \doresetsubscript{##1}{\scriptfont2}%
- \doresetsubscript{##1}{\scriptscriptfont2}}%
- %dodoresetsubscript\mathsupnormal
- \dodoresetsubscript\mathsubnormal
- \dodoresetsubscript\mathsubcombined
- \global\loweredsubscriptsfalse
- \endlatexmathmodehack
- \fi}
-
-\let\beginlatexmathmodehack = \relax
-\let\endlatexmathmodehack = \relax
-
-\def\chem#1#2#3%
- {\bgroup
- \setsubscripts
- \mathematics{\hbox{#1}_{#2}^{#3}}%
- \resetsubscripts
- \egroup}
-
\unexpanded\def\celsius #1{#1\mathematics{^\circ}C}
\unexpanded\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax}
\unexpanded\def\fraction#1#2{\mathematics{#1\over#2}}
diff --git a/tex/context/base/core-spa.lua b/tex/context/base/core-spa.lua
index 0e33bf609..ab08755cc 100644
--- a/tex/context/base/core-spa.lua
+++ b/tex/context/base/core-spa.lua
@@ -22,6 +22,12 @@ local trace_page_vspacing = false trackers.register("nodes.page_vspacing",
local trace_collect_vspacing = false trackers.register("nodes.collect_vspacing", function(v) trace_collect_vspacing = v end)
local trace_vspacing = false trackers.register("nodes.vspacing", function(v) trace_vspacing = v end)
+local skip_category = attributes.private('skip-category')
+local skip_penalty = attributes.private('skip-penalty')
+local skip_order = attributes.private('skip-order')
+local snap_category = attributes.private('snap-category')
+local display_math = attributes.private('display-math')
+
local has_attribute = node.has_attribute
local unset_attribute = node.unset_attribute
local set_attribute = node.set_attribute
@@ -88,7 +94,12 @@ vspacing.data.skip = vspacing.data.skip or { }
storage.register("vspacing/data/map", vspacing.data.map, "vspacing.data.map")
storage.register("vspacing/data/skip", vspacing.data.skip, "vspacing.data.skip")
-do
+do -- todo: interface.variables
+
+ local function logger(c,s)
+ logs.report("vspacing",s)
+ texsprint(c,s)
+ end
vspacing.fixed = false
@@ -100,81 +111,62 @@ do
local keyword = lpeg.C((1-category)^1)
local splitter = (multiplier + lpeg.Cc(1)) * keyword * (category + lpeg.Cc(false))
- local function analyse(str,category,order,penalty,command,fixed)
+ local function analyse(str,oldcategory,texsprint)
for s in gmatch(str,"([^ ,]+)") do
local amount, keyword, detail = splitter:match(s)
if keyword then
local mk = map[keyword]
if mk then
- analyse(mk,category,order,penalty,command,fixed)
+ category = analyse(mk,category,texsprint)
elseif keyword == "fixed" then
- fixed = true
+ texsprint(ctxcatcodes,"\\fixedblankskip")
elseif keyword == "flexible" then
- fixed = false
+ texsprint(ctxcatcodes,"\\flexibleblankskip")
elseif keyword == "category" then
- -- is a set
- local n = tonumber(detail)
- if n then
- category[categories[n]] = true
- else
- category[detail] = true
+ local category = tonumber(detail)
+ if category then
+ texsprint(ctxcatcodes,format("\\setblankcategory{%s}",category))
+ if category ~= oldcategory then
+ texsprint(ctxcatcodes,"\\flushblankhandling")
+ oldcategory = category
+ end
+ end
+ elseif keyword == "order" and detail then
+ local order = tonumber(detail)
+ if order then
+ texsprint(ctxcatcodes,format("\\setblankorder{%s}",order))
+ end
+ elseif keyword == "penalty" and detail then
+ local penalty = tonumber(detail)
+ if penalty then
+ texsprint(ctxcatcodes,format("\\setblankpenalty{%s}",penalty))
+ texsprint(ctxcatcodes,"\\flushblankhandling")
end
- elseif keyword == "order" then
- -- last one counts
- order = tonumber(detail) or 0
- elseif keyword == "penalty" then
- -- last one counts
- penalty = tonumber(detail) or 0
- elseif keyword == "skip" then
- -- last one counts
- command[#command+1] = { 1, tonumber(detail or 1) or 1}
else
amount = tonumber(amount) or 1
local sk = skip[keyword]
if sk then
- command[#command+1] = { amount, sk[1], sk[2] or sk[1]}
+ texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,sk[1],sk[2] or sk[1]))
else -- no check
- command[#command+1] = { amount, keyword, keyword, keyword}
+ texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,keyword,keyword))
end
end
else
- logs.report("vspacing","unknown directive: %s",str)
+ logs.report("vspacing","unknown directive: %s",s)
end
end
- end
-
- local function logger(c,s)
- logs.report("vspacing",s)
- texsprint(c,s)
+ return category
end
function vspacing.analyse(str)
local texsprint = (trace_vspacing and logger) or texsprint
- local category, order, penalty, command, fixed = { }, 0, 0, { }, vspacing.fixed
- analyse(str,category,order,penalty,command,fixed)
- category = set.tonumber(category)
texsprint(ctxcatcodes,"\\startblankhandling")
- if category > 0 then
- texsprint(ctxcatcodes,format("\\setblankcategory{%s}",category))
- end
- if order > 0 then
- texsprint(ctxcatcodes,format("\\setblankorder{%s}",order))
- end
- if penalty > 0 then
- texsprint(ctxcatcodes,format("\\setblankpenalty{%s}",penalty))
- end
- for i=1,#command do
- local c = command[i]
- texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",c[1],c[2],c[3] or c[2]))
- end
- if fixed then
- texsprint(ctxcatcodes,"\\fixedblankskip")
- else
- texsprint(ctxcatcodes,"\\flexibleblankskip")
- end
+ analyse(str,1,texsprint)
texsprint(ctxcatcodes,"\\stopblankhandling")
end
+ --
+
function vspacing.setmap(from,to)
map[from] = to
end
@@ -295,14 +287,6 @@ local function show_tracing(head)
end
end
--- we assume that these are defined
-
-local skip_category = attributes.private('skip-category')
-local skip_penalty = attributes.private('skip-penalty')
-local skip_order = attributes.private('skip-order')
-local snap_category = attributes.private('snap-category')
-local display_math = attributes.private('display-math')
-
-- alignment box begin_of_par vmode_par hmode_par insert penalty before_display after_display
local user_skip = 0
@@ -349,8 +333,7 @@ local skips = {
local free_glue_node = free_node
local free_glue_spec = free_node
---~ local free_glue_node = function(n) free_node(n) end
---~ local free_glue_spec = function(n) end
+local discard, largest, force, penalty, add, disable, nowhite, goback = 0, 1, 2, 3, 4, 5, 6, 7
local function collapser(head,where,what,trace) -- maybe also pass tail
if trace then
@@ -402,16 +385,15 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
current = current.next
end
else
- local sct = categories[sc] -- or 'unknown'
- if sct == 'disable' then
+ if sc == disable then
ignore_following = true
- if trace then trace_skip(sct,sc,so,sp,current) end
+ if trace then trace_skip("disable",sc,so,sp,current) end
head, current = remove_node(head, current, true)
- elseif sct == 'nowhite' then
+ elseif sc == nowhite then
ignore_whitespace = true
head, current = remove_node(head, current, true)
- elseif sct == 'discard' then
- if trace then trace_skip(sct,sc,so,sp,current) end
+ elseif sc == discard then
+ if trace then trace_skip("discard",sc,so,sp,current) end
head, current = remove_node(head, current, true)
else
if sp then
@@ -427,7 +409,7 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
if trace then trace_skip("disabled",sc,so,sp,current) end
head, current = remove_node(head, current, true)
elseif not glue_data then
- if trace then trace_skip("assign " .. sct,sc,so,sp,current) end
+ if trace then trace_skip("assign",sc,so,sp,current) end
glue_order = so
head, current, glue_data = remove_node(head, current)
elseif glue_order < so then
@@ -436,7 +418,8 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
free_glue_node(glue_data)
head, current, glue_data = remove_node(head, current)
elseif glue_order == so then
- if sct == 'largest' then
+ -- is now exclusive, maybe support goback as combi, else why a set
+ if sc == largest then
local cs, gs = current.spec, glue_data.spec
local cw = (cs and cs.width) or 0
local gw = (gs and gs.width) or 0
@@ -448,21 +431,21 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
if trace then trace_skip('remove smallest',sc,so,sp,current) end
head, current = remove_node(head, current, true)
end
- elseif sct == 'goback' then
+ elseif sc == goback then
if trace then trace_skip('goback',sc,so,sp,current) end
free_glue_node(glue_data) -- also free spec
head, current, glue_data = remove_node(head, current)
- elseif sct == 'force' then
+ elseif sc == force then
-- todo: inject kern
if trace then trace_skip('force',sc,so,sp,current) end
free_glue_node(glue_data) -- also free spec
head, current, glue_data = remove_node(head, current)
- elseif sct == 'penalty' then
+ elseif sc == penalty then
if trace then trace_skip('penalty',sc,so,sp,current) end
free_glue_node(glue_data) -- also free spec
glue_data = nil
head, current = remove_node(head, current, true)
- elseif sct == 'add' then
+ elseif sc == add then
if trace then trace_skip('add',sc,so,sp,current) end
local old, new = glue_data.spec, current.spec
old.width = old.width + new.width
@@ -522,17 +505,18 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
--~ current.spec = nil
--~ current = current.next
else
- if glue_data then
- if trace then trace_done("flushed",glue_data) end
- head, current = insert_node_before(head,current,glue_data)
- glue_order, glue_data = 0, nil
- end
+-- reversed
if penalty_data then
local p = make_penalty_node(penalty_data)
if trace then trace_done("flushed",p) end
head, current = insert_node_before(head,current,p)
penalty_data = nil
end
+ if glue_data then
+ if trace then trace_done("flushed",glue_data) end
+ head, current = insert_node_before(head,current,glue_data)
+ glue_order, glue_data = 0, nil
+ end
if trace then trace_node(current) end
if id == hlist and where == 'hmode_par' then
local list = current.list
@@ -552,7 +536,6 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
current = current.next
end
end
- local tail = find_node_tail(head) -- still needed, check previous code ?
if trace then trace_info("stop analyzing",where,what) end
--~ if natural_penalty and (not penalty_data or natural_penalty > penalty_data) then
--~ penalty_data = natural_penalty
@@ -560,12 +543,15 @@ local function collapser(head,where,what,trace) -- maybe also pass tail
if trace and (glue_data or penalty_data) then
trace_info("start flushing",where,what)
end
+ local tail
if penalty_data then
+ tail = find_node_tail(head)
local p = make_penalty_node(penalty_data)
if trace then trace_done("result",p) end
head, tail = insert_node_after(head,tail,p)
end
if glue_data then
+ if not tail then tail = find_node_tail(head) end
if trace then trace_done("result",glue_data) end
head, tail = insert_node_after(head,tail,glue_data)
end
@@ -600,7 +586,7 @@ function nodes.handle_page_spacing(where)
statistics.starttiming(vspacing)
local newtail = find_node_tail(newhead)
local flush = false
- for n in traverse_nodes(newhead) do
+ for n in traverse_nodes(newhead) do -- we could just look for glue nodes
local id = n.id
if id == glue then
if n.subtype == 0 then
@@ -682,16 +668,16 @@ function vspacing.disable()
callback.register('buildpage_filter', nil)
end
--- we will split this module
+-- we will split this module hence the locals
local attribute = attributes.private('graphicvadjust')
---~ local hlist = node.id('hlist')
---~ local vlist = node.id('vlist')
+local hlist = node.id('hlist')
+local vlist = node.id('vlist')
---~ local remove_node = nodes.remove
---~ local hpack_node = node.hpack
---~ local has_attribute = node.has_attribute
+local remove_node = nodes.remove
+local hpack_node = node.hpack
+local has_attribute = node.has_attribute
function nodes.repackage_graphicvadjust(head,groupcode) -- we can make an actionchain for mvl only
if groupcode == "" then -- mvl only
diff --git a/tex/context/base/core-spa.mkiv b/tex/context/base/core-spa.mkiv
index ad59f7779..71845b119 100644
--- a/tex/context/base/core-spa.mkiv
+++ b/tex/context/base/core-spa.mkiv
@@ -1047,6 +1047,8 @@
\let\normalspaceprimitive=\ % space-comment is really needed
+% hm ...
+
\unexpanded\def\ {\mathortext\normalspaceprimitive\space} % no \dontleavehmode\space (else no frenchspacing)
% Because I strip spaces at the end of lines (in the editor) we need a bit of
@@ -2057,9 +2059,23 @@
%D
%D Dirty hack, needed in margin content that can run of a page.
+% just before margintexts ... will eventually be done differently in mkiv using
+% attributes
+
+\newcount\nofkeeplinestogether
+\let\restoreinterlinepenalty\relax
+
+\def\dorestoreinterlinepenalty
+ {\global\let\restoreinterlinepenalty\relax
+ \global\resetpenalties\interlinepenalties
+ \global\nofkeeplinestogether\zerocount}
+
\def\keeplinestogether#1%
- {\xdef\restoreinterlinepenalty{\global\resetpenalties\interlinepenalties}%
- \global\setpenalties\interlinepenalties{#1}\plustenthousand}
+ {\ifnum#1>\nofkeeplinestogether
+ \global\nofkeeplinestogether#1%
+ \global\setpenalties\interlinepenalties\nofkeeplinestogether\plustenthousand
+ \global\let\restoreinterlinepenalty\dorestoreinterlinepenalty
+ \fi}
\newif\ifgridsnapping % to be sure
@@ -2852,29 +2868,12 @@
% using just flushleft is not okay here due to the fact that
% leftskip has less stretch than the inter character spacing
-% category:
-%
-% 0 == discard
-% 1 == only if larger
-% 2 == force even if smaller
-% 3 == only take penalty component
-% 4 == add to existing skip
-% 5 == ignore following skips (== disable)
-
-% penalty:
-%
-% larger wins
-
-% order:
-%
-% larger wins
-
\registerctxluafile{core-spa}{1.001}
\definesystemattribute[kern-chars]
-\definesystemattribute[skip-category]
-\definesystemattribute[skip-penalty]
-\definesystemattribute[skip-order]
+\definesystemattribute[skip-category] \chardef\skipcategoryattribute \dogetattributeid{skip-category}
+\definesystemattribute[skip-penalty] \chardef\skippenaltyattribute \dogetattributeid{skip-penalty}
+\definesystemattribute[skip-order] \chardef\skiporderattribute \dogetattributeid{skip-order}
\definesystemattribute[snap-category]
\definesystemattribute[display-math]
@@ -2922,25 +2921,47 @@
\newtoks\everyafterblankhandling
\appendtoks
- \dosetattribute{skip-category}\plusone
- \doresetattribute{skip-order}%
- \doresetattribute{skip-penalty}%
+ \blankskip\zeropoint
+ \attribute\skipcategoryattribute\plusone
+ \attribute\skippenaltyattribute \attributeunsetvalue
+ \attribute\skiporderattribute \attributeunsetvalue
+ \ifblankflexible
+ \setfalse\blankisfixed
+ \else
+ \settrue\blankisfixed
+ \fi
\to \everybeforeblankhandling
\appendtoks
- \ifblankflexible \else
- \fixedblankskip
+ \ifconditional\blankisfixed
+ \blankskip1\blankskip
+ \else
+ \blankskip1\blankskip\!!plus\skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip
\fi
\to \everyafterblankhandling
-\def\startblankhandling{\begingroup \blankskip\zeropoint \the\everybeforeblankhandling}
-\def\stopblankhandling {\the\everyafterblankhandling \vskip \blankskip \endgroup}
-\def\setblankcategory#1{\dosetattribute{skip-category}{#1}}
-\def\setblankorder #1{\dosetattribute{skip-order}{#1}}
-\def\setblankpenalty #1{\dosetattribute{skip-penalty}{#1}}
+\def\setblankcategory#1{\attribute\skipcategoryattribute#1\relax}
+\def\setblankorder #1{\attribute\skiporderattribute #1\relax}
+\def\setblankpenalty #1{\attribute\skippenaltyattribute #1\relax}
\def\addblankskip#1#2#3{\advance\blankskip#1\dimexpr\ifgridsnapping#3\else#2\fi\relax\relax}
-\def\fixedblankskip {\blankskip1\blankskip}
-\def\flexibleblankskip {\blankskip1\blankskip\!!plus \skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip}
+\def\fixedblankskip {\settrue \blankisfixed} % \blankskip1\blankskip}
+\def\flexibleblankskip {\setfalse\blankisfixed} % \blankskip1\blankskip\!!plus\skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip}
+
+\def\startblankhandling
+ {\begingroup
+ \the\everybeforeblankhandling}
+
+\def\stopblankhandling
+ {\the\everyafterblankhandling
+ \vskip\blankskip
+ \endgroup}
+
+\def\flushblankhandling
+ {\the\everyafterblankhandling
+ \vskip\blankskip
+ \the\everybeforeblankhandling}
+
+% % % %
\def\definevspacingamount
{\dotripleempty\dodefinevspacingamount}
@@ -2960,6 +2981,8 @@
\def\dovspacing[#1]%
{\ctxlua{vspacing.analyse("\iffirstargument#1\else default\fi")}}
+% category:4 is default
+
\definevspacingamount[\v!big] [\bigskipamount] [\openlineheight]
\definevspacingamount[\v!medium] [\medskipamount] [0.50\openlineheight]
\definevspacingamount[\v!small] [\smallskipamount][0.25\openlineheight]
@@ -3901,9 +3924,13 @@
\def\flushatparagraph#1%
{\global\chardef\everyparagraphintro\plusone
- \global\appendtoks{#1}\to\everyfirstparagraphintro}
+ \global\appendtoks{#1}\to\everyfirstparagraphintro
+ \global\let\insertparagraphintro\doinsertparagraphintro}
-\def\doinsertparagraphintro
+\def\doinsertparagraphintro % can be merged with the next
+ {\ifcase\everyparagraphintro\else\@EA\dodoinsertparagraphintro\fi}
+
+\def\dodoinsertparagraphintro
{\begingroup
\everypar\emptytoks
\ifcase\everyparagraphintro\relax
@@ -3919,12 +3946,10 @@
\@@everyparagraphtoks\everynextparagraphintro
\fi
\the\@@everyparagraphtoks
+ \global\let\insertparagraphintro\relax
\endgroup}
-\def\insertparagraphintro
- {\ifcase\everyparagraphintro\else\@EA\doinsertparagraphintro\fi}
-
-% \appendtoksonce\insertparagraphintro\to\everypar % should come last
+\let\insertparagraphintro\relax
%D \starttyping
%D \setupparagraphintro[first][\hbox to 3.5em{\tt FIRST \hss}]
@@ -3953,18 +3978,19 @@
%D This macro collects data that will be flushed at the next paragraph.
%D By using this macro you can avoid interfering nodes (writes, etc).
-\newbox \postponednodedata
+\newbox\postponednodedata
+\let\flushpostponednodedata\relax
\def\flushatnextpar
{\bgroup
- \dowithnextbox
- {\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}%
- \hbox}
+ \global\let\flushpostponednodedata\doflushpostponednodedata
+ \dowithnextbox{\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}\hbox}
-\def\flushpostponednodedata
+\def\doflushpostponednodedata
{\ifvoid\postponednodedata\else
\hbox{\smashedbox\postponednodedata}%
- \fi}
+ \fi
+ \global\let\flushpostponednodedata\relax}
% Very nasty but needed for margin stuff inside colored
% paragraphs.
diff --git a/tex/context/base/core-var.mkiv b/tex/context/base/core-var.mkiv
index 9a0b190d8..d6e02e392 100644
--- a/tex/context/base/core-var.mkiv
+++ b/tex/context/base/core-var.mkiv
@@ -184,13 +184,7 @@
%D This boolean can be used to bypass certain
%D initializations.
-\ifx\protectionlevel\undefined \newcount\protectionlevel \fi
-
-\newif\ifproductionrun
-
-\appendtoks \productionruntrue \to \everydump
-
-\appendtoks \ifcase\protectionlevel\else\reportunprotection\fi \to \everydump
+\newif\ifproductionrun \appendtoks \productionruntrue \to \everydump
%D \macros
%D {everyboxedcontent, ifboxedcontent,
@@ -255,8 +249,6 @@
%D Add-ons:
-\let\startlayoutcomponent \gobbletwoarguments % obsolete
-\let\stoplayoutcomponent \relax % obsolete
\let\setlayoutcomponentattribute \gobbletwoarguments
\let\resetlayoutcomponentattribute\relax
\let\layoutcomponentboxattribute \empty
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 339e521a9..06884bb12 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -1101,7 +1101,7 @@
\let\localrelativefontsize\defaultrelativefontsize
\let\localabsolutefontsize\fontbody
\lowleveldefinefont{#2}\rawfontidentifier
- \let\localrelativefontsize\defaultrelativefontsize % not needed
+% \let\localrelativefontsize\defaultrelativefontsize % not needed
\csname\rawfontidentifier\endcsname
\autofontsizefalse
\setfontcharacteristics
@@ -1114,7 +1114,7 @@
\def\localrelativefontsize{#1}%
\def\localabsolutefontsize{#2}%
\lowleveldefinefont{#4}\newfontidentifier
- \let\localrelativefontsize\defaultrelativefontsize % not needed
+% \let\localrelativefontsize\defaultrelativefontsize % not needed
\fi
\csname\newfontidentifier\endcsname
\autofontsizefalse
@@ -2091,8 +2091,9 @@
\fi
\to \everymathematics
-\def\nobigmath{\chardef\synchronizebigmathflag 0 }
-\def\bigmath {\chardef\synchronizebigmathflag 2 \synchronizebigmath}
+\def\nobigmath {\chardef\synchronizebigmathflag\zerocount}
+\def\autobigmath{\chardef\synchronizebigmathflag\plusone\synchronizebigmath}
+\def\bigmath {\chardef\synchronizebigmathflag\plustwo\synchronizebigmath}
\let\bigmathfontsize\empty
@@ -2113,7 +2114,7 @@
\synchronizebigmath
\fi}
-%D So far for synchronisation.
+%D So far for synchronisation. (We can inline the following macros.)
\def\dosetcurrentfontsize#1%
{\edef\fontsize{#1}%
@@ -2139,10 +2140,17 @@
\ifx\checkfontclass\undefined \let\checkfontclass\gobbleoneargument \fi % implemented in type-ini
+% \def\setcurrentfontstyle#1%
+% {%\message{[3 #1]}%
+% \checkfontclass{#1}%
+% \edef\fontstyle{#1}%
+% \ifmmode\mr\fi % otherwise \rm not downward compatible
+% \synchronizefont}
+
\def\setcurrentfontstyle#1%
{%\message{[3 #1]}%
- \checkfontclass{#1}%
\edef\fontstyle{#1}%
+ \checkfontclass\fontstyle
\ifmmode\mr\fi % otherwise \rm not downward compatible
\synchronizefont}
@@ -2221,8 +2229,6 @@
#1\csname\fontclass#2#3#4#5\endcsname \tryingfontfalse
\fi}
-% old sequence
-
\appendtoks \iftryingfont \fontstrategy \autofontsizefalse % --- --- --- --- % pt tt bf a
\fontbody \fontstyle \fontalternative \fontsize
\fi \to \fontstrategies
@@ -2258,7 +2264,7 @@
\fi
\to \everybodyfont
-%D Setting the normal sized as well as the x and xx smaller
+%D Setting the normal sizes as well as the x and xx smaller
%D sizes is accomplished by the next set of macros. When in
%D math mode, the commands \type{\tx} and \type{\txx} are
%D just a switch to the script and double script styles, but
diff --git a/tex/context/base/font-run.mkiv b/tex/context/base/font-run.mkiv
index 5dd8d6086..4cc098e2c 100644
--- a/tex/context/base/font-run.mkiv
+++ b/tex/context/base/font-run.mkiv
@@ -128,7 +128,7 @@
{\red
\dostepwiserecurse{0}{15}{1}
{\let\col\recurselevel
- \@EA\scratchcounter\normaldblquote\hexnumber\row\hexnumber\col\relax
+ \@EA\scratchcounter\string"\hexnumber\row\hexnumber\col\relax
\edef\rowcol{\the\scratchcounter}%
\iffontchar\font\scratchcounter
\setbox\scratchbox\ruledhbox{\black\char\scratchcounter}%
diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua
index 2f4bebbaf..d50d44100 100644
--- a/tex/context/base/font-syn.lua
+++ b/tex/context/base/font-syn.lua
@@ -100,7 +100,7 @@ names.environment_path_variable = "OSFONTDIR" -- the official way, in minimals
filters.paths = { }
filters.names = { }
-function names.getpaths()
+function names.getpaths(trace)
local hash, result = { }, { }
local function collect(t)
for i=1, #t do
@@ -117,11 +117,45 @@ function names.getpaths()
collect(resolvers.expanded_path_list(path))
end
if xml then
- local name = names.xml_configuration_file or ""
- if name ~= "" then
- local name = resolvers.find_file(name,"other")
- if name ~= "" then
- collect(xml.collect_texts(xml.load(name),"dir",true))
+ local confname = names.xml_configuration_file or ""
+ if confname ~= "" then
+ -- first look in the tex tree
+ local name = resolvers.find_file(confname,"other")
+ if name == "" then
+ -- after all, fontconfig is a unix thing
+ name = file.join("/etc",confname)
+ if not lfs.isfile(name) then
+ name = "" -- force quit
+ end
+ end
+ if name ~= "" and lfs.isfile(name) then
+ if trace then
+ logs.report("fontnames","loading fontconfig file: %s",name)
+ end
+ local xmldata = xml.load(name)
+ -- begin of untested mess
+ xml.include(xmldata,"include","",true,function(incname)
+ if not file.is_qualified_path(incname) then
+ local path = file.dirname(name) -- main name
+ if path ~= "" then
+ incname = file.join(path,incname)
+ end
+ end
+ if lfs.isfile(incname) then
+ if trace then
+ logs.report("fontnames","merging included fontconfig file: %s",incname)
+ end
+ return io.loaddata(incname)
+ elseif trace then
+ logs.report("fontnames","ignoring included fontconfig file: %s",incname)
+ end
+ end)
+ -- end of untested mess
+ local fontdirs = xml.collect_texts(xmldata,"dir",true)
+ if trace then
+ logs.report("fontnames","%s dirs found in fontconfig",#fontdirs)
+ end
+ collect(fontdirs)
end
end
end
@@ -266,7 +300,7 @@ function names.identify(verbose) -- lsr is for kpse
end)
else
traverse("system", function(suffix) -- OSFONTDIR cum suis
- walk_tree(names.getpaths(),suffix)
+ walk_tree(names.getpaths(trace),suffix)
end)
end
local t = { }
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index d5151c521..3fe30458e 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -16,7 +16,6 @@
%D todo:
%D
%D - color conversion
-%D - color separation
%D - alternative images
%D - a few more obscure things
@@ -33,7 +32,6 @@
\newtoks \everyexternalfigureresets
\newtoks \everyexternalfigurechecks
\newtoks \externalfigurepostprocessors
-\chardef \splitexternalfigure \zerocount % 0 nosplit 1 split/yes 2 split/no
\let\traceexternalfigures \traceexternalfigurestrue
@@ -185,16 +183,6 @@
\let\@@efframe\v!off}%
\doifsomething\@@efwidth {\doifdimensionelse\@@efwidth {\edef\@@efwidth {\the\dimexpr\@@efwidth }}\donothing}%
\doifsomething\@@efheight{\doifdimensionelse\@@efheight{\edef\@@efheight{\the\dimexpr\@@efheight}}\donothing}%
- % seperation, seldom used
- \doifseparatingcolorselse
- {\let\@@efforegroundcolor\empty
- \doifelsenothing\@@efsplit
- {\chardef\splitexternalfigure\zerocount}
- {\doifcolorchannelelse\@@efsplit
- {\let\@@efobject\v!no % why?
- \chardef\splitexternalfigure\plusone}
- {\chardef\splitexternalfigure\plustwo}}}
- {\chardef\splitexternalfigure\zerocount}%
% fake color in gray bitmaps, assumes that
% a transparent color is used
\doifsomething\@@efforegroundcolor
@@ -311,10 +299,10 @@
\fakebox\foundexternalfigure
\else\ifcase\figurestatus
% nothing
- \else\ifnum\splitexternalfigure=\plustwo\else
+ \else
\the\externalfigurepostprocessors
\box\foundexternalfigure
- \fi\fi\fi
+ \fi\fi
\else
\iftrialtypesetting \else \feedbackexternalfigure \fi
\settrue\externalfigurelevel
@@ -326,8 +314,6 @@
\fi
\else\ifcase\figurestatus
\externalfigurereplacement\figurelabel\figurefileoriginal{unknown}%
- \else\ifnum\splitexternalfigure=\plustwo
- \backgroundline[\@@efsplitcolor]{\fakebox\foundexternalfigure}%
\else
\the\externalfigurepostprocessors
\doifelse\@@efreset\v!yes
@@ -340,15 +326,8 @@
[\c!offset=\v!overlay,
\c!width=\figurewidth,
\c!height=\figureheight]
- {\vfilll
- \ifnum\splitexternalfigure=\plusone
- % hm, eigenlijk in dit geval achtergrondkleur
- \hidesplitcolorfalse % really needed
- \backgroundline[\@@efsplitcolor]{\box\foundexternalfigure}%
- \else % = 0, no split mode
- \box\foundexternalfigure
- \fi}}%
- \fi\fi\fi
+ {\vfilll\box\foundexternalfigure}}%
+ \fi\fi
\fi
\else
% maybe also \the\externalfigurepostprocessors
diff --git a/tex/context/base/l-set.lua b/tex/context/base/l-set.lua
index 199253ee2..7fc67b24b 100644
--- a/tex/context/base/l-set.lua
+++ b/tex/context/base/l-set.lua
@@ -11,6 +11,7 @@ set = set or { }
local nums = { }
local tabs = { }
local concat = table.concat
+local next, type = next, type
set.create = table.tohash
@@ -18,17 +19,19 @@ function set.tonumber(t)
if next(t) then
local s = ""
-- we could save mem by sorting, but it slows down
- for k, v in pairs(t) do
+ for k, v in next, t do
if v then
-- why bother about the leading space
s = s .. " " .. k
end
end
- if not nums[s] then
- tabs[#tabs+1] = t
- nums[s] = #tabs
+ local n = nums[s]
+ if not n then
+ n = #tabs + 1
+ tabs[n] = t
+ nums[s] = n
end
- return nums[s]
+ return n
else
return 0
end
@@ -42,6 +45,20 @@ function set.totable(n)
end
end
+function set.tolist(n)
+ if n == 0 or not tabs[n] then
+ return ""
+ else
+ local t = { }
+ for k, v in next, tabs[n] do
+ if v then
+ t[#t+1] = k
+ end
+ end
+ return concat(t," ")
+ end
+end
+
function set.contains(n,s)
if type(n) == "table" then
return n[s]
diff --git a/tex/context/base/lang-url.lua b/tex/context/base/lang-url.lua
index 6d909641c..3d93a046a 100644
--- a/tex/context/base/lang-url.lua
+++ b/tex/context/base/lang-url.lua
@@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['lang-url'] = {
local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
+local utfbyte, utfgsub = utf.byte, utf.gsub
local ctxcatcodes = tex.ctxcatcodes
@@ -70,16 +71,15 @@ do
local n = 0
local b = math.max(left or commands.hyphenatedurl.lefthyphenmin,2)
local e = math.min(#str-(right or commands.hyphenatedurl.righthyphenmin)+2,#str)
- local u = utf.byte
- str = utf.gsub(str,"(.)",function(s)
+ str = utfgsub(str,"(.)",function(s)
n = n + 1
local c = chars[s]
if not c or n<=b or n>=e then
- return "\\n{" .. u(s) .. "}"
+ return "\\n{" .. utfbyte(s) .. "}"
elseif c == 1 then
- return "\\b{" .. u(s) .. "}"
+ return "\\b{" .. utfbyte(s) .. "}"
elseif c == 2 then
- return "\\a{" .. u(s) .. "}"
+ return "\\a{" .. utfbyte(s) .. "}"
end
end )
return str
diff --git a/tex/context/base/lang-url.mkiv b/tex/context/base/lang-url.mkiv
index c22f9f420..392a0285b 100644
--- a/tex/context/base/lang-url.mkiv
+++ b/tex/context/base/lang-url.mkiv
@@ -63,9 +63,11 @@
\def\dohyphenatedurlbefore#1{\discretionary{\hyphenatedurlseparator}{}{}\char#1\relax}%
\def\dohyphenatedurlnormal#1{\char#1\relax}%
-\def\sethyphenatedurlnormal#1{\ctxlua{commands.hyphenatedurl.characters[\!!bs#1\!!es]=0}}
-\def\sethyphenatedurlbefore#1{\ctxlua{commands.hyphenatedurl.characters[\!!bs#1\!!es]=1}}
-\def\sethyphenatedurlafter #1{\ctxlua{commands.hyphenatedurl.characters[\!!bs#1\!!es]=2}}
+\def\sethyphenatedurlnormal#1{\ctxlua{commands.hyphenatedurl.setcharacters(\!!bs#1\!!es,0)}}
+\def\sethyphenatedurlbefore#1{\ctxlua{commands.hyphenatedurl.setcharacters(\!!bs#1\!!es,1)}}
+\def\sethyphenatedurlafter #1{\ctxlua{commands.hyphenatedurl.setcharacters(\!!bs#1\!!es,2)}}
+
+% \sethyphenatedurlafter{ABCDEF}
\chardef\hyphenatedurllefthyphenmin = 3
\chardef\hyphenatedurlrighthyphenmin = 3
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 4f136ad79..87014365b 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -94,7 +94,7 @@ local function link(url,filename,destination,page,actions)
elseif filename and filename ~= "" then
return pdfdictionary {
S = pdf_gotor,
- F = pdffile,
+ F = filename,
D = destination and destination ~= "" and destination,
NewWindow = (actions.newwindow and true) or nil,
}
@@ -337,7 +337,7 @@ end
function specials.url(var,actions)
local url = var.operation
if url then
- local u = urls[url]
+ local u = jobreferences.urls[url]
if u then
local u, f = u[1], u[2]
if f and f ~= "" then
@@ -353,9 +353,9 @@ end
function specials.file(var,actions)
local file = var.operation
if file then
- local f = files[file]
+ local f = jobreferences.files[file]
if f then
- file = f[1]
+ file = f[1] or file
end
end
return link(nil,file,var.arguments,nil,actions)
@@ -364,7 +364,7 @@ end
function specials.program(var,content)
local program = var.operation
if program then
- local p = programs[program]
+ local p = jobreferences.programs[program]
if p then
program = p[1]
end
@@ -556,7 +556,7 @@ local function build(levels,start,parent,method)
end
end
pdfimmediateobj(child,tostring(entry))
- return _, n, first, last
+ return nil, n, first, last
end
function codeinjections.addbookmarks(levels,method)
diff --git a/tex/context/base/lpdf-col.lua b/tex/context/base/lpdf-col.lua
index 219188369..2973f7e76 100644
--- a/tex/context/base/lpdf-col.lua
+++ b/tex/context/base/lpdf-col.lua
@@ -125,16 +125,16 @@ local intransparency = false
local pdfcolor = lpdf.color
function lpdf.rgbcode(model,r,g,b)
- return pdfcolor(model,registercolor('color',nil,'rgb',r,g,b))
+ return pdfcolor(model,registercolor(nil,'rgb',r,g,b))
end
function lpdf.cmykcode(model,c,m,y,k)
- return pdfcolor(model,registercolor('color',nil,'cmyk',c,m,y,k))
+ return pdfcolor(model,registercolor(nil,'cmyk',c,m,y,k))
end
function lpdf.graycode(model,s)
- return pdfcolor(model,registercolor('color',nil,'gray',s))
+ return pdfcolor(model,registercolor(nil,'gray',s))
end
function lpdf.spotcode(model,n,f,d,p)
- return pdfcolor(model,registercolor('color',nil,'spot',n,f,d,p)) -- incorrect
+ return pdfcolor(model,registercolor(nil,'spot',n,f,d,p)) -- incorrect
end
function lpdf.transparencycode(a,t)
intransparency = true
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index bc89c4872..1b099ed9b 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -181,7 +181,7 @@ local function value_z() return nil end -- the call is e
local function value_t() return true end -- the call is experimental
local function value_b() return false end -- the call is experimental
local function value_r() return t[1] end -- the call is experimental
-local function value_v() return t end -- the call is experimental
+local function value_v() return t[1] end -- the call is experimental
local function add_x(t,k,v) rawset(t,k,tostring(v)) end
@@ -273,8 +273,8 @@ function lpdf.reference(r)
return setmetatable({ r or 0 },mt_r)
end
-function lpdf.verbose(t)
- return setmetatable(t or { },mt_v)
+function lpdf.verbose(t) -- maybe check for type
+ return setmetatable({ t or "" },mt_v)
end
--~ local d = lpdf.dictionary()
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index 4a8a097ff..87230aff2 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -37,6 +37,8 @@ local pdfimmediateobj = pdf.immediateobj
local tobasepoints = number.tobasepoints
+local variables = interfaces.variables
+
lpdf.addtoinfo ("Trapped", pdfboolean(false))
lpdf.addtocatalog("Version", pdfconstant(format("1.%s",tex.pdfminorversion)))
@@ -133,7 +135,7 @@ function codeinjections.setupidentity(specification)
lpdf.addtoinfo("ModDate", pdfstring(date))
end
local keywords = specification.keywords or "" if keywords ~= "" then
- keywords = string.gsub("[%s,]+", " ")
+ keywords = string.gsub(keywords, "[%s,]+", " ")
lpdf.addtoinfo("Keywords",pdfunicode(keywords))
end
lpdf.addtoinfo("ID", pdfstring(format("%s.%s",tex.jobname,os.date("%Y%m%d.%H%M")))) -- needed for pdf/x
@@ -160,11 +162,14 @@ lpdf.registerdocumentfinalizer(flushjavascripts)
-- -- --
local pagespecs = {
- max = { "FullScreen", false, false },
- bookmark = { "UseOutlines", false, false },
- fit = { "UseNone", false, true },
- doublesided = { "UseNone", "TwoColumnRight", true },
- default = { "UseNone", "auto", false },
+ [variables.max] = { "FullScreen", false, false },
+ [variables.bookmark] = { "UseOutlines", false, false },
+ [variables.fit] = { "UseNone", false, true },
+ [variables.doublesided] = { "UseNone", "TwoColumnRight", true },
+ [variables.singlesided] = { "UseNone", false, false },
+ [variables.default] = { "UseNone", "auto", false },
+ [variables.auto] = { "UseNone", "auto", false },
+ [variables.none] = { false, false, false },
}
local pagespec, topoffset, leftoffset, height, width, doublesided = "default", 0, 0, 0, 0, false
@@ -190,11 +195,15 @@ function codeinjections.setupcanvas(specification)
end
local function documentspecification()
- local spec = pagespecs[pagespec] or pagespecs.default
+ local spec = pagespecs[pagespec] or pagespecs[variables.default]
local mode, layout, fit = spec[1], spec[2], spec[3]
- if layout == "auto" and doublesided then
- spec = pagespecs.doublesided
- mode, layout, fit = spec[1], spec[2], spec[3]
+ if layout == variables.auto then
+ if doublesided then
+ spec = pagespecs.doublesided
+ mode, layout, fit = spec[1], spec[2], spec[3]
+ else
+ layout = false
+ end
end
mode = mode and pdfconstant(mode)
layout = layout and pdfconstant(layout)
diff --git a/tex/context/base/lpdf-ren.lua b/tex/context/base/lpdf-ren.lua
index 05a6658e7..746db7efd 100644
--- a/tex/context/base/lpdf-ren.lua
+++ b/tex/context/base/lpdf-ren.lua
@@ -56,7 +56,6 @@ function backends.pdf.layerreference(name)
return pdfln[name]
end
-
function codeinjections.defineviewerlayer(specification)
if textlayers then
local tag = specification.tag
diff --git a/tex/context/base/m-visual.tex b/tex/context/base/m-visual.tex
index 2be669d19..d78455190 100644
--- a/tex/context/base/m-visual.tex
+++ b/tex/context/base/m-visual.tex
@@ -281,32 +281,36 @@
{\def\PDFcode{\lowlevelstream\PDFcode\gobbleoneargument}%
\def\special{\lowlevelstream\special\gobbleoneargument}}
-\let\normaldostartgraymode \dostartgraymode
-\let\normaldostartgraycolormode\dostartgraycolormode
-\let\normaldostartrgbcolormode \dostartrgbcolormode
-\let\normaldostartcmykcolormode\dostartcmykcolormode
-\let\normaldostartspotcolormode\dostartspotcolormode
+\startnotmode[mkiv]
-\def\traceddostartgraymode#1%
- {#1\normaldostartgraymode{#1}}
+ \let\normaldostartgraymode \dostartgraymode
+ \let\normaldostartgraycolormode\dostartgraycolormode
+ \let\normaldostartrgbcolormode \dostartrgbcolormode
+ \let\normaldostartcmykcolormode\dostartcmykcolormode
+ \let\normaldostartspotcolormode\dostartspotcolormode
-\def\traceddostartgraycolormode#1%
- {#1\normaldostartgraycolormode{#1}}
+ \def\traceddostartgraymode#1%
+ {#1\normaldostartgraymode{#1}}
-\def\traceddostartrgbcolormode#1#2#3%
- {#1 #2 #3\normaldostartrgbcolormode{#1}{#2}{#3}}
+ \def\traceddostartgraycolormode#1%
+ {#1\normaldostartgraycolormode{#1}}
-\def\traceddostartcmykcolormode#1#2#3#4%
- {#1 #2 #3 #4\normaldostartcmykcolormode{#1}{#2}{#3}{#4}}
+ \def\traceddostartrgbcolormode#1#2#3%
+ {#1 #2 #3\normaldostartrgbcolormode{#1}{#2}{#3}}
-\def\traceddostartspotcolormode#1#2%
- {#1 #2\normaldostartspotcolormode{#1}{#2}}
+ \def\traceddostartcmykcolormode#1#2#3#4%
+ {#1 #2 #3 #4\normaldostartcmykcolormode{#1}{#2}{#3}{#4}}
-\def\showcolormodes
- {\let\dostartgraymode \traceddostartgraymode
- \let\dostartgraycolormode\traceddostartgraycolormode
- \let\dostartrgbcolormode \traceddostartrgbcolormode
- \let\dostartcmykcolormode\traceddostartcmykcolormode
- \let\dostartspotcolormode\traceddostartspotcolormode}
+ \def\traceddostartspotcolormode#1#2%
+ {#1 #2\normaldostartspotcolormode{#1}{#2}}
+
+ \def\showcolormodes
+ {\let\dostartgraymode \traceddostartgraymode
+ \let\dostartgraycolormode\traceddostartgraycolormode
+ \let\dostartrgbcolormode \traceddostartrgbcolormode
+ \let\dostartcmykcolormode\traceddostartcmykcolormode
+ \let\dostartspotcolormode\traceddostartspotcolormode}
+
+\stopnotmode
\protect \endinput
diff --git a/tex/context/base/math-pln.mkiv b/tex/context/base/math-pln.mkiv
index 23d7d935c..40d73b228 100644
--- a/tex/context/base/math-pln.mkiv
+++ b/tex/context/base/math-pln.mkiv
@@ -97,7 +97,7 @@
\def\relbar {\mathrel{\smash-}} % - has the same height as +
\def\Relbar {\mathrel=}
-\def\Longrightarrow {\Relbar\joinrel\Rightarrow}
+\def\Longrightarrow {\Relbar\joinrel\Rightarrow} % beware, this overloades cambria native
\def\longrightarrow {\relbar\joinrel\rightarrow}
\def\longleftarrow {\leftarrow\joinrel\relbar}
\def\Longleftarrow {\Leftarrow\joinrel\Relbar}
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index 042f7247e..ea3870dc2 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -142,10 +142,10 @@
\setMPrandomseed % this has to change
% we need to preexpand the token lists
\doifelsevalue{\@@MPF\currentMPgraphicinstance\s!extensions}\v!yes
- {\settrue\includeMPextensions\letgvalue{\@@MPF\currentMPgraphicinstance\s!extensions}\v!no}
+ {\settrue \includeMPextensions\letgvalue{\@@MPF\currentMPgraphicinstance\s!extensions}\v!no}
{\setfalse\includeMPextensions}%
\doifelsevalue{\@@MPF\currentMPgraphicinstance\s!initializations}\v!yes
- {\settrue\includeMPinitializations }%
+ {\settrue \includeMPinitializations}%
{\setfalse\includeMPinitializations}%
\setbox\MPgraphicbox\hbox\bgroup
\normalexpanded{\noexpand\ctxlua{metapost.graphic("\currentMPgraphicinstance", "\currentMPgraphicformat",
diff --git a/tex/context/base/mlib-ctx.lua b/tex/context/base/mlib-ctx.lua
index 2b16af28e..821b702c6 100644
--- a/tex/context/base/mlib-ctx.lua
+++ b/tex/context/base/mlib-ctx.lua
@@ -41,12 +41,11 @@ end
statistics.register("metapost processing time", function()
local n = metapost.n
if n > 0 then
- local e = metapost.externals.n
+ local e, t = metapost.externals.n, statistics.elapsedtime
local str = format("%s seconds, loading: %s seconds, execution: %s seconds, n: %s",
- statistics.elapsedtime(metapost), statistics.elapsedtime(mplib),
- statistics.elapsedtime(metapost.exectime), n)
+ t(metapost), t(mplib), t(metapost.exectime), n)
if e > 0 then
- return format("%s, external: %s seconds (%s calls)", str, statistics.elapsedtime(metapost.externals), e)
+ return format("%s, external: %s seconds (%s calls)", str, t(metapost.externals), e)
else
return str
end
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index d5ce9e869..a2313f405 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -13,6 +13,8 @@ local format, gmatch, concat, round, match = string.format, string.gmatch, table
local sprint = tex.sprint
local tonumber, type = tonumber, type
+local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
+
local ctxcatcodes = tex.ctxcatcodes
local trace_textexts = false trackers.register("metapost.textexts", function(v) trace_textexts = v end)
@@ -124,7 +126,7 @@ end
local function spotcolorconverter(parent, n, d, p)
registerspotcolor(parent)
- return pdfcolor(colors.model,registercolor('color',nil,'spot',parent,n,d,p))
+ return pdfcolor(colors.model,registercolor(nil,'spot',parent,n,d,p))
end
function metapost.colorhandler(cs, object, result, colorconverter) -- handles specials
@@ -770,17 +772,17 @@ end
function metapost.getclippath(data)
local mpx = metapost.format("metafun")
if mpx and data then
- statistics.starttiming(metapost)
- statistics.starttiming(metapost.exectime)
+ starttiming(metapost)
+ starttiming(metapost.exectime)
local result = mpx:execute(format("beginfig(1);%s;endfig;",data))
- statistics.stoptiming(metapost.exectime)
+ stoptiming(metapost.exectime)
if result.status > 0 then
print("error", result.status, result.error or result.term or result.log)
result = ""
else
result = metapost.filterclippath(result)
end
- statistics.stoptiming(metapost)
+ stoptiming(metapost)
sprint(result)
end
end
@@ -819,15 +821,17 @@ function metapost.intermediate.actions.makempy()
if #graphics > 0 then
local externals = metapost.externals
externals.n = externals.n + 1
- statistics.starttiming(externals)
+ starttiming(externals)
local mpofile = tex.jobname .. "-mpgraph"
local mpyfile = file.replacesuffix(mpofile,"mpy")
local pdffile = file.replacesuffix(mpofile,"pdf")
local texfile = file.replacesuffix(mpofile,"tex")
io.savedata(texfile, { start, preamble, metapost.tex.get(), concat(graphics,"\n"), stop }, "\n")
- os.execute(format("context --once %s", texfile))
+ local command = format("context --once %s %s", (tex.interactionmode == 0 and "--batchmode") or "", texfile)
+ os.execute(command)
if io.exists(pdffile) then
- os.execute(format("pstoedit -ssp -dt -f mpost %s %s", pdffile, mpyfile))
+ command = format("pstoedit -ssp -dt -f mpost %s %s", pdffile, mpyfile)
+ os.execute(command)
local result = { }
if io.exists(mpyfile) then
local data = io.loaddata(mpyfile)
@@ -837,7 +841,7 @@ function metapost.intermediate.actions.makempy()
io.savedata(mpyfile,concat(result,""))
end
end
- statistics.stoptiming(externals)
+ stoptiming(externals)
graphics = { } -- ?
end
end
diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua
index b155dd344..7351c332f 100644
--- a/tex/context/base/mlib-run.lua
+++ b/tex/context/base/mlib-run.lua
@@ -33,6 +33,9 @@ local trace_graphics = false trackers.register("metapost.graphics", function(v)
local format = string.format
+local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
+
+
metapost = metapost or { }
metapost.showlog = false
@@ -54,13 +57,6 @@ end
metapost.finder = finder
---~ statistics = {
---~ ["hash_size"]=1774,
---~ ["main_memory"]=50237,
---~ ["max_in_open"]=5,
---~ ["param_size"]=4,
---~ }
-
metapost.parameters = {
hash_size = 100000,
main_memory = 2000000,
@@ -77,19 +73,8 @@ mp_parent_version := "%s";
input %s ; dump ;
]]
-if not mplib.pen_info then -- temp compatibility hack
-
-preamble = [[\\ ;
-boolean mplib; string mp_parent_version;
-mplib := true;
-mp_parent_version := "%s";
-input %s ; dump ;
-]]
-
-end
-
function metapost.make(name, target, version)
- statistics.starttiming(mplib)
+ starttiming(mplib)
target = file.replacesuffix(target or name, "mem")
local mpx = mplib.new ( table.merged (
metapost.parameters,
@@ -100,16 +85,16 @@ function metapost.make(name, target, version)
}
) )
if mpx then
- statistics.starttiming(metapost.exectime)
+ starttiming(metapost.exectime)
local result = mpx:execute(format(preamble,version or "unknown",name))
- statistics.stoptiming(metapost.exectime)
+ stoptiming(metapost.exectime)
mpx:finish()
end
- statistics.stoptiming(mplib)
+ stoptiming(mplib)
end
function metapost.load(name)
- statistics.starttiming(mplib)
+ starttiming(mplib)
local mpx = mplib.new ( table.merged (
metapost.parameters,
{
@@ -120,25 +105,19 @@ function metapost.load(name)
}
) )
local result
- if mpx then
- if not mplib.pen_info then -- temp compatibility hack
- statistics.starttiming(metapost.exectime)
- result = mpx:execute("\\")
- statistics.stoptiming(metapost.exectime)
- end
- else
+ if not mpx then
result = { status = 99, error = "out of memory"}
end
- statistics.stoptiming(mplib)
+ stoptiming(mplib)
return mpx, result
end
function metapost.unload(mpx)
- statistics.starttiming(mplib)
+ starttiming(mplib)
if mpx then
mpx:finish()
end
- statistics.stoptiming(mplib)
+ stoptiming(mplib)
end
function metapost.reporterror(result)
@@ -248,7 +227,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass,
mpx = metapost.format(mpx) -- goody
end
if mpx and data then
- statistics.starttiming(metapost)
+ starttiming(metapost)
if trace_graphics then
if not mp_inp[mpx] then
mp_tag = mp_tag + 1
@@ -266,9 +245,9 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass,
if trace_graphics then
mp_inp[mpx]:write(d)
end
- statistics.starttiming(metapost.exectime)
+ starttiming(metapost.exectime)
result = mpx:execute(d)
- statistics.stoptiming(metapost.exectime)
+ stoptiming(metapost.exectime)
if trace_graphics and result then
local str = result.log or result.error
if str and str ~= "" then
@@ -295,9 +274,9 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass,
if trace_graphics then
mp_inp:write(data)
end
- statistics.starttiming(metapost.exectime)
+ starttiming(metapost.exectime)
result = mpx[mpx]:execute(data)
- statistics.stoptiming(metapost.exectime)
+ stoptiming(metapost.exectime)
if trace_graphics and result then
local str = result.log or result.error
if str and str ~= "" then
@@ -324,7 +303,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass,
mp_inp[mpx]:write(banner)
mp_log[mpx]:write(banner)
end
- statistics.stoptiming(metapost)
+ stoptiming(metapost)
end
return converted, result
end
diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex
index e5f9f1c1a..2fd74251c 100644
--- a/tex/context/base/mult-sys.tex
+++ b/tex/context/base/mult-sys.tex
@@ -174,6 +174,7 @@
\definesystemconstant {skewchar}
\definesystemconstant {hyphenchar}
+\definesystemconstant {catcodes}
\definesystemconstant {encoding}
\definesystemconstant {resource}
\definesystemconstant {mapping}
@@ -589,6 +590,7 @@
\definesystemvariable {tm} % TypesynonyM
\definesystemvariable {tp} % TyPen
\definesystemvariable {tx} % TeXtflow
+\definesystemvariable {tr} % TRacer
\definesystemvariable {ts} % TypeScript
\definesystemvariable {tt} % TabulaTe
\definesystemvariable {ty} % TYpe
diff --git a/tex/context/base/node-dum.lua b/tex/context/base/node-dum.lua
index b210d0adb..f39a0873f 100644
--- a/tex/context/base/node-dum.lua
+++ b/tex/context/base/node-dum.lua
@@ -8,11 +8,6 @@ if not modules then modules = { } end modules ['node-dum'] = {
nodes = nodes or { }
-function nodes.simple_font_dummy(head,tail)
- -- ligaturing, kerning
- return head, tail
-end
-
function nodes.simple_font_handler(head)
-- lang.hyphenate(head)
head = nodes.process_characters(head)
diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua
index a801e9acb..e83a354f2 100644
--- a/tex/context/base/node-fin.lua
+++ b/tex/context/base/node-fin.lua
@@ -74,11 +74,11 @@ end
-- duplicate code once that we have more state handlers
local function process_attribute(head,plugin) -- head,attribute,enabled,initializer,resolver,processor,finalizer
- starttiming(attributes)
- local done, used, ok = false, nil, false
- local attribute = numbers[plugin.name] -- todo: plugin.attribute
local namespace = plugin.namespace
if namespace.enabled then
+ starttiming(attributes)
+ local done, used, ok = false, nil, false
+ local attribute = namespace.attribute or numbers[plugin.name] -- todo: plugin.attribute
local processor = plugin.processor
if processor then
local initializer = plugin.initializer
@@ -102,19 +102,69 @@ local function process_attribute(head,plugin) -- head,attribute,enabled,initiali
done = true
end
end
+ stoptiming(attributes)
+ return head, done
+ else
+ return head, false
end
- stoptiming(attributes)
- return head, done
end
nodes.process_attribute = process_attribute
-function nodes.install_attribute_handler(plugin)
+function nodes.install_attribute_handler(plugin) -- we need to avoid this nested function
return function(head)
return process_attribute(head,plugin)
end
end
+--~ experiment (maybe local to function makes more sense)
+--~
+--~ plugindata = { }
+--~
+--~ local template = [[
+--~ local plugin = plugindata["%s"]
+--~ local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
+--~ local namespace = plugin.namespace
+--~ local attribute = namespace.attribute
+--~ local processor = plugin.processor
+--~ local initializer = plugin.initializer
+--~ local resolver = plugin.resolver
+--~ local finalizer = plugin.finalizer
+--~ local flusher = plugin.flusher
+--~ return function (head)
+--~ if namespace.enabled then
+--~ starttiming(attributes)
+--~ local done, used, ok = false, nil, false
+--~ if procesxsor then
+--~ local inheritance = (resolver and resolver()) or nil -- -0x7FFFFFFF -- we can best use nil and skip !
+--~ if initializer then
+--~ initializer(namespace,attribute,head)
+--~ end
+--~ head, ok = processor(namespace,attribute,head,inheritance)
+--~ if ok then
+--~ if finalizer then
+--~ head, ok, used = finalizer(namespace,attribute,head)
+--~ if used and flusher then
+--~ head = flusher(namespace,attribute,head,used)
+--~ end
+--~ end
+--~ done = true
+--~ end
+--~ end
+--~ stoptiming(attributes)
+--~ return head, done
+--~ else
+--~ return head, false
+--~ end
+--~ end
+--~ ]]
+--~
+--~ function nodes.install_attribute_handler(plugin) -- we need to avoid this nested function
+--~ plugindata[plugin.name] = plugin
+--~ local str = format(template,plugin.name)
+--~ return loadstring(str)()
+--~ end
+
-- the injectors
local insert_node_before = node.insert_before
@@ -125,7 +175,7 @@ local current, current_selector, done = 0, 0, false -- nb, stack has a local cur
function states.initialize(namespace,attribute,head)
nsdata, nsnone = namespace.data, namespace.none
- nsforced, nsselector = namespace.forced, namespace.selector
+ nsforced, nsselector, nslistwise = namespace.forced, namespace.selector, namespace.listwise
nstrigger = triggering and namespace.triggering and trigger
current, current_selector, done = 0, 0, false -- todo: done cleanup
end
@@ -315,12 +365,15 @@ end
states.selective = selective
--- todo: each line now gets the (e.g. layer) property, hard to avoid (and not needed too)
+-- Ideally the next one should be merged with the previous but keeping it separate is
+-- safer. We deal with two situations: efficient boxwise (layoutareas) and mixed layers
+-- (as used in the stepper). In the stepper we cannot use the box branch as it involves
+-- paragraph lines and then getsmixed up. A messy business (esp since we want to be
+-- efficient).
local function stacked(namespace,attribute,head,default) -- no triggering, no inheritance, but list-wise
local stack, done = head, false
---~ local current, depth = 0, 0
-local current, depth = default or 0, 0
+ local current, depth = default or 0, 0
while stack do
local id = stack.id
if id == glyph or (id == rule and stack.width ~= 0) or (id == glue and stack.leader) then -- or disc
@@ -349,14 +402,21 @@ local current, depth = default or 0, 0
elseif id == hlist or id == vlist then
local content = stack.list
if content then
- local c = has_attribute(stack,attribute)
- if c and current ~= c then
- local p = current
- current, done = c, true
- head = insert_node_before(head,stack,copy_node(nsdata[c]))
- stack.list = stacked(namespace,attribute,content,current)
- head, stack = insert_node_after(head,stack,copy_node(nsnone))
- current = p
+ -- the problem is that broken lines gets the attribute which can be a later one
+ if nslistwise then
+ local c = has_attribute(stack,attribute)
+ if c and current ~= c and nslistwise[c] then -- viewerlayer
+ local p = current
+ current, done = c, true
+ head = insert_node_before(head,stack,copy_node(nsdata[c]))
+ stack.list = stacked(namespace,attribute,content,current)
+ head, stack = insert_node_after(head,stack,copy_node(nsnone))
+ current = p
+ else
+ local ok = false
+ stack.list, ok = stacked(namespace,attribute,content,current)
+ done = done or ok
+ end
else
local ok = false
stack.list, ok = stacked(namespace,attribute,content,current)
@@ -379,6 +439,6 @@ states.stacked = stacked
statistics.register("attribute processing time", function()
if statistics.elapsedindeed(attributes) then
- return format("%s seconds",statistics.elapsedtime(attributes))
+ return format("%s seconds (front- and backend)",statistics.elapsedtime(attributes))
end
end)
diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua
index 571ba3dd7..8e7c3e983 100644
--- a/tex/context/base/node-ref.lua
+++ b/tex/context/base/node-ref.lua
@@ -250,14 +250,14 @@ local function colorize(width,height,depth,n)
local ucolor = u_colors[n]
if not ucolor then
if n == 1 then
- u_color = register_color('color',nil,'rgb',.75,0,0)
+ u_color = register_color(nil,'rgb',.75,0,0)
elseif n == 2 then
- u_color = register_color('color',nil,'rgb',0,.75,0)
+ u_color = register_color(nil,'rgb',0,.75,0)
elseif n == 3 then
- u_color = register_color('color',nil,'rgb',0,0,.75)
+ u_color = register_color(nil,'rgb',0,0,.75)
else
n = 0
- u_color = register_color('color',nil,'gray',.5)
+ u_color = register_color(nil,'gray',.5)
end
u_colors[n] = u_color
end
diff --git a/tex/context/base/node-shp.lua b/tex/context/base/node-shp.lua
index 22b97ca6e..8cde38dc0 100644
--- a/tex/context/base/node-shp.lua
+++ b/tex/context/base/node-shp.lua
@@ -10,41 +10,30 @@ local hlist = node.id('hlist')
local vlist = node.id('vlist')
local disc = node.id('disc')
local mark = node.id('mark')
+local kern = node.id('kern')
+local glue = node.id('glue')
-local free_node = node.free
+local free_node = node.free
+local remove_node = node.remove
local function cleanup_page(head) -- rough
- local prev, start = nil, head
+ local start = head
while start do
- local id, nx = start.id, start.next
- if id == disc or id == mark then
- if prev then
- prev.next = nx
- end
- if start == head then
- head = nx
- end
- local tmp = start
- start = nx
+ local id = start.id
+ if id == disc or (id == glue and not start.spec) or (id == kern and start.kern == 0) or id == mark then
+ head, start, tmp = remove_node(head,start)
free_node(tmp)
elseif id == hlist or id == vlist then
local sl = start.list
if sl then
start.list = cleanup_page(sl)
- prev, start = start, nx
+ start = start.next
else
- if prev then
- prev.next = nx
- end
- if start == head then
- head = nx
- end
- local tmp = start
- start = nx
+ head, start, tmp = remove_node(head,start)
free_node(tmp)
end
else
- prev, start = start, nx
+ start = start.next
end
end
return head
@@ -53,6 +42,7 @@ end
nodes.cleanup_page_first = false
function nodes.cleanup_page(head)
+ -- about 10% of the nodes make no sense for the backend
if nodes.cleanup_page_first then
head = cleanup_page(head)
end
@@ -64,3 +54,5 @@ local actions = tasks.actions("shipouts",0) -- no extra arguments
function nodes.process_page(head) -- problem, attr loaded before node, todo ...
return actions(head)
end
+
+--~ nodes.process_page = actions
diff --git a/tex/context/base/norm-ltx.tex b/tex/context/base/norm-ltx.tex
index c83a49b90..a779735dd 100644
--- a/tex/context/base/norm-ltx.tex
+++ b/tex/context/base/norm-ltx.tex
@@ -13,7 +13,7 @@
%D This file will become obsolete!
-% luatex primitives
+% luatex primitives (incomplete)
\let \normalUdelcode = \Udelcode
\let \normalUdelcodenum = \Udelcodenum
diff --git a/tex/context/base/norm-ptx.tex b/tex/context/base/norm-ptx.tex
index 992fd38ff..8f911d874 100644
--- a/tex/context/base/norm-ptx.tex
+++ b/tex/context/base/norm-ptx.tex
@@ -42,7 +42,7 @@
\let \normalpdffontname = \pdffontname
\let \normalpdffontobjnum = \pdffontobjnum
\let \normalpdffontsize = \pdffontsize
-\let \normalpdfforcepagebox = \pdfforcepagebox
+\let \normalpdfforcepagebox = \pdfforcepagebox % obsolete
\let \normalpdfgamma = \pdfgamma
\let \normalpdfgentounicode = \pdfgentounicode
\let \normalpdfglyphtounicode = \pdfglyphtounicode
@@ -72,14 +72,14 @@
\let \normalpdfmapfile = \pdfmapfile
\let \normalpdfmapline = \pdfmapline
\let \normalpdfminorversion = \pdfminorversion
-\let \normalpdfmovechars = \pdfmovechars
+\let \normalpdfmovechars = \pdfmovechars % obsolete
\let \normalpdfnames = \pdfnames
\let \normalpdfnoligatures = \pdfnoligatures
\let \normalpdfnormaldeviate = \pdfnormaldeviate
\let \normalpdfobj = \pdfobj
\let \normalpdfobjcompresslevel = \pdfobjcompresslevel
-\let \normalpdfoptionalwaysusepdfpagebox = \pdfoptionalwaysusepdfpagebox
-\let \normalpdfoptionpdfinclusionerrorlevel = \pdfoptionpdfinclusionerrorlevel
+\let \normalpdfoptionalwaysusepdfpagebox = \pdfoptionalwaysusepdfpagebox % obsolete
+\let \normalpdfoptionpdfinclusionerrorlevel = \pdfoptionpdfinclusionerrorlevel % obsolete
\let \normalpdfoptionpdfminorversion = \pdfoptionpdfminorversion
\let \normalpdfoutline = \pdfoutline
\let \normalpdfoutput = \pdfoutput
diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv
index a12ab0263..2ab765d7d 100644
--- a/tex/context/base/pack-box.mkiv
+++ b/tex/context/base/pack-box.mkiv
@@ -166,7 +166,7 @@
\def\dodosetcollector[#1][#2]% todo: keep reference point
{\def\currentcollector{#1}%
- \mathchardef\collectorbox\csname\@@collectorbox#1\endcsname
+ \chardef\collectorbox\csname\@@collectorbox#1\endcsname
\getparameters[\??cb#1][#2]%
\@@layerxsiz\wd\collectorbox
\@@layerysiz\ht\collectorbox
@@ -263,7 +263,7 @@
\def\doadaptcollector[#1][#2]%
{\bgroup
\def\currentcollector{#1}%
- \mathchardef\collectorbox\csname\@@collectorbox#1\endcsname
+ \chardef\collectorbox\csname\@@collectorbox#1\endcsname
\getparameters[\??cb#1][\c!voffset=\zeropoint,\c!hoffset=\zeropoint,#2]%
\scratchdimen\wd\collectorbox
\advance\scratchdimen\collectorparameter\c!hoffset
diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv
index 5bb89fccf..fc1ea91c3 100644
--- a/tex/context/base/pack-lyr.mkiv
+++ b/tex/context/base/pack-lyr.mkiv
@@ -508,8 +508,7 @@
\fi\fi
\fi
\fi
- \chardef\layerbox\csname\@@layerbox#2\endcsname % mathchardef no longer needed can be chardef or just let
-% \chardef\layerbox\csname\@@layerbox\currentlayer\endcsname % mathchardef no longer needed can be chardef or just let
+ \chardef\layerbox\csname\@@layerbox#2\endcsname % \@@layerbox\currentlayer
% we need to copy in order to retain the negative offsets for a next
% stage of additions, i.e. llx/lly accumulate in repeat mode and the
% compensation may differ each flush depending on added content
diff --git a/tex/context/base/pack-obj.mkiv b/tex/context/base/pack-obj.mkiv
index 562b15e94..14afef623 100644
--- a/tex/context/base/pack-obj.mkiv
+++ b/tex/context/base/pack-obj.mkiv
@@ -327,7 +327,7 @@
\let\objectwidth \!!zeropoint
\let\objectheight\!!zeropoint
\let\objectdepth \!!zeropoint
- \labelcsname\r!object#1::#2\endcsname}
+ \csname\r!object#1::#2\endcsname}
%D Apart from this kind of objects, that have typeset content,
%D we can have low level driver specific objects. Both types
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index 249b6eca6..6beba4492 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -150,55 +150,88 @@
\let\OTRdefault\empty
+% obsolete
+
+\def\installotr#1% andere naam, beter \connectotr of zo
+ {\def\OTRidentifier{#1}}
+
+% \def\OTRcommand#1%
+% {\csname\@@OTR
+% \ifcsname\@@OTR\OTRidentifier\strippedcsname#1\endcsname
+% \OTRidentifier
+% \else\ifcsname\@@OTR\OTRdefault\strippedcsname#1\endcsname % fallback
+% \OTRdefault
+% \fi\fi
+% \strippedcsname#1\endcsname}
+%
+% maybe faster but at least less tracing:
+
\def\OTRcommand#1%
{\csname\@@OTR
- \ifcsname\@@OTR\OTRidentifier\strippedcsname#1\endcsname
+ \ifcsname\@@OTR\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
\OTRidentifier
- \else\ifcsname\@@OTR\OTRdefault\strippedcsname#1\endcsname % fallback
+ \else\ifcsname\@@OTR\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname % fallback
\OTRdefault
\fi\fi
- \strippedcsname#1\endcsname}
-
-% obsolete
-
-\def\installotr#1% andere naam, beter \connectotr of zo
- {\def\OTRidentifier{#1}}
+ \expandafter\gobbleoneargument\string#1\endcsname}
\def\activateotr#1#2%
{\def\OTRidentifier{#1}%
\def\OTRdefault {#2}}
-%D The initialization of the \type {\hsize} and \type {\vsize}
-%D depends on the OTR used.
+% variant that does a preset:
-\def\setvsize {\OTRcommand\setvsize}
-\def\sethsize {\OTRcommand\sethsize}
-\def\finalsidefloatoutput {\OTRcommand\finalsidefloatoutput}
-\def\dopagecontents {\OTRcommand\dopagecontents}
+\newtoks\registeredotrcommands
-\def\dosettopinserts {\OTRcommand\dosettopinserts}
-\def\dosetbotinserts {\OTRcommand\dosetbotinserts}
-\def\dotopinsertions {\OTRcommand\dotopinsertions}
-\def\dobotinsertions {\OTRcommand\dobotinsertions}
-\def\dosetbothinserts {\OTRcommand\dosetbothinserts}
+\def\registerotrcommand#1%
+ {\appendtoks\dowithotrcommand#1\to\registeredotrcommands}
-\def\doflushfloats {\OTRcommand\doflushfloats}
-\def\flushfloatbox {\OTRcommand\flushfloatbox}
-\def\docheckiffloatfits {\OTRcommand\docheckiffloatfits}
+\def\dopresetotrcommand#1%
+ {\expandafter\let\expandafter#1\csname\@@OTR
+ \ifcsname\@@OTR\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
+ \OTRidentifier
+ \else\ifcsname\@@OTR\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname % fallback
+ \OTRdefault
+ \fi\fi
+ \expandafter\gobbleoneargument\string#1\endcsname}
-\def\someherefloat {\OTRcommand\someherefloat}
-\def\somefixdfloat {\OTRcommand\somefixdfloat}
-\def\somepagefloat {\OTRcommand\somepagefloat}
-\def\sometopsfloat {\OTRcommand\sometopsfloat}
-\def\somebotsfloat {\OTRcommand\somebotsfloat}
-\def\somesidefloat {\OTRcommand\somesidefloat}
+\def\activateotr#1#2%
+ {\def\OTRidentifier{#1}%
+ \def\OTRdefault {#2}%
+ \let\dowithotrcommand\dopresetotrcommand
+ \the\registeredotrcommands}
-\def\flushsavedfloats {\OTRcommand\flushsavedfloats}
+\appendtoks
+ \activateotr{ONE}{}%
+\to\everydump
-\def\synchronizehsize {\OTRcommand\synchronizehsize}
+%D The initialization of the \type {\hsize} and \type {\vsize}
+%D depends on the OTR used.
-\def\gotonextpage {\OTRcommand\gotonextpage }
-\def\gotonextpageX{\OTRcommand\gotonextpageX} % will become obsolete
+% todo: \registerotrcommand\output, is a toks
+
+\registerotrcommand\setvsize % \def\setvsize {\OTRcommand\setvsize}
+\registerotrcommand\sethsize % \def\sethsize {\OTRcommand\sethsize}
+\registerotrcommand\finalsidefloatoutput % \def\finalsidefloatoutput {\OTRcommand\finalsidefloatoutput}
+\registerotrcommand\dopagecontents % \def\dopagecontents {\OTRcommand\dopagecontents}
+\registerotrcommand\dosettopinserts % \def\dosettopinserts {\OTRcommand\dosettopinserts}
+\registerotrcommand\dosetbotinserts % \def\dosetbotinserts {\OTRcommand\dosetbotinserts}
+\registerotrcommand\dotopinsertions % \def\dotopinsertions {\OTRcommand\dotopinsertions}
+\registerotrcommand\dobotinsertions % \def\dobotinsertions {\OTRcommand\dobotinsertions}
+\registerotrcommand\dosetbothinserts % \def\dosetbothinserts {\OTRcommand\dosetbothinserts}
+\registerotrcommand\doflushfloats % \def\doflushfloats {\OTRcommand\doflushfloats}
+\registerotrcommand\flushfloatbox % \def\flushfloatbox {\OTRcommand\flushfloatbox}
+\registerotrcommand\docheckiffloatfits % \def\docheckiffloatfits {\OTRcommand\docheckiffloatfits}
+\registerotrcommand\someherefloat % \def\someherefloat {\OTRcommand\someherefloat}
+\registerotrcommand\somefixdfloat % \def\somefixdfloat {\OTRcommand\somefixdfloat}
+\registerotrcommand\somepagefloat % \def\somepagefloat {\OTRcommand\somepagefloat}
+\registerotrcommand\sometopsfloat % \def\sometopsfloat {\OTRcommand\sometopsfloat}
+\registerotrcommand\somebotsfloat % \def\somebotsfloat {\OTRcommand\somebotsfloat}
+\registerotrcommand\somesidefloat % \def\somesidefloat {\OTRcommand\somesidefloat}
+\registerotrcommand\flushsavedfloats % \def\flushsavedfloats {\OTRcommand\flushsavedfloats}
+\registerotrcommand\synchronizehsize % \def\synchronizehsize {\OTRcommand\synchronizehsize}
+\registerotrcommand\gotonextpage % \def\gotonextpage {\OTRcommand\gotonextpage }
+\registerotrcommand\gotonextpageX % \def\gotonextpageX {\OTRcommand\gotonextpageX} % will become obsolete
% beter een \installotr#1 met #1 = macro en auto test
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 5d0b06418..18972c350 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -1030,6 +1030,8 @@
\expandafter\redoifoddpageelse
\fi}
+\newdimen\texthoffset
+
\def\settexthoffset
{\texthoffset\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}}
diff --git a/tex/context/base/page-mar.mkii b/tex/context/base/page-mar.mkii
index f7c5328f3..96223bafe 100644
--- a/tex/context/base/page-mar.mkii
+++ b/tex/context/base/page-mar.mkii
@@ -215,7 +215,7 @@
\getparameters[\??im#2][#1]%
% will become an \everyinmarginsetup thing
\ifcase\executeifdefined{\??im#2\c!sidemethod}{0}\else
- \positioningtrue \positioningpartrue % global ?
+ \enableparpositions
\fi}
\def\checkinmargin[#1]%
diff --git a/tex/context/base/page-mar.mkiv b/tex/context/base/page-mar.mkiv
index 28f82efe5..b85a99aa6 100644
--- a/tex/context/base/page-mar.mkiv
+++ b/tex/context/base/page-mar.mkiv
@@ -215,7 +215,7 @@
\getparameters[\??im#2][#1]%
% will become an \everyinmarginsetup thing
\ifcase\executeifdefined{\??im#2\c!sidemethod}{0}\else
- \positioningtrue \positioningpartrue % global ?
+ \enableparpositions
\fi}
\def\checkinmargin[#1]%
@@ -654,8 +654,6 @@
%D flushed at every paragraph by the following macro. Note for
%D myself: here the location (plaats) is no longer a tag (number).
-% gone: \def\doflushmargincontent{\doinmargin[\@@implaats][\v!normaal][]} % + [#1][#2]{#3}}
-
%D These are now all the same (long ago they had different
%D implementations, somewhere in Sork time if I remember
%D right).
@@ -669,6 +667,7 @@
\def\domargincontent[#1][#2]#3% we used to check for #2/#1 being number, no longer now
{\global\chardef\margintextcollected\plusone
+ \global\let\flushmargincontents\doflushmargincontents
\edef\margincontenttag{#1}%
\ifx\margincontenttag\empty
\global\advance\margincontentlevel\plusone
@@ -683,15 +682,14 @@
{#3}%
\to \collectedmargintexts}
-\let\restoreinterlinepenalty\relax
+\def\doflushmargincontents % plural
+ {\ifcase\margintextcollected\else
+ \expandafter\flushmargincontentsindeed
+ \fi}
-\def\flushmargincontents % plural
- {\restoreinterlinepenalty % here?
- \ifcase\margintextcollected\else % called quite often, so we
- \expandafter\doflushmargincontents % speed up the \fi scan by
- \fi} % using a \do..
+\let\flushmargincontents\relax
-\def\doflushmargincontents % links + rechts
+\def\flushmargincontentsindeed % links + rechts
{\bgroup
\forgetall
\global\margincontentheight\zeropoint
@@ -736,6 +734,7 @@
% a bit dangerous
\vadjust{\nobreak}%
\fi
+ \global\let\flushmargincontents\relax
\egroup}
\def\setmargincontentpenalties
@@ -765,22 +764,12 @@
\global\chardef\margintextcollected\zerocount
\global\collectedmargintexts\emptytoks}
-% \def\placemargincontent
-% {\ifcase\margintextcollected\else
-% \bgroup
-% \chardef\graphicvadjustmode\zerocount
-% \doflushmargincontents
-% \egroup
-% \fi}
-%
-% font fix:
-
\def\placemargincontent
{\ifcase\margintextcollected\else % was level check
\bgroup
\redoconvertfont % !!
\chardef\graphicvadjustmode\zerocount
- \doflushmargincontents
+ \flushmargincontentsindeed
\egroup
\fi}
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index e50c5ec21..8dc8a2fd9 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -2230,8 +2230,12 @@
\startcolor[blue](\the\vsize->\number\columnfirstcell\#\number\columnfreecells)\stopcolor
\hskip\leftskip}}
-\def\OTRSETshowstatus
- {\iftracecolumnset \doOTRSETshowstatus \fi}
+\installtextracer{OTRSET} % low level
+
+\def\enabletextracerOTRSET {\tracecolumnsettrue \let\OTRSETshowstatus\doOTRSETshowstatus}
+\def\disabletextracerOTRSET{\tracecolumnsetfalse\let\OTRSETshowstatus\relax}
+
+\disabletextracerOTRSET
% \appendtoks \OTRSETshowstatus \to \everypar
diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv
index 0848c9d8c..ecfa195e6 100644
--- a/tex/context/base/page-sid.mkiv
+++ b/tex/context/base/page-sid.mkiv
@@ -107,37 +107,6 @@
\newdimen\sidefloatrightskip
\newdimen\sidefloatmaximum
-% \def\checksidefloatshift
-% {\ifdim\sidefloatmaximum>\zeropoint
-% \ifcase\sidefloattype
-% % invalid
-% \or
-% % backspace
-% \or
-% \global\sidefloatshift-\sidefloatmaximum
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftedgedistance \rightedgedistance
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftmarginwidth \rightmarginwidth
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftmargindistance \rightmargindistance
-% \or
-% \global\sidefloatshift-\sidefloatmaximum
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftmargindistance \rightmargindistance
-% \or
-% % left
-% \or
-% % right
-% \or
-% \global\sidefloatshift-\sidefloatmaximum
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftmargindistance \rightmargindistance
-% \or
-% \global\sidefloatshift-\sidefloatmaximum
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftedgedistance \rightedgedistance
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftmarginwidth \rightmarginwidth
-% \global\advance\sidefloatshift-\rightorleftpageaction \leftmargindistance \rightmargindistance
-% \or
-% % cutspace
-% \fi
-% \fi}
-
\def\checksidefloatshift
{\ifdim\sidefloatmaximum>\zeropoint
\ifcase\sidefloattype
@@ -276,71 +245,6 @@
% pagetotal enz niet zijn aangepast. Inner kan overigens niet
% betrouwbaar worden getest!
-% \def\flushsidefloats%
-% {\par
-% \sidefloatprogress=\sidefloatvsize
-% \advance\sidefloatprogress by -\pagetotal
-% \ifdim\sidefloatprogress>\zeropoint
-% \witruimte % nog checken op interferentie
-% \kern\sidefloatprogress
-% \fi
-% \global\sidefloatvsize=\nofloatvsize
-% \global\floatflagfalse}
-%
-% no, too buggy, leads to top of page crap
-%
-%\def\flushsidefloats
-% {\par
-% \dochecksidefloat
-% \scratchcounter=-\hangafter
-% \dorecurse{\scratchcounter}{\strut\hfill\strut\par}}
-%
-%\def\flushsidefloats
-% {\par
-% \!!heighta\sidefloatvsize
-% \advance\!!heighta -\pagetotal
-% \ifdim\!!heighta>\zeropoint
-% % to be checked for interference
-% \witruimte
-% % will be option
-% \getnoflines\!!heighta
-% \!!heighta\noflines\lineheight
-% % so far for option
-% \kern\!!heighta
-% \fi
-% % == \forgetsidefloats
-% \global\sidefloatvsize\nofloatvsize
-% \global\floatshortfalse
-% \global\floatflagfalse}
-
-% \def\flushsidefloats
-% {\par
-% \!!heighta\sidefloatvsize
-% \advance\!!heighta -\pagetotal
-% \ifdim\!!heighta>\zeropoint
-% % to be checked for interference
-% \witruimte
-% % will be option
-% \getnoflines\!!heighta
-% \!!heighta\noflines\lineheight
-% % so far for option
-% \ifdim\sidefloatbottomskip>\zeropoint\relax
-% \ifdim\!!heighta>\sidefloatbottomskip
-% \advance\!!heighta-\sidefloatbottomskip
-% \kern\!!heighta
-% \vskip\sidefloatbottomskip
-% \else
-% \kern\!!heighta
-% \fi
-% \else
-% \kern\!!heighta
-% \fi
-% \fi
-% % == \forgetsidefloats
-% \global\sidefloatvsize\nofloatvsize
-% \global\floatshortfalse
-% \global\floatflagfalse}
-
\newif\iftracesidefloats
\def\flushsidefloats
@@ -389,15 +293,17 @@
% also here if used at all \global\holdinginserts\zerocount
\global\floatflagfalse}
+\def\dochecksidefloatafterpar
+ {\dochecksidefloat
+ \ifdim\oldpagetotal=\pagetotal \else
+ \global\let\checksidefloat\dochecksidefloat
+ \flushsidefloats
+ \global\sidefloatsidelines\zerocount % here !
+ \fi}
+
\def\flushsidefloatsafterpar
{\xdef\oldpagetotal{\the\pagetotal}%
- \gdef\checksidefloat
- {\dochecksidefloat
- \ifdim\oldpagetotal=\pagetotal \else
- \global\let\checksidefloat\dochecksidefloat
- \flushsidefloats
- \global\sidefloatsidelines\zerocount % here !
- \fi}}
+ \global\let\checksidefloat\dochecksidefloatafterpar}
\def\forgetsidefloats
{\global\sidefloatvsize\nofloatvsize
@@ -568,51 +474,45 @@
{\everypar\emptytoks\forgetall\verticalstrut\vskip-\struttotal}% moved
\checksidefloatshift
\ifdim\sidefloatshift=\zeropoint \relax
- \ifnum\sidefloattype=4
+ \ifnum\sidefloattype=\plusfour
\global\advance\sidefloatshift\sidefloatextrashift
\global\sidefloatextrashift\zeropoint
- \else\ifnum\sidefloattype=5
+ \else\ifnum\sidefloattype=\plusfive
\global\advance\sidefloatshift\sidefloatextrashift
\global\sidefloatextrashift\zeropoint
\fi\fi
\else
- \ifnum\sidefloattype<4
- \global\chardef\sidefloattype4
- \else\ifnum\sidefloattype>5
- \global\chardef\sidefloattype5
+ \ifnum\sidefloattype<\plusfour
+ \global\chardef\sidefloattype\plusfour
+ \else\ifnum\sidefloattype>\plusfive
+ \global\chardef\sidefloattype\plusfive
\fi\fi
\fi
\previoussidefloat
\stallsidefloat
- %\global\setbox\floatbox\hbox
- % {\ifmarginfloat\else\ifrightfloat\else\kern\sidefloatleftshift\fi\fi
- % \hskip\ifrightfloat-\sidefloatextrashift\else\sidefloatshift\fi
- % \vbox{#1\ifnum\sidefloatalign=4 \removedepth\fi}%
- % \kern\ifrightfloat\sidefloatshift\else-\sidefloatextrashift\fi
- % \ifmarginfloat\else\ifrightfloat\kern\sidefloatrightshift\fi\fi}%
\global\setbox\floatbox\hbox % no \hskip, but \kern here
- {\ifnum\sidefloattype=4
+ {\ifnum\sidefloattype=\plusfour
\hskip\sidefloatleftshift
- \else\ifnum\sidefloattype=1
+ \else\ifnum\sidefloattype=\plusone
\hskip\sidefloatleftshift
\fi\fi
- \ifnum\sidefloattype>4
+ \ifnum\sidefloattype>\plusfour
\hskip-\sidefloatextrashift
\else
\hskip\sidefloatshift
\fi
- \vbox{#1\ifnum\sidefloatalign=4 \removedepth\fi}%
- \ifnum\sidefloattype>4
+ \vbox{#1\ifnum\sidefloatalign=\plusfour \removedepth\fi}%
+ \ifnum\sidefloattype>\plusfour
\kern\sidefloatshift
\else
\kern-\sidefloatextrashift
\fi
\ifnum\sidefloattype=8
\kern\sidefloatrightshift
- \else\ifnum\sidefloattype=5
+ \else\ifnum\sidefloattype=\plusfive
\kern\sidefloatrightshift
\fi\fi}%
- \ifnum\sidefloatalign=4
+ \ifnum\sidefloatalign=\plusfour
\getnoflines{\ht\floatbox}%
\scratchdimen\noflines\lineheight
\advance\scratchdimen-\strutdepth
@@ -628,9 +528,9 @@
\global\sidefloattopskip\zeropoint
\fi
\scratchdimen
- \ifnum\sidefloattype<4
+ \ifnum\sidefloattype<\plusfour
\sidefloattopskip
- \else\ifnum\sidefloattype>5
+ \else\ifnum\sidefloattype>\plusfive
\sidefloattopskip
\else
\zeropoint
@@ -661,39 +561,42 @@
{\vskip\scratchdimen
\nointerlineskip
\box\floatbox
- \ifnum\sidefloatalign=5 \vskip-\lineheight \fi}}%
- \ifnum\sidefloattype<4
+ \ifnum\sidefloatalign=\plusfive \vskip-\lineheight \fi}}%
+ \ifnum\sidefloattype<\plusfour
\global\sidefloattopskip\zeropoint
- \else\ifnum\sidefloattype>5
+ \else\ifnum\sidefloattype>\plusfive
\global\sidefloattopskip\zeropoint
\fi\fi
\global\sidefloatdownshift\zeropoint
\measuresidefloat
\ifroomforfloat \else
- \tosssidefloat
+ \vfill\eject % inline \tosssidefloat
\measuresidefloat
\stallsidefloat
\fi
\setsidefloat}
+% \def\progresssidefloat
+% {\sidefloatprogress\sidefloatvsize
+% \iffloatflag
+% \advance\sidefloatprogress -\sidefloatpagetotal
+% \global\floatflagfalse
+% \else
+% \advance\sidefloatprogress -\pagetotal
+% \fi}
+%
+% more compact:
+
\def\progresssidefloat
{\sidefloatprogress\sidefloatvsize
- \iffloatflag
- \advance\sidefloatprogress -\sidefloatpagetotal
- \global\floatflagfalse
- \else
- \advance\sidefloatprogress -\pagetotal
- \fi}
-
-\def\tosssidefloat
- {\vfill\eject}
+ \advance\sidefloatprogress-\iffloatflag\sidefloatpagetotal\global\floatflagfalse\else\pagetotal\fi}
\def\measuresidefloat
{\global\floatflagtrue
\global\sidefloatpagetotal \pagetotal % global
- \ifnum\sidefloattype<4
+ \ifnum\sidefloattype<\plusfour
\global \sidefloatwidth \zeropoint
- \else\ifnum\sidefloattype>5
+ \else\ifnum\sidefloattype>\plusfive
\global \sidefloatwidth \zeropoint
\else
\global \sidefloatwidth \wd\floatbox
@@ -742,14 +645,13 @@
\def\setsidefloat% nilling everypar saves time and redudant pos's
{% removed here dec 2001
% {\everypar\emptytoks\forgetall\verticalstrut\vskip-\struttotal}%
- \ifnum\sidefloattype=4 \kern\sidefloattopskip \fi
- \ifnum\sidefloattype=5 \kern\sidefloattopskip \fi
+ \ifnum\sidefloattype=\plusfour \kern\sidefloattopskip \fi
+ \ifnum\sidefloattype=\plusfive \kern\sidefloattopskip \fi
\edef\presidefloatdepth{\the\prevdepth}%
\nointerlineskip
\bgroup
\everypar\emptytoks
\parskip\zeropoint
- %\checksidefloatshift
\setsidefloatskips
\logsidefloat
\relax
@@ -840,7 +742,7 @@
\advance\!!counta -\sidefloatsidelines\relax
\advance\scratchcounter\!!counta
\dorecurse\!!counta
- {\ifnum\sidefloattype>4
+ {\ifnum\sidefloattype>\plusfour
\appendtoks \zeropoint \scratchdimen \to \scratchtoks
\else
\appendtoks \sidefloatwidth \scratchdimen \to \scratchtoks
@@ -850,7 +752,7 @@
\parshape \scratchcounter \the\scratchtoks \zeropoint \hsize\relax
\else
% new till here
- \hangindent \ifnum\sidefloattype>4 -\fi\sidefloatwidth
+ \hangindent \ifnum\sidefloattype>\plusfour -\fi\sidefloatwidth
\hangafter-\!!counta
\fi
\fi
@@ -864,7 +766,7 @@
\fi}
\def\resetsidefloatparagraph
- {\global\sidefloatparagraph\zerocount }
+ {\global\sidefloatparagraph\zerocount}
\def\dochecksidefloat
{\progresssidefloat
@@ -875,8 +777,7 @@
\fi
\parskip\ctxparskip}
-\def\checksidefloat
- {\dochecksidefloat}
+\let\checksidefloat\dochecksidefloat
\def\synchronizesidefloats
{\ifinner \else \checksidefloat \fi}
@@ -895,7 +796,7 @@
\ifdim\sidefloatprogress>\zeropoint \relax
\iffloatshort
\global\floatshortfalse
- \tosssidefloat
+ \vfill\eject % inline \tosssidefloat
\else
\kern\sidefloatprogress
\fi
@@ -925,7 +826,7 @@
% \let\OTRMULflushsidefloats \forgetsidefloats
% \let\OTRMULsynchronizesidefloats\forgetsidefloats
-\def\synchronizesidefloats{\OTRcommand\synchronizesidefloats}
-\def\flushsidefloats {\OTRcommand\flushsidefloats}
+\registerotrcommand\synchronizesidefloats % \def\synchronizesidefloats{\OTRcommand\synchronizesidefloats}
+\registerotrcommand\flushsidefloats % \def\flushsidefloats {\OTRcommand\flushsidefloats}
\protect \endinput
diff --git a/tex/context/base/ppchtex.mkiv b/tex/context/base/ppchtex.mkiv
index fb9e610e9..f0fc54bcc 100644
--- a/tex/context/base/ppchtex.mkiv
+++ b/tex/context/base/ppchtex.mkiv
@@ -296,7 +296,7 @@
\def\endlatexmathmodehack{$}$\@@dochemicalstyle\empty
\fi}
-\def\setsubscripts%
+\def\setsubscripts
{\beginlatexmathmodehack
\def\dosetsubscript##1##2##3%
{\dimen0=##3\fontexheight##2%
diff --git a/tex/context/base/pret-lua.lua b/tex/context/base/pret-lua.lua
index 81e02c360..3faf81081 100644
--- a/tex/context/base/pret-lua.lua
+++ b/tex/context/base/pret-lua.lua
@@ -14,30 +14,31 @@ local byte, sub, find, match = string.byte, string.sub, string.find, string.matc
local texsprint, texwrite = tex.sprint, tex.write
local ctxcatcodes = tex.ctxcatcodes
-buffers.visualizers.lua = buffers.visualizers.lua or { }
-buffers.visualizers.lua.identifiers = buffers.visualizers.lua.identifiers or { }
+local visualizer = buffers.newvisualizer("lua")
+
+visualizer.identifiers = { }
-- borrowed from scite
-buffers.visualizers.lua.identifiers.core = {
+visualizer.identifiers.core = {
"and", "break", "do", "else", "elseif", "end", "false", "for", "function",
"if", "in", "local", "nil", "not", "or", "repeat", "return", "then",
"true", "until", "while"
}
-buffers.visualizers.lua.identifiers.base = {
+visualizer.identifiers.base = {
"assert", "collectgarbage", "dofile", "error", "gcinfo", "loadfile",
"loadstring", "print", "rawget", "rawset", "require", "tonumber",
"tostring", "type", "unpack",
}
-buffers.visualizers.lua.identifiers.five = {
+visualizer.identifiers.five = {
"_G", "getfenv", "getmetatable", "ipairs", "loadlib", "next", "pairs",
"pcall", "rawequal", "setfenv", "setmetatable", "xpcall", "string", "table",
"math", "coroutine", "io", "os", "debug", "load", "module", "select"
}
-buffers.visualizers.lua.identifiers.libs = {
+visualizer.identifiers.libs = {
-- coroutine
"coroutine.create", "coroutine.resume", "coroutine.status", "coroutine.wrap",
"coroutine.yield", "coroutine.running",
@@ -70,20 +71,20 @@ buffers.visualizers.lua.identifiers.libs = {
local known_words = { }
-for k,v in pairs(buffers.visualizers.lua.identifiers) do
+for k,v in pairs(visualizer.identifiers) do
for _,w in pairs(v) do
known_words[w] = k
end
end
-buffers.visualizers.lua.styles = {
+visualizer.styles = {
core = "",
base = "\\sl ",
five = "\\sl ",
libs = "\\sl ",
}
-local styles = buffers.visualizers.lua.styles
+local styles = visualizer.styles
local colors = {
"prettyone",
@@ -123,14 +124,14 @@ end
local incomment, inlongstring = false, false
-function buffers.visualizers.lua.reset()
+function visualizer.reset()
incomment, inlongstring = false, false -- needs to be hooked into flusher
end
-- we will also provide a proper parser based pretty printer although normaly
-- a pretty printer should handle faulty code too (educational purposes)
-function buffers.visualizers.lua.flush_line(str, nested)
+function visualizer.flush_line(str, nested)
local state, instr, inesc, word = 0, false, false, nil
buffers.currentcolors = colors
local code, comment = match(str,"^(.-)%-%-%[%[(.*)$")
diff --git a/tex/context/base/pret-mp.lua b/tex/context/base/pret-mp.lua
index c4904e2d4..939065230 100644
--- a/tex/context/base/pret-mp.lua
+++ b/tex/context/base/pret-mp.lua
@@ -13,10 +13,11 @@ local utfbyte, utffind = utf.byte, utf.find
local texsprint, texwrite = tex.sprint, tex.write
local ctxcatcodes = tex.ctxcatcodes
-buffers.visualizers.mp = buffers.visualizers.mp or { }
-buffers.visualizers.mp.identifiers = buffers.visualizers.mp.identifiers or { }
+local visualizer = buffers.newvisualizer("mp")
-buffers.visualizers.mp.identifiers.primitives = {
+visualizer.identifiers = { }
+
+visualizer.identifiers.primitives = {
'charcode', 'day', 'linecap', 'linejoin', 'miterlimit', 'month', 'pausing',
'prologues', 'showstopping', 'time', 'tracingcapsules', 'tracingchoices',
'tracingcommands', 'tracingequations', 'tracinglostchars',
@@ -58,7 +59,7 @@ buffers.visualizers.mp.identifiers.primitives = {
'end', 'btex', 'etex', 'verbatimtex'
}
-buffers.visualizers.mp.identifiers.plain = {
+visualizer.identifiers.plain = {
'ahangle', 'ahlength', 'bboxmargin', 'defaultpen', 'defaultscale',
'labeloffset', 'background', 'currentpen', 'currentpicture', 'cuttings',
'defaultfont', 'extra_beginfig', 'extra_endfig',
@@ -85,7 +86,7 @@ buffers.visualizers.mp.identifiers.plain = {
'font_extra_space'
}
-buffers.visualizers.mp.identifiers.metafun = {
+visualizer.identifiers.metafun = {
'unitcircle', 'fulldiamond', 'unitdiamond',
'halfcircle', 'quartercircle',
'llcircle', 'lrcircle', 'urcircle', 'ulcircle',
@@ -107,13 +108,13 @@ buffers.visualizers.mp.identifiers.metafun = {
'loadfigure', 'externalfigure'
}
-buffers.visualizers.mp.styles = buffers.visualizers.mp.styles or {
+visualizer.styles = {
primitives = "",
plain = "\\sl",
metafun = "\\sl",
}
-local styles = buffers.visualizers.mp.styles
+local styles = visualizer.styles
-- btex .. etex
@@ -134,7 +135,7 @@ local states = {
local known_words = { }
-for k,v in pairs(buffers.visualizers.mp.identifiers) do
+for k,v in pairs(visualizer.identifiers) do
for _,w in pairs(v) do
known_words[w] = k
end
@@ -181,7 +182,7 @@ end
-- to be considered: visualizer => table [result, instr, incomment, word]
-function buffers.visualizers.mp.flush_line(str,nested)
+function visualizer.flush_line(str,nested)
local state, word, instr, intex, incomment = 0, nil, false, false, false
buffers.currentcolors = colors
for c in utfcharacters(str) do
diff --git a/tex/context/base/pret-tex.lua b/tex/context/base/pret-tex.lua
index 7b3c116a5..080075eb8 100644
--- a/tex/context/base/pret-tex.lua
+++ b/tex/context/base/pret-tex.lua
@@ -14,7 +14,7 @@ local rep = string.rep
local texsprint, texwrite = tex.sprint, tex.write
local ctxcatcodes, vrbcatcodes = tex.ctxcatcodes, tex.vrbcatcodes
-buffers.visualizers.tex = { }
+local visualizer = buffers.newvisualizer("tex")
local colors = {
"prettytwo",
@@ -36,7 +36,7 @@ local change_state, finish_state = buffers.change_state, buffers.finish_state
local chardata = characters.data
local is_letter = characters.is_letter
-function buffers.visualizers.tex.flush_line(str,nested)
+function visualizer.flush_line(str,nested)
local state, first = 0, false
buffers.currentcolors = colors
for c in utfcharacters(str) do
diff --git a/tex/context/base/prop-lay.mkiv b/tex/context/base/prop-lay.mkiv
index a34a71632..67e103ffb 100644
--- a/tex/context/base/prop-lay.mkiv
+++ b/tex/context/base/prop-lay.mkiv
@@ -96,14 +96,14 @@
%D \stoptext
\def\doinitializelayoutcomponent#1#2%
- {\ctxlua{backends.codeinjections.defineviewerlayer{
+ {\ctxlua{backends.codeinjections.defineviewerlayer{% this will move to the lua end i.e be merged with register
tag = "#1:#2",
title = "#1 #2",
visible = "\v!start",
kind = 0, % 1 == frozen
printable = "\v!yes"
}}%
- \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \ctxlua{tex.write(viewerlayers.register('#1:#2'))} }%
+ \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \ctxlua{tex.write(viewerlayers.register('#1:#2',true))}\relax}%
\expandafter\glet\csname\??ly>#1:#2\endcsname\layoutcomponentboxattribute}
\def\dosetlayoutcomponentattribute#1#2% make this faster
@@ -115,8 +115,6 @@
\def\doresetlayoutcomponentattribute
{\let\layoutcomponentboxattribute\empty}
-\let\startlayoutcomponent \gobbletwoarguments % obsolete
-\let\stoplayoutcomponent \relax % obsolete
\let\setlayoutcomponentattribute \gobbletwoarguments
\let\resetlayoutcomponentattribute\relax
\let\layoutcomponentboxattribute \empty
diff --git a/tex/context/base/s-pre-67.tex b/tex/context/base/s-pre-67.tex
new file mode 100644
index 000000000..541955432
--- /dev/null
+++ b/tex/context/base/s-pre-67.tex
@@ -0,0 +1,140 @@
+% todo: version of placement that also takes the sync node
+
+\usemodule[s][abr-02]
+\usemodule[s][pre-60]
+
+\definecolor[red:fullcolor] [r=1]
+\definecolor[red:lightcolor] [r=.5]
+\definecolor[red:darkcolor] [r=.375]
+
+\definecolor[green:fullcolor] [g=1]
+\definecolor[green:lightcolor] [g=.5]
+\definecolor[green:darkcolor] [g=.375]
+
+\definecolor[blue:fullcolor] [b=1]
+\definecolor[blue:lightcolor] [b=.5]
+\definecolor[blue:darkcolor] [b=.375]
+
+\definepalet[red-scheme] [fullcolor=red:fullcolor, lightcolor=red:lightcolor, darkcolor=red:darkcolor]
+\definepalet[green-scheme][fullcolor=green:fullcolor,lightcolor=green:lightcolor,darkcolor=green:darkcolor]
+\definepalet[blue-scheme] [fullcolor=blue:fullcolor, lightcolor=blue:lightcolor, darkcolor=blue:darkcolor]
+
+\setuppalet[red-scheme]
+
+\setupcolors
+ [textcolor=darkcolor]
+
+\setupinteraction
+ [color=darkcolor,
+ contrastcolor=darkcolor]
+
+\startuseMPgraphic{bullet}
+ path b, p ;
+ p := fullsquare scaled .5LineHeight ;
+ b := boundingbox p ;
+ p := p rotatedaround(center p, 45) ;
+ p := p shifted (0,-.125StrutDepth) ;
+ fill p withcolor \MPcolor{lightcolor} ;
+ setbounds currentpicture to b ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{bar}
+ path b, p ;
+ p := fullsquare scaled .25LineHeight ;
+ b := boundingbox p ;
+ p := p rotatedaround(center p, 45) ;
+ p := p shifted (0,+.25StrutDepth) ;
+ fill p withcolor \MPcolor{lightcolor} ;
+ setbounds currentpicture to b ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{page}
+ StartPage ;
+ fill Page enlarged 5mm withcolor .1[white,\MPcolor{fullcolor}] ;
+ interim linecap := butt ;
+ numeric h ; h := bbheight(Page)/4 ;
+ numeric w ; w := bbwidth(Page)/4 ;
+ h := h randomized(h) ;
+ w := w randomized(w) ;
+ draw
+ ulcorner Page shifted (0,-h) -- ulcorner Page -- ulcorner Page shifted (w,0)
+ withpen pensquare scaled .5cm
+ withcolor \MPcolor{lightcolor} ;
+ numeric h ; h := bbheight(Page)/4 ;
+ numeric w ; w := bbwidth(Page)/4 ;
+ h := h randomized(h) ;
+ w := w randomized(w) ;
+ draw
+ lrcorner Page shifted (0,h) -- lrcorner Page -- lrcorner Page shifted (-w,0)
+ withpen pensquare scaled .5cm
+ withcolor \MPcolor{lightcolor} ;
+ setbounds currentpicture to Page ;
+ StopPage ;
+\stopuseMPgraphic
+
+\defineoverlay[page][\useMPgraphic{page}]
+
+\definesymbol[1][\reuseMPgraphic{bullet}]
+\definesymbol[2][\reuseMPgraphic{bar}]
+
+\setupitemgroup[itemize][2][width=1em]
+
+\setuppapersize
+ [S6][S6]
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ header=0pt,
+ footer=0pt,
+ backspace=1cm,
+% topspace=1cm]
+ topspace=.5cm]
+
+\setupbackgrounds
+ [page]
+ [background=page]
+
+\setuphead
+ [chapter]
+ [command=\MyCommand,
+ before=,
+ after={\blank[disable]},
+ color=lightcolor,
+ style=\bfc]
+
+\definelayer
+ [title]
+ [width=\paperwidth,
+ height=\paperheight]
+
+\setupbackgrounds
+ [page]
+ [background={page,title}]
+
+\setupwhitespace
+ [big]
+
+\def\MyCommand#1#2%
+ {\setlayer[title][preset=rightbottom,x=.75cm,y=.5cm]{#2}}
+
+\def\titlepage#1#2%
+ {\startstandardmakeup
+ \definefont[LargeFont][Normal at 120pt]
+ \setlayerframed
+ [title]
+ [preset=lefttop,x=1cm,y=.25cm]
+ [align=flushleft,foregroundstyle=\LargeFont,offset=0pt,foregroundcolor=lightcolor,frame=off]
+ {#1}
+ \definefont[SmallFont][Normal at 60pt]
+ \setlayerframed
+ [title]
+ [preset=rightbottom,x=1cm,y=.5cm]
+ [align=flushright,foregroundstyle=\SmallFont,offset=0pt,foregroundcolor=lightcolor,frame=off]
+ {#2}
+ \stopstandardmakeup}
+
+\let\Title\title
+\let\TitlePage\titlepage
+
+\endinput
diff --git a/tex/context/base/scrn-int.mkiv b/tex/context/base/scrn-int.mkiv
index ddf6e5938..a68c374dd 100644
--- a/tex/context/base/scrn-int.mkiv
+++ b/tex/context/base/scrn-int.mkiv
@@ -227,14 +227,19 @@
\setvalue{\??cc:\c!location:\v!leftmargin }{\raisedcommentanchors\inleftmargin }
\setvalue{\??cc:\c!location:\v!rightmargin}{\raisedcommentanchors\inrightmargin}
+\let\flushcommentanchors\relax
+
\def\doflushcommentanchors
+ {\global\let\flushcommentanchors\relax
+ \ifvoid\commentbox\else\dodoflushcommentanchors\fi} % in everypar so indirect
+
+\def\dodoflushcommentanchors
{\executeifdefined{\??cc:\c!location:\@@cclocation}\hbox{\box\commentbox}}
\def\setupcomment
{\dodoubleargument\getparameters[\??cc]}
-\def\placecomments {\box\commentcollection} % when option=buffer
-\def\flushcommentanchors{\ifvoid\commentbox\else\doflushcommentanchors\fi} % in everypar so indirect
+\def\placecomments{\box\commentcollection} % when option=buffer
\def\doinsertcomment#1%
{\begingroup
@@ -270,7 +275,8 @@
\def\stopcomment
{\doif\@@ccstate\v!start
- {\global\setbox\commentbox\frozenhbox
+ {\global\let\flushcommentanchors\doflushcommentanchors
+ \global\setbox\commentbox\frozenhbox
{\hbox to \zeropoint{\struttedbox{\tbox{\doinsertcomment{\v!comment\v!buffer}}}\hss}%
\hskip\ifvoid\commentbox\@@ccmargin\else\@@ccdistance\fi
\box\commentbox}}%
@@ -583,7 +589,7 @@
\c!veroffset=\!!zeropoint,
\c!backspace=\backspace,
\c!topspace=\topspace,
- \c!option=\v!min,
+ \c!option=\v!auto,
\c!delay=\v!none]
\protect \endinput
diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua
index 23d39a110..76599c371 100644
--- a/tex/context/base/strc-doc.lua
+++ b/tex/context/base/strc-doc.lua
@@ -11,6 +11,7 @@ local format, gsub, find, concat = string.format, string.gsub, string.find, tabl
local texsprint, texwrite = tex.sprint, tex.write
local ctxcatcodes = tex.ctxcatcodes
+local variables = interfaces.variables
if not trackers then trackers = { register = function() end } end
@@ -41,6 +42,7 @@ local data
function documents.initialize()
data = {
numbers = { },
+ forced = { },
ownnumbers = { },
status = { },
checkers = { },
@@ -53,6 +55,7 @@ end
function documents.reset()
data.numbers = { }
+ data.forced = { }
data.ownnumbers = { }
data.status = { }
data.checkers = { }
@@ -183,8 +186,8 @@ end
function sections.somelevel(given)
-- old number
- local numbers, ownnumbers, status, olddepth = data.numbers, data.ownnumbers, data.status, data.depth
- local newdepth = tonumber(levelmap[given.metadata.name] or (olddepth > 0 and olddepth) or 1)
+ local numbers, ownnumbers, forced, status, olddepth = data.numbers, data.ownnumbers, data.forced, data.status, data.depth
+ local newdepth = tonumber(levelmap[given.metadata.name] or (olddepth > 0 and olddepth) or 1) -- hm, levelmap only works for section-*
local directives = given.directives
local resetset = (directives and directives.resetset) or ""
local resetter = sets.getall("structure:resets",data.block,resetset)
@@ -234,17 +237,30 @@ function sections.somelevel(given)
-- new number
olddepth = newdepth
if given.metadata.increment then
- if numbers[newdepth] then
- numbers[newdepth] = numbers[newdepth] + 1
+ local oldn, newn = numbers[newdepth], 0
+ local fd = forced[newdepth]
+ if fd then
+ if fd[1] == "add" then
+ newn = oldn + fd[2] + 1
+ else
+ newn = fd[2] + 1
+ end
+ if newn < 0 then
+ newn = 1 -- maybe zero is nicer
+ end
+ forced[newdepth] = nil
+ elseif newn then
+ newn = oldn + 1
else
local s = tonumber(sets.get("structure:resets",data.block,resetset,newdepth))
--~ logs.report("structure =","old: %s, new:%s, reset: %s (%s: %s)",olddepth,newdepth,s,resetset,table.concat(resetter,","))
if not s or s == 0 then
- numbers[newdepth] = numbers[newdepth] or 0
+ newn = oldn or 0
else
- numbers[newdepth] = s - 1
+ newn = s - 1
end
end
+ numbers[newdepth] = newn
end
status[newdepth] = given or { }
for k, v in pairs(data.checkers) do
@@ -290,19 +306,16 @@ function sections.writestatus()
end
function sections.setnumber(depth,n)
- local numbers, depth = data.numbers, data.depth
- local d = numbers[depth]
+ local forced, depth, new = data.forced, depth or data.depth, tonumber(n)
if type(n) == "string" then
if n:find("^[%+%-]") then
- d = d + tonumber(n)
+ forced[depth] = { "add", new }
else
- d = tonumber(n)
+ forced[depth] = { "set", new }
end
else
- d = n
+ forced[depth] = { "set", new }
end
- numbers[depth] = d
- -- todo reset
end
function sections.number_at_depth(depth)
@@ -322,8 +335,9 @@ function sections.cct()
texsprint((metadata and metadata.catcodes) or ctxcatcodes)
end
-function sections.structuredata(key,default,honorcatcodetable)
- local data = data.status[data.depth]
+function sections.structuredata(depth,key,default,honorcatcodetable) -- todo: spec table and then also depth
+ if not depth or depth == 0 then depth = data.depth end
+ local data = data.status[depth]
local d = data
for k in key:gmatch("([^.]+)") do
if type(d) == "table" then
@@ -334,9 +348,16 @@ function sections.structuredata(key,default,honorcatcodetable)
end
end
if type(d) == "string" then
- if honorcatcodetable then
+ if honorcatcodetable == true or honorcatcodetable == variables.auto then
local metadata = data.metadata
texsprint((metadata and metadata.catcodes) or ctxcatcodes,d)
+ elseif not honorcatcodetable then
+ texsprint(ctxcatcodes,d)
+ elseif type(honorcatcodetable) == "number" then
+ texsprint(honorcatcodetable,d)
+ elseif type(honorcatcodetable) == "string" and honorcatcodetable ~= "" then
+ honorcatcodetable = tex[honorcatcodetable] or ctxcatcodes-- we should move ctxcatcodes to another table, ctx or so
+ texsprint(honorcatcodetable,d)
else
texsprint(ctxcatcodes,d)
end
@@ -348,9 +369,10 @@ function sections.structuredata(key,default,honorcatcodetable)
end
end
-function sections.userdata(key,default)
- if data.depth > 0 then
- local userdata = data.status[data.depth]
+function sections.userdata(depth,key,default)
+ if not depth or depth == 0 then depth = data.depth end
+ if depth > 0 then
+ local userdata = data.status[depth]
userdata = userdata and userdata.userdata
userdata = (userdata and userdata[key]) or default
if userdata then
@@ -398,6 +420,10 @@ end
-- \section{bla 2} \subsection{bla 2 1} \subsection{bla 2 2}
-- }
+-- sign=all => also zero and negative
+-- sign=positive => also zero
+-- sign=hang => llap sign
+
function sections.typesetnumber(entry,kind,...) -- kind='section','number','prefix'
if entry and entry.hidenumber ~= true then -- can be nil
local separatorset = ""
@@ -407,7 +433,8 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref
local connector = ""
local set = ""
local segments = ""
- for _, data in ipairs { ... } do
+ local criterium = ""
+ for _, data in ipairs { ... } do -- can be multiple parametersets
if data then
if separatorset == "" then separatorset = data.separatorset or "" end
if conversionset == "" then conversionset = data.conversionset or "" end
@@ -416,15 +443,26 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref
if connector == "" then connector = data.connector or "" end
if set == "" then set = data.set or "" end
if segments == "" then segments = data.segments or "" end
+ if criterium == "" then criterium = data.criterium or "" end
end
end
- if separatorset == "" then separatorset = "default" end
- if conversionset == "" then conversionset = "default" end
- if conversion == "" then conversion = nil end
- if stopper == "" then stopper = nil end
- if connector == "" then connector = nil end
- if set == "" then set = "default" end
- if segments == "" then segments = nil end
+ if separatorset == "" then separatorset = "default" end
+ if conversionset == "" then conversionset = "default" end
+ if conversion == "" then conversion = nil end
+ if stopper == "" then stopper = nil end
+ if connector == "" then connector = nil end
+ if set == "" then set = "default" end
+ if segments == "" then segments = nil end
+ --
+ if criterium == variables.strict then
+ criterium = 0
+ elseif criterium == variables.positive then
+ criterium = -1
+ elseif criterium == variables.all then
+ criterium = -1000000
+ else
+ criterium = 0
+ end
--
local firstprefix, lastprefix = 0, 100
if segments then
@@ -448,7 +486,7 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref
local function process(index) -- move to outer
local number = numbers and (numbers[index] or 0)
local ownnumber = ownnumbers and ownnumbers[index] or ""
- if number > 0 or (ownnumber ~= "") then
+ if number > criterium or (ownnumber ~= "") then
local block = entry.block
if preceding then
local separator = sets.get("structure:separators",b,s,preceding,".")
diff --git a/tex/context/base/strc-doc.mkiv b/tex/context/base/strc-doc.mkiv
index 637248929..4ff87b742 100644
--- a/tex/context/base/strc-doc.mkiv
+++ b/tex/context/base/strc-doc.mkiv
@@ -39,10 +39,13 @@
\c!sectionstopper=,\c!sectionsegments=,
\c!sectionresetset=,\c!reference=,
\c!expansion=\v!no,
+ \s!catcodes=,
\c!saveinlist=\v!yes,
\c!command=\showstructuredata]
% maybe flags for list, bm, mark
+%
+% hm messed up
\def\dostructurecomponent[#1][#2]% #1=interfaced-settings, #2=optional user data (not yet supported)
{\begingroup
@@ -56,18 +59,16 @@
\else
\edef\currentstructureexpansion{\structureparameter\c!expansion}
\fi
-
\ifx\currentstructureexpansion\s!xml
- % goes via lua anyway
- \xdef\currentstructuretitle {\detokenizedstructureparameter\c!title}%
- \xdef\currentstructurebookmark{\detokenizedstructureparameter\c!bookmark}%
- \xdef\currentstructuremarking {\detokenizedstructureparameter\c!marking}%
- \xdef\currentstructurelist {\detokenizedstructureparameter\c!list}%
+ % maybe just title xml and inherit xml then in which case we have to test
+ % when typesetting marks, lists, refs etc (+specific env)
+ \xdef\currentstructuretitle {\detokenizedstructureparameter\c!title}% maybe xml
+ \xdef\currentstructurebookmark{\detokenizedstructureparameter\c!bookmark}% no xml
+ \xdef\currentstructuremarking {\detokenizedstructureparameter\c!marking}% no xml
+ \xdef\currentstructurelist {\detokenizedstructureparameter\c!list}% no xml
\ifx\currentstructurelist\empty
- \globallet\currentstructurelist\currentstructuretitle
- \else
\xmlstartraw
- \xdef\currentstructurelist{\structureparameter\c!list}%
+ \xdef\currentstructurelist{\structureparameter\c!title}%
\xmlstopraw
\fi
%
@@ -199,9 +200,11 @@ hidenumber = \ifx\currentstructureshownumber\v!no true\else nil\fi, % titles
% \stopchapter
% \stoptext
-\def\structurevariable #1{\ctxlua{structure.sections.structuredata("#1")}}
-\def\structureuservariable#1{\ctxlua{structure.sections.userdata("#1")}}
-\def\structurenumber {\ctxlua{structure.sections.fullnumber()}}
-\def\structurecatcodedget #1{\ctxlua{structure.sections.structuredata("#1",nil,true)}} % bad name
+\def\structurevariable #1{\ctxlua{structure.sections.structuredata(nil,"#1")}}
+\def\structureuservariable #1{\ctxlua{structure.sections.userdata(nil,"#1")}}
+\def\structurenumber {\ctxlua{structure.sections.fullnumber()}}
+\def\structurecatcodedget #1{\ctxlua{structure.sections.structuredata(nil,"#1",nil,true)}} % bad name
+\def\structuregivencatcodedget#1#2{\ctxlua{structure.sections.structuredata(nil,"#1",nil,\number#2)}} % bad name
+\def\structureautocatcodedget #1#2{\ctxlua{structure.sections.structuredata(nil,"#1",nil,"#2")}}
\protect \endinput
diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv
index fc0b9ef3b..bb19146a1 100644
--- a/tex/context/base/strc-flt.mkiv
+++ b/tex/context/base/strc-flt.mkiv
@@ -2092,16 +2092,16 @@
\installfloathandler {fxtb} \someslotfloat
\installfloathandler {fxbt} \someslotfloat
-\def\placesomeslotfloat {\OTRcommand\someslotfloat}
-\def\placesomeherefloat {\OTRcommand\someherefloat}
-\def\placesomefixdfloat {\OTRcommand\somefixdfloat}
-\def\placesomepagefloat {\OTRcommand\somepagefloat}
-\def\placesomeleftpagefloat {\OTRcommand\someleftpagefloat}
-\def\placesomerightpagefloat{\OTRcommand\somerightpagefloat}
-\def\placesometopsfloat {\OTRcommand\sometopsfloat}
-\def\placesomebotsfloat {\OTRcommand\somebotsfloat}
-\def\placesomesidefloat {\OTRcommand\somesidefloat}
-\def\placesomefacefloat {\OTRcommand\somefacefloat}
+\registerotrcommand\placesomeslotfloat % \def\placesomeslotfloat {\OTRcommand\someslotfloat}
+\registerotrcommand\placesomeherefloat % \def\placesomeherefloat {\OTRcommand\someherefloat}
+\registerotrcommand\placesomefixdfloat % \def\placesomefixdfloat {\OTRcommand\somefixdfloat}
+\registerotrcommand\placesomepagefloat % \def\placesomepagefloat {\OTRcommand\somepagefloat}
+\registerotrcommand\placesomeleftpagefloat % \def\placesomeleftpagefloat {\OTRcommand\someleftpagefloat}
+\registerotrcommand\placesomerightpagefloat % \def\placesomerightpagefloat{\OTRcommand\somerightpagefloat}
+\registerotrcommand\placesometopsfloat % \def\placesometopsfloat {\OTRcommand\sometopsfloat}
+\registerotrcommand\placesomebotsfloat % \def\placesomebotsfloat {\OTRcommand\somebotsfloat}
+\registerotrcommand\placesomesidefloat % \def\placesomesidefloat {\OTRcommand\somesidefloat}
+\registerotrcommand\placesomefacefloat % \def\placesomefacefloat {\OTRcommand\somefacefloat}
\def\someleftsidefloat [#1]{\somesidefloat[#1]\presetindentation}
\def\somerightsidefloat [#1]{\somesidefloat[#1]}
diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv
index 2abe54d50..6799a02a6 100644
--- a/tex/context/base/strc-itm.mkiv
+++ b/tex/context/base/strc-itm.mkiv
@@ -179,6 +179,8 @@
\definestructurecounter[itemgroup:#1]%
\popmacro\currentitemgroup}}
+\newtoks\everysetupitemgroup
+
\def\setupitemgroups % [#1]
{\dodoubleargument\getparameters[\??oo]} % [#1]
@@ -347,6 +349,7 @@
\def\currentitemgroup{#1}%
\dododosetupitemgroup[#2][#3]%
\doifsomething{#4}{\dododosetupitemgroup[#2][#4]}%
+ \the\everysetupitemgroup
\popmacro\currentitemgroup}
\def\dosetupitemgroup[#1][#2][#3][#4]%
@@ -383,6 +386,7 @@
\setupstructurecounter
[\currentitemgroupcounter]
[\c!prefix=\v!no,
+ \c!criterium=\getitemparameter\currentitemlevel\c!criterium,
\c!numberorder=\ifconditional\reverselistitem\v!reverse\else\v!normal\fi,
\c!numberstopper=\expdoif{\getitemparameter\currentitemlevel\c!placestopper}\v!yes{\getitemparameter\currentitemlevel\c!stopper},
%\c!numberseparatorset=,
@@ -1180,6 +1184,7 @@
\c!lefttext=(,
\c!righttext=),
\c!start=1,
+ \c!criterium=\v!all, % permits 0 and negative numbers
%\c!option=,
\c!command=\defaultitemcommand,
\c!symbol=\currentitemlevel]
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index 37c520306..47855e3dd 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -13,6 +13,7 @@ if not modules then modules = { } end modules ['strc-lst'] = {
local format, tonumber = string.format, tonumber
local texsprint, texprint, texwrite, texcount = tex.sprint, tex.print, tex.write, tex.count
+local insert, remove = table.insert, table.remove
local ctxcatcodes = tex.ctxcatcodes
@@ -117,7 +118,19 @@ end
-- we can use level instead but we can also decide to remove level from the metadata
--- we need level instead of cnumbers and we also need to deal with inbetween
+local nesting = { }
+
+function lists.pushnesting(i)
+ local r = lists.result[i]
+ local name = r.metadata.name
+ local n = (r and r.numberdata.numbers[sections.getlevel(name)]) or 0
+ insert(nesting, { number = n, name = name, result = lists.result })
+end
+
+function lists.popnesting()
+ local old = remove(nesting)
+ lists.result = old.result
+end
local function filter_collected(names, criterium, number, collected)
local numbers, depth = documents.data.numbers, documents.data.depth
@@ -222,8 +235,11 @@ local function filter_collected(names, criterium, number, collected)
end
end
end
- elseif criterium == variables["local"] then
- if sections.autodepth(documents.data.numbers) == 0 then
+ elseif criterium == variables["local"] then -- not yet ok
+ local nested = nesting[#nesting]
+ if nested then
+ return filter_collected(names,nested.name,nested.number,collected)
+ elseif sections.autodepth(documents.data.numbers) == 0 then
return filter_collected(names,variables.all,number,collected)
else
return filter_collected(names,variables.current,number,collected)
@@ -312,7 +328,8 @@ function lists.title(name,n,tag) -- tag becomes obsolete
if data then
local titledata = data.titledata
if titledata then
- texsprint(ctxcatcodes,titledata[tag] or titledata.list or titledata.title or "")
+ helpers.title(titledata[tag] or titledata.list or titledata.title or "",data.metadata)
+--~ texsprint(ctxcatcodes,titledata[tag] or titledata.list or titledata.title or "")
end
end
end
@@ -322,7 +339,8 @@ function lists.savedtitle(name,n,tag)
if data then
local titledata = data.titledata
if titledata then
- texsprint(ctxcatcodes,titledata[tag] or titledata.title or "")
+ helpers.title(titledata[tag] or titledata.title or "",data.metadata)
+--~ texsprint(ctxcatcodes,titledata[tag] or titledata.title or "")
end
end
end
diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv
index e56f492c9..440047a42 100644
--- a/tex/context/base/strc-lst.mkiv
+++ b/tex/context/base/strc-lst.mkiv
@@ -149,8 +149,17 @@
\installstructurelistprocessor\s!default
{no list method}
+% push pop test:
+%
+% \starttext
+% \placelist[chapter] [after={\placelist[section][criterium=local]}]
+% \chapter{One} \section{Alpha} \section{Beta}
+% \chapter{Two} \section{First} \section{Second}
+% \stoptext
+
\def\processlistofstructure#1#2#3% name, method, n
- {\edef\currentlist {#1}%
+ {\ctxlua{structure.lists.pushnesting(#3)}%
+ \edef\currentlist {#1}%
\edef\currentlistmethod{#2}%
\edef\currentlistindex {#3}%
\csname\@@structurelistprocess
@@ -158,7 +167,8 @@
\ifcsname\@@structurelistprocess\currentlistmethod \endcsname\currentlistmethod \else
\ifcsname\@@structurelistprocess\currentlist \endcsname\currentlist \else
\s!default \fi\fi\fi
- \endcsname}
+ \endcsname
+ \ctxlua{structure.lists.popnesting()}}
% \installstructcurelistprocessor{pubs:userdata}
% {\ctxlua{structure.lists.userdata("\currentlist",\currentlistindex,"bibref")}}
@@ -333,7 +343,7 @@
\edef\currentlist{\firststructureelementinlist{#1}}%
\the\everystructurelist
\doif{\listparameter\c!coupling}\v!on{\startlistreferences{#1}}%
- \placestructurelist{#1}{\listparameter\c!criterium}{\listparameter\c!number}%
+ \placestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}%
\stoplistreferences
\endgroup
\dosetlistmode}
@@ -422,7 +432,7 @@
\def\listsymbol@default
{% prefix = no, none, yes
\strut
- \doif{\listparameter\c!label}\v!yes{\leftlabeltext\currentlist}%
+ \doif{\listparameter\c!label}\v!yes{\leftlabeltext\currentlist}% we can use the new command that does left and right
\currentlistnumber
\listparameter\c!stopper
\doif{\listparameter\c!label}\v!yes{\rightlabeltext\currentlist}}
@@ -791,7 +801,7 @@
\dosetuplist[#1][#2]%
\edef\currentlist{\firststructureelementinlist{#1}}%
\the\everystructurelist
- \analysestructurelist{#1}{\listparameter\c!criterium}{\listparameter\c!number}%
+ \analysestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}%
\xdef\utilitylistlength{\structurelistsize}%
\endgroup
\dosetlistmode}
diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv
index d432deb30..4b033cbf9 100644
--- a/tex/context/base/strc-not.mkiv
+++ b/tex/context/base/strc-not.mkiv
@@ -796,23 +796,24 @@
\def\postponenotes
{\ifconditional\postponingnotes\else
\global\settrue\postponingnotes
+ \global\let\flushnotes\doflushnotes
\ctxlua{structure.notes.postpone()}%
\fi}
-\def\flushnotes
+\let\flushnotes\relax
+
+\def\doflushnotes
{\ifconditional\postponingnotes
- \flushnotesindeed
+ \begingroup
+ \let\flushnotes \relax
+ \let\postponenotes\relax
+ \ctxlua{structure.notes.flushpostponed()}% this also resets the states !
+ \global\setfalse\postponednote
+ \global\setfalse\postponingnotes
+ \global\let\flushnotes\relax
+ \endgroup
\fi}
-\def\flushnotesindeed
- {\begingroup
- \let\flushnotes \relax
- \let\postponenotes\relax
- \ctxlua{structure.notes.flushpostponed()}% this also resets the states !
- \global\setfalse\postponednote
- \global\setfalse\postponingnotes
- \endgroup}
-
%D \macros
%D {startlocalfootnotes,placelocalfootnotes}
%D
diff --git a/tex/context/base/strc-num.lua b/tex/context/base/strc-num.lua
index b80c27f3c..431200b39 100644
--- a/tex/context/base/strc-num.lua
+++ b/tex/context/base/strc-num.lua
@@ -121,7 +121,7 @@ local function allocate(name,i)
cd = {
level = 1,
numbers = nil,
- state = interfaces.variables.start, -- true
+ state = variables.start, -- true
data = { }
}
tobesaved[name] = { }
@@ -245,7 +245,7 @@ function counters.setvalue(name,tag,value)
end
function counters.setstate(name,value) -- true/false
- value = interfaces.variables[value]
+ value = variables[value]
if value then
counters.setvalue(name,"state",value)
end
@@ -335,7 +335,7 @@ end
function counters.add(name,n,delta)
local cd = counterdata[name]
- if cd and cd.state == interfaces.variables.start then
+ if cd and cd.state == variables.start then
local data = cd.data
local d = allocate(name,n)
d.number = (d.number or d.start or 0) + delta*(d.step or 0)
@@ -382,12 +382,11 @@ function counters.converted(name,spec) -- name can be number and reference to st
cd = counterdata[name]
end
if cd then
- local vars = interfaces.variables
local spec = spec or { }
local numbers, ownnumbers = { }, { }
- local reverse = spec.order == vars["reverse"]
+ local reverse = spec.order == variables["reverse"]
local kind = spec.type or "number"
- local v_first, v_next, v_previous, v_last = vars.first, vars.next, vars.previous, vars.last
+ local v_first, v_next, v_previous, v_last = variables.first, variables.next, variables.previous, variables.last
local data = cd.data
for k=1,#data do
local v = data[k]
diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv
index eb2f441fd..9f6733a6c 100644
--- a/tex/context/base/strc-num.mkiv
+++ b/tex/context/base/strc-num.mkiv
@@ -218,6 +218,7 @@
stopper = \!!bs\structurecounterparameter{#1}\c!numberstopper\!!es,
segments = "\structurecounterparameter{#1}\c!numbersegments",
type = "\structurecounterparameter{#1}\c!type",
+ criterium = "\structurecounterparameter{#1}\c!criterium", % might change if we also want this with sectioning
}
)}%
\endgroup}
diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv
index 3cd0def78..e010b0ad3 100644
--- a/tex/context/base/strc-ref.mkiv
+++ b/tex/context/base/strc-ref.mkiv
@@ -833,7 +833,7 @@
%D Instead of a text, one can specify a label, which should
%D be defined with \type {\setuplabeltext}.
-% todo: inherit
+% todo: inherit; probably not yet mkiv okay
\def\definereferenceformat
{\dodoubleargument\dodefinereferenceformat}
@@ -871,25 +871,91 @@
\let\textofreference \relax
% fails on metafun {\leftofreference#1\ignorespaces#3\removeunwantedspaces\rightofreference}{#2}[#4]%
+%
+% \def\dodododoinatreference#1#2#3[#4]% no \removeunwantedspaces (fails on metafun)
+% {\ifx\next\bgroup
+% \dododododoinatreference{\leftofreference#1\ignorespaces#3\rightofreference}{#2}[#4]%
+% \else
+% \dododododoinatreference{\leftofreference#1\rightofreference}{#2#3}[#4]%
+% \fi}
+%
+% \def\dododododoinatreference#1#2[#3]%
+% {\dontleavehmode % replaces \leaveoutervmode
+% \begingroup
+% \postponenotes
+% \doifreferencefoundelse{#3}
+% {\doifelsenothing{#1}\dosymbolreference\dowantedreference{#1}{#2}[#3]}%
+% {\dounknownreference{#1}{#2}[#3]}%
+% \endgroup}
+
+% \starttext
+% \definereferenceformat[inxx] [left=(,right=),text=txt]
+% \setupinteraction[state=start]
+% \chapter[one]{xx}
+% [\goto{state}[file(mk-last-state)]]
+% [\goto{state} [file(mk-last-state)]]
+% [\at{page} [one]]
+% [\at{page}[one]]
+% [\at{page}{okay}[one]]
+% [\inxx{a}{b}[one]]
+% \stoptext
+
+\unexpanded\def\dospecialin{\let\currentreferencecontent\currentreferencenumber\doinatreference}
+\unexpanded\def\dospecialat{\let\currentreferencecontent\currentreferencepage \doinatreference}
+
+\newtoks\leftreferencetoks
+\newtoks\rightreferencetoks
+
+\def\doinatreference
+ {\futurelet\next\doinatreferenceone}
+
+\def\doinatreferenceone
+ {\ifx\next\bgroup
+ \afterassignment\doinatreferenceonetwo
+ \expandafter\leftreferencetoks
+ \else
+ \leftreferencetoks\emptytoks
+ \expandafter\dodoinatreferencenone
+ \fi}
+
+\def\doinatreferenceonetwo
+ {\futurelet\next\doinatreferencetwo}
-\def\dodododoinatreference#1#2#3[#4]% no \removeunwantedspaces (fails on metafun)
+\def\doinatreferencetwo
{\ifx\next\bgroup
- \dododododoinatreference{\leftofreference#1\ignorespaces#3\rightofreference}{#2}[#4]%
+ \afterassignment\dodoinatreferenceboth
+ \expandafter\rightreferencetoks
\else
- \dododododoinatreference{\leftofreference#1\rightofreference}{#2#3}[#4]%
+ \rightreferencetoks\emptytoks
+ \expandafter\dodoinatreferenceleft
\fi}
-\let\dosymbolreference\dowantedreference
+\def\dodoinatreferencenone
+ {\dodoinatreferenceindeed
+ {\leftofreference\currentreferencecontent\rightofreference}
+ {}}
+
+\def\dodoinatreferenceleft
+ {\dodoinatreferenceindeed
+ {\leftofreference\currentreferencecontent\rightofreference}
+ {\the\leftreferencetoks}}
-\def\dododododoinatreference#1#2[#3]%
+\def\dodoinatreferenceboth
+ {\dodoinatreferenceindeed
+ {\leftofreference\currentreferencecontent\the\rightreferencetoks\rightofreference}
+ {\the\leftreferencetoks}}
+
+\def\dodoinatreferenceindeed#1#2#3[#4]% #3 gobbles space
{\dontleavehmode % replaces \leaveoutervmode
\begingroup
\postponenotes
- \doifreferencefoundelse{#3}
- {\doifelsenothing{#1}\dosymbolreference\dowantedreference{#1}{#2}[#3]}%
- {\dounknownreference{#1}{#2}[#3]}%
+ \doifreferencefoundelse{#4}
+ {\doifelsenothing{#1}\dosymbolreference\dowantedreference{#1}{#2}[#4]}%
+ {\dounknownreference{#1}{#2}[#4]}%
\endgroup}
+\let\dosymbolreference\dowantedreference
+
%D In interactive documents going to a specific location is not
%D bound to cross references. The \type{\goto} commands can be
%D used to let users access another part of the document. In
@@ -906,6 +972,12 @@
%D split at spaces. This means that, although hyphenation is
%D prevented, long references can cross line endings.
+% \starttext
+% \setupinteraction[state=start]
+% [\goto{state}[file(mk-last-state)]]
+% [\goto{state} [file(mk-last-state)]]
+% \stoptext
+
\newconditional\uselocationstrut \settrue\uselocationstrut
\def\extrareferencearguments{\luaconditional\highlighthyperlinks,\luaconditional\gotonewwindow,"\currentviewerlayer"}
@@ -938,33 +1010,33 @@
#1%
\endgroup}
-\def\dogoto#1[#2]%
+\def\dogoto#1#2[#3]% #2 gobbles spaces after #1 so that \goto{xx} [yy] works ok
{\dontleavehmode
\begingroup
\attribute\referenceattribute\attributeunsetvalue
\iflocation
- \ctxlua{jobreferences.doifelse("\referenceprefix","#2",\extrareferencearguments)}%
+ \ctxlua{jobreferences.doifelse("\referenceprefix","#3",\extrareferencearguments)}%
{\expandtexincurrentreference
\ctxlua{jobreferences.injectcurrentset(\number\ht\strutbox,\number\dp\strutbox)}%
\setlocationattributes\??ia
\setstrut % can be option
\attribute\referenceattribute\lastreferenceattribute}%
- {\unknownreference{#2}}%
+ {\unknownreference{#3}}%
\fi
#1%
\endgroup}
-\def\dogotohtdp#1[#2]%
+\def\dogotohtdp#1#2[#3]% #2 gobbles spaces after #1 so that \goto{xx} [yy] works ok
{\dontleavehmode
\begingroup
\attribute\referenceattribute\attributeunsetvalue
\iflocation
- \ctxlua{jobreferences.doifelse("\referenceprefix","#2",\extrareferencearguments)}%
+ \ctxlua{jobreferences.doifelse("\referenceprefix","#3",\extrareferencearguments)}%
{\expandtexincurrentreference
\ctxlua{jobreferences.injectcurrentset(\number\dimexpr\@@iaheight\relax,\number\dimexpr\@@iadepth\relax)}%
\setlocationattributes\??ia
\attribute\referenceattribute\lastreferenceattribute}%
- {\unknownreference{#2}}%
+ {\unknownreference{#3}}%
\fi
#1%
\endgroup}
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index fef1dd01e..d64af6a53 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -39,13 +39,14 @@
% \section{test} \subsection{test} \subsection{test}
% \section{test} \subsection{test} \subsection{test}
-% lua interface
+% lua interface / names and interface might change
-\def\setstructurelevel #1#2{\ctxlua{structure.sections.setlevel("#1","#2")}} % name, level|parent
-\def\getstructurelevel #1{\ctxlua{structure.sections.getcurrentlevel("#1")}}% name
-\def\setstructurenumber #1#2{\ctxlua{structure.sections.setnumber(#1,"#2")}} % level, number (+/-)
-\def\getstructurenumber #1{\ctxlua{structure.sections.getnumber(#1)}} % level
-\def\getfullstructurenumber#1{\ctxlua{structure.sections.fullnumber(#1)}} % level
+\def\setstructurelevel #1#2{\ctxlua{structure.sections.setlevel("#1","#2")}} % name, level|parent
+\def\getstructurelevel #1{\ctxlua{structure.sections.getcurrentlevel("#1")}}% name
+\def\setstructurenumber #1#2{\ctxlua{structure.sections.setnumber(#1,"#2")}} % level, number (+/-)
+\def\getstructurenumber #1{\ctxlua{structure.sections.getnumber(#1)}} % level
+\def\getfullstructurenumber #1{\ctxlua{structure.sections.fullnumber(#1)}} % level
+\def\getspecificstructuretitle#1{\ctxlua{structure.sections.structuredata(#1,"titledata.title",nil,"\structureheadparameter\s!catcodes")}}%
% interface
@@ -193,8 +194,9 @@
\doifelse{\structureheadparameter\c!ownnumber}\v!yes
{\setevalue\currentstructurehead{\noexpand\dohandlestructureheadown[\currentstructurehead]}}
{\setevalue\currentstructurehead{\noexpand\dohandlestructureheadnop[\currentstructurehead]}}%
+ \setevalue{\e!next \currentstructurehead}{\noexpand\donextstructurehead [\currentstructurehead]}%
\setevalue{\e!start\currentstructurehead}{\noexpand\dostartstructurehead[\currentstructurehead]}%
- \setevalue{\e!stop\currentstructurehead }{\noexpand\dostopstructurehead[\currentstructurehead]}%
+ \setevalue{\e!stop \currentstructurehead}{\noexpand\dostopstructurehead [\currentstructurehead]}%
\to \everystructureheadsetup
% todo, check if section is defined
@@ -240,6 +242,11 @@
\xdef\currentstructurehead{#1}% recover
\the\everyafterstructurehead}
+\def\donextstructurehead[#1][#2][#3]%
+ {\setfalse\currentstructureown
+ \xdef\currentstructurehead{#1}%
+ \dohandlestructurehead{#1}{#2}{#3}} % name -- -- -- userdata
+
% \newconditional\structurereversesectionnumbers % todo: key/val
\newconditional\structureheadtolist
@@ -332,6 +339,9 @@
\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo
\def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode!
+\unexpanded\def\fullstructureheadtitle
+ {\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}}
+
\let\currentstructurehead \empty
\let\currentstructureheadcoupling\empty
\let\currentstructureheadsection \empty
@@ -364,23 +374,32 @@
[#3]%
\reportcurrentstructure}
-\unexpanded\def\placeheadtext {\doquintupleempty\doplaceheadtextornumber[\c!textstyle] [\c!textcolor] [\empty]}
-\unexpanded\def\placeheadnumber{\doquintupleempty\doplaceheadtextornumber[\c!numberstyle][\c!numbercolor][\v!number]}
+\unexpanded\def\placeheadtext {\dosingleempty\doplaceheadtext } % use with care
+\unexpanded\def\placeheadnumber{\dosingleempty\doplaceheadnumber} % use with care
-\def\doplaceheadtextornumber[#1][#2][#3][#4][#5]%
+\def\doplaceheadtext[#1]%
{\dontleavehmode
\begingroup
- \xdef\currentstructurehead {\iffifthargument#5\else#4\fi}%
- \xdef\currentstructureheadcoupling{\structuresectionheadcoupling\currentstructurehead}%
- \xdef\currentstructureheadsection {\structuresectionheadsection \currentstructureheadcoupling}%
- \xdef\currentstructureheadlevel {\structuresectionlevel \currentstructureheadsection}%
+ \edef\currentstructurehead{#1}%
\dosetstructureheadattributes\c!style\c!color
- \dosetstructureheadattributes#1#2%
+ \dosetstructureheadattributes\c!textstyle\c!textcolor
\dontconvertfont
\setupinterlinespace
- % temp hack most be fixed (see s-pre-61)
- % \begstrut\getmarking[#4#3]\endstrut
- \doifelse{#3}\v!number\fullstructureheadnumber\fullstructureheadtitle
+ \relax
+ \getspecificstructuretitle{\thenamedstructureheadlevel{#1}}%
+ \endgraf
+ \endgroup}
+
+\def\doplaceheadnumber[#1]%
+ {\dontleavehmode
+ \begingroup
+ \edef\currentstructurehead{#1}%
+ \dosetstructureheadattributes\c!style\c!color
+ \dosetstructureheadattributes\c!numberstyle\c!numbercolor
+ \dontconvertfont
+ \setupinterlinespace
+ \relax
+ \getfullstructurenumber{\thenamedstructureheadlevel{#1}}%
\endgraf
\endgroup}
@@ -464,15 +483,15 @@
% typesetting
-\def\placestructureheadnumbertext
+\def\placestructureheadnumbertext % dummy, will be overloaded
{\getstructureheadnumber/\getstructureheadtitle
\getstructureheadsyncs}
-\def\placestructureheadtext
+\def\placestructureheadtext % dummy, will be overloaded
{\getstructureheadtitle
\getstructureheadsyncs}
-\def\placestructureheadnothing
+\def\placestructureheadnothing % dummy, will be overloaded
{\getstructureheadsyncs}
% pagebreaks
@@ -623,10 +642,14 @@
\def\dohandlepagebreakX{\dopreventbreakafterstructureheadspec} % no \let so we can redefind
-% todo:
+% we do support negative numbers but it can have side effects that we won't
+% catch
+%
+% \chapter{some} \setupheadnumber[chapter][3] \chapter{more}
+% \setupheadnumber[section][8] \section{b} \section{c} \setupheadnumber[section][-1] \section{d}
\def\thecurrentstructureheadlevel#1%
- {\getstructurelevel{#1}}
+ {\getcurrentstructurelevel{#1}}
\def\thenamedstructureheadlevel#1%
{\structuresectionlevel{\structuresectionheadsection{\structuresectionheadcoupling{#1}}}}
@@ -635,7 +658,7 @@
{\dodoubleargument\dosetupheadnumber}
\def\dosetupheadnumber[#1][#2]% todo: reset if at other level
- {\setstructurenumber{\thecurrentstructureheadlevel{#1}}{#2}}
+ {\setstructurenumber{\thenamedstructureheadlevel{#1}}{#2}}
\def\currentstructureheadnumber{0} % ==> \currentheadnumber
diff --git a/tex/context/base/strc-xml.mkiv b/tex/context/base/strc-xml.mkiv
index 04c5e71b8..3f11c0ac9 100644
--- a/tex/context/base/strc-xml.mkiv
+++ b/tex/context/base/strc-xml.mkiv
@@ -85,3 +85,50 @@
\starttext
\xmlprocessfile{demo}{oeps.xml}{}
\stoptext
+
+% example by thomas:
+
+\startbuffer[test]
+
+
+ MyTitle
+
+ Hello world
+
+
+
+\stopbuffer
+
+\startxmlsetups xml:mysetups
+ \xmlsetsetup{\xmldocument}{auth|section|title|content|emph}{xml:*}
+\stopxmlsetups
+
+\xmlregistersetup{xml:mysetups}
+
+\startxmlsetups xml:auth
+ \xmlflush{#1}
+\stopxmlsetups
+
+\startxmlsetups xml:section
+ \xmlflush{#1}\par \midaligned{\hl[5]}
+\stopxmlsetups
+
+\startxmlsetups xml:title
+ \section{\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:content
+ \xmlflush{#1}\par
+\stopxmlsetups
+
+\startxmlsetups xml:emph
+ {\bgroup\em \xmlflush{#1}\egroup}
+\stopxmlsetups
+
+\setuphead
+ [section]
+ [style=normal,number=no,expansion=yes,page=yes]
+
+\starttext
+ \xmlprocessbuffer{main}{test}{}
+\stoptext
diff --git a/tex/context/base/supp-box.tex b/tex/context/base/supp-box.tex
index e2f537a8c..e314305d7 100644
--- a/tex/context/base/supp-box.tex
+++ b/tex/context/base/supp-box.tex
@@ -3100,10 +3100,10 @@
\fi
\egroup}
-% makes sense:
-
-\showboxbreadth\maxdimen
-\showboxdepth \maxdimen
+% makes sense but too much log for overfull boxes:
+%
+% \showboxbreadth\maxdimen
+% \showboxdepth \maxdimen
\protect \endinput
diff --git a/tex/context/base/supp-dir.mkiv b/tex/context/base/supp-dir.mkiv
index 7d2e10070..2d7f6bd66 100644
--- a/tex/context/base/supp-dir.mkiv
+++ b/tex/context/base/supp-dir.mkiv
@@ -15,7 +15,4 @@
\unprotect
-\chardef \inlinedirection \zerocount % 0==notset 1==LR 2==RL
-\let \checkinlinedirection \donothing
-
\protect \endinput
diff --git a/tex/context/base/supp-fil.mkiv b/tex/context/base/supp-fil.mkiv
index caeaa67cd..00263a85f 100644
--- a/tex/context/base/supp-fil.mkiv
+++ b/tex/context/base/supp-fil.mkiv
@@ -538,26 +538,8 @@
\def\doifparentfileelse#1{\ctxlua{support.doifparentfileelse([[#1]])}}
-\def\normalless {<} % geen \let !
-\def\normalmore {>} % geen \let !
-\def\normalequal {=} % geen \let !
-\def\normaldblquote{"} % geen \let !
-
\newcount\readingfilelevel
-\def\popfilecharacter#1#2%
- {\ifnum\catcode`#1=\@@other \ifnum#2=\@@other \else
- %\message{[popping catcode #1 to #2]}%
- \catcode`#1=#2\relax
- \fi \fi}
-
-\ifx\\\undefined \let\\\relax \fi
-
-%D This changing catcodes is a direct result from the fact
-%D that we support some long standing conventions with
-%D regards to active characters (german ", polish /,
-%D french : and ;).
-
%D We need to redo this: catcode sets and such
\newtoks \everystartreadingfile
@@ -573,9 +555,6 @@
{\endrestorecatcodes
\the\everystopreadingfile
\global\advance\readingfilelevel\minusone}
-
-\let\normalstartreadingfile\startreadingfile
-\let\normalstopreadingfile \stopreadingfile
%D \macros
%D {splitfilename}
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 89aa21df1..5952cbfd2 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -1135,6 +1135,19 @@
{\def\docommand##1{#2[##1]}%
\processcommalist[#1]\docommand}
+%D \macros
+%D {startprocesscommalist,startprocesscommacommand}
+%D
+%D Two more:
+
+\long\def\startprocesscommalist[#1]#2\stopprocesscommalist
+ {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}%
+ \processcommalist[#1]\currentcommalistcommand}
+
+\long\def\startprocesscommacommand[#1]#2\stopprocesscommacommand
+ {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}%
+ \normalexpanded{\noexpand\processcommacommand[#1]}\currentcommalistcommand}
+
%D \macros
%D {processaction,
%D processfirstactioninset,
@@ -1768,14 +1781,6 @@
\let\getexpandedparameters=\geteparameters
-% \def\dogetparameters#1[#2]#3[#4%
-% {\if\noexpand#4]%
-% \expandafter\gobbleoneargument
-% \else
-% \def\p!dogetparameter{\p!doassign#1#2}%
-% \expandafter\xdogetparameters
-% \fi#4}
-
\def\dogetparameters#1[#2]#3[#4%
{\if\noexpand#4]%
\expandafter\gobbleoneargument
@@ -1801,31 +1806,6 @@
\def\xshowassignerror#1#2#3%
{\showassignerror{#2}{\the\inputlineno\space(#1)}}
-% \def\p!n!doassign#1#2\@relax@#3=#4=#5#6\@relax@
-% {\ifx\empty#3\empty
-% \@EA\xshowassignerror
-% \else\ifx#5\empty
-% \@EAEAEA\xshowassignerror
-% \else
-% \@EAEAEA#1%
-% \fi\fi
-% {#2}{#3}{#4}}
-
-% \def\p!e!doassign#1#2\@relax@#3=#4=#5#6\@relax@
-% {\ifx\empty#3\empty
-% \@EA\xshowassignerror
-% \else\ifx#5\empty
-% \@EAEAEA\xshowassignerror
-% \else
-% \ifcsname#2#3\endcsname
-% \@EA\let\@EA\currentvalue\csname#2#3\endcsname
-% \else
-% \let\currentvalue\empty
-% \fi
-% \@EAEAEA#1%
-% \fi\fi
-% {#2}{#3}{#4}}
-
\def\p!n!doassign#1\@relax@#2=#3=#4#5\@relax@
{\ifx\empty#2\empty
\@EA\xshowassignerror
@@ -1836,7 +1816,6 @@
\fi\fi
{#1}{#2}{#3}}
-
\def\p!e!doassign#1\@relax@#2=#3=#4#5\@relax@
{\ifx\empty#2\empty
\@EA\xshowassignerror
@@ -1862,6 +1841,26 @@
\def\doeassign [#1][#2]{\let\setsomevalue\dosetevalue \p!doassign#1\@relax@#2==\empty\@relax@}
\def\undoassign[#1][#2]{\let\setsomevalue\doresetvalue\p!doassign#1\@relax@#2==\empty\@relax@}
+%D \macros
+%D {processassignmentlist,processassignmentcommand}
+%D
+%D For Wolfgang:
+%D
+%D \starttyping
+%D \def\showpair#1#2{key:#1, value:#2\par}
+%D \processassignmentlist[a=1,b=2]\showpair
+%D \stoptyping
+%D
+%D We can optimize this one if needed but it's not a core macro so hardly
+%D worth the trouble and tokens.
+
+\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
+ {\def\doprocessassignmententry##1{#2}% {##2}{##3} % namespace is ignored
+ \dogetparameters\doprocessassignmententry[][#1]}
+
+\def\processassignmentcommand[#1]%
+ {\normalexpanded{\noexpand\processassignmentlist[#1]}}
+
%D \macros{currentvalue}
%D
%D Just in case a \type{\getparameter} argument itself ends up
diff --git a/tex/context/base/syst-ext.mkii b/tex/context/base/syst-ext.mkii
index 2ef1053d3..3eb91cb5d 100644
--- a/tex/context/base/syst-ext.mkii
+++ b/tex/context/base/syst-ext.mkii
@@ -3039,6 +3039,19 @@
{\global\let\globalcommacommand#2%
\expandafter\globalprocesscommaitem#1,],}
+%D \macros
+%D {startprocesscommalist,startprocesscommacommand}
+%D
+%D Two more:
+
+\long\def\startprocesscommalist[#1]#2\stopprocesscommalist
+ {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}%
+ \processcommalist[#1]\currentcommalistcommand}
+
+\long\def\startprocesscommacommand[#1]#2\stopprocesscommacommand
+ {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}%
+ \processcommacommand[#1]\currentcommalistcommand}
+
%D \macros
%D {withoutpt,PtToCm,
%D numberofpoints,dimensiontocount}
diff --git a/tex/context/base/syst-gen.mkii b/tex/context/base/syst-gen.mkii
index 993512b74..2db71650f 100644
--- a/tex/context/base/syst-gen.mkii
+++ b/tex/context/base/syst-gen.mkii
@@ -2910,6 +2910,23 @@
\def\doassignempty[#1][#2=#3]%
{\ifundefined{#1#2}\dosetvalue{#1}{#2}{#3}\fi}
+%D \macros
+%D {processassignmentlist,processassignmentcommand}
+%D
+%D For Wolfgang:
+%D
+%D \starttyping
+%D \def\showpair#1#2{key:#1, value:#2\par}
+%D \processassignmentlist[a=1,b=2]\showpair
+%D \stoptyping
+
+\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
+ {\def\doprocessassignmententry##1{#2}% {##2}{##3} % namespace is ignored
+ \dogetparameters\doprocessassignmententry[][#1]}
+
+\def\processassignmentcommand[#1]%
+ {\normalexpanded{\noexpand\processassignmentlist[#1]}}
+
%D \macros
%D {getparameters,geteparameters,getgparameters,
%D forgetparameters}
diff --git a/tex/context/base/syst-ini.tex b/tex/context/base/syst-ini.tex
index 50999d813..8a756731b 100644
--- a/tex/context/base/syst-ini.tex
+++ b/tex/context/base/syst-ini.tex
@@ -424,6 +424,8 @@
%D characters. Because we are not that good at remembering numbers,
%D we introduce some symbolic names.
+%D As we now have catc-* files, we also have more readable names
+
\chardef\@@escape = 0
\chardef\@@begingroup = 1
\chardef\@@endgroup = 2
diff --git a/tex/context/base/trac-inf.lua b/tex/context/base/trac-inf.lua
index d83dc8d2f..3dfaf7119 100644
--- a/tex/context/base/trac-inf.lua
+++ b/tex/context/base/trac-inf.lua
@@ -19,27 +19,34 @@ statistics.threshold = 0.05
local clock = os.gettimeofday or os.clock
+local notimer
+
function statistics.hastimer(instance)
return instance and instance.starttime
end
function statistics.starttiming(instance)
- if instance then
- local it = instance.timing
- if not it then
- it = 0
- end
- if it == 0 then
- instance.starttime = clock()
- if not instance.loadtime then
- instance.loadtime = 0
- end
+ if not instance then
+ notimer = { }
+ instance = notimer
+ end
+ local it = instance.timing
+ if not it then
+ it = 0
+ end
+ if it == 0 then
+ instance.starttime = clock()
+ if not instance.loadtime then
+ instance.loadtime = 0
end
- instance.timing = it + 1
end
+ instance.timing = it + 1
end
function statistics.stoptiming(instance, report)
+ if not instance then
+ instance = notimer
+ end
if instance then
local it = instance.timing
if it > 1 then
@@ -63,10 +70,16 @@ function statistics.stoptiming(instance, report)
end
function statistics.elapsedtime(instance)
+ if not instance then
+ instance = notimer
+ end
return format("%0.3f",(instance and instance.loadtime) or 0)
end
function statistics.elapsedindeed(instance)
+ if not instance then
+ instance = notimer
+ end
local t = (instance and instance.loadtime) or 0
return t > statistics.threshold
end
diff --git a/tex/context/base/trac-tex.mkiv b/tex/context/base/trac-tex.mkiv
new file mode 100644
index 000000000..844354160
--- /dev/null
+++ b/tex/context/base/trac-tex.mkiv
@@ -0,0 +1,36 @@
+%D \module
+%D [ file=trac-tex,
+%D version=2009.07.20,
+%D title=\CONTEXT\ Tracking Macros,
+%D subtitle=\TEX,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%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 Tracking Macros / TeX}
+
+%D All tracing flags at the \TEX\ end will be redone this way so
+%D that we have a similar mechanism for \TEX\ and \LUA. Also, the
+%D currently used if's might become conditionals.
+
+\unprotect
+
+% \def\enabletextracerwhatever {...}
+% \def\disabletextracerwhatever{...}
+
+\let\alltextracers\empty % so that we can report available tracers
+
+\def\installtextracer#1%
+ {\addtocommalist{#1}\alltextracers}
+
+\def\enabletextracers [#1]{\processcommalist[#1]\doenabletextracer}
+\def\disabletextracers[#1]{\processcommalist[#1]\dodisabletextracer}
+
+\def\doenabletextracer #1{\csname enabletracer#1\endcsname}
+\def\dodisabletextracer#1{\csname disabletracer#1\endcsname}
+
+\protect \endinput
diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv
index c76666e92..6b0fdba94 100644
--- a/tex/context/base/trac-vis.mkiv
+++ b/tex/context/base/trac-vis.mkiv
@@ -257,52 +257,49 @@
%D By setting the next macros one can influence the length of
%D the marks as well as the horizontal and vertical divisions.
+\newdimen\tractempwidth
+\newdimen\tractempheight
+\newdimen\tractempdepth
+
\def\cutmarklength {2\bodyfontsize}
+
\chardef\horizontalcutmarks = 2
\chardef\verticalcutmarks = 2
\chardef\cutmarkoffset = 1
+
\let\cutmarksymbol = \relax
\let\cutmarktoptext = \empty
\let\cutmarkbottomtext = \empty
\def\horizontalcuts
- {\normalhbox to \ruledwidth
- {\dorecurse\horizontalcutmarks
- {\vrule\!!width\boxrulewidth\!!height\cutmarklength\normalhfill}%
+ {\normalhbox to \tractempwidth
+ {\dorecurse\horizontalcutmarks{\vrule\!!width\boxrulewidth\!!height\cutmarklength\normalhfill}%
\unskip}}
\def\verticalcuts
- {\scratchdimen\ruledheight
- \advance\scratchdimen \ruleddepth
- \normalvbox to \scratchdimen
+ {\normalvbox to \dimexpr\tractempheight+\tractempdepth\relax
{\hsize\cutmarklength
- \dorecurse\verticalcutmarks
- {\vrule\!!height\boxrulewidth\!!width\hsize\normalvfill}%
+ \dorecurse\verticalcutmarks{\vrule\!!height\boxrulewidth\!!width\hsize\normalvfill}%
\unskip}}
\def\baselinecuts
- {\ifdim\ruleddepth>\zeropoint
- \scratchdimen\ruledheight
- \advance\scratchdimen \ruleddepth
- \normalvbox to \scratchdimen
- {\scratchdimen\cutmarklength
- \divide\scratchdimen 2
- \hsize\scratchdimen
- \normalvskip\zeropoint\!!plus\ruledheight
+ {\ifdim\tractempdepth>\zeropoint
+ \normalvbox to \dimexpr\tractempheight+\tractempdepth\relax
+ {\hsize\dimexpr\cutmarklength/2\relax
+ \normalvskip\zeropoint\!!plus\tractempheight
\vrule\!!height\boxrulewidth\!!width\hsize
- \normalvskip\zeropoint\!!plus\ruleddepth}%
+ \normalvskip\zeropoint\!!plus\tractempdepth}%
\fi}
\def\cutmarksymbols#1%
- {\normalhbox to \ruledwidth
+ {\normalhbox to \tractempwidth
{\setbox\scratchbox\normalhbox to \cutmarklength
{\normalhss\infofont\cutmarksymbol\normalhss}%
\normalhss
\normalvbox to \cutmarklength
- {\scratchdimen\cutmarklength
- \divide\scratchdimen \plustwo
+ {\scratchdimen\dimexpr\cutmarklength/2\relax
\normalvss
- \hbox to \ruledwidth
+ \hbox to \tractempwidth
{\llap{\copy\scratchbox\normalhskip\cutmarkoffset\scratchdimen}%
\normalhskip\scratchdimen\hss\infofont#1\hss\normalhskip\scratchdimen
\rlap{\normalhskip\cutmarkoffset\scratchdimen\copy\scratchbox}}%
@@ -310,24 +307,22 @@
\normalhss}}
\def\makecutbox#1% simplier with layers, todo
- {\edef\ruledheight{\the\ht#1}%
- \edef\ruleddepth {\the\dp#1}%
- \edef\ruledwidth {\the\wd#1}%
+ {\tractempheight\ht#1%
+ \tractempdepth \dp#1%
+ \tractempwidth \wd#1%
\setbox#1\normalhbox
{\dontcomplain
\forgetall
\boxmaxdepth\maxdimen
\offinterlineskip
- \scratchdimen\cutmarklength
- \divide\scratchdimen \plustwo
- \hsize\ruledwidth
+ \scratchdimen\dimexpr\cutmarklength/2\relax
+ \hsize\tractempwidth
\setbox\scratchbox\normalvbox
{\setbox\scratchbox\normalhbox{\horizontalcuts}%
- \normalvskip-\cutmarkoffset\scratchdimen
- \normalvskip-2\scratchdimen
+ \normalvskip\dimexpr-\cutmarkoffset\scratchdimen-2\scratchdimen\relax
\copy\scratchbox
\normalvskip\cutmarkoffset\scratchdimen
- \hbox to \ruledwidth
+ \hbox to \tractempwidth
{\setbox\scratchbox\normalhbox{\verticalcuts}%
\llap{\copy\scratchbox\normalhskip\cutmarkoffset\scratchdimen}%
\bgroup
@@ -339,10 +334,9 @@
\rlap{\normalhskip\cutmarkoffset\scratchdimen\copy\scratchbox}}%
\normalvskip\cutmarkoffset\scratchdimen
\copy\scratchbox}%
- \ht\scratchbox\ruledheight
- \dp\scratchbox\ruleddepth
+ \ht\scratchbox\tractempheight
+ \dp\scratchbox\tractempdepth
\wd\scratchbox\zeropoint
- \resetcolorseparation
\startcolor[\defaulttextcolor]%
\box\scratchbox
\ifx\cutmarksymbol\relax \else
@@ -351,32 +345,24 @@
\vskip-\cutmarklength
\normalhbox{\cutmarksymbols\cutmarktoptext}%
\vskip\cutmarkoffset\scratchdimen
- \vskip\ruledheight
- \vskip\ruleddepth
+ \vskip\tractempheight
+ \vskip\tractempdepth
\vskip\cutmarkoffset\scratchdimen
\normalhbox{\cutmarksymbols\cutmarkbottomtext}}%
- \ht\scratchbox\ruledheight
- \dp\scratchbox\ruleddepth
+ \ht\scratchbox\tractempheight
+ \dp\scratchbox\tractempdepth
\wd\scratchbox\zeropoint
\box\scratchbox
\fi
\stopcolor
\box#1}%
- \wd#1=\ruledwidth
- \ht#1=\ruledheight
- \dp#1=\ruleddepth}
+ \wd#1\tractempwidth
+ \ht#1\tractempheight
+ \dp#1\tractempdepth}
-\def\cuthbox
- {\normalhbox\bgroup
- \dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalhbox}
-
-\def\cutvbox
- {\normalvbox\bgroup
- \dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvbox}
-
-\def\cutvtop
- {\normalvtop\bgroup
- \dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvtop}
+\def\cuthbox{\normalhbox\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalhbox}
+\def\cutvbox{\normalvbox\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvbox}
+\def\cutvtop{\normalvtop\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvtop}
%D \macros
%D {colormarkbox,rastermarkbox}
@@ -391,167 +377,136 @@
\def\colormarkoffset{\cutmarkoffset}
\def\colormarklength{\cutmarklength}
-\def\colorrangeA#1#2#3#4%
+\def\dodocolorrangeA#1%
+ {\fastcolored[#1]{\hrule\!!width3em\!!height\scratchdimen\!!depth\zeropoint}}
+
+\def\docolorrangeA#1 #2 %
{\vbox
- {\scratchdimen-\colormarklength
- \multiply\scratchdimen 4
- \advance\scratchdimen \ruledheight
- \advance\scratchdimen \ruleddepth
- \divide\scratchdimen 21
- \def\docommand##1%
- {\vbox
- {\hsize3em % \scratchdimen
- \definecolor
- [\s!dummy]
- [\c!c=#2##1\else0\fi,
- \c!m=#3##1\else0\fi,
- \c!y=#4##1\else0\fi,
- \c!k=0]%
- \startcolor[\s!dummy]%
- \hrule
- \!!width 3em
- \!!height \scratchdimen
- \!!depth \zeropoint
- \stopcolor
- \ifdim\scratchdimen>1ex
- \vskip-\scratchdimen
- \vbox to \scratchdimen
- {\vss
- \hbox to 3em
- {\hss
- \startcolor[\s!white]%
- \ifdim##1\points=\zeropoint#1\else##1\fi
- \stopcolor
- \hss}%
- \vss}%
- \fi}}%
+ {\hsize3em % \scratchdimen
+ \ifcase#1\or
+ \dodocolorrangeA{c=#2}\or
+ \dodocolorrangeA{m=#2}\or
+ \dodocolorrangeA{y=#2}\or
+ \dodocolorrangeA{m=#2,y=#2}\or
+ \dodocolorrangeA{c=#2,y=#2}\or
+ \dodocolorrangeA{c=#2,m=#2}\fi
+ \ifdim\scratchdimen>1ex
+ \vskip-\scratchdimen
+ \vbox to \scratchdimen
+ {\vss\hbox to 3em{\hss#2\hss}\vss}%
+ \fi}}
+
+\def\colorrangeA#1%
+ {\vbox
+ {\startcolor[\s!white]%
+ \scratchdimen\dimexpr(-\colormarklength*4+\tractempheight+\tractempdepth)/21\relax
\offinterlineskip
- \processcommalist[1.00,0.95,0.75,0.50,0.25,0.05,0.00]\docommand}}
+ \docolorrangeA #1 1.00 \docolorrangeA #1 0.95
+ \docolorrangeA #1 0.75
+ \docolorrangeA #1 0.50
+ \docolorrangeA #1 0.25 \docolorrangeA #1 0.05
+ \docolorrangeA #1 0.00
+ \stopcolor}}
+
+\def\docolorrangeB #1 #2 #3 #4 #5 %
+ {\fastcolored
+ [\c!c=#2,\c!m=#3,\c!y=#4,\c!k=#5]
+ {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}%
+ \ifdim\scratchdimen>2em
+ \hskip-\scratchdimen
+ \vbox to \colormarklength
+ {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}%
+ \fi}
\def\colorrangeB
{\hbox
- {\scratchdimen-\colormarklength
- \multiply\scratchdimen \plustwo
- \advance\scratchdimen \ruledwidth
- \divide\scratchdimen 11
- \def\docommand ##1 ##2 ##3##4##5##6%
- {\definecolor
- [\s!dummy]
- [\c!c=##3##2\else0\fi,
- \c!m=##4##2\else0\fi,
- \c!y=##5##2\else0\fi,
- \c!k=##6##2\else0\fi]%
- \startcolor[\s!dummy]%
- \vrule
- \!!width \scratchdimen
- \!!height \colormarklength
- \!!depth \zeropoint
- \stopcolor
- \ifdim\scratchdimen>2em
- \hskip-\scratchdimen
- \vbox to \colormarklength
- {\vss
- \hbox to \scratchdimen
- {\hss
- \startcolor[\s!white]%
- \ifdim##2\points=.5\points##2~\fi##1%
- \stopcolor
- \hss}
- \vss}%
- \fi}%
- \docommand C .5 \iftrue \iffalse\iffalse\iffalse
- \docommand M .5 \iffalse\iftrue \iffalse\iffalse
- \docommand Y .5 \iffalse\iffalse\iftrue \iffalse
- \docommand K .5 \iffalse\iffalse\iffalse\iftrue
- \docommand C 1 \iftrue \iffalse\iffalse\iffalse
- \docommand G 1 \iftrue \iffalse\iftrue \iffalse
- \docommand Y 1 \iffalse\iffalse\iftrue \iffalse
- \docommand R 1 \iffalse\iftrue \iftrue \iffalse
- \docommand M 1 \iffalse\iftrue \iffalse\iffalse
- \docommand B 1 \iftrue \iftrue \iffalse\iffalse
- \docommand K 1 \iffalse\iffalse\iffalse\iftrue}}
+ {\startcolor[\s!white]%
+ \scratchdimen\dimexpr(-\colormarklength*\plustwo+\tractempwidth)/11\relax
+ \docolorrangeB .5~C .5 0 0 0
+ \docolorrangeB .5~M 0 .5 0 0
+ \docolorrangeB .5~Y 0 0 .5 0
+ \docolorrangeB .5~K 0 0 0 .5
+ \docolorrangeB C 1 0 0 0
+ \docolorrangeB G 1 0 1 0
+ \docolorrangeB Y 0 0 1 0
+ \docolorrangeB R 0 1 1 0
+ \docolorrangeB M 0 1 0 0
+ \docolorrangeB B 1 1 0 0
+ \docolorrangeB K 0 0 0 1
+ \stopcolor}}
+
+\def\docolorrangeC#1 %
+ {\fastcolored
+ [\c!s=#1]%
+ {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}%
+ \ifdim\scratchdimen>2em
+ \hskip-\scratchdimen
+ \vbox to \colormarklength
+ {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}%
+ \fi}
\def\colorrangeC
{\hbox
- {\resetcolorseparation
- \scratchdimen-\colormarklength
- \multiply\scratchdimen 2
- \advance\scratchdimen \ruledwidth
- \divide\scratchdimen 14
- \def\docommand##1%
- {\definecolor[\s!dummy][\c!s=##1]%
- \startcolor[\s!dummy]%
- \vrule
- \!!width \scratchdimen
- \!!height \colormarklength
- \!!depth \zeropoint
- \stopcolor
- \ifdim\scratchdimen>2em
- \hskip-\scratchdimen
- \vbox to \colormarklength
- {\vss
- \startcolor[\s!white]%
- \hbox to \scratchdimen{\hss##1\hss}
- \stopcolor
- \vss}%
- \fi}%
- \processcommalist[1,.95,.9,.85,.8,.75,.7,.6,.5,.4,.3,.2,.1,0]\docommand}}
+ {\startcolor[\s!white]%
+ \scratchdimen\dimexpr(-\colormarklength*2+\tractempwidth)/14\relax
+ \docolorrangeC 1 \docolorrangeC .95
+ \docolorrangeC .9 \docolorrangeC .85
+ \docolorrangeC .8 \docolorrangeC .75
+ \docolorrangeC .7
+ \docolorrangeC .6
+ \docolorrangeC .5
+ \docolorrangeC .4
+ \docolorrangeC .3
+ \docolorrangeC .2
+ \docolorrangeC .1
+ \docolorrangeC 0
+ \stopcolor}}
\def\docolormarkbox#1#2%
- {\edef\ruledheight{\the\ht#2}%
- \edef\ruleddepth {\the\dp#2}%
- \edef\ruledwidth {\the\wd#2}%
+ {\tractempheight\ht#2%
+ \tractempdepth \dp#2%
+ \tractempwidth \wd#2%
\setbox#2\hbox
- {\scratchdimen\colormarklength
- \divide\scratchdimen \plustwo
+ {\scratchdimen\dimexpr\colormarklength/2\relax
\forgetall
\ssxx
\setbox\scratchbox\vbox
{\offinterlineskip
- \vskip-\colormarkoffset\scratchdimen
- \vskip-2\scratchdimen\relax % relax needed
- % beware: no \ifcase, due to nested \iftrue/\iffalse
- % and lacking \fi's
- \doifelse{#1}{0}%
- {\vskip\colormarklength
- \vskip\colormarkoffset\scratchdimen
- \vskip\ruledheight}
- {\hbox to \ruledwidth{\hss\hbox{\colorrangeB}\hss}%
- \vskip\colormarkoffset\scratchdimen
- \vbox to \ruledheight
- {\vss
- \hbox to \ruledwidth
- {\llap{\colorrangeA C\iftrue\iffalse\iffalse\hskip\colormarkoffset\scratchdimen}%
- \hfill
- \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA R\iffalse\iftrue\iftrue}}%
- \vss
- \hbox to \ruledwidth
- {\llap{\colorrangeA M\iffalse\iftrue\iffalse\hskip\colormarkoffset\scratchdimen}%
- \hfill
- \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA G\iftrue\iffalse\iftrue}}%
- \vss
- \hbox to \ruledwidth
- {\llap{\colorrangeA Y\iffalse\iffalse\iftrue\hskip\colormarkoffset\scratchdimen}%
- \hfill
- \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA B\iftrue\iftrue\iffalse}}%
- \vss}}%
+ \vskip\dimexpr-\colormarkoffset\scratchdimen-2\scratchdimen\relax
+ \ifcase#1\relax
+ \vskip\dimexpr\colormarklength+\scratchdimen+\tractempheight\relax
+ \else
+ \hbox to \tractempwidth{\hss\hbox{\colorrangeB}\hss}%
+ \vskip\colormarkoffset\scratchdimen
+ \vbox to \tractempheight
+ {\vss
+ \hbox to \tractempwidth
+ {\llap{\colorrangeA1\hskip\colormarkoffset\scratchdimen}\hfill
+ \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA4}}%
+ \vss
+ \hbox to \tractempwidth
+ {\llap{\colorrangeA2\hskip\colormarkoffset\scratchdimen}\hfill
+ \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA5}}%
+ \vss
+ \hbox to \tractempwidth
+ {\llap{\colorrangeA3\hskip\colormarkoffset\scratchdimen}\hfill
+ \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA6}}%
+ \vss}%
+ \fi
\vskip\colormarkoffset\scratchdimen
- \hbox to \ruledwidth
- {\hss\lower\ruleddepth\hbox{\colorrangeC}\hss}}%
- \ht\scratchbox\ruledheight
- \dp\scratchbox\ruleddepth
+ \hbox to \tractempwidth
+ {\hss\lower\tractempdepth\hbox{\colorrangeC}\hss}}%
+ \ht\scratchbox\tractempheight
+ \dp\scratchbox\tractempdepth
\wd\scratchbox\zeropoint
\box\scratchbox
\box#2}%
- \wd#2=\ruledwidth
- \ht#2=\ruledheight
- \dp#2=\ruleddepth}
-
-\def\colormarkbox % #1
- {\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi1}
+ \wd#2\tractempwidth
+ \ht#2\tractempheight
+ \dp#2\tractempdepth}
-\def\rastermarkbox % #1
- {\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi0}
+\def\colormarkbox {\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi\plusone } % #1
+\def\rastermarkbox{\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi\zerocount} % #1
%D \macros
%D {showwhatsits, dontshowwhatsits}
@@ -618,11 +573,17 @@
\ttx
\ifvmode\donetrue\else\donefalse\fi
\setbox\scratchbox\hbox
- {\ifdone\dostartgraycolormode0\else\dostartrgbcolormode#1#2#3\fi
- #5\dostopcolormode}%
+ {\ifdone
+ \colored[r=#1,g=#2,b=#3]{#5}% temp hack
+ \else
+ \colored[s=0]{#5}% temp hack
+ \fi}%
\setbox\scratchbox\hbox
- {\ifdone\dostartrgbcolormode#1#2#3\else\dostartgraycolormode0\fi
- \vrule\!!width\wd\scratchbox\dostopcolormode
+ {\ifdone
+ \colored[r=#1,g=#2,b=#3]{\vrule\!!width\wd\scratchbox}% temp hack
+ \else
+ \colored[s=0]{\vrule\!!width\wd\scratchbox}% temp hack
+ \fi
\hskip-\wd\scratchbox\box\scratchbox}%
\scratchdimen1ex
\setbox\scratchbox\hbox
diff --git a/tex/context/base/type-ini.mkiv b/tex/context/base/type-ini.mkiv
index bffc220fa..4076cf7b8 100644
--- a/tex/context/base/type-ini.mkiv
+++ b/tex/context/base/type-ini.mkiv
@@ -125,7 +125,7 @@
\pushmacro\stoptypescript
\typescriptfoundfalse
\iftracetypescripts\writestatus\m!fonts{request: [\@@typescriptone] [\@@typescripttwo] [\@@typescriptthree]}\fi
- \processcommacommand[\typescriptfiles]\dododousetypescript
+ \processcommacommand[\typescriptfiles]\dododousetypescriptfile
\the\documenttypescripts
\firsttypescriptpassfalse % testen
\popmacro\stoptypescript
@@ -138,19 +138,6 @@
\popmacro\@@typescripttwo
\popmacro\@@typescriptone}
-% simple version:
-%
-% \def\dododousetypescript#1%
-% {\startreadingfile
-% \pushmacro\currenttypefile
-% \def\currenttypefile{#1}%
-% \def\currenttypefile{#1}%
-% \readfile\currenttypefile\donothing\donothing
-% \popmacro\currenttypefile
-% \stopreadingfile}
-%
-% tricky version:
-
\newconditional\preloadingtypescripts
\def\preloadtypescripts{\ifproductionrun\settrue\preloadingtypescripts\fi}
@@ -161,39 +148,14 @@
\long\def\xxstarttypescriptcollection#1\stoptypescriptcollection
{\global\loadedtypescripts\@EA{\the\loadedtypescripts\starttypescriptcollection#1\stoptypescriptcollection}}
-\def\dododousetypescript#1%
+\def\dododousetypescriptfile#1%
{\setfalse\quittingtypescript
\pushmacro\currenttypefile
\def\currenttypefile{#1}%
\ifconditional\preloadingtypescripts
- % load files once, and use saved data
- \def\loadedtypescripts{\csname\??ts:\c!file:#1\endcsname}%
- \@EAEAEA\ifx\loadedtypescripts\relax
- \@EAEAEA\newtoks\loadedtypescripts
- \bgroup
- \let\starttypescript\xxstarttypescript
- \let\starttypescriptcollection\xxstarttypescriptcollection
- \startreadingfile
- \pushendofline
- \unprotect
- \readfile\currenttypefile\donothing\donothing
- \protect
- \popendofline
- \stopreadingfile
- \egroup
- \fi
- %\message{[\space\currenttypefile}%
- \the\loadedtypescripts
- %\message{\ifconditional\quittingtypescript quit\space\fi]}%
+ \doprocessandbuffertypescriptfile
\else
- % process files each time
- \startreadingfile
- \pushendofline
- \unprotect
- \readfile\currenttypefile\donothing\donothing
- \protect
- \popendofline
- \stopreadingfile
+ \doprocesstypescriptfile
\fi
\popmacro\currenttypefile
\ifconditional\quittingtypescript
@@ -201,6 +163,31 @@
\setfalse\quittingtypescript
\fi}
+\def\doprocessandbuffertypescriptfile
+ {\expandafter\let\expandafter\loadedtypescripts\csname\??ts:\c!file:\currenttypefile\endcsname
+ \ifx\loadedtypescripts\relax
+ \dobuffertypescriptfile
+ \fi
+ \the\loadedtypescripts}
+
+\def\dobuffertypescriptfile
+ {\newtoks\loadedtypescripts
+ \bgroup
+ \let\starttypescript\xxstarttypescript
+ \let\starttypescriptcollection\xxstarttypescriptcollection
+ \doprocesstypescriptfile
+ \egroup
+ \expandafter\let\csname\??ts:\c!file:\currenttypefile\endcsname\loadedtypescripts}
+
+\def\doprocesstypescriptfile
+ {\startreadingfile
+ \pushendofline
+ \unprotect
+ \readfile\currenttypefile\donothing\donothing
+ \protect
+ \popendofline
+ \stopreadingfile}
+
\def\usetypescriptonce
{\dotripleempty\dousetypescriptonce}
@@ -274,10 +261,13 @@
\expandafter\noprocesstypescript
\fi}
+\def\typescriptwritestatus
+ {\writestatus\m!fonts{match:\ifx\currenttypefile\relax\space *\fi \typescriptmatch}}
+
\long\def\dostarttypescriptyes
{\ifdone
\typescriptfoundtrue
- \iftracetypescripts\writestatus\m!fonts{match:\ifx\currenttypefile\relax\space *\fi \typescriptmatch}\fi
+ \iftracetypescripts\typescriptwritestatus\fi
\expandafter\doprocesstypescript
\else
\expandafter\noprocesstypescript
@@ -620,41 +610,25 @@
{\doifelsenothing{#2}
{\doinherittypeface[#1][\c!rm,\c!ss,\c!tt,\c!mm][\fontclass]}
{\doifnot{#1}{#3}
- {\def\docommand##1{\setevalue{#1-##1}{#3}}%
+ {\global\let\checkfontclass\docheckfontclass
+ \def\docommand##1{\setevalue{#1-##1}{#3}}%
\processcommalist[#2]\docommand}}}
-%D This hook sinto the font mechanism with:
-
-\def\checkfontclass#1%
- {\edef\fontclass{\executeifdefined{\fontclass-#1}{\fontclass}}}
+%D This hooks into the font mechanism with:
-%D For backward compatibility we reimplement the font file
-%D loading macro.
+% \def\checkfontclass#1% called often
+% {\edef\fontclass{\executeifdefined{\fontclass-#1}{\fontclass}}}
-\ifx\normaldoreadfontdefinitionfile\undefined
- \let\normaldoreadfontdefinitionfile\doreadfontdefinitionfile
-\fi
+% \def\checkfontclass#1% called often
+% {\edef\fontclass{\ifcsname\fontclass-#1\endcsname\csname\fontclass-#1\endcsname\else\fontclass\fi}}
-\def\doreadfontdefinitionfile#1#2% #1 = set/switch state
- {\ifcsname\??tf#2\c!default\endcsname
- \ifcase#1\relax
- \switchtotypeface[#2]%
- \else
- \setuptypeface[#2]%
- \fi
- \else
- \pushmacro\starttypescript
- \scratchtoks\emptytoks
- % locate downward compatibility definitions, one argument !
- \long\def\starttypescript[##1]##2\stoptypescript
- {\doif{##1}{#2}{\scratchtoks{##2}}}
- \startreadingfile
- \readfile{\f!typeprefix pre}\donothing\donothing
- \stopreadingfile
- \popmacro\starttypescript
- \the\scratchtoks
+\def\docheckfontclass#1% called often
+ {\ifcsname\fontclass-#1\endcsname
+ \expandafter\let\expandafter\fontclass\csname\fontclass-#1\endcsname
\fi}
+\let\checkfontclass\gobbleoneargument
+
\fetchruntimecommand \typetypescript {\f!typeprefix\s!run.mkiv} % will become module
\protect \endinput
diff --git a/tex/context/base/type-siz.mkiv b/tex/context/base/type-siz.mkiv
index ab31c415f..734c262b5 100644
--- a/tex/context/base/type-siz.mkiv
+++ b/tex/context/base/type-siz.mkiv
@@ -21,7 +21,7 @@
it=LMRoman12-Italic,
sl=LMRoman12-Oblique,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [11pt] [rm]
@@ -30,7 +30,7 @@
it=LMRoman10-Italic sa 1,
sl=LMRoman10-Oblique sa 1,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [10pt] [rm]
@@ -39,7 +39,7 @@
it=LMRoman10-Italic,
sl=LMRoman10-Oblique,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [9pt] [rm]
@@ -48,7 +48,7 @@
it=LMRoman9-Italic,
sl=LMRoman9-Oblique,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [8pt] [rm]
@@ -57,7 +57,7 @@
it=LMRoman8-Italic,
sl=LMRoman8-Oblique,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [7pt] [rm]
@@ -66,7 +66,7 @@
it=LMRoman7-Italic sa 1,
sl=LMRoman8-Oblique sa 1,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [6pt] [rm]
@@ -75,7 +75,7 @@
it=LMRoman7-Italic sa 1,
sl=LMRoman8-Oblique sa 1,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [5pt] [rm]
@@ -84,7 +84,7 @@
it=LMRoman7-Italic sa 1,
sl=LMRoman8-Oblique sa 1,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [4pt] [rm]
@@ -93,7 +93,7 @@
it=LMRoman7-Italic sa 1,
sl=LMRoman8-Oblique sa 1,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\definebodyfont [14.4pt,17.3pt,20.7pt] [rm]
@@ -102,7 +102,7 @@
it=LMRoman12-Italic sa 1,
sl=LMRoman12-Oblique sa 1,
bi=LMRoman10-BoldItalic sa 1,
- bs=LMRoman10-BoldObliqu sa 1,
+ bs=LMRoman10-BoldOblique sa 1,
sc=LMRoman10-CapsRegular sa 1]
\stoptypescript
diff --git a/tex/context/base/typo-brk.lua b/tex/context/base/typo-brk.lua
index d01b9d653..33837ab7a 100644
--- a/tex/context/base/typo-brk.lua
+++ b/tex/context/base/typo-brk.lua
@@ -25,10 +25,11 @@ local make_disc_node = nodes.disc
local glyph = node.id("glyph")
local kern = node.id("kern")
-breakpoints = breakpoints or { }
-breakpoints.mapping = breakpoints.mapping or { }
-breakpoints.methods = breakpoints.methods or { }
-breakpoints.enabled = false
+breakpoints = breakpoints or { }
+breakpoints.mapping = breakpoints.mapping or { }
+breakpoints.methods = breakpoints.methods or { }
+breakpoints.enabled = false
+breakpoints.attribute = attributes.private("breakpoint")
storage.register("breakpoints/mapping", breakpoints.mapping, "breakpoints.mapping")
@@ -183,4 +184,4 @@ chars.handle_breakpoints = nodes.install_attribute_handler {
name = "breakpoint",
namespace = breakpoints,
processor = breakpoints.process,
- }
+}
diff --git a/tex/context/base/typo-cap.lua b/tex/context/base/typo-cap.lua
index b6eedb330..c232ac728 100644
--- a/tex/context/base/typo-cap.lua
+++ b/tex/context/base/typo-cap.lua
@@ -22,9 +22,10 @@ local kern = node.id("kern")
local fontdata = fonts.ids
local chardata = characters.data
-cases = cases or { }
-cases.enabled = false
-cases.actions = { }
+cases = cases or { }
+cases.enabled = false
+cases.actions = { }
+cases.attribute = attributes.private("case")
local actions = cases.actions
local lastfont = nil
diff --git a/tex/context/base/typo-krn.lua b/tex/context/base/typo-krn.lua
index ea416477f..d3031633d 100644
--- a/tex/context/base/typo-krn.lua
+++ b/tex/context/base/typo-krn.lua
@@ -31,9 +31,10 @@ local vlist = node.id('vlist')
local fontdata = fonts.ids
local chardata = characters.data
-kerns = kerns or { }
-kerns.mapping = kerns.mapping or { }
-kerns.enabled = false
+kerns = kerns or { }
+kerns.mapping = kerns.mapping or { }
+kerns.enabled = false
+kerns.attribute = attributes.private("kern")
storage.register("kerns/mapping", kerns.mapping, "kerns.mapping")
diff --git a/tex/context/base/typo-mir.lua b/tex/context/base/typo-mir.lua
index f2cbbb4fa..806b8e0a0 100644
--- a/tex/context/base/typo-mir.lua
+++ b/tex/context/base/typo-mir.lua
@@ -59,6 +59,7 @@ local chardata = characters.data
mirror = mirror or { }
mirror.enabled = false
mirror.strip = false
+mirror.attribute = attributes.private("mirror")
local state = attributes.private('state')
local mirrora = attributes.private('mirror')
diff --git a/tex/context/base/typo-spa.lua b/tex/context/base/typo-spa.lua
index c134fc281..20861d08b 100644
--- a/tex/context/base/typo-spa.lua
+++ b/tex/context/base/typo-spa.lua
@@ -23,9 +23,10 @@ local make_glue_node = nodes.glue
local glyph = node.id("glyph")
local fontdata = fonts.ids
-spacings = spacings or { }
-spacings.mapping = spacings.mapping or { }
-spacings.enabled = false
+spacings = spacings or { }
+spacings.mapping = spacings.mapping or { }
+spacings.enabled = false
+spacings.attribute = attributes.private("spacing")
storage.register("spacings/mapping", spacings.mapping, "spacings.mapping")
diff --git a/tex/context/base/unic-ini.mkiv b/tex/context/base/unic-ini.mkiv
index 8b0c819d9..51c300e4c 100644
--- a/tex/context/base/unic-ini.mkiv
+++ b/tex/context/base/unic-ini.mkiv
@@ -13,14 +13,10 @@
\writestatus{loading}{ConTeXt Unicode Support / Initialization}
-%D Much of this is not needed at all in \LUATEX\ and we can save some
-%D 50K on the compressed format.
-
\unprotect
-\let \keeputfcharacters\relax
-\chardef\utfunicodetracer \zerocount
-\chardef\utfunicommandmode\zerocount
+\let \keeputfcharacters\relax % used in xtag
+\chardef\utfunicodetracer \zerocount % used in xtag
\def\unicodechar #1{\char\numexpr#1\relax} % no lookahead
\def\unicodenumber #1{\the \numexpr#1\relax} % no lookahead
diff --git a/tex/context/base/x-fo.tex b/tex/context/base/x-fo.tex
index 1f9e55259..395ec7eb3 100644
--- a/tex/context/base/x-fo.tex
+++ b/tex/context/base/x-fo.tex
@@ -2463,7 +2463,7 @@ leader-pattern-width=12pt,
\egroup
\stopsetups
-\positioningpartrue \positioningtrue
+\enableparpositions % slows down but who uses fo anyway ...
\startsetups fo:position:absolute:start
\setbox\FOpositionbox\hbox\bgroup
diff --git a/tex/context/interface/cont-cs.xml b/tex/context/interface/cont-cs.xml
index a94af8caf..3bfad5fb4 100644
--- a/tex/context/interface/cont-cs.xml
+++ b/tex/context/interface/cont-cs.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-de.xml b/tex/context/interface/cont-de.xml
index b70518625..2fe0f460c 100644
--- a/tex/context/interface/cont-de.xml
+++ b/tex/context/interface/cont-de.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-en.xml b/tex/context/interface/cont-en.xml
index 354bdab81..e15d017a2 100644
--- a/tex/context/interface/cont-en.xml
+++ b/tex/context/interface/cont-en.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-fr.xml b/tex/context/interface/cont-fr.xml
index bdec329eb..0a4e5bb4d 100644
--- a/tex/context/interface/cont-fr.xml
+++ b/tex/context/interface/cont-fr.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-it.xml b/tex/context/interface/cont-it.xml
index e0f77e265..8064a3294 100644
--- a/tex/context/interface/cont-it.xml
+++ b/tex/context/interface/cont-it.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml
index d6a236795..c8f221c58 100644
--- a/tex/context/interface/cont-nl.xml
+++ b/tex/context/interface/cont-nl.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-pe.xml b/tex/context/interface/cont-pe.xml
index c2e43dc32..0f320aa8e 100644
--- a/tex/context/interface/cont-pe.xml
+++ b/tex/context/interface/cont-pe.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/context/interface/cont-ro.xml b/tex/context/interface/cont-ro.xml
index 61dd00f59..152201dc4 100644
--- a/tex/context/interface/cont-ro.xml
+++ b/tex/context/interface/cont-ro.xml
@@ -8722,6 +8722,9 @@
+
+
+
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index e369b6746..03eeed936 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 07/17/09 13:18:01
+-- merge date : 07/23/09 20:13:36
do -- begin closure to overcome local limits and interference
@@ -2924,11 +2924,6 @@ if not modules then modules = { } end modules ['node-dum'] = {
nodes = nodes or { }
-function nodes.simple_font_dummy(head,tail)
- -- ligaturing, kerning
- return head, tail
-end
-
function nodes.simple_font_handler(head)
-- lang.hyphenate(head)
head = nodes.process_characters(head)
diff --git a/tex/generic/context/luatex-fonts.lua b/tex/generic/context/luatex-fonts.lua
index 690a6e599..56768138b 100644
--- a/tex/generic/context/luatex-fonts.lua
+++ b/tex/generic/context/luatex-fonts.lua
@@ -37,7 +37,7 @@ local function loadmodule(name,continue)
end
else
if verbose then
- texio.write(string.format(" <%s>",string.match(name,"([a-z%-]-%.[a-z]-)$"))) -- no file.basename yet
+ texio.write(string.format(" <%s>",foundname)) -- no file.basename yet
end
dofile(foundname)
end
@@ -128,8 +128,8 @@ end
-- In order to deal with the fonts we need to initialize some
-- callbacks. One can overload them later on if needed.
-callback.register('ligaturing', nodes.simple_font_dummy) -- better: false
-callback.register('kerning', nodes.simple_font_dummy) -- better: false
+callback.register('ligaturing', false)
+callback.register('kerning', false)
callback.register('pre_linebreak_filter', nodes.simple_font_handler)
callback.register('hpack_filter', nodes.simple_font_handler)
callback.register('define_font' , fonts.define.read)
--
cgit v1.2.3