summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/attr-eff.mkiv39
-rw-r--r--tex/context/base/attr-lay.lua69
-rw-r--r--tex/context/base/attr-lay.mkiv73
-rw-r--r--tex/context/base/attr-neg.mkiv6
-rw-r--r--tex/context/base/back-exp.lua2
-rw-r--r--tex/context/base/back-ini.lua1
-rw-r--r--tex/context/base/back-pdf.lua4
-rw-r--r--tex/context/base/cldf-com.lua37
-rw-r--r--tex/context/base/colo-ini.mkiv5
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.mkiv9
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/core-fil.mkii6
-rw-r--r--tex/context/base/core-fil.mkiv24
-rw-r--r--tex/context/base/data-env.lua338
-rw-r--r--tex/context/base/data-res.lua149
-rw-r--r--tex/context/base/data-tex.lua4
-rw-r--r--tex/context/base/font-chk.lua2
-rw-r--r--tex/context/base/font-col.lua2
-rw-r--r--tex/context/base/font-ctx.lua120
-rw-r--r--tex/context/base/font-def.lua117
-rw-r--r--tex/context/base/font-dum.lua2
-rw-r--r--tex/context/base/font-ext.lua2
-rw-r--r--tex/context/base/font-gds.lua2
-rw-r--r--tex/context/base/font-ini.lua26
-rw-r--r--tex/context/base/font-ini.mkiv4
-rw-r--r--tex/context/base/font-ota.lua2
-rw-r--r--tex/context/base/font-otd.lua2
-rw-r--r--tex/context/base/font-otf.lua14
-rw-r--r--tex/context/base/font-otn.lua2
-rw-r--r--tex/context/base/font-tfm.lua6
-rw-r--r--tex/context/base/font-xtx.lua2
-rw-r--r--tex/context/base/java-ini.mkiv3
-rw-r--r--tex/context/base/l-dimen.lua2
-rw-r--r--tex/context/base/l-file.lua7
-rw-r--r--tex/context/base/l-lpeg.lua10
-rw-r--r--tex/context/base/lpdf-ano.lua2
-rw-r--r--tex/context/base/lpdf-fld.lua2
-rw-r--r--tex/context/base/lpdf-ini.lua2
-rw-r--r--tex/context/base/lpdf-ren.lua44
-rw-r--r--tex/context/base/lpdf-swf.lua4
-rw-r--r--tex/context/base/lpdf-u3d.lua28
-rw-r--r--tex/context/base/luat-cnf.lua68
-rw-r--r--tex/context/base/luat-exe.lua11
-rw-r--r--tex/context/base/luat-iop.lua6
-rw-r--r--tex/context/base/m-chart.mkii1269
-rw-r--r--tex/context/base/m-chart.mkiv2539
-rw-r--r--tex/context/base/m-chart.tex1269
-rw-r--r--tex/context/base/m-chemic.tex17
-rw-r--r--tex/context/base/m-database.lua24
-rw-r--r--tex/context/base/m-database.mkiv2
-rw-r--r--tex/context/base/m-graph.mkii161
-rw-r--r--tex/context/base/m-graph.mkiv69
-rw-r--r--tex/context/base/m-graph.tex175
-rw-r--r--tex/context/base/m-pstricks.tex16
-rw-r--r--tex/context/base/m-punk.mkiv2
-rw-r--r--tex/context/base/m-punk.tex3
-rw-r--r--tex/context/base/math-ext.lua4
-rw-r--r--tex/context/base/math-ini.lua6
-rw-r--r--tex/context/base/math-noa.lua28
-rw-r--r--tex/context/base/math-vfu.lua32
-rw-r--r--tex/context/base/meta-ini.mkiv11
-rw-r--r--tex/context/base/mult-sys.mkiv2
-rw-r--r--tex/context/base/node-aux.lua8
-rw-r--r--tex/context/base/node-dum.lua55
-rw-r--r--tex/context/base/node-fin.lua3
-rw-r--r--tex/context/base/node-fnt.lua10
-rw-r--r--tex/context/base/node-inj.lua22
-rw-r--r--tex/context/base/node-mig.mkiv7
-rw-r--r--tex/context/base/node-res.lua5
-rw-r--r--tex/context/base/node-rul.lua2
-rw-r--r--tex/context/base/node-ser.lua5
-rw-r--r--tex/context/base/node-spl.lua2
-rw-r--r--tex/context/base/node-tra.lua120
-rw-r--r--tex/context/base/norm-ptx.tex2
-rw-r--r--tex/context/base/page-ini.mkiv31
-rw-r--r--tex/context/base/page-mak.mkiv4
-rw-r--r--tex/context/base/page-mar.mkiv2
-rw-r--r--tex/context/base/page-mul.mkiv2
-rw-r--r--tex/context/base/page-set.mkiv29
-rw-r--r--tex/context/base/page-txt.mkiv76
-rw-r--r--tex/context/base/prop-eff.mkiv46
-rw-r--r--tex/context/base/prop-ini.mkiv140
-rw-r--r--tex/context/base/prop-lay.mkiv140
-rw-r--r--tex/context/base/prop-neg.mkiv40
-rw-r--r--tex/context/base/s-fnt-10.tex8
-rw-r--r--tex/context/base/s-fnt-23.tex6
-rw-r--r--tex/context/base/s-fnt-25.tex4
-rw-r--r--tex/context/base/s-fnt-29.tex2
-rw-r--r--tex/context/base/s-map-10.mkii (renamed from tex/context/base/s-map-10.tex)0
-rw-r--r--tex/context/base/s-map-10.mkiv463
-rw-r--r--tex/context/base/s-pre-30.mkii (renamed from tex/context/base/s-pre-30.tex)0
-rw-r--r--tex/context/base/s-pre-30.mkiv257
-rw-r--r--tex/context/base/s-pre-60.mkii (renamed from tex/context/base/s-pre-60.tex)44
-rw-r--r--tex/context/base/s-pre-60.mkiv132
-rw-r--r--tex/context/base/s-pre-71.mkii (renamed from tex/context/base/s-pre-71.tex)0
-rw-r--r--tex/context/base/s-pre-71.mkiv213
-rw-r--r--tex/context/base/scrp-ini.lua2
-rw-r--r--tex/context/base/spac-ver.lua6
-rw-r--r--tex/context/base/strc-def.mkiv1
-rw-r--r--tex/context/base/strc-ini.mkiv4
-rw-r--r--tex/context/base/strc-mar.lua535
-rw-r--r--tex/context/base/strc-mar.mkiv548
-rw-r--r--tex/context/base/strc-ref.mkiv5
-rw-r--r--tex/context/base/strc-ren.mkiv48
-rw-r--r--tex/context/base/strc-sbe.mkiv8
-rw-r--r--tex/context/base/strc-sec.mkiv105
-rw-r--r--tex/context/base/supp-fil.lua33
-rw-r--r--tex/context/base/symb-ini.mkiv5
-rw-r--r--tex/context/base/tabl-tab.mkiv58
-rw-r--r--tex/context/base/trac-set.lua27
-rw-r--r--tex/context/base/typo-cap.lua5
-rw-r--r--tex/context/base/typo-dir.lua6
-rw-r--r--tex/context/base/typo-rep.lua2
-rw-r--r--tex/context/base/util-seq.lua16
-rw-r--r--tex/context/base/x-chemml.tex16
-rw-r--r--tex/context/base/x-mathml.tex16
-rw-r--r--tex/context/base/x-newcml.mkii (renamed from tex/context/base/x-newcml.tex)0
-rw-r--r--tex/context/base/x-newmme.mkii (renamed from tex/context/base/x-newmme.tex)0
-rw-r--r--tex/context/base/x-newmml.tex16
-rw-r--r--tex/context/base/x-newmmo.mkii (renamed from tex/context/base/x-newmmo.tex)0
-rw-r--r--tex/context/base/x-newpml.mkii (renamed from tex/context/base/x-newpml.tex)0
-rw-r--r--tex/context/base/x-physml.tex16
-rw-r--r--tex/context/base/x-res-50.mkii (renamed from tex/context/base/x-res-50.tex)0
-rw-r--r--tex/context/base/x-res-50.mkiv427
-rw-r--r--tex/context/base/x-set-11.tex110
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua269
-rw-r--r--tex/generic/context/luatex-fonts.lua29
128 files changed, 7667 insertions, 3419 deletions
diff --git a/tex/context/base/attr-eff.mkiv b/tex/context/base/attr-eff.mkiv
index f4b05a14e..ea2dfcd4b 100644
--- a/tex/context/base/attr-eff.mkiv
+++ b/tex/context/base/attr-eff.mkiv
@@ -15,6 +15,8 @@
\registerctxluafile{attr-eff}{1.001}
+% more will move to the lua end (old code, early luatex approach)
+
\unprotect
\def\registereffect#1#2#3% #2=stretch #3=rulethickness
@@ -28,10 +30,37 @@
\csname(es:##1:##2:\number\dimexpr##3\relax)\endcsname}%
\dotriggereffect}
-% \registereffect{normal}
-% \registereffect{inner}
-% \registereffect{outer}
-% \registereffect{both}
-% \registereffect{hidden}
+\unexpanded\def\setupeffect
+ {\dodoubleargument\dosetupeffect}
+
+\def\dosetupeffect[#1][#2]%
+ {\getparameters[\??et#1][#2]}
+
+\unexpanded\def\defineeffect
+ {\dodoubleargument\dodefineeffect}
+
+\def\dodefineeffect[#1][#2]%
+ {\getparameters[\??et#1][\c!method=\v!none,\c!stretch=0,\c!rulethickness=\zeropoint,\c!alternative=\v!normal,#2]%
+ \doif{\getvalue{\??et#1\c!method}}\v!command
+ {\setugvalue{\e!start#1}{\starteffect[#1]}%
+ \setugvalue{\e!stop #1}{\stopeffect }}}
+
+% yes or no grouped
+
+\unexpanded\def\starteffect[#1]%
+ {\dotriggereffect{\getvalue{\??et#1\c!alternative}}{\getvalue{\??et#1\c!stretch}}{\getvalue{\??et#1\c!rulethickness}}}
+
+\unexpanded\def\stopeffect % can be special
+ {\dotriggereffect\v!normal0\zeropoint}
+
+\unexpanded\def\effect[#1]%
+ {\groupedcommand{\starteffect[#1]}{\stopeffect}}
+
+\defineeffect [\v!inner] [\c!alternative=\v!inner,\c!rulethickness=.25pt]
+\defineeffect [\v!outer] [\c!alternative=\v!outer,\c!rulethickness=.25pt]
+\defineeffect [\v!both] [\c!alternative=\v!both, \c!rulethickness=.25pt]
+\defineeffect [\v!normal] [\c!alternative=\v!normal]
+\defineeffect [\v!hidden] [\c!alternative=\v!hidden]
+\defineeffect [\v!stretch] [\c!alternative=\v!stretch,\c!stretch=1]
\protect \endinput
diff --git a/tex/context/base/attr-lay.lua b/tex/context/base/attr-lay.lua
index df7a4e6bb..1c13762c4 100644
--- a/tex/context/base/attr-lay.lua
+++ b/tex/context/base/attr-lay.lua
@@ -12,6 +12,7 @@ if not modules then modules = { } end modules ['attr-lay'] = {
local type = type
local format = string.format
+local insert, remove = table.insert, table.remove
local allocate = utilities.storage.allocate
@@ -26,21 +27,28 @@ local report_viewerlayers = logs.new("viewerlayers")
local attributes, nodes = attributes, nodes
attributes.viewerlayers = attributes.viewerlayers or { }
+local viewerlayers = attributes.viewerlayers
-local viewerlayers = attributes.viewerlayers
+local a_viewerlayer = attributes.private("viewerlayer")
viewerlayers = viewerlayers or { }
viewerlayers.data = allocate()
viewerlayers.registered = viewerlayers.registered or { }
viewerlayers.values = viewerlayers.values or { }
viewerlayers.listwise = allocate()
-viewerlayers.attribute = attributes.private("viewerlayer")
+viewerlayers.attribute = a_viewerlayer
viewerlayers.supported = true
viewerlayers.hasorder = true
-local states = attributes.states
-local tasks = nodes.tasks
-local nodeinjections = backends.nodeinjections
+local states = attributes.states
+local tasks = nodes.tasks
+local nodeinjections = backends.nodeinjections
+local codeinjections = backends.codeinjections
+
+local texsetattribute = tex.setattribute
+local texgetattribute = tex.getattribute
+local texsettokenlist = tex.settoks
+local unsetvalue = attributes.unsetvalue
storage.register("attributes/viewerlayers/registered", viewerlayers.registered, "attributes.viewerlayers.registered")
storage.register("attributes/viewerlayers/values", viewerlayers.values, "attributes.viewerlayers.values")
@@ -81,7 +89,7 @@ local function initializer(...)
return states.initialize(...)
end
-viewerlayers.register = function(name,lw) -- if not inimode redefine data[n] in first call
+local function register(name,lw) -- if not inimode redefine data[n] in first call
local stamp = format(template,name)
local n = registered[stamp]
if not n then
@@ -93,6 +101,8 @@ viewerlayers.register = function(name,lw) -- if not inimode redefine data[n] in
return registered[stamp] -- == n
end
+viewerlayers.register = register
+
attributes.viewerlayers.handler = nodes.installattributehandler {
name = "viewerlayer",
namespace = viewerlayers,
@@ -118,3 +128,50 @@ end
function viewerlayers.setfeatures(hasorder)
viewerlayers.hasorder = hasorder
end
+
+local stack, enabled, global = { }, false, false
+
+function viewerlayers.start(name)
+ if not enabled then
+ viewerlayers.enable(true)
+ end
+ insert(stack,texgetattribute(a_viewerlayer))
+ if global then
+ texsetattribute("global",a_viewerlayer,register(name) or unsetvalue)
+ else
+ texsetattribute(a_viewerlayer,register(name) or unsetvalue)
+ end
+ texsettokenlist("currentviewerlayertoks",name)
+end
+
+function viewerlayers.stop()
+ local a = remove(stack)
+ if a >= 0 then
+ if global then
+ texsetattribute("global",a_viewerlayer,a)
+ else
+ texsetattribute(a_viewerlayer,a)
+ end
+ texsettokenlist("currentviewerlayertoks",values[a])
+ else
+ if global then
+ texsetattribute("global",a_viewerlayer,unsetvalue)
+ else
+ texsetattribute(a_viewerlayer,unsetvalue)
+ end
+ texsettokenlist("currentviewerlayertoks","")
+ end
+end
+
+function viewerlayers.define(settings)
+ local tag = settings.tag
+ if not tag or tag == "" then
+ -- error
+ else
+ local title = settings.title
+ if not title or title == "" then
+ settings.title = tag
+ end
+ codeinjections.defineviewerlayer(settings)
+ end
+end
diff --git a/tex/context/base/attr-lay.mkiv b/tex/context/base/attr-lay.mkiv
index 42a628f03..efc9f4514 100644
--- a/tex/context/base/attr-lay.mkiv
+++ b/tex/context/base/attr-lay.mkiv
@@ -15,6 +15,8 @@
\unprotect
+\def\c!printable{printable} % todo
+
\registerctxluafile{attr-lay}{1.001}
% needs to work over stopitemize grouping etc
@@ -29,4 +31,75 @@
\gdef\dotriggerviewerlayer##1{\csname(vl:##1)\endcsname}%
\dotriggerviewerlayer}
+\getparameters
+ [\??lr]
+ [\c!state=\v!start,
+ \c!title=,
+ \c!printable=\v!yes,
+ \c!method=\v!none]
+
+\def\defineviewerlayer
+ {\dodoubleargument\dodefineviewerlayer}
+
+\def\dodefineviewerlayer[#1][#2]% document wide properties
+ {\begingroup
+ \getparameters[\??lr][#2]%
+ \ctxlua{attributes.viewerlayers.define{
+ tag = "#1",
+ title = "\@@lrtitle",
+ visible = "\@@lrstate",
+ kind = 0, % 1 == frozen
+ printable = "\@@lrprintable",
+ }}%
+ \doif\@@lrmethod\v!command
+ {\setugvalue{\e!start#1}{\startviewerlayer[#1]}%
+ \setugvalue{\e!stop #1}{\stopviewerlayer }}%
+ \endgroup}
+
+\unexpanded\def\startviewerlayer[#1]{\ctxlua{attributes.viewerlayers.start("#1")}} % not grouped
+\unexpanded\def\stopviewerlayer {\ctxlua{attributes.viewerlayers.stop()}} % not grouped
+\unexpanded\def\viewerlayer [#1]{\groupedcommand{\startviewerlayer[#1]}{\stopviewerlayer}} % grouped
+
+% some day we will keep this at the lua end as the info is only needed there
+
+\let\currentviewerlayer\empty \newtoks\currentviewerlayertoks % soon we can set macros at the lua end
+
+\def\currentviewerlayer{\the\currentviewerlayertoks}
+
+\appendtoks
+ \let\currentviewerlayer\empty
+\to \everypagebody
+
+% layout components are implemented rather directly (speed)
+
+\def\doinitializelayoutcomponent#1#2%
+ {\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(attributes.viewerlayers.register('#1:#2',true))}\relax}%
+ \expandafter\glet\csname\??ly>#1:#2\endcsname\layoutcomponentboxattribute}
+
+\def\dosetlayoutcomponentattribute#1#2% make this faster
+ {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??ly>#1:#2\endcsname
+ \ifx\layoutcomponentboxattribute\relax
+ \doinitializelayoutcomponent{#1}{#2}% get rid of { }
+ \fi}
+
+\def\doresetlayoutcomponentattribute
+ {\let\layoutcomponentboxattribute\empty}
+
+\let\setlayoutcomponentattribute \gobbletwoarguments
+\let\resetlayoutcomponentattribute\relax
+\let\layoutcomponentboxattribute \empty
+
+\def\showlayoutcomponents
+ {\ctxlua{attributes.viewerlayers.enable()}%
+ \let\setlayoutcomponentattribute \dosetlayoutcomponentattribute
+ \let\resetlayoutcomponentattribute\doresetlayoutcomponentattribute}
+
+
\protect \endinput
diff --git a/tex/context/base/attr-neg.mkiv b/tex/context/base/attr-neg.mkiv
index 20a1489c3..7ffd7ae19 100644
--- a/tex/context/base/attr-neg.mkiv
+++ b/tex/context/base/attr-neg.mkiv
@@ -28,4 +28,10 @@
\registernegative{positive}{positive}
\registernegative{negative}{negative}
+\unexpanded\def\startnegative{\dotriggernegative\v!negative}
+\unexpanded\def\stopnegative {\dotriggernegative\v!positive}
+
+\unexpanded\def\startpositive{\dotriggernegative\v!positive}
+\unexpanded\def\stoppositive {\dotriggernegative\v!negative}
+
\protect \endinput
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua
index 28cb5c18c..892f35946 100644
--- a/tex/context/base/back-exp.lua
+++ b/tex/context/base/back-exp.lua
@@ -56,7 +56,7 @@ local attributes = attributes
local variables = interfaces.variables
local tasks = nodes.tasks
-local fontchar = fonts.chr
+local fontchar = fonts.characters
local languagenames = languages.numbers
local nodecodes = nodes.nodecodes
diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua
index 1bceea691..10f908798 100644
--- a/tex/context/base/back-ini.lua
+++ b/tex/context/base/back-ini.lua
@@ -75,6 +75,7 @@ backends.codeinjections = {
setpagetransition = nothing,
defineviewerlayer = nothing,
+ useviewerlayer = nothing,
addbookmarks = nothing,
diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua
index c9c0982f0..eec82d5f2 100644
--- a/tex/context/base/back-pdf.lua
+++ b/tex/context/base/back-pdf.lua
@@ -90,6 +90,7 @@ local cache = { }
function nodeinjections.startlayer(name)
local c = cache[name]
if not c then
+ codeinjections.useviewerlayer(name)
c = register(pdfliteral(format("/OC /%s BDC",name)))
cache[name] = c
end
@@ -104,9 +105,10 @@ end
local cache = { }
-function nodeinjections.switchlayer(name)
+function nodeinjections.switchlayer(name) -- not used, optimization
local c = cache[name]
if not c then
+ codeinjections.useviewerlayer(name)
c = register(pdfliteral(format("EMC /OC /%s BDC",name)))
end
return copy_node(c)
diff --git a/tex/context/base/cldf-com.lua b/tex/context/base/cldf-com.lua
index 3bbeabb0f..5ab1d8c8d 100644
--- a/tex/context/base/cldf-com.lua
+++ b/tex/context/base/cldf-com.lua
@@ -6,8 +6,45 @@ if not modules then modules = { } end modules ['cldf-com'] = {
license = "see context related readme files"
}
+local context = context
local generics = context.generics
local variables = interfaces.variables
generics.starttabulate = "start" .. variables.tabulate -- todo: e!start
generics.stoptabulate = "stop" .. variables.tabulate -- todo: e!stop
+
+local NC, NR = context.NC, context.NR
+
+local function tabulaterow(how,...)
+ local t = { ... }
+ for i=1,#t do
+ local ti = tostring(t[i])
+ NC()
+ if how then
+ context[how](ti)
+ else
+ context(ti)
+ end
+ end
+ NC()
+ NR()
+end
+
+function context.tabulaterow (...) tabulaterow(false, ...) end
+function context.tabulaterowbold(...) tabulaterow("bold",...) end
+function context.tabulaterowtype(...) tabulaterow("type",...) end
+function context.tabulaterowtyp (...) tabulaterow("typ", ...) end
+
+function context.concat(t,separator)
+ local done = false
+ for i=1,#t do
+ local ti = t[i]
+ if ti ~= "" then
+ if done then
+ context(separator)
+ end
+ context(t)
+ done = true
+ end
+ end
+end
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv
index a94495a0b..406cc619d 100644
--- a/tex/context/base/colo-ini.mkiv
+++ b/tex/context/base/colo-ini.mkiv
@@ -217,9 +217,8 @@
\processcommalist[#1]\dodosetupcolor}}
\def\dodosetupcolor#1%
- {\makeshortfilename[\truefilename{\f!colorprefix#1}]%
- \startreadingfile
- \readsysfile\shortfilename
+ {\startreadingfile
+ \readsysfile{\truefilename{\f!colorprefix#1}}
{\showcolormessage\m!colors4\colorstyle}
{\showcolormessage\m!colors5\colorstyle}%
\stopreadingfile}
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index ed43fb610..56f0cc8c6 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{2010.11.03 19:42}
+\newcontextversion{2010.11.12 18:22}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 754b518f8..7748b750e 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -91,6 +91,7 @@
\loadmarkfile{attr-col}
\loadmarkfile{attr-lay}
+\loadmarkfile{attr-neg}
\loadmarkfile{attr-eff}
\loadmarkfile{trac-tex}
@@ -275,10 +276,10 @@
\loadmarkfile{scrp-ini}
-\loadmarkfile{prop-ini}
-\loadmarkfile{prop-lay}
-\loadmarkfile{prop-eff}
-\loadmarkfile{prop-neg}
+\loadmarkfile{prop-ini} % only for downward compatibility
+%loadmarkfile{prop-lay}
+%loadmarkfile{prop-neg}
+%loadmarkfile{prop-eff}
\loadmarkfile{mlib-ctx}
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index bfd1b6119..272c2f1a4 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{2010.11.03 19:42}
+\edef\contextversion{2010.11.12 18:22}
%D For those who want to use this:
diff --git a/tex/context/base/core-fil.mkii b/tex/context/base/core-fil.mkii
index fca253a7b..ad22ade1e 100644
--- a/tex/context/base/core-fil.mkii
+++ b/tex/context/base/core-fil.mkii
@@ -128,6 +128,12 @@
%D More information on the specific modules can be found in
%D their dedicated manuals. We use \type {\next} so that we
%D can \type {\end} in modules.
+%D
+%D In \MKIV\ we load the \type {mkiv} file when there is a \type
+%D {tex} file on the same path but in \MKII\ we start with the \type
+%D {tex} file as in many cases a \type {mkii} will be the same as an
+%D (old) \type {tex} one simply because we don't update drastically
+%D (or load a mark file indirectly).
\newconditional\moduleisloaded
diff --git a/tex/context/base/core-fil.mkiv b/tex/context/base/core-fil.mkiv
index 14856fc0f..e96feae07 100644
--- a/tex/context/base/core-fil.mkiv
+++ b/tex/context/base/core-fil.mkiv
@@ -75,32 +75,10 @@
%D
%D The implementation shows that nesting is supported.
-\def\truefilename#1%
+\def\truefilename#1% this will move to lua
{\ifcsname\??fs#1\endcsname\expandafter\truefilename\csname\??fs#1\endcsname\else#1\fi}
%D \macros
-%D {makeshortfilename}
-%D
-%D To prevent cross platform problems with filenames, we
-%D lowercase them as well as only use the first 8~characters.
-%D
-%D \starttyping
-%D \def\domakeshortfilename[#1#2#3#4#5#6#7#8#9]%
-%D {\lowercase{\edef\shortfilename{#1#2#3#4#5#6#7#8.}}%
-%D \expandafter\beforesplitstring\shortfilename\at.\to\shortfilename}
-%D
-%D \def\makeshortfilename[#1]%
-%D {\edef\fullfilename{#1.........}%
-%D \expanded{\domakeshortfilename[\fullfilename]}}
-%D \stoptyping
-%D
-%D In 2005 there is no need for the 8~character limit any more, so:
-
-\def\makeshortfilename[#1]% no need for further cleanup and shortening
- {\lowercase{\edef\shortfilename{#1.}}%
- \expandafter\beforesplitstring\shortfilename\at.\to\shortfilename}
-
-%D \macros
%D {usemodule}
%D
%D Most of \CONTEXT is preloaded in the format file. Some very
diff --git a/tex/context/base/data-env.lua b/tex/context/base/data-env.lua
index ac476593d..c6035d799 100644
--- a/tex/context/base/data-env.lua
+++ b/tex/context/base/data-env.lua
@@ -7,125 +7,245 @@ if not modules then modules = { } end modules ['data-env'] = {
}
local allocate = utilities.storage.allocate
+local lower, gsub = string.lower, string.gsub
+
+local fileextname = file.extname
local resolvers = resolvers
-local formats = allocate() resolvers.formats = formats
-local suffixes = allocate() resolvers.suffixes = suffixes
-local dangerous = allocate() resolvers.dangerous = dangerous
-local suffixmap = allocate() resolvers.suffixmap = suffixmap
-local alternatives = allocate() resolvers.alternatives = alternatives
-
-formats['afm'] = 'AFMFONTS' suffixes['afm'] = { 'afm' }
-formats['enc'] = 'ENCFONTS' suffixes['enc'] = { 'enc' }
-formats['fmt'] = 'TEXFORMATS' suffixes['fmt'] = { 'fmt' }
-formats['map'] = 'TEXFONTMAPS' suffixes['map'] = { 'map' }
-formats['mp'] = 'MPINPUTS' suffixes['mp'] = { 'mp' }
-formats['ofm'] = 'OFMFONTS' suffixes['ofm'] = { 'ofm', 'tfm' }
-formats['otf'] = 'OPENTYPEFONTS' suffixes['otf'] = { 'otf' }
-formats['opl'] = 'OPLFONTS' suffixes['opl'] = { 'opl' }
-formats['otp'] = 'OTPINPUTS' suffixes['otp'] = { 'otp' }
-formats['ovf'] = 'OVFFONTS' suffixes['ovf'] = { 'ovf', 'vf' }
-formats['ovp'] = 'OVPFONTS' suffixes['ovp'] = { 'ovp' }
-formats['tex'] = 'TEXINPUTS' suffixes['tex'] = { 'tex' }
-formats['tfm'] = 'TFMFONTS' suffixes['tfm'] = { 'tfm' }
-formats['ttf'] = 'TTFONTS' suffixes['ttf'] = { 'ttf', 'ttc', 'dfont' }
-formats['pfb'] = 'T1FONTS' suffixes['pfb'] = { 'pfb', 'pfa' }
-formats['vf'] = 'VFFONTS' suffixes['vf'] = { 'vf' }
-formats['fea'] = 'FONTFEATURES' suffixes['fea'] = { 'fea' }
-formats['cid'] = 'FONTCIDMAPS' suffixes['cid'] = { 'cid', 'cidmap' }
-formats['icc'] = 'ICCPROFILES' suffixes['icc'] = { 'icc' }
-formats['texmfscripts'] = 'TEXMFSCRIPTS' suffixes['texmfscripts'] = { 'rb', 'pl', 'py' }
-formats['lua'] = 'LUAINPUTS' suffixes['lua'] = { 'lua', 'luc', 'tma', 'tmc' }
-formats['lib'] = 'CLUAINPUTS' suffixes['lib'] = (os.libsuffix and { os.libsuffix }) or { 'dll', 'so' }
-
--- backward compatible ones
-
-alternatives['map files'] = 'map'
-alternatives['enc files'] = 'enc'
-alternatives['cid maps'] = 'cid' -- great, why no cid files
-alternatives['font feature files'] = 'fea' -- and fea files here
-alternatives['opentype fonts'] = 'otf'
-alternatives['truetype fonts'] = 'ttf'
-alternatives['truetype collections'] = 'ttc'
-alternatives['truetype dictionary'] = 'dfont'
-alternatives['type1 fonts'] = 'pfb'
-alternatives['icc profiles'] = 'icc'
-
---[[ldx--
-<p>If you wondered about some of the previous mappings, how about
-the next bunch:</p>
---ldx]]--
-
--- kpse specific ones (a few omitted) .. we only add them for locating
--- files that we don't use anyway
-
-formats['base'] = 'MFBASES' suffixes['base'] = { 'base', 'bas' }
-formats['bib'] = '' suffixes['bib'] = { 'bib' }
-formats['bitmap font'] = '' suffixes['bitmap font'] = { }
-formats['bst'] = '' suffixes['bst'] = { 'bst' }
-formats['cmap files'] = 'CMAPFONTS' suffixes['cmap files'] = { 'cmap' }
-formats['cnf'] = '' suffixes['cnf'] = { 'cnf' }
-formats['cweb'] = '' suffixes['cweb'] = { 'w', 'web', 'ch' }
-formats['dvips config'] = '' suffixes['dvips config'] = { }
-formats['gf'] = '' suffixes['gf'] = { '<resolution>gf' }
-formats['graphic/figure'] = '' suffixes['graphic/figure'] = { 'eps', 'epsi' }
-formats['ist'] = '' suffixes['ist'] = { 'ist' }
-formats['lig files'] = 'LIGFONTS' suffixes['lig files'] = { 'lig' }
-formats['ls-R'] = '' suffixes['ls-R'] = { }
-formats['mem'] = 'MPMEMS' suffixes['mem'] = { 'mem' }
-formats['MetaPost support'] = '' suffixes['MetaPost support'] = { }
-formats['mf'] = 'MFINPUTS' suffixes['mf'] = { 'mf' }
-formats['mft'] = '' suffixes['mft'] = { 'mft' }
-formats['misc fonts'] = '' suffixes['misc fonts'] = { }
-formats['other text files'] = '' suffixes['other text files'] = { }
-formats['other binary files'] = '' suffixes['other binary files'] = { }
-formats['pdftex config'] = 'PDFTEXCONFIG' suffixes['pdftex config'] = { }
-formats['pk'] = '' suffixes['pk'] = { '<resolution>pk' }
-formats['PostScript header'] = 'TEXPSHEADERS' suffixes['PostScript header'] = { 'pro' }
-formats['sfd'] = 'SFDFONTS' suffixes['sfd'] = { 'sfd' }
-formats['TeX system documentation'] = '' suffixes['TeX system documentation'] = { }
-formats['TeX system sources'] = '' suffixes['TeX system sources'] = { }
-formats['Troff fonts'] = '' suffixes['Troff fonts'] = { }
-formats['type42 fonts'] = 'T42FONTS' suffixes['type42 fonts'] = { }
-formats['web'] = '' suffixes['web'] = { 'web', 'ch' }
-formats['web2c files'] = 'WEB2C' suffixes['web2c files'] = { }
-formats['fontconfig files'] = 'FONTCONFIG_PATH' suffixes['fontconfig files'] = { } -- not unique
-
-alternatives['subfont definition files'] = 'sfd'
+local formats = allocate() resolvers.formats = formats
+local suffixes = allocate() resolvers.suffixes = suffixes
+local dangerous = allocate() resolvers.dangerous = dangerous
+local suffixmap = allocate() resolvers.suffixmap = suffixmap
--- A few accessors, mostly for command line tool.
+local relations = allocate {
+ core = {
+ ofm = {
+ names = { "ofm", "omega font metric", "omega font metrics" },
+ variable = 'OFMFONTS',
+ suffixes = { 'ofm', 'tfm' },
+ },
+ ovf = {
+ names = { "ovf", "omega virtual font", "omega virtual fonts" },
+ variable = 'OVFFONTS',
+ suffixes = { 'ovf', 'vf' },
+ },
+ tfm = {
+ names = { "tfm", "tex font metric", "tex font metrics" },
+ variable = 'TFMFONTS',
+ suffixes = { 'tfm' },
+ },
+ vf = {
+ names = { "vf", "virtual font", "virtual fonts" },
+ variable = 'VFFONTS',
+ suffixes = { 'vf' },
+ },
+ otf = {
+ names = { "otf", "opentype", "opentype font", "opentype fonts"},
+ variable = 'OPENTYPEFONTS',
+ suffixes = { 'otf' },
+ },
+ ttf = {
+ names = { "ttf", "truetype", "truetype font", "truetype fonts", "truetype collection", "truetype collections", "truetype dictionary", "truetype dictionaries" },
+ variable = 'TTFONTS',
+ suffixes = { 'ttf', 'ttc', 'dfont' },
+ },
+ afm = {
+ names = { "afm", "adobe font metric", "adobe font metrics" },
+ variable = "AFMFONTS",
+ suffixes = { "afm" },
+ },
+ pfb = {
+ names = { "pfb", "type1", "type 1", "type1 font", "type 1 font", "type1 fonts", "type 1 fonts" },
+ variable = 'T1FONTS',
+ suffixes = { 'pfb', 'pfa' },
+ },
+ fea = {
+ names = { "fea", "font feature", "font features", "font feature file", "font feature files" },
+ variable = 'FONTFEATURES',
+ suffixes = { 'fea' },
+ },
+ cid = {
+ names = { "cid", "cid map", "cid maps", "cid file", "cid files" },
+ variable = 'FONTCIDMAPS',
+ suffixes = { 'cid', 'cidmap' },
+ },
+ fmt = {
+ names = { "fmt", "format", "tex format" },
+ variable = 'TEXFORMATS',
+ suffixes = { 'fmt' },
+ },
+ mem = {
+ names = { 'mem', "metapost format" },
+ variable = 'MPMEMS',
+ suffixes = { 'mem' },
+ },
+ mp = {
+ names = { "mp" },
+ variable = 'MPINPUTS',
+ suffixes = { 'mp' },
+ },
+ tex = {
+ names = { "tex" },
+ variable = 'TEXINPUTS',
+ suffixes = { 'tex', "mkiv", "mkii" },
+ },
+ icc = {
+ names = { "icc", "icc profile", "icc profiles" },
+ variable = 'ICCPROFILES',
+ suffixes = { 'icc' },
+ },
+ texmfscripts = {
+ names = { "texmfscript", "texmfscripts", "script", "scripts" },
+ variable = 'TEXMFSCRIPTS',
+ suffixes = { 'rb', 'pl', 'py' },
+ },
+ lua = {
+ names = { "lua" },
+ variable = 'LUAINPUTS',
+ suffixes = { 'lua', 'luc', 'tma', 'tmc' },
+ },
+ lib = {
+ names = { "lib" },
+ variable = 'CLUAINPUTS',
+ suffixes = os.libsuffix and { os.libsuffix } or { 'dll', 'so' },
+ },
+ bib = {
+ names = { 'bib' },
+ suffixes = { 'bib' },
+ },
+ bst = {
+ names = { 'bst' },
+ suffixes = { 'bst' },
+ },
+ fontconfig = {
+ names = { 'fontconfig', 'fontconfig file', 'fontconfig files' },
+ variable = 'FONTCONFIG_PATH',
+ },
+ },
+ obsolete = {
+ enc = {
+ names = { "enc", "enc files", "enc file", "encoding files", "encoding file" },
+ variable = 'ENCFONTS',
+ suffixes = { 'enc' },
+ },
+ map = {
+ names = { "map", "map files", "map file" },
+ variable = 'TEXFONTMAPS',
+ suffixes = { 'map' },
+ },
+ lig = {
+ names = { "lig files", "lig file", "ligature file", "ligature files" },
+ variable = 'LIGFONTS',
+ suffixes = { 'lig' },
+ },
+ opl = {
+ names = { "opl" },
+ variable = 'OPLFONTS',
+ suffixes = { 'opl' },
+ },
+ otp = {
+ names = { "otp" },
+ variable = 'OTPINPUTS',
+ suffixes = { 'otp' },
+ },
+ ovp = {
+ names = { "ovp" },
+ variable = 'OVPFONTS',
+ suffixes = { 'ovp' },
+ },
+ },
+ kpse = { -- subset
+ base = {
+ names = { 'base', "metafont format" },
+ variable = 'MFBASES',
+ suffixes = { 'base', 'bas' },
+ },
+ cmap = {
+ names = { 'cmap', 'cmap files', 'cmap file' },
+ variable = 'CMAPFONTS',
+ suffixes = { 'cmap' },
+ },
+ cnf = {
+ names = { 'cnf' },
+ suffixes = { 'cnf' },
+ },
+ web = {
+ names = { 'web' },
+ suffixes = { 'web', 'ch' }
+ },
+ cweb = {
+ names = { 'cweb' },
+ suffixes = { 'w', 'web', 'ch' },
+ },
+ gf = {
+ names = { 'gf' },
+ suffixes = { '<resolution>gf' },
+ },
+ mf = {
+ names = { 'mf' },
+ variable = 'MFINPUTS',
+ suffixes = { 'mf' },
+ },
+ mft = {
+ names = { 'mft' },
+ suffixes = { 'mft' },
+ },
+ pk = {
+ names = { 'pk' },
+ suffixes = { '<resolution>pk' },
+ },
+ },
+}
-function resolvers.suffixofformat(str)
- local s = suffixes[str]
- return s and s[1] or ""
+resolvers.relations = relations
+
+-- formats: maps a format onto a variable
+
+for category, categories in next, relations do
+ for name, relation in next, categories do
+ local rn = relation.names
+ local rv = relation.variable
+ local rs = relation.suffixes
+ if rn and rv then
+ for i=1,#rn do
+ local rni = lower(gsub(rn[i]," ",""))
+ formats[rni] = rv
+ if rs then
+ suffixes[rni] = rs
+ for i=1,#rs do
+ local rsi = rs[i]
+ suffixmap[rsi] = rni
+ end
+ end
+ end
+ end
+ if rs then
+ end
+ end
end
-function resolvers.suffixesofformat(str)
- return suffixes[str] or { }
+local function simplified(t,k)
+ return rawget(t,lower(gsub(k," ","")))
end
--- As we don't register additional suffixes anyway, we can as well
--- freeze the reverse map here.
+setmetatablekey(formats, "__index", simplified)
+setmetatablekey(suffixes, "__index", simplified)
+setmetatablekey(suffixmap, "__index", simplified)
-for name, suffixlist in next, suffixes do
- for i=1,#suffixlist do
- suffixmap[suffixlist[i]] = name
- end
-end
+-- A few accessors, mostly for command line tool.
-local mt = getmetatable(suffixes)
+function resolvers.suffixofformat(str)
+ local s = suffixes[str]
+ return s and s[1] or ""
+end
-mt.__newindex = function(suffixes,name,suffixlist)
- rawset(suffixes,name,suffixlist)
- suffixes[name] = suffixlist
- for i=1,#suffixlist do
- suffixmap[suffixlist[i]] = name
- end
+function resolvers.suffixofformat(str)
+ return suffixes[str] or { }
end
for name, format in next, formats do
- dangerous[name] = true
+ dangerous[name] = true -- still needed ?
end
-- because vf searching is somewhat dangerous, we want to prevent
@@ -139,15 +259,15 @@ dangerous.tex = nil
-- more helpers
function resolvers.formatofvariable(str)
- return formats[str] or formats[alternatives[str]] or ''
+ return formats[str] or ''
end
function resolvers.formatofsuffix(str) -- of file
- return suffixmap[file.extname(str)] or 'tex' -- so many map onto tex (like mkiv, cld etc)
+ return suffixmap[fileextname(str)] or 'tex' -- so many map onto tex (like mkiv, cld etc)
end
function resolvers.variableofformat(str)
- return formats[str] or formats[alternatives[str]] or ''
+ return formats[str] or ''
end
function resolvers.variableofformatorsuffix(str)
@@ -155,10 +275,6 @@ function resolvers.variableofformatorsuffix(str)
if v then
return v
end
- v = formats[alternatives[str]]
- if v then
- return v
- end
v = suffixmap[fileextname(str)]
if v then
return formats[v]
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index 8e3428b2f..d45597093 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -56,7 +56,6 @@ local formats = resolvers.formats
local suffixes = resolvers.suffixes
local dangerous = resolvers.dangerous
local suffixmap = resolvers.suffixmap
-local alternatives = resolvers.alternatives
resolvers.defaultsuffixes = { "tex" } -- "mkiv", "cld" -- too tricky
@@ -68,7 +67,6 @@ function resolvers.newinstance()
local newinstance = {
progname = 'context',
engine = 'luatex',
- format = '',
environment = allocate(),
variables = allocate(),
expansions = allocate(),
@@ -88,7 +86,6 @@ function resolvers.newinstance()
renewcache = false,
loaderror = false,
savelists = true,
- allresults = false,
pattern = nil, -- lists
force_suffixes = true,
}
@@ -175,7 +172,8 @@ end
local function entry(entries,name)
if name and name ~= "" then
name = gsub(name,'%$','')
- local result = entries[name..'.'..instance.progname] or entries[name]
+ -- local result = entries[name..'.'..instance.progname] or entries[name]
+ local result = entries[instance.progname .. '.' .. name] or entries[name]
if result then
return result
else
@@ -193,7 +191,8 @@ end
local function is_entry(entries,name)
if name and name ~= "" then
name = gsub(name,'%$','')
- return (entries[name..'.'..instance.progname] or entries[name]) ~= nil
+ -- return (entries[name..'.'..instance.progname] or entries[name]) ~= nil
+ return (entries[instance.progname .. '.' .. name] or entries[name]) ~= nil
else
return false
end
@@ -254,19 +253,28 @@ local function load_configuration_files()
end
-- flattening is easier to deal with as we need to collapse
local t = { }
- for k, v in next, data do -- v = progname
+ for k, v in next, data do -- k = progname or setter or variables
if v ~= unset_variable then
local kind = type(v)
if kind == "string" then
+ -- still supported, but preferably use the variables subtable
t[k] = v
elseif kind == "table" then
- -- this operates on the table directly
- initializesetter(filename,k,v)
- -- this doesn't (maybe metatables some day)
- for kk, vv in next, v do -- vv = variable
- if vv ~= unset_variable then
- if type(vv) == "string" then
- t[kk.."."..k] = vv
+ if initializesetter(filename,k,v) then
+ -- directives, experiments, trackers, ...
+ else
+ for kk, vv in next, v do -- vv = variable
+ if vv ~= unset_variable then
+ if type(vv) == "string" then
+ -- t[kk.."."..k] = vv
+ if k == "variables" then
+ -- special table, shared variables can be grouped
+ t[kk] = vv
+ else
+ -- category.variable (progname)
+ t[k .. "." .. kk] = vv
+ end
+ end
end
end
end
@@ -536,12 +544,12 @@ function resolvers.expandvariables()
if engine ~= "" then environment['engine'] = engine end
if progname ~= "" then environment['progname'] = progname end
for k,v in next, environment do
- local a, b = match(k,"^(%a+)%_(.*)%s*$")
- if a and b then
- expansions[a..'.'..b] = v
- else
+ -- local a, b = match(k,"^(%a+)%_(.*)%s*$") -- too many vars have an _ in the name
+ -- if a and b then -- so let's forget about it; it was a
+ -- expansions[a..'.'..b] = v -- hack anyway for linux and not needed
+ -- else -- anymore as we now have directives
expansions[k] = v
- end
+ -- end
end
for k,v in next, environment do -- move environment to expansions (variables are already in there)
if not expansions[k] then expansions[k] = v end
@@ -595,7 +603,7 @@ function resolvers.unexpandedpathlist(str)
end
function resolvers.unexpandedpath(str)
- return file.joinpath(resolvers.unexpandedpath_list(str))
+ return file.joinpath(resolvers.unexpandedpathlist(str))
end
local done = { }
@@ -856,13 +864,14 @@ local function can_be_dir(name) -- can become local
return fakepaths[name] == 1
end
-local function collect_instance_files(filename,collected) -- todo : plugin (scanners, checkers etc)
- local result = collected or { }
+local function collect_instance_files(filename,askedformat,allresults) -- todo : plugin (scanners, checkers etc)
+ local result = { }
local stamp = nil
+ askedformat = askedformat or ""
filename = collapsepath(filename)
-- speed up / beware: format problem
- if instance.remember then
- stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
+ if instance.remember and not allresults then
+ stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. askedformat
if instance.found[stamp] then
if trace_locating then
report_resolvers("remembering file '%s'",filename)
@@ -871,12 +880,14 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
return instance.found[stamp]
end
end
- if not dangerous[instance.format or "?"] then
+ if not dangerous[askedformat] then
if resolvers.isreadable.file(filename) then
if trace_detail then
report_resolvers("file '%s' found directly",filename)
end
- instance.found[stamp] = { filename }
+ if stamp then
+ instance.found[stamp] = { filename }
+ end
return { filename }
end
end
@@ -884,7 +895,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if trace_locating then
report_resolvers("checking wildcard '%s'", filename)
end
- result = resolvers.findwildcardfiles(filename)
+ result = resolvers.findwildcardfiles(filename) -- we can use th elocal
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
@@ -894,7 +905,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
else
local forcedname, ok, suffix = "", false, fileextname(filename)
if suffix == "" then -- why
- local format_suffixes = instance.format == "" and resolvers.defaultsuffixes or suffixes[instance.format]
+ local format_suffixes = askedformat == "" and resolvers.defaultsuffixes or suffixes[askedformat]
if format_suffixes then
for i=1,#format_suffixes do
local s = format_suffixes[i]
@@ -914,21 +925,22 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- matching last part of the name
local basename = filebasename(filename)
local pattern = gsub(filename .. "$","([%.%-])","%%%1")
- local savedformat = instance.format
+ -- messy .. to be sorted out
+ local savedformat = askedformat
local format = savedformat or ""
if format == "" then
- instance.format = resolvers.formatofsuffix(suffix)
+ askedformat = resolvers.formatofsuffix(suffix)
end
if not format then
- instance.format = "othertextfiles" -- kind of everything, maybe texinput is better
+ askedformat = "othertextfiles" -- kind of everything, maybe texinput is better
end
--
if basename ~= filename then
- local resolved = collect_instance_files(basename)
+ local resolved = collect_instance_files(basename,askedformat,allresults)
if #result == 0 then
local lowered = lower(basename)
if filename ~= lowered then
- resolved = collect_instance_files(lowered)
+ resolved = collect_instance_files(lowered,askedformat,allresults)
end
end
resolvers.format = savedformat
@@ -970,7 +982,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
else
wantedfiles[#wantedfiles+1] = filename
end
- if instance.format == "" then
+ if askedformat == "" then
if ext == "" or not suffixmap[ext] then
local defaultsuffixes = resolvers.defaultsuffixes
for i=1,#defaultsuffixes do
@@ -989,14 +1001,14 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
else
if ext == "" or not suffixmap[ext] then
- local format_suffixes = suffixes[instance.format]
+ local format_suffixes = suffixes[askedformat]
if format_suffixes then
for i=1,#format_suffixes do
wantedfiles[#wantedfiles+1] = filename .. "." .. format_suffixes[i]
end
end
end
- filetype = instance.format
+ filetype = askedformat
if trace_locating then
report_resolvers("using given filetype '%s'",filetype)
end
@@ -1067,7 +1079,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
--- todo, test for readable
result[#result+1] = fl[3]
done = true
- if instance.allresults then
+ if allresults then
if trace_detail then
report_resolvers("match to '%s' in hash for file '%s' and path '%s', continue scanning",expression,f,d)
end
@@ -1098,7 +1110,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
result[#result+1] = fname
done = true
- if not instance.allresults then break end
+ if not allresults then break end
end
end
else
@@ -1110,7 +1122,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not done and doscan then
-- todo: slow path scanning ... although we now have tree:// supported in $TEXMF
end
- if done and not instance.allresults then break end
+ if done and not allresults then break end
end
end
end
@@ -1119,7 +1131,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
result[k] = rk
resolvers.registerintrees(rk) -- for tracing used files
end
- if instance.remember then
+ if stamp then
instance.found[stamp] = result
end
return result
@@ -1128,37 +1140,30 @@ end
resolvers.concatinators.tex = filejoin
resolvers.concatinators.file = resolvers.concatinators.tex
-function resolvers.findfiles(filename,filetype,mustexist)
- if type(mustexist) == boolean then
- -- all set
- elseif type(filetype) == 'boolean' then
- filetype, mustexist = nil, false
- elseif type(filetype) ~= 'string' then
- filetype, mustexist = nil, false
- end
- instance.format = filetype or ''
- local result = collect_instance_files(filename)
+local function findfiles(filename,filetype,allresults)
+ local result = collect_instance_files(filename,filetype or "",allresults)
if #result == 0 then
local lowered = lower(filename)
if filename ~= lowered then
- return collect_instance_files(lowered)
+ return collect_instance_files(lowered,filetype or "",allresults)
end
end
- instance.format = ''
return result
end
-function resolvers.findfile(filename,filetype,mustexist)
- return (resolvers.findfiles(filename,filetype,mustexist)[1] or "")
+function resolvers.findfiles(filename,filetype)
+ return findfiles(filename,filetype,true)
+end
+
+function resolvers.findfile(filename,filetype)
+ return findfiles(filename,filetype,false)[1] or ""
end
function resolvers.findpath(filename,filetype)
- local path = resolvers.findfiles(filename,filetype)[1] or ""
- -- todo return current path
- return file.dirname(path)
+ return file.dirname(findfiles(filename,filetype,false)[1] or "")
end
-function resolvers.findgivenfiles(filename)
+local function findgivenfiles(filename,allresults)
local bname, result = filebasename(filename), { }
local hashes = instance.hashes
for k=1,#hashes do
@@ -1176,12 +1181,12 @@ function resolvers.findgivenfiles(filename)
if blist then
if type(blist) == 'string' then
result[#result+1] = resolvers.concatinators[hash.type](hash.tag,blist,bname) or ""
- if not instance.allresults then break end
+ if not allresults then break end
else
for kk=1,#blist do
local vv = blist[kk]
result[#result+1] = resolvers.concatinators[hash.type](hash.tag,vv,bname) or ""
- if not instance.allresults then break end
+ if not allresults then break end
end
end
end
@@ -1189,8 +1194,12 @@ function resolvers.findgivenfiles(filename)
return result
end
+function resolvers.findgivenfiles(filename)
+ return findgivenfiles(filename,true)
+end
+
function resolvers.findgivenfile(filename)
- return (resolvers.findgivenfiles(filename)[1] or "")
+ return findgivenfiles(filename,false)[1] or ""
end
local function doit(path,blist,bname,tag,kind,result,allresults)
@@ -1216,7 +1225,7 @@ local function doit(path,blist,bname,tag,kind,result,allresults)
return done
end
-function resolvers.findwildcardfiles(filename) -- todo: remap: and lpeg
+local function findwildcardfiles(filename,allresults) -- todo: remap: and lpeg
local result = { }
local bname, dname = filebasename(filename), filedirname(filename)
local path = gsub(dname,"^*/","")
@@ -1230,7 +1239,7 @@ function resolvers.findwildcardfiles(filename) -- todo: remap: and lpeg
name = gsub(name,"-","%%-")
path = lower(path)
name = lower(name)
- local files, allresults, done = instance.files, instance.allresults, false
+ local files, done = instance.files, false
if find(name,"%*") then
local hashes = instance.hashes
for k=1,#hashes do
@@ -1259,8 +1268,12 @@ function resolvers.findwildcardfiles(filename) -- todo: remap: and lpeg
return result
end
+function resolvers.findwildcardfiles(filename)
+ return findwildcardfiles(filename,true)
+end
+
function resolvers.findwildcardfile(filename)
- return (resolvers.findwildcardfiles(filename)[1] or "")
+ return findwildcardfiles(filename,false)[1] or ""
end
-- main user functions
@@ -1292,14 +1305,14 @@ local function report(str)
end
end
-function resolvers.dowithfilesandreport(command, files, filetype, mustexist)
+function resolvers.dowithfilesandreport(command, files, ...)
if files and #files > 0 then
if trace_locating then
report('') -- ?
end
for f=1,#files do
local file = files[f]
- local result = command(file,filetype,mustexist)
+ local result = command(file,...)
if type(result) == 'string' then
report(result)
else
@@ -1321,9 +1334,7 @@ function resolvers.showpath(str) -- output search path for file type NAME
end
-- resolvers.findfile(filename)
--- resolvers.findfile(filename, filetype, mustexist)
--- resolvers.findfile(filename, mustexist)
--- resolvers.findfile(filename, filetype)
+-- resolvers.findfile(filename, f.iletype)
function resolvers.registerfile(files, name, path)
if files[name] then
@@ -1352,7 +1363,7 @@ function resolvers.locateformat(name)
local barename = gsub(name,"%.%a+$","")
local fmtname = caches.getfirstreadablefile(barename..".fmt","formats") or ""
if fmtname == "" then
- fmtname = resolvers.findfiles(barename..".fmt")[1] or ""
+ fmtname = resolvers.findfile(barename..".fmt")
fmtname = resolvers.cleanpath(fmtname)
end
if fmtname ~= "" then
diff --git a/tex/context/base/data-tex.lua b/tex/context/base/data-tex.lua
index cf66913c1..bd6eb0599 100644
--- a/tex/context/base/data-tex.lua
+++ b/tex/context/base/data-tex.lua
@@ -225,9 +225,9 @@ function resolvers.openfile(filename)
end
end
-function resolvers.texdatablob(filename, filetype)
+function resolvers.loadtexfile(filename, filetype)
local ok, data, size = resolvers.loadbinfile(filename, filetype)
return data or ""
end
-resolvers.loadtexfile = resolvers.texdatablob
+resolvers.texdatablob = resolvers.loadtexfile
diff --git a/tex/context/base/font-chk.lua b/tex/context/base/font-chk.lua
index 1fa520452..78b3253c5 100644
--- a/tex/context/base/font-chk.lua
+++ b/tex/context/base/font-chk.lua
@@ -15,7 +15,7 @@ local fonts = fonts
fonts.checkers = fonts.checkers or { }
local checkers = fonts.checkers
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local is_character = characters.is_character
local chardata = characters.data
local tasks = nodes.tasks
diff --git a/tex/context/base/font-col.lua b/tex/context/base/font-col.lua
index d22a8088e..ef08c0b8c 100644
--- a/tex/context/base/font-col.lua
+++ b/tex/context/base/font-col.lua
@@ -28,7 +28,7 @@ local definitions = collections.definitions
collections.vectors = collections.vectors or { }
local vectors = collections.vectors
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local glyph = node.id('glyph')
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 6101644e0..eb0990ec1 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -28,7 +28,6 @@ local report_mapfiles = logs.new("mapfiles")
local fonts = fonts
local tfm = fonts.tfm
-local fontdata = fonts.identifiers
local definers = fonts.definers
local specifiers = definers.specifiers
local currentfont = font.current
@@ -47,8 +46,105 @@ local synonyms = specifiers.synonyms
local triggers = fonts.triggers
local names = fonts.names
--- Beware, number can be shared between redefind features but as it is
--- applied only for special cases it probably doesn't matter.
+local allocate, mark = utilities.storage.allocate, utilities.storage.mark
+
+fonts.internalized = allocate() -- internal tex numbers
+
+fonts.characters = mark(fonts.characters or { }) -- chardata
+fonts.csnames = mark(fonts.csnames or { }) -- namedata
+fonts.quads = mark(fonts.quads or { }) -- quaddata
+fonts.xheights = mark(fonts.xheights or { }) -- xheightdata
+
+local fontdata = fonts.identifiers
+local chardata = fonts.characters
+local quaddata = fonts.quads
+local xheightdata = fonts.xheights
+
+fonts.ids = fontdata -- we keep this one for a while (as it is used in mk etc)
+
+local nulldata = {
+ name = "nullfont",
+ characters = { },
+ descriptions = { },
+ parameters = {
+ xheight = 0,
+ quad = 0,
+ },
+}
+
+setmetatablekey(fontdata, "__index", function(t,k)
+ return nulldata
+end)
+
+setmetatablekey(chardata, "__index", function(t,k)
+ local characters = fontdata[k].characters
+ chardata[k] = characters
+ return characters
+end)
+
+setmetatablekey(quaddata, "__index", function(t,k)
+ local parameters = fontdata[k].parameters
+ local quad = parameters and parameters.quad or 0
+ quaddata[k] = quad
+ return quad
+end)
+
+setmetatablekey(xheightdata, "__index", function(t,k)
+ local parameters = fontdata[k].parameters
+ local xheight = parameters and parameters.xheight or 0
+ xheightdata[k] = xheight
+ return quad
+end)
+
+-- local function enhancetfmdata(tfmdata)
+-- local characters = tfmdata.characters
+-- local parameters = tfmdata.parameters
+-- local shared = tfmdata.shared
+-- setmetatablekey(chardata, "__index", function(t,k)
+-- if type(k) == "number" then
+-- return characters[k]
+-- else
+-- -- t[k] = v -- can be option
+-- return parameters[k] or shared[k]
+-- end
+-- return v
+-- end)
+-- end
+
+-- Here we overload the registration code.
+
+function definers.registered(hash)
+ local id = fonts.internalized[hash]
+ return id, id and fonts.identifiers[id]
+end
+
+function definers.register(tfmdata,id)
+ if tfmdata and id then
+ local hash = tfmdata.hash
+ if not fonts.internalized[hash] then
+ fonts.internalized[hash] = id
+ if trace_defining then
+ report_define("registering font, id: %s, hash: %s",id or "?",hash or "?")
+ end
+ -- enhancetfmdata(tfmdata)
+ local characters = tfmdata.characters
+ local parameters = tfmdata.parameters
+ fontdata[id] = tfmdata
+ -- chardata [id] = characters
+ -- quaddata [id] = parameters and parameters.quad or 0
+ -- xheightdata[id] = parameters and parameters.xheight or 0
+ --
+ tfmdata.mathconstants = tfmdata.mathconstants or tfmdata.MathMonstants
+ --
+ parameters.xheight = parameters.xheight or parameters.x_height
+ parameters.extraspace = parameters.extraspace or parameters.extra_space
+ parameters.spacestretch = parameters.spacestretch or parameters.space_stretch
+ parameters.spaceshrink = parameters.spaceshrink or parameters.space_shrink
+ end
+ end
+end
+
+-- End of overload.
--[[ldx--
<p>So far we haven't really dealt with features (or whatever we want
@@ -71,7 +167,7 @@ local function predefined(specification)
return specification
end
-definers.registersplit("@", predefined)
+definers.registersplit("@", predefined,"virtual")
storage.register("fonts/setups" , setups , "fonts.definers.specifiers.contextsetups" )
storage.register("fonts/numbers", numbers, "fonts.definers.specifiers.contextnumbers")
@@ -319,7 +415,7 @@ local function starred(features) -- no longer fallbacks here
return features
end
-definers.registersplit('*',starred)
+definers.registersplit('*',starred,"featureset")
-- define (two steps)
@@ -428,6 +524,10 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf
specification.fallbacks = classfallbacks
end
local tfmdata = definers.read(specification,size) -- id not yet known
+ local cs = specification.cs
+ if cs then
+ fonts.csnames[cs] = tfmdata -- new (beware: locals can be forgotten)
+ end
if not tfmdata then
report_define("unable to define %s as \\%s",name,cs)
texsetcount("global","lastfontid",-1)
@@ -445,7 +545,7 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf
local id = font.define(tfmdata)
-- print(name,os.clock()-t)
tfmdata.id = id
- definers.register(tfmdata,id)
+ definers.register(tfmdata,id) -- to be sure, normally already done
tex.definefont(global,cs,id)
tfm.cleanuptable(tfmdata)
if trace_defining then
@@ -487,7 +587,7 @@ function definers.define(specification)
specification.specification = "" -- not used
specification.resolved = ""
specification.forced = ""
- specification.features = { } -- via detail
+ specification.features = { } -- via detail, maybe some day
--
-- we don't care about mathsize textsize goodies fallbacks
--
@@ -848,6 +948,10 @@ function fonts.definetypeface(name,t)
context.dofastdefinetypeface(name, shortcut, shape, size, settings)
end
-function fonts.current(id) -- todo: also handle name
+function fonts.current() -- todo: also handle name
return fontdata[currentfont()] or fontdata[0]
end
+
+function fonts.currentid()
+ return currentfont() or 0
+end
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index 2f530f022..b9d8c403b 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -6,7 +6,8 @@ if not modules then modules = { } end modules ['font-def'] = {
license = "see context related readme files"
}
-local format, concat, gmatch, match, find, lower = string.format, table.concat, string.gmatch, string.match, string.find, string.lower
+local concat = table.concat
+local format, gmatch, match, find, lower, gsub = string.format, string.gmatch, string.match, string.find, string.lower, string.gsub
local tostring, next = tostring, next
local lpegmatch = lpeg.match
@@ -29,13 +30,11 @@ default loader that only handles <l n='tfm'/>.</p>
local fonts = fonts
local tfm = fonts.tfm
local vf = fonts.vf
-local fontcsnames = fonts.csnames
fonts.used = allocate()
tfm.readers = tfm.readers or { }
tfm.fonts = allocate()
-tfm.internalized = allocate() -- internal tex numbers
local readers = tfm.readers
local sequence = allocate { 'otf', 'ttf', 'afm', 'tfm' }
@@ -125,9 +124,12 @@ end
definers.getspecification = getspecification
-function definers.registersplit(symbol,action)
+function definers.registersplit(symbol,action,verbosename)
addspecifier(symbol)
variants[symbol] = action
+ if verbosename then
+ variants[verbosename] = action
+ end
end
function definers.makespecification(specification, lookup, name, sub, method, detail, size)
@@ -338,7 +340,8 @@ function tfm.read(specification)
if not tfmtable then
local forced = specification.forced or ""
if forced ~= "" then
- tfmtable = readers[lower(forced)](specification)
+ local reader = readers[lower(forced)]
+ tfmtable = reader and reader(specification)
if not tfmtable then
report_define("forced type %s of %s not found",forced,specification.name)
end
@@ -391,17 +394,17 @@ function tfm.readanddefine(name,size) -- no id
local hash = tfm.hashinstance(specification)
local id = definers.registered(hash)
if not id then
- local fontdata = tfm.read(specification)
- if fontdata then
- fontdata.hash = hash
- id = font.define(fontdata)
- definers.register(fontdata,id)
- tfm.cleanuptable(fontdata)
+ local tfmdata = tfm.read(specification)
+ if tfmdata then
+ tfmdata.hash = hash
+ id = font.define(tfmdata)
+ definers.register(tfmdata,id)
+ tfm.cleanuptable(tfmdata)
else
id = 0 -- signal
end
end
- return fonts.ids[id], id
+ return fonts.identifiers[id], id
end
--[[ldx--
@@ -489,6 +492,16 @@ function readers.afm(specification,method)
return tfmtable
end
+function readers.pfb(specification,method) -- only called when forced
+ local original = specification.specification
+ if trace_loading then
+ report_afm("using afm reader for '%s'",original)
+ end
+ specification.specification = gsub(original,"%.pfb",".afm")
+ specification.forced = "afm"
+ return readers.afm(specification,method)
+end
+
-- maybe some day a set of names
local function check_otf(forced,specification,suffix,what)
@@ -568,31 +581,29 @@ not gain much. By the way, passing id's back to in the callback was
introduced later in the development.</p>
--ldx]]--
-local lastdefined = nil -- we don't want this one to end up in s-tra-02
+local lastdefined = nil -- we don't want this one to end up in s-tra-02
+local internalized = { }
function definers.current() -- or maybe current
return lastdefined
end
-function definers.register(fontdata,id)
- if fontdata and id then
- local hash = fontdata.hash
- if not tfm.internalized[hash] then
+function definers.register(tfmdata,id) -- will be overloaded
+ if tfmdata and id then
+ local hash = tfmdata.hash
+ if not internalized[hash] then
if trace_defining then
- report_define("loading at 2 id %s, hash: %s",id or "?",hash or "?")
+ report_define("registering font, id: %s, hash: %s",id or "?",hash or "?")
end
- fonts.identifiers[id] = fontdata
- fonts.characters [id] = fontdata.characters
- fonts.quads [id] = fontdata.parameters and fontdata.parameters.quad
- -- todo: extra functions, e.g. setdigitwidth etc in list
- tfm.internalized[hash] = id
+ fonts.identifiers[id] = tfmdata
+ internalized[hash] = id
end
end
end
-function definers.registered(hash)
- local id = tfm.internalized[hash]
- return id, id and fonts.ids[id]
+function definers.registered(hash) -- will be overloaded
+ local id = internalized[hash]
+ return id, id and fonts.identifiers[id]
end
local cache_them = false
@@ -625,49 +636,45 @@ function definers.read(specification,size,id) -- id can be optional, name can al
specification = definers.resolve(specification)
local hash = tfm.hashinstance(specification)
if cache_them then
- local fontdata = containers.read(fonts.cache,hash) -- for tracing purposes
+ local tfmdata = containers.read(fonts.cache,hash) -- for tracing purposes
end
- local fontdata = definers.registered(hash) -- id
- if not fontdata then
+ local tfmdata = definers.registered(hash) -- id
+ if not tfmdata then
if specification.features.vtf and specification.features.vtf.preset then
- fontdata = tfm.make(specification)
+ tfmdata = tfm.make(specification)
else
- fontdata = tfm.read(specification)
- if fontdata then
- tfm.checkvirtualid(fontdata)
+ tfmdata = tfm.read(specification)
+ if tfmdata then
+ tfm.checkvirtualid(tfmdata)
end
end
if cache_them then
- fontdata = containers.write(fonts.cache,hash,fontdata) -- for tracing purposes
+ tfmdata = containers.write(fonts.cache,hash,tfmdata) -- for tracing purposes
end
- if fontdata then
- fontdata.hash = hash
- fontdata.cache = "no"
+ if tfmdata then
+ tfmdata.hash = hash
+ tfmdata.cache = "no"
if id then
- definers.register(fontdata,id)
+ definers.register(tfmdata,id)
end
end
end
- lastdefined = fontdata or id -- todo ! ! ! ! !
- if not fontdata then -- or id?
+ lastdefined = tfmdata or id -- todo ! ! ! ! !
+ if not tfmdata then -- or id?
report_define( "unknown font %s, loading aborted",specification.name)
- elseif trace_defining and type(fontdata) == "table" then
+ elseif trace_defining and type(tfmdata) == "table" then
report_define("using %s font with id %s, name:%s size:%s bytes:%s encoding:%s fullname:%s filename:%s",
- fontdata.type or "unknown",
- id or "?",
- fontdata.name or "?",
- fontdata.size or "default",
- fontdata.encodingbytes or "?",
- fontdata.encodingname or "unicode",
- fontdata.fullname or "?",
- file.basename(fontdata.filename or "?"))
- end
- local cs = specification.cs
- if cs then
- fontcsnames[cs] = fontdata -- new (beware: locals can be forgotten)
+ tfmdata.type or "unknown",
+ id or "?",
+ tfmdata.name or "?",
+ tfmdata.size or "default",
+ tfmdata.encodingbytes or "?",
+ tfmdata.encodingname or "unicode",
+ tfmdata.fullname or "?",
+ file.basename(tfmdata.filename or "?"))
end
statistics.stoptiming(fonts)
- return fontdata
+ return tfmdata
end
function vf.find(name)
@@ -698,4 +705,4 @@ end
--ldx]]--
callbacks.register('define_font' , definers.read, "definition of fonts (tfmtable preparation)")
-callbacks.register('find_vf_file', vf.find , "locating virtual fonts, insofar needed") -- not that relevant any more
+callbacks.register('find_vf_file', vf.find, "locating virtual fonts, insofar needed") -- not that relevant any more
diff --git a/tex/context/base/font-dum.lua b/tex/context/base/font-dum.lua
index 14d155aba..dac820274 100644
--- a/tex/context/base/font-dum.lua
+++ b/tex/context/base/font-dum.lua
@@ -275,7 +275,7 @@ end
-- bonus
function fonts.otf.nametoslot(name)
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
if tfmdata and tfmdata.shared then
local otfdata = tfmdata.shared.otfdata
local unicode = otfdata.luatex.unicodes[name]
diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua
index c17516653..16665d373 100644
--- a/tex/context/base/font-ext.lua
+++ b/tex/context/base/font-ext.lua
@@ -590,7 +590,7 @@ initializers.node.afm.extend = initializers.common.extend
-- historic stuff, move from font-ota
local delete_node = nodes.delete
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua
index f18f8b395..ac83a611c 100644
--- a/tex/context/base/font-gds.lua
+++ b/tex/context/base/font-gds.lua
@@ -210,7 +210,7 @@ local function setcolorscheme(tfmdata,scheme)
tfmdata.colorscheme = false
end
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local fcs = fonts.colors.set
local has_attribute = node.has_attribute
local traverse_id = node.traverse_id
diff --git a/tex/context/base/font-ini.lua b/tex/context/base/font-ini.lua
index 6082c1d1d..eb741f0f7 100644
--- a/tex/context/base/font-ini.lua
+++ b/tex/context/base/font-ini.lua
@@ -25,14 +25,18 @@ fontloader.totable = fontloader.to_table
fonts = fonts or { }
--- we will also have des and fam hashes
+-- beware, some already defined
--- beware, soem alreadyu defined
+fonts.identifiers = mark(fonts.identifiers or { }) -- fontdata
+-----.characters = mark(fonts.characters or { }) -- chardata
+-----.csnames = mark(fonts.csnames or { }) -- namedata
+-----.quads = mark(fonts.quads or { }) -- quaddata
-fonts.ids = mark(fonts.ids or { }) fonts.identifiers = fonts.ids -- aka fontdata
-fonts.chr = mark(fonts.chr or { }) fonts.characters = fonts.chr -- aka chardata
-fonts.qua = mark(fonts.qua or { }) fonts.quads = fonts.qua -- aka quaddata
-fonts.css = mark(fonts.css or { }) fonts.csnames = fonts.css -- aka namedata
+--~ fonts.identifiers[0] = { -- nullfont
+--~ characters = { },
+--~ descriptions = { },
+--~ name = "nullfont",
+--~ }
fonts.tfm = fonts.tfm or { }
fonts.vf = fonts.vf or { }
@@ -41,15 +45,7 @@ fonts.pfb = fonts.pfb or { }
fonts.otf = fonts.otf or { }
fonts.privateoffset = 0xF0000 -- 0x10FFFF
-fonts.verbose = false -- more verbose cache tables
-
-fonts.ids[0] = { -- nullfont
- characters = { },
- descriptions = { },
- name = "nullfont",
-}
-
-fonts.chr[0] = { }
+fonts.verbose = false -- more verbose cache tables (will move to context namespace)
fonts.methods = fonts.methods or {
base = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } },
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 79e5529ff..b99d44545 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -79,7 +79,7 @@
\registerctxluafile{font-oth}{1.001} % otf helpers
\registerctxluafile{font-vf} {1.001}
\registerctxluafile{font-def}{1.001}
-\registerctxluafile{font-ctx}{1.001}
+\registerctxluafile{font-ctx}{1.001} % after def as it overloads
\registerctxluafile{font-xtx}{1.001}
\registerctxluafile{font-gds}{1.001}
\registerctxluafile{font-fbk}{1.001}
@@ -4050,7 +4050,7 @@
% \startluacode
% function commands.doifelsecurrentfonthasfeature(name)
-% local f = fonts.ids[font.current()]
+% local f = fonts.identifiers[font.current()]
% f = f and f.shared
% f = f and f.otfdata
% f = f and f.luatex
diff --git a/tex/context/base/font-ota.lua b/tex/context/base/font-ota.lua
index 18b0bf2d8..f972d289f 100644
--- a/tex/context/base/font-ota.lua
+++ b/tex/context/base/font-ota.lua
@@ -40,7 +40,7 @@ local has_attribute = node.has_attribute
local traverse_id = node.traverse_id
local traverse_node_list = node.traverse
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local state = attributes.private('state')
local categories = characters and characters.categories or { } -- sorry, only in context
diff --git a/tex/context/base/font-otd.lua b/tex/context/base/font-otd.lua
index 910725a9f..4d078017a 100644
--- a/tex/context/base/font-otd.lua
+++ b/tex/context/base/font-otd.lua
@@ -12,7 +12,7 @@ local report_otf = logs.new("load otf")
local fonts = fonts
local otf = fonts.otf
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
otf.features = otf.features or { }
otf.features.default = otf.features.default or { }
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 25bccfa29..922574ed2 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -42,7 +42,7 @@ fonts.otf = fonts.otf or { }
local otf = fonts.otf
local tfm = fonts.tfm
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local chardata = characters and characters.data -- not used
otf.features = otf.features or { }
@@ -1392,7 +1392,7 @@ actions["check metadata"] = function(data,filename,raw)
data.map = nil
end
-local private_math_parameters = {
+local private_mathparameters = {
"FractionDelimiterSize",
"FractionDelimiterDisplayStyleSize",
}
@@ -1400,8 +1400,8 @@ local private_math_parameters = {
actions["check math parameters"] = function(data,filename,raw)
local mathdata = data.metadata.math
if mathdata then
- for m=1,#private_math_parameters do
- local pmp = private_math_parameters[m]
+ for m=1,#private_mathparameters do
+ local pmp = private_mathparameters[m]
if not mathdata[pmp] then
if trace_loading then
report_otf("setting math parameter '%s' to 0", pmp)
@@ -1614,7 +1614,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
local unicodes = luatex.unicodes -- names to unicodes
local indices = luatex.indices
local mode = data.mode or "base"
- local characters, parameters, math_parameters, descriptions = { }, { }, { }, { }
+ local characters, parameters, mathparameters, descriptions = { }, { }, { }, { }
local designsize = metadata.designsize or metadata.design_size or 100
if designsize == 0 then
designsize = 100
@@ -1629,7 +1629,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
if metadata.math then
-- parameters
for name, value in next, metadata.math do
- math_parameters[name] = value
+ mathparameters[name] = value
end
-- we could use a subset
for u, char in next, characters do
@@ -1744,7 +1744,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
return {
characters = characters,
parameters = parameters,
- math_parameters = math_parameters,
+ mathparameters = mathparameters,
descriptions = descriptions,
indices = indices,
unicodes = unicodes,
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua
index ec246d20d..41169618f 100644
--- a/tex/context/base/font-otn.lua
+++ b/tex/context/base/font-otn.lua
@@ -211,7 +211,7 @@ local markonce = true
local cursonce = true
local kernonce = true
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
otf.features.process = { }
diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua
index e8b24270b..4c5e668e1 100644
--- a/tex/context/base/font-tfm.lua
+++ b/tex/context/base/font-tfm.lua
@@ -38,7 +38,7 @@ fonts.initializers.common = fonts.initializers.common or { }
local set_attribute = node.set_attribute
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local nodecodes = nodes.nodecodes
local disc_code = nodecodes.disc
@@ -304,7 +304,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
end
-- status
local isvirtual = tfmtable.type == "virtual" or tfmtable.virtualized
- local hasmath = (tfmtable.math_parameters ~= nil and next(tfmtable.math_parameters) ~= nil) or (tfmtable.MathConstants ~= nil and next(tfmtable.MathConstants) ~= nil)
+ local hasmath = (tfmtable.mathparameters ~= nil and next(tfmtable.mathparameters) ~= nil) or (tfmtable.MathConstants ~= nil and next(tfmtable.MathConstants) ~= nil)
local nodemode = tfmtable.mode == "node"
local hasquality = tfmtable.auto_expand or tfmtable.auto_protrude
local hasitalic = tfmtable.has_italic
@@ -330,7 +330,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
t.fonts = table.fastcopy(tfmtable.fonts) -- hm also at the end
end
local tp = t.parameters
- local mp = t.math_parameters
+ local mp = t.mathparameters
local tfmp = tfmtable.parameters -- let's check for indexes
--
tp.slant = (tfmp.slant or tfmp[1] or 0)
diff --git a/tex/context/base/font-xtx.lua b/tex/context/base/font-xtx.lua
index 5e9fea12f..505e08583 100644
--- a/tex/context/base/font-xtx.lua
+++ b/tex/context/base/font-xtx.lua
@@ -97,4 +97,4 @@ local function colonized(specification) -- xetex mode
return specification
end
-definers.registersplit(":",colonized)
+definers.registersplit(":",colonized,"cryptic")
diff --git a/tex/context/base/java-ini.mkiv b/tex/context/base/java-ini.mkiv
index 23379c357..a26c562b4 100644
--- a/tex/context/base/java-ini.mkiv
+++ b/tex/context/base/java-ini.mkiv
@@ -146,9 +146,8 @@
{\ifcsname\c!file\f!javascriptprefix#1\endcsname \else
\startnointerference
\letgvalueempty{\c!file\f!javascriptprefix#1}%
- \makeshortfilename[\f!javascriptprefix#1]%
\startreadingfile
- \readsysfile\shortfilename{\showmessage\m!javascript1{#1}}\donothing
+ \readsysfile{\truefilename{\f!javascriptprefix#1}}{\showmessage\m!javascript1{#1}}\donothing
\stopreadingfile
\stopnointerference
\fi}}
diff --git a/tex/context/base/l-dimen.lua b/tex/context/base/l-dimen.lua
index cb97e35f6..0d77d13d3 100644
--- a/tex/context/base/l-dimen.lua
+++ b/tex/context/base/l-dimen.lua
@@ -325,7 +325,7 @@ yet be available.</p>
--ldx]]--
function dimensions.texify() -- todo: %
- local fti, fc = fonts and fonts.ids and fonts.ids, font and font.current
+ local fti, fc = fonts and fonts.identifiers, font and font.current
if fti and fc then
dimenfactors["ex"] = function() return fti[fc()].ex_height end
dimenfactors["em"] = function() return fti[fc()].quad end
diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua
index 264b6a286..a2c461190 100644
--- a/tex/context/base/l-file.lua
+++ b/tex/context/base/l-file.lua
@@ -418,3 +418,10 @@ end
--~ return (gsub(currentdir(),"\\","/"))
--~ end
--~ end
+
+-- for myself:
+
+function file.strip(name,dir)
+ local b, a = match(name,"^(.-)" .. dir .. "(.*)$")
+ return a ~= "" and a or name
+end
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index 4eb601432..00b55d622 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-lpeg.lua
@@ -106,11 +106,6 @@ end
patterns.textline = content
---~ local p = lpeg.splitat("->",false) print(match(p,"oeps->what->more")) -- oeps what more
---~ local p = lpeg.splitat("->",true) print(match(p,"oeps->what->more")) -- oeps what->more
---~ local p = lpeg.splitat("->",false) print(match(p,"oeps")) -- oeps
---~ local p = lpeg.splitat("->",true) print(match(p,"oeps")) -- oeps
-
local splitters_s, splitters_m = { }, { }
local function splitat(separator,single)
@@ -132,6 +127,11 @@ end
lpeg.splitat = splitat
+--~ local p = splitat("->",false) print(match(p,"oeps->what->more")) -- oeps what more
+--~ local p = splitat("->",true) print(match(p,"oeps->what->more")) -- oeps what->more
+--~ local p = splitat("->",false) print(match(p,"oeps")) -- oeps
+--~ local p = splitat("->",true) print(match(p,"oeps")) -- oeps
+
local cache = { }
function lpeg.split(separator,str)
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index fcb330506..f2e3be8ec 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -201,7 +201,7 @@ local function pdfaction(actions)
what = what(a,actions)
end
if what then
- action.next = what
+ action.Next = what
action = what
else
-- error
diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua
index 9e49e0098..969383595 100644
--- a/tex/context/base/lpdf-fld.lua
+++ b/tex/context/base/lpdf-fld.lua
@@ -361,7 +361,7 @@ end
local function fieldlayer(specification) -- we can move this in line
local layer = specification.layer
- return (layer and lpdf.layerreferences[layer]) or nil
+ return (layer and lpdf.layerreference(layer)) or nil
end
-- defining
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index 4b7972abe..29dc1bfbc 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -328,7 +328,7 @@ local function pdfverbose(t) -- maybe check for type
return setmetatable({ t or "" },mt_v)
end
-lpdf.stream = pdfstream
+lpdf.stream = pdfstream -- THIS WILL PROBABLY CHANGE
lpdf.dictionary = pdfdictionary
lpdf.array = pdfarray
lpdf.string = pdfstring
diff --git a/tex/context/base/lpdf-ren.lua b/tex/context/base/lpdf-ren.lua
index 6cc00fc3e..404c45e11 100644
--- a/tex/context/base/lpdf-ren.lua
+++ b/tex/context/base/lpdf-ren.lua
@@ -42,20 +42,26 @@ local pdf_setocgstate = pdfconstant("SetOCGState")
local lpdf_usage = pdfdictionary { Print = pdfdictionary { PrintState = pdfconstant("OFF") } }
+-- We can have references to layers before they are places, for instance from
+-- hide and vide actions. This is why we need to be able to force usage of layers
+-- at several moments.
+
local pdfln, pdfld = { }, { }
local textlayers, hidelayers, videlayers = pdfarray(), pdfarray(), pdfarray()
-local pagelayers = pdfdictionary()
-
-lpdf.layerreferences = pdfln
-
-function backends.pdf.layerreference(name)
- return pdfln[name]
-end
-
local pagelayers, pagelayersreference, cache = nil, nil, { }
+local specifications = { }
+
function codeinjections.defineviewerlayer(specification)
if viewerlayers.supported and textlayers then
+ specifications[specification.tag] = specification
+ end
+end
+
+local function useviewerlayer(name)
+ local specification = specifications[name]
+ if specification then
+ specifications[name] = nil -- or not
if not pagelayers then
pagelayers = pdfdictionary()
pagelayersreference = pdfreserveobject()
@@ -90,6 +96,20 @@ function codeinjections.defineviewerlayer(specification)
end
end
+codeinjections.useviewerlayer = useviewerlayer
+
+local function layerreference(name)
+ local r = pdfln[name]
+ if r then
+ return r
+ else
+ useviewerlayer(name)
+ return pdfln[name]
+ end
+end
+
+lpdf.layerreference = layerreference -- also triggered when a hide or vide happens
+
local function flushtextlayers()
if viewerlayers.supported then
if pagelayers then
@@ -130,7 +150,7 @@ local function setlayer(what,arguments)
arguments = (type(arguments) == "table" and arguments) or settings_to_array(arguments)
local state = pdfarray { what }
for i=1,#arguments do
- local p = pdfln[arguments[i]]
+ local p = layerreference(arguments[i])
if p then
state[#state+1] = p
end
@@ -141,9 +161,9 @@ local function setlayer(what,arguments)
}
end
-function executers.hidelayer (arguments) setlayer(pdf_off, arguments) end
-function executers.videlayer (arguments) setlayer(pdf_on, arguments) end
-function executers.togglelayer(arguments) setlayer(pdf_toggle,arguments) end
+function executers.hidelayer (arguments) return setlayer(pdf_off, arguments) end
+function executers.videlayer (arguments) return setlayer(pdf_on, arguments) end
+function executers.togglelayer(arguments) return setlayer(pdf_toggle,arguments) end
-- transitions
diff --git a/tex/context/base/lpdf-swf.lua b/tex/context/base/lpdf-swf.lua
index a55ad9d1b..2d26a6867 100644
--- a/tex/context/base/lpdf-swf.lua
+++ b/tex/context/base/lpdf-swf.lua
@@ -26,6 +26,8 @@ local pdfimmediateobject = lpdf.immediateobject
local codeinjections = backends.pdf.codeinjections
local nodeinjections = backends.pdf.nodeinjections
+local pdfannotation_node = nodes.pool.pdfannotation
+
local function insertswf(spec)
local width, height, filename = spec.width, spec.height, spec.foundname
@@ -124,5 +126,5 @@ function backends.pdf.nodeinjections.insertswf(spec)
-- controls = spec.controls,
-- label = spec.label,
}
- node.write(pdfannotation(spec.width,spec.height,0,annotation()))
+ node.write(pdfannotation_node(spec.width,spec.height,0,annotation()))
end
diff --git a/tex/context/base/lpdf-u3d.lua b/tex/context/base/lpdf-u3d.lua
index dc0f6f43f..44e568ee1 100644
--- a/tex/context/base/lpdf-u3d.lua
+++ b/tex/context/base/lpdf-u3d.lua
@@ -18,20 +18,22 @@ local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, m
local backends, lpdf = backends, lpdf
-local nodeinjections = backends.pdf.nodeinjections
+local nodeinjections = backends.pdf.nodeinjections
-local pdfconstant = lpdf.constant
-local pdfboolean = lpdf.boolean
-local pdfnumber = lpdf.number
-local pdfunicode = lpdf.unicode
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfnull = lpdf.null
-local pdfreference = lpdf.reference
-local pdfimmediateobject = lpdf.immediateobject
+local pdfconstant = lpdf.constant
+local pdfboolean = lpdf.boolean
+local pdfnumber = lpdf.number
+local pdfunicode = lpdf.unicode
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfnull = lpdf.null
+local pdfreference = lpdf.reference
+local pdfimmediateobject = lpdf.immediateobject
-local checkedkey = lpdf.checkedkey
-local limited = lpdf.limited
+local checkedkey = lpdf.checkedkey
+local limited = lpdf.limited
+
+local pdfannotation_node = nodes.pool.pdfannotation
local schemes = table.tohash {
"Artwork", "None", "White", "Day", "Night", "Hard",
@@ -486,5 +488,5 @@ function nodeinjections.insertu3d(spec)
controls = spec.controls,
label = spec.label,
}
- node.write(pdfannotation(spec.width,spec.height,0,annotation()))
+ node.write(pdfannotation_node(spec.width,spec.height,0,annotation()))
end
diff --git a/tex/context/base/luat-cnf.lua b/tex/context/base/luat-cnf.lua
index 2ab97e71d..609dc412b 100644
--- a/tex/context/base/luat-cnf.lua
+++ b/tex/context/base/luat-cnf.lua
@@ -17,37 +17,35 @@ texconfig.shell_escape = 't'
luatex = luatex or { }
local luatex = luatex
-local variablenames = allocate { -- most of this becomes obsolete
- 'buf_size', -- 3000
- 'dvi_buf_size', -- 16384
- 'error_line', -- 79
- 'expand_depth', -- 10000
- 'half_error_line', -- 50
- 'hash_extra', -- 0
- 'nest_size', -- 50
- 'max_in_open', -- 15
- 'max_print_line', -- 79
- 'max_strings', -- 15000
- 'param_size', -- 60
- 'pk_dpi', -- 72
- 'save_size', -- 4000
- 'stack_size', -- 300
- 'strings_free', -- 100
-}
-
-local function initialize()
- local t, variable = allocate(), resolvers.variable
- for i=1,#variablenames do
- local name = variablenames[i]
- local value = variable(name)
- value = tonumber(value) or value
- texconfig[name], t[name] = value, value
- end
- initialize = nil
- return t
-end
-
-luatex.variables = initialize()
+texconfig.error_line = 79 -- 79 -- obsolete
+texconfig.half_error_line = 50 -- 50 -- obsolete
+
+texconfig.expand_depth = 10000 -- 10000
+texconfig.hash_extra = 100000 -- 0
+texconfig.nest_size = 1000 -- 50
+texconfig.max_in_open = 500 -- 15
+texconfig.max_print_line = 10000 -- 79
+texconfig.max_strings = 500000 -- 15000
+texconfig.param_size = 25000 -- 60
+texconfig.save_size = 50000 -- 4000
+texconfig.stack_size = 10000 -- 300
+
+--~ local function initialize()
+--~ local t, variable = allocate(), resolvers.variable
+--~ for name, default in next, variablenames do
+--~ local name = variablenames[i]
+--~ local value = variable(name)
+--~ value = tonumber(value)
+--~ if not value or value == "" or value == 0 then
+--~ value = default
+--~ end
+--~ texconfig[name], t[name] = value, value
+--~ end
+--~ initialize = nil
+--~ return t
+--~ end
+
+--~ luatex.variables = initialize()
local stub = [[
@@ -151,6 +149,14 @@ end)
-- done, from now on input and callbacks are internal
]]
+
+local variablenames = {
+ "error_line", "half_error_line",
+ "expand_depth", "hash_extra", "nest_size",
+ "max_in_open", "max_print_line", "max_strings",
+ "param_size", "save_size", "stack_size",
+}
+
local function makestub()
name = name or (environment.jobname .. ".lui")
firsttable = firsttable or lua.firstbytecode
diff --git a/tex/context/base/luat-exe.lua b/tex/context/base/luat-exe.lua
index e7f319e9c..fe7968896 100644
--- a/tex/context/base/luat-exe.lua
+++ b/tex/context/base/luat-exe.lua
@@ -13,7 +13,7 @@ local concat = table.concat
local report_executers = logs.new("executers")
-resolvers.executers = resolver.executers or { }
+resolvers.executers = resolvers.executers or { }
local executers = resolvers.executers
local permitted = { }
@@ -29,7 +29,7 @@ local function register(...)
end
local function finalize() -- todo: os.exec, todo: report ipv print
- execute = function execute(...)
+ execute = function(...)
-- todo: make more clever first split
local t, name, arguments = { ... }, "", ""
local one = t[1]
@@ -68,9 +68,12 @@ executers.finalize = function(...) finalize(...) end
executers.register = function(...) register(...) end
executers.execute = function(...) execute (...) end
+local execution_mode directives.register("system.executionmode", function(v) execution_mode = v end)
+local execution_list directives.register("system.executionlist", function(v) execution_list = v end)
+
function executers.check()
- local mode = resolvers.variable("command_mode")
- local list = resolvers.variable("command_list")
+ local mode = execution_mode or resolvers.variable("command_mode") -- or ... will become obsolete
+ local list = execution_list or resolvers.variable("command_list") -- or ... will become obsolete
if mode == "none" then
finalize()
elseif mode == "list" and list ~= "" then
diff --git a/tex/context/base/luat-iop.lua b/tex/context/base/luat-iop.lua
index 6642a2383..091639de2 100644
--- a/tex/context/base/luat-iop.lua
+++ b/tex/context/base/luat-iop.lua
@@ -133,10 +133,12 @@ function ioout.modes.handy()
o_permit('[^/]')
end
+local input_mode directives.register("system.inputmode", function(v) input_mode = v end)
+local output_mode directives.register("system.outputmode", function(v) output_mode = v end)
function io.checkopeners()
- local inp = resolvers.variable("input_mode")
- local out = resolvers.variable("output_mode")
+ local inp = input_mode or resolvers.variable("input_mode") -- or ... will become obsolete
+ local out = output_mode or resolvers.variable("output_mode") -- or ... will become obsolete
inp = inp and ioinp.modes[inp]
out = out and ioinp.modes[out]
if inp then inp() end
diff --git a/tex/context/base/m-chart.mkii b/tex/context/base/m-chart.mkii
index 2554fa2d4..bddd435ef 100644
--- a/tex/context/base/m-chart.mkii
+++ b/tex/context/base/m-chart.mkii
@@ -11,10 +11,1277 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D The \XML\ interface:
+% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
+% todo: make mkiv variant
+% todo: use dimexpr/numspr
+
+% will be redone with layers and dimexpr or even better, by just using
+% textext .. a nice example of old code
+
+%D This is an experimental module. Pieces of code will be moved
+%D to other modules. More features are possible but will be
+%D interfaces later.
+%D
+%D When finished this module will be documented. The main macro
+%D is still a rather big one and there is some redundant and
+%D slow code that needs a clean up.
+
+% arrow, dash
+% crossing
+% \goto -> \normalgoto
+% class -> class:name (ref prefix)
+% c, automatisch geen overlap zoeken
+% eind eerder chart connecties
+% relateren aan korps
+% check op bestaan naam, bestaan shape
+% auto als extern figuur
+% subchart
+% pijlen
+% focus
+% ook nog \MPmessage
+% areapath -> krappe vlak
+% clippath -> gehele vlak
+%
+% offset : clip offset
+% breedte : breedte cel
+% hoogte : hoogte cel
+% dx : halve afstand in breedte (grid breedte = breedte + 2dx)
+% dy : halve afstand in hoogte (grid hoogte = hoogte + 2dy)
+% x : x offset (clipping)
+% y : y offset (clipping)
+% nx : minimaal aantal cellen horizontaal
+% ny : minimaal aantal cellen vertikaal
+%
+% shape none en geen equivalent maken
+%
+% kaderkleur achtergrondkleur
+% lijnkleur lijndikte
+% focus focuskaderkleur focusachtergrondkleur
+% richting
+%
+% focus koppelen aan kleur
\unprotect
+\definesorting [flowchart] [flowcharts] [\v!none] % no access
+\setupsorting [flowchart] [\c!state=\v!stop] % off by default
+
+\def\@FLOW@{@FLOW@}
+\def\@FLOC@{@FLOC@}
+\def\@FLOX@{@FLOX@}
+
+\def\@@FLOW{@@FLOW}
+\def\@@FLOL{@@FLOL}
+\def\@@FLOS{@@FLOS}
+\def\@@FLOF{@@FLOF}
+\def\@@FLOT{@@FLOT}
+\def\@@FLOX{@@FLOX}
+
+\def\@@MPx {@@MPx}
+\def\@@MPy {@@MPy}
+
+\def\FLOWbufferprefix{flw-}
+
+\def\processFLOWbuffer#1{\getbuffer[\FLOWbufferprefix#1]}
+\def\typeFLOWbuffer #1{\typebuffer[\FLOWbufferprefix#1]}
+
+\def\setFLOWname#1#2% funny hack that makes sure that we get
+ {\bgroup % names that are acceptable for METAPOST
+ \lccode`0=`a\lccode`1=`b\lccode`2=`c\lccode`3=`d\lccode`4=`e%
+ \lccode`5=`f\lccode`6=`g\lccode`7=`h\lccode`8=`i\lccode`9=`j%
+ \lccode` =`\_\lccode`-=`\_\lccode`_=`\_%
+ \lowercase{\gdef#1{#2}}%
+ \egroup}
+
+% een gobble als default is sneller, en dan alleen setten als
+% nodig
+
+\def\resetFLOWcell
+ {% variables
+ \global\let\FLOWname \empty
+ \global\let\FLOWalign \empty
+ \global\let\FLOWshape \empty
+ \global\let\FLOWlocation \empty
+ \global\let\FLOWtext \empty
+ \global\let\FLOWhelp \empty
+ \global\let\FLOWdestination\empty
+ \global\let\FLOWoverlay \empty
+ \global\let\FLOWfocus \empty
+ \global\let\tFLOWlabel \empty
+ \global\let\bFLOWlabel \empty
+ \global\let\lFLOWlabel \empty
+ \global\let\rFLOWlabel \empty
+ \global\let\bcFLOWlabel \empty
+ \global\let\tcFLOWlabel \empty
+ \global\let\lcFLOWlabel \empty
+ \global\let\rcFLOWlabel \empty
+ \global\let\tFLOWexit \empty
+ \global\let\bFLOWexit \empty
+ \global\let\lFLOWexit \empty
+ \global\let\rFLOWexit \empty
+ % commands
+ \let\name \doFLOWname
+ \let\shape \doFLOWshape
+ \let\destination\doFLOWdestination
+ \let\location \doFLOWlocation
+ \let\focus \doFLOWfocus
+ \let\overlay \doFLOWoverlay
+ \let\figure \doFLOWfigure
+ \let\text \doFLOWtext
+ \let\comment \doFLOWcomment
+ \let\label \doFLOWlabel
+ \let\help \doFLOWhelp
+ \let\connection \doFLOWconnection
+ \let\exit \doFLOWexit
+ % convenience commands
+ \let\locate \doFLOWlocate
+ \let\connect \doFLOWconnect}
+
+\let\FLOWcell \s!unknown
+\let\FLOWshape \s!unknown
+\let\FLOWdestination\s!unknown
+\let\FLOWfocus \s!unknown
+\let\FLOWoverlay \empty
+\let\FLOWtext \empty
+
+\def\doFLOWname#1%
+ {\def\FLOWcell{#1}\setFLOWname\FLOWname{name_#1}\ignorespaces}
+
+\def\doFLOWshape#1%
+ {\gdef\FLOWshape{#1}\ignorespaces}
+
+\def\doFLOWdestination#1%
+ {\gdef\FLOWdestination{#1}\ignorespaces}
+
+\def\doFLOWlocation#1%
+ {\setFLOWlocation#1\end\ignorespaces}
+
+\def\doFLOWfocus#1%
+ {\gdef\FLOWfocus{#1}\ignorespaces}
+
+\def\doFLOWoverlay#1%
+ {\gdef\FLOWoverlay{#1}\ignorespaces}
+
+\def\doFLOWfigure#1%
+ {\defineoverlay[\s!dummy][\overlayfigure{#1}]%
+ \overlay\s!dummy}
+
+\def\doFLOWtext
+ {\dosingleempty\dodoFLOWtext}
+
+\def\dodoFLOWtext[#1]% % #2%
+ {\gdef\FLOWalign{#1}\gdef\FLOWtext}% {#2}}
+
+\def\doFLOWcomment[#1]#2%
+ {\ignorespaces\dogobblesingleempty}
+
+\def\doFLOWlabel[#1]#2% wordt dit gebruikt ?
+ {\setgvalue{#1FLOWlabel}{#2}\ignorespaces}
+
+\def\doFLOWhelp#1%
+ {\gdef\FLOWhelp{#1}\ignorespaces}
+
+\def\doFLOWconnection
+ {\dodoubleempty\dodoFLOWconnection}
+
+\def\dodoFLOWconnection[#1][#2]#3%
+ {\ignorespaces}
+
+\def\doFLOWconnect
+ {\connection}
+
+\def\doFLOWlocate
+ {\location}
+
+\def\doFLOWexit[#1]#2%
+ {\setgvalue{#1FLOWexit}{#2}\ignorespaces}
+
+\def\startFLOWchart
+ {\bgroup
+ \let\stopFLOWchart\egroup
+ \obeylines % lelijk, buffers nog eens fatsoeneren
+ \dodoubleempty\dostartFLOWchart}
+
+\def\dostartFLOWchart[#1][#2]%
+ {\preparenextFLOWchart{#1}{#2}%
+ \dostartbuffer[\FLOWbufferprefix\nofFLOWcharts][startFLOWchart][stopFLOWchart]}
+
+\def\defineFLOWchart%
+ {\dodoubleempty\dodefineFLOWchart}
+
+\long\def\dodefineFLOWchart[#1][#2]#3%
+ {\preparenextFLOWchart{#1}{#2}%
+ \setbuffer[\FLOWbufferprefix\nofFLOWcharts]#3\endbuffer}
+
+\def\preparenextFLOWchart#1#2%
+ {\doglobal\increment\nofFLOWcharts
+ \flowchart{#1}%
+ \setxvalue{\@FLOW@-#1}{\noexpand\dohandleflowchart[\nofFLOWcharts][#2]}}
+
+\def\setupFLOWcharts{\dodoubleargument\getparameters[\@@FLOW]}
+\def\setupFLOWlines {\dodoubleargument\getparameters[\@@FLOL]}
+\def\setupFLOWshapes{\dodoubleargument\getparameters[\@@FLOS]}
+\def\setupFLOWfocus {\dodoubleargument\getparameters[\@@FLOF]}
+\def\setupFLOWsets {\dodoubleargument\getparameters[\@@FLOX]}
+
+\setupFLOWcharts
+ [\c!option=,
+ \c!bodyfont=,
+ \c!dot=, % private option
+ \c!width=12\bodyfontsize,
+ \c!height=7\bodyfontsize,
+ \c!maxwidth=,
+ \c!maxheight=,
+ \c!offset=\v!standard, % == auto offset
+ \c!dx=2\bodyfontsize,
+ \c!dy=2\bodyfontsize,
+ \c!nx=0, % 1,
+ \c!ny=0, % 1,
+ \c!x=1,
+ \c!y=1,
+ \c!autofocus=,
+ \c!focus=,
+ \c!background=, % \v!color,
+ \c!backgroundcolor=\s!white,
+ \c!rulethickness=\linewidth,
+ \c!frame=\v!off,
+ \c!framecolor=]
+
+\setupFLOWlines
+ [\c!corner=\v!round,
+ \c!arrow=\v!yes,
+ \c!dash=\v!no,
+ \c!radius=.375\bodyfontsize, % 2.5\c!rulethickness
+ \c!color=FLOWlinecolor,
+ \c!rulethickness=.15\bodyfontsize, % 2pt,
+ \c!offset=\v!none]
+
+\setupFLOWshapes
+ [\c!default=action,
+ \c!framecolor=FLOWframecolor,
+ \c!background=\v!color,
+ \c!backgroundcolor=FLOWbackgroundcolor,
+ \c!backgroundscreen=\@@rsscreen,
+ \c!rulethickness=.15\bodyfontsize, % 2pt,
+ \c!offset=.5\bodyfontsize]
+
+\setupFLOWfocus
+ [\c!framecolor=FLOWfocuscolor,
+ \c!background=\@@FLOSbackground,
+ \c!backgroundcolor=\@@FLOSbackgroundcolor,
+ \c!backgroundscreen=\@@FLOSbackgroundscreen,
+ \c!rulethickness=\@@FLOSrulethickness,
+ \c!offset=\@@FLOSoffset]
+
+\definecolor [FLOWfocuscolor] [s=.2]
+\definecolor [FLOWlinecolor] [s=.5]
+\definecolor [FLOWframecolor] [s=.7]
+\definecolor [FLOWbackgroundcolor] [s=.9]
+
+\newcounter\includeFLOWx
+\newcounter\includeFLOWy
+
+\def\includeFLOWchart
+ {\dodoubleempty\doincludeFLOWchart}
+
+\def\doincludeFLOWchart[#1][#2]%
+ {\pushmacro\includeFLOWx
+ \pushmacro\includeFLOWy
+ \getparameters[FLOWi][x=1,y=1,#2]%
+ \increment(\includeFLOWx,0\FLOWix)\decrement\includeFLOWx
+ \increment(\includeFLOWy,0\FLOWiy)\decrement\includeFLOWy
+ \def\dodoincludeFLOWchart##1%
+ {\doifdefined{\@FLOW@-##1}
+ {\globalpushmacro\dohandleflowchart % was local
+ \gdef\dohandleflowchart[####1][####2]%
+ {\globalpopmacro\dohandleflowchart % was local
+ \resetFLOWlocation
+ \processFLOWbuffer{####1}}%
+ \getvalue{\@FLOW@-##1}}}%
+ \processcommalist[#1]\dodoincludeFLOWchart
+ \popmacro\includeFLOWx
+ \popmacro\includeFLOWy}
+
+\def\resetFLOWlocation
+ {\globallet\lastFLOWx\!!zerocount
+ \globallet\lastFLOWy\!!zerocount}
+
+\def\dosetFLOWlocation[#1#2]#3#4%
+ {\processaction
+ [#1#2]
+ [ +=>\scratchcounter\numexpr#4+ 1+#3\relax,
+ -=>\scratchcounter\numexpr#4- 1+#3\relax,
+ +#2=>\scratchcounter\numexpr#4+#2+#3\relax,
+ -#2=>\scratchcounter\numexpr#4-#2+#3\relax,
+ \s!default=>\scratchcounter\numexpr#4 +#3\relax,
+ \s!unknown=>\scratchcounter\numexpr0#1#2+#3\relax]%
+ \xdef#4{\the\scratchcounter}}
+
+\def\setFLOWlocation#1,#2\end
+ {\dosetFLOWlocation[#1\empty]\includeFLOWx\lastFLOWx
+ \dosetFLOWlocation[#2\empty]\includeFLOWy\lastFLOWy
+ \xdef\FLOWlocation{\lastFLOWx,\lastFLOWy}}
+
+\def\FLOWshapes
+ {node, action, procedure, product, decision, archive,
+ loop, wait, subprocedure, singledocument, multidocument,
+ sub procedure, single document, multi document, up, down,
+ left, right}
+
+\def\FLOWlines
+ {up, down, left, right}
+
+\def\FLOWsetconnect#1%
+ {\donefalse
+ \let\cFLOWfrom\empty
+ \let\cFLOWto\empty
+ \let\zFLOWfrom\!!zerocount
+ \let\zFLOWto\!!zerocount
+ \handletokens#1\with\doFLOWsetconnect
+ \ifx\cFLOWto\empty\let\cFLOWfrom\empty\fi}
+
+\def\doFLOWsetconnect#1%
+ {\ifx #1p%
+ \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
+ \else\ifx#1+%
+ \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
+ \else\ifx#1n%
+ \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
+ \else\ifx#1-%
+ \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
+ \else\ifdone
+ \edef\cFLOWto{\FLOWconnector#1}%
+ \else
+ \edef\cFLOWfrom{\FLOWconnector#1}%
+ \donetrue
+ \fi\fi\fi\fi\fi}
+
+\def\FLOWconnector#1%
+ {\if#1bbottom\else\if#1ttop\else\if#1lleft\else\if#1rright\fi\fi\fi\fi}
+
+\newif\ifFLOWscaling \FLOWscalingtrue
+
+\def\@@FLOW@@offset{\@@FLOWoffset}
+
+\def\getFLOWchart
+ {\dodoubleempty\dogetFLOWchart}
+
+\def\dogetFLOWchart[#1][#2]%
+ {\doifundefinedelse{\@FLOW@-#1}
+ {\writestatus{FLOW}{unknown chart #1}%
+ \framed
+ [\c!width=12\bodyfontsize,\c!height=8\bodyfontsize]
+ {\tttf [chart #1]}}
+ {\dodogetFLOWchart[#1][#2]}}
+
+\def\dodogetFLOWchart[#1][#2]% to be split a bit more
+ {\vbox\bgroup
+ \insidefloattrue
+ \forgetall
+ \dontcomplain
+ % \offinterlineskip % we now explicitly use \nointerlineskip later on
+ \def\dohandleflowchart[##1][##2]%
+ {\def\currentFLOWnumber{##1}%
+ \getparameters[\@@FLOW][##2]}%
+ \getvalue{\@FLOW@-#1}%
+ \getparameters[\@@FLOW][#2]% dubbelop ?
+ \doifsomething{\@@FLOWautofocus}
+ {\checkFLOWautofocus}%
+ %\message{AUTOSHAPE 3: (\@@FLOWx,\@@FLOWy)->(\@@FLOWnx,\@@FLOWny)}\wait
+ \global\let\FLOWwidth \@@FLOWnx
+ \global\let\FLOWheight\@@FLOWny
+ \let\startFLOWcell\startFLOWcellA
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ \ifcase\@@FLOWnx\relax \let\@@FLOWnx\FLOWwidth \fi
+ \ifcase\@@FLOWny\relax \let\@@FLOWny\FLOWheight \fi
+ \doifnothing{\@@FLOWmaxwidth\@@FLOWmaxheight}{\FLOWscalingfalse}%
+ \ifFLOWscaling
+ \doifnothing{\@@FLOWmaxwidth }{\let\@@FLOWmaxwidth \maxdimen}%
+ \doifnothing{\@@FLOWmaxheight}{\let\@@FLOWmaxheight\maxdimen}%
+ \scratchcounter\bodyfontpoints
+ \doloop % NOG FONTSWITCH OM EX EN EM TE LATEN WERKEN
+ {\ifnum\scratchcounter>1 % NU DIMENSIONS IN TERMS OF BODYFONTSIZE
+ \bodyfontsize=\the\scratchcounter pt
+ \dimen0=\@@FLOWmaxwidth
+ \dimen2=\@@FLOWwidth
+ \dimen4=\@@FLOWdx
+ \advance\dimen2 2\dimen4
+ \dimen2=\@@FLOWnx\dimen2
+ \advance\dimen2 2\dimen4
+ \ifdim\dimen2>\dimen0
+ \advance\scratchcounter \minusone
+ \else
+ \dimen0=\@@FLOWmaxheight
+ \dimen2=\@@FLOWheight
+ \dimen4=\@@FLOWdy
+ \advance\dimen2 2\dimen4
+ \dimen2=\@@FLOWny\dimen2
+ \advance\dimen2 2\dimen4
+ \ifdim\dimen2>\dimen0
+ \advance\scratchcounter \minusone
+ \else
+ \exitloop
+ \fi
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ \expanded{\switchtobodyfont[\the\scratchcounter pt]}%
+ \forgetall
+ % \offinterlineskip % needed ?
+ \else\ifx\@@FLOWbodyfont\empty\else
+ \expanded{\switchtobodyfont[\@@FLOWbodyfont]}% \expanded ?
+ \fi\fi
+ \global\let\FLOWcells\empty
+ \dimen0=\@@FLOWwidth
+ \edef\FLOWshapewidth{\the\dimen0}%
+ \dimen2=\@@FLOWdx
+ \advance\dimen0 2\dimen2
+ \edef\FLOWgridwidth{\the\dimen0}%
+ \dimen0=\@@FLOWheight
+ \edef\FLOWshapeheight{\the\dimen0}%
+ \dimen2=\@@FLOWdy
+ \advance\dimen0 2\dimen2
+ \edef\FLOWgridheight{\the\dimen0}%
+ \scratchdimen=\@@FLOSrulethickness
+ \edef\@@FLOSrulethickness{\the\scratchdimen}%
+ \scratchdimen=\@@FLOFrulethickness
+ \edef\@@FLOFrulethickness{\the\scratchdimen}%
+ \scratchdimen=\@@FLOLrulethickness
+ \edef\@@FLOLrulethickness{\the\scratchdimen}%
+ \ifdim\@@FLOLradius<2.5\scratchdimen
+ \scratchdimen=2.5\scratchdimen
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \ifdim\@@FLOLradius>\@@FLOWdx
+ \scratchdimen=\@@FLOWdx
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \ifdim\@@FLOLradius>\@@FLOWdy
+ \scratchdimen=\@@FLOWdy
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \else
+ \scratchdimen=\@@FLOLradius
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \processaction % magic 2.5
+ [\@@FLOWoffset]
+ [ \v!none=>\scratchdimen=-2.5\scratchdimen,
+ \v!overlay=>\scratchdimen=-2.5\scratchdimen,
+ \v!standard=>\scratchdimen=\scratchdimen,
+ \s!unknown=>\scratchdimen=\@@FLOWoffset,
+ \s!default=>\scratchdimen=-2.5\scratchdimen]%
+ \edef\@@FLOW@@offset{\the\scratchdimen}%
+ \forgetall
+ \offinterlineskip
+ \resetMPdrawing
+ \doglobal\newcounter\FLOWcomment
+ \startMPdrawing
+ if unknown context_char : input mp-char.mp ; fi ;
+ grid_width := \FLOWgridwidth ;
+ grid_height := \FLOWgridheight ;
+ shape_width := \FLOWshapewidth ;
+ shape_height := \FLOWshapeheight ;
+ connection_line_width := \@@FLOLrulethickness ;
+ connection_smooth_size := \@@FLOLradius ;
+ connection_arrow_size := \@@FLOLradius ;
+ connection_dash_size := \@@FLOLradius ;
+ currentpicture := nullpicture ;
+ begin_chart(0,\FLOWwidth,\FLOWheight);
+ reverse_y := true ;
+ chart_offset := \@@FLOW@@offset ;
+ \stopMPdrawing
+ \doifelsenothing\@@FLOWbackgroundcolor
+ {\startMPdrawing
+ chart_background_color := white ;
+ \stopMPdrawing}
+ {\startMPdrawing
+ chart_background_color := \MPcolor{\@@FLOWbackgroundcolor} ;
+ \stopMPdrawing}%
+ \doif\@@FLOWoption\v!test
+ {\startMPdrawing
+ show_con_points := true ;
+ show_mid_points := true ;
+ show_all_points := true ;
+ \stopMPdrawing}%
+ \processaction % private
+ [\@@FLOWdot]
+ [ \v!yes=>\startMPdrawing
+ show_con_points := true ;
+ show_mid_points := true ;
+ show_all_points := true ;
+ \stopMPdrawing,
+ \s!unknown=>\startMPdrawing
+ show_\@@FLOWdot_points := true ;
+ \stopMPdrawing]%
+\doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellB
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+\doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellC
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ \startMPdrawing
+ clip_chart(\@@FLOWx,\@@FLOWy,\@@FLOWnx,\@@FLOWny) ;
+ end_chart ;
+ \stopMPdrawing
+ \MPdrawingdonetrue
+ \setbox0\hbox
+ {\MPstaticgraphictrue
+ \MPshiftdrawingfalse
+ \getMPdrawing}%
+ \def\MPmessage##1%
+ {\writestatus{MP charts}{##1}}%
+ \def\MPposition##1##2##3%
+ {\setvalue{\@@MPx##1}{##2}\setvalue{\@@MPy##1}{##3}}%
+ \def\MPclippath##1##2##3##4%
+ {\def\clipMPllx{##1bp}\def\clipMPlly{##2bp}%
+ \def\clipMPurx{##3bp}\def\clipMPury{##4bp}}%
+ \def\MPareapath##1##2##3##4%
+ {\def\areaMPllx{##1bp}\def\areaMPlly{##2bp}%
+ \def\areaMPurx{##3bp}\def\areaMPury{##4bp}}%
+ \getMPdata
+ \doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellD
+ \setbox2\vbox to \ht0
+ {\forgetall % \offinterlineskip
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber\vss}%
+ \setbox2\hbox
+ {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box2}%
+ \wd2\wd0\ht2\ht0\dp2\dp0
+ \let\startFLOWcell\startFLOWcellE
+ \setbox4\vbox to \ht0
+ {\forgetall % \offinterlineskip
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber\vss}%
+ \setbox4\hbox
+ {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box4}%
+ \wd4\wd0\ht4\ht0\dp4\dp0
+ \doifelse\@@FLOWoption\v!test
+ {\setbox6\vbox
+ {\forgetall
+ \vskip\@@FLOW@@offset
+ \hskip\@@FLOW@@offset
+ \basegrid
+ [\c!x=\@@FLOWx,\c!nx=\@@FLOWnx,\c!dx=\withoutpt\FLOWgridwidth,
+ \c!y=\@@FLOWy,\c!ny=\@@FLOWny,\c!dy=\withoutpt\FLOWgridheight,
+ \c!xstep=1,\c!ystep=1,
+ \c!unit=pt,\c!location=\v!middle]}%
+ \wd6\wd0\ht6\ht0\dp6\dp0
+ \setbox8\vbox
+ {\forgetall
+ \offinterlineskip
+ \vskip\@@FLOW@@offset
+ \dostepwiserecurse\@@FLOWy\@@FLOWny\plusone
+ {\vbox to \FLOWgridheight
+ {\vfill
+ \hskip\@@FLOW@@offset
+ \hbox
+ {\dostepwiserecurse\@@FLOWx\@@FLOWnx\plusone
+ {\hbox to \FLOWgridwidth
+ {\hfill
+ \framed
+ [\c!framecolor=red,
+ \c!width=\FLOWshapewidth,
+ \c!height=\FLOWshapeheight]
+ {}%
+ \hfill}}}
+ \vfill}}}%
+ \wd8\wd0\ht8\ht0\dp8\dp0
+ \framed
+ [\c!offset=\v!overlay,\c!framecolor=green]
+ {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2\hskip-\wd6\box6\hskip-\wd8\box8}}}
+ {\framed
+ [\c!offset=\v!overlay,
+ \c!frame=\@@FLOWframe,
+ \c!rulethickness=\@@FLOWrulethickness,
+ \c!framecolor=\@@FLOWframecolor,
+ \c!background=\@@FLOWbackground,
+ \c!backgroundcolor=\@@FLOWbackgroundcolor]
+ {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2}}}%
+ %\message{[\FLOWcells]}\wait
+ \egroup}
+
+% Pass A
+
+\long\def\startFLOWcellA#1\stopFLOWcell%
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \expandafter\getFLOWlocationA\FLOWlocation\end
+ \ignorespaces}
+
+\def\getFLOWlocationA#1,#2\end
+ {\ifnum0#1>\FLOWwidth \xdef\FLOWwidth {#1}\fi
+ \ifnum0#2>\FLOWheight\xdef\FLOWheight{#2}\fi}
+
+% Pass B
+%
+% beware: the - after \@FLOC@ is needed since name can be
+% empty and we don't want to redefine \@FLOC@ itself by
+% mistake
+
+\long\def\startFLOWcellB#1\stopFLOWcell
+ {\resetFLOWcell\ignorespaces#1\unskip
+ \setxvalue{\@FLOC@-\FLOWname}{\FLOWlocation}% kost veel cs's
+ \ifx\FLOWshape\empty
+ \global\let\FLOWshape\@@FLOSdefault
+ \fi
+ \doifnot\FLOWshape{none} % {\v!none}
+ {\ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWshapes}
+ {\edef\FLOWshapetag{shape_\FLOWshape}% beter \expanded
+ \@EA\setFLOWname\@EA\FLOWshapetag\@EA{\FLOWshapetag}}
+ {\doifnumberelse\FLOWshape
+ {\let\FLOWshapetag\FLOWshape}
+ {\let\FLOWshapetag\empty}}%
+ \ifx\FLOWshapetag\empty \else
+ \ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWlines}
+ {\chardef\FLOWstate0 }
+ {\ExpandBothAfter\doifcommonelse{\FLOWcell,\FLOWfocus}{\@@FLOWfocus}
+ {\chardef\FLOWstate1 }
+ {\chardef\FLOWstate2 }}%
+ \startMPdrawing
+ begin_sub_chart ;
+ \ifcase\FLOWstate
+ shape_line_color := \MPcolor{\@@FLOLcolor} ;
+ shape_fill_color := \MPcolor{\@@FLOLcolor} ;
+ shape_line_width := \@@FLOLrulethickness ;
+ \or
+ shape_line_color := \MPcolor{\@@FLOFframecolor} ;
+ shape_fill_color := \MPcolor{\@@FLOFbackgroundcolor} ;
+ shape_line_width := \@@FLOFrulethickness ;
+ \or
+ shape_line_color := \MPcolor{\@@FLOSframecolor} ;
+ shape_fill_color := \MPcolor{\@@FLOSbackgroundcolor} ;
+ shape_line_width := \@@FLOSrulethickness ;
+ \fi
+ %\ifx\FLOWoverlay\empty
+ % peepshape := false ;
+ %\else
+ % peepshape := true ;
+ %\fi
+ peepshape := \ifx\FLOWoverlay\empty false \else true \fi ;
+ new_shape(\FLOWlocation,\FLOWshapetag) ;
+ end_sub_chart ;
+ \stopMPdrawing
+ \fi}%
+ \ignorespaces}
+
+% Pass C
+
+\long\def\startFLOWcellC#1\stopFLOWcell%
+ {\resetFLOWcell
+\pushmacro\lastFLOWx
+\pushmacro\lastFLOWy
+ \ignorespaces#1\unskip % makes sure that vars are set
+\popmacro\lastFLOWy
+\popmacro\lastFLOWx
+ \let\connection\doFLOWconnectionC
+ \ignorespaces#1\unskip}
+
+\def\FLOWorigin{0,0}
+
+\def\doFLOWdisplace[#1,#2,#3]% experiment
+ {dsp_x := #1 ; dsp_y := #2 ;}
+
+\def\doFLOWconnectionC
+ {\dodoubleempty\dodoFLOWconnectionC}
+
+\def\dodoFLOWconnectionC[#1][#2]#3%
+ {\doglobal\increment\FLOWcomment
+ \setFLOWname\otherFLOWname{name_#3}%
+ \doifdefinedelse{\@FLOC@-\FLOWname}
+ {\edef\FLOWfrom{\getvalue{\@FLOC@-\FLOWname}}}
+ {\let \FLOWfrom \FLOWorigin}%
+ \ifx\FLOWfrom\FLOWorigin \else
+ \doifdefinedelse{\@FLOC@-\otherFLOWname}
+ {\edef\FLOWto {\getvalue{\@FLOC@-\otherFLOWname}}}
+ {\let \FLOWto \FLOWorigin}%
+ \ifx\FLOWto\FLOWorigin \else
+ \FLOWsetconnect{#1}%
+ \ifx\cFLOWfrom\empty \else
+ \doifelse\@@FLOLcorner\v!round
+ {\startMPdrawing smooth := true ; \stopMPdrawing}
+ {\startMPdrawing smooth := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLdash\v!yes
+ {\startMPdrawing dashline := true ; \stopMPdrawing}
+ {\startMPdrawing dashline := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLarrow\v!yes
+ {\startMPdrawing arrowtip := true ; \stopMPdrawing}
+ {\startMPdrawing arrowtip := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLoffset\v!none
+ {\startMPdrawing touchshape := true ; \stopMPdrawing}
+ {\startMPdrawing touchshape := false ; \stopMPdrawing}%
+%\doifsomething{#2}
+% {\startMPdrawing
+% \doFLOWdisplace[0#2,0,0]%
+% \stopMPdrawing}%
+ \startMPdrawing
+\doFLOWdisplace[0#2,0,0]%
+ connection_line_color := \MPcolor{\@@FLOLcolor} ;
+ connection_line_width := \@@FLOLrulethickness ;
+ connect_\cFLOWfrom_\cFLOWto (\FLOWfrom,\zFLOWfrom) (\FLOWto,\zFLOWto) ;
+\doFLOWdisplace[0,0,0]%
+ \stopMPdrawing
+ \fi
+ \fi
+ \fi
+ \ignorespaces}
+
+% Pass D
+
+\long\def\startFLOWcellD#1\stopFLOWcell
+ {\resetFLOWcell
+\pushmacro\lastFLOWx
+\pushmacro\lastFLOWy
+ \ignorespaces#1\unskip % presets vars
+\popmacro\lastFLOWy
+\popmacro\lastFLOWx
+ \let\doprocessFLOWcell\doprocessFLOWcellD
+ \expandafter\doprocessFLOWcellD\FLOWlocation\end
+ \let\connection\doFLOWconnectionD
+ \let\comment\doFLOWcommentD
+ \ignorespaces#1\unskip\ignorespaces}
+
+\def\doFLOWconnectionD
+ {\dodoubleempty\dodoFLOWconnectionD}
+
+\def\dodoFLOWconnectionD[#1][#2]#3%
+ {\doglobal\increment\FLOWcomment
+ \ignorespaces}
+
+\def\doFLOWcommentD[#1]#2%
+ {\bgroup
+ \let\FLOW \middlebox
+ \let\FLOWb \bottombox
+ \let\FLOWbl\bottomleftbox
+ \let\FLOWbr\bottomrightbox
+ \let\FLOWt \topbox
+ \let\FLOWtl\topleftbox
+ \let\FLOWtr\toprightbox
+ \let\FLOWl \leftbox
+ \let\FLOWlt\lefttopbox
+ \let\FLOWlb\leftbottombox
+ \let\FLOWr \rightbox
+ \let\FLOWrt\righttopbox
+ \let\FLOWrb\rightbottombox
+ \let\FLOWc \middlebox
+%\ifdefined{FLOW#1}%
+ \ifcase0\getvalue{\@@MPx\FLOWcomment}\getvalue{\@@MPy\FLOWcomment}\relax
+ \else
+ \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp<\areaMPllx\relax\else
+ \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp>\areaMPurx\relax\else
+ \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp<\areaMPlly\relax\else
+ \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp>\areaMPury\relax\else
+ \dimen0=\getvalue{\@@MPx\FLOWcomment}\s!bp
+ \advance\dimen0 -\@@FLOW@@offset
+ \advance\dimen0 -\clipMPllx
+ \dimen2=\clipMPury
+ \advance\dimen2 -\@@FLOW@@offset
+ \advance\dimen2 -\getvalue{\@@MPy\FLOWcomment}\s!bp
+ \setbox\scratchbox\hbox{\strut#2}%
+ \boxoffset.5\bodyfontsize
+ \setbox\scratchbox\hbox{\hskip\dimen0\lower\dimen2\getvalue{FLOW#1}{\box\scratchbox}}%
+ \smashbox\scratchbox
+ \box\scratchbox
+ \boxoffset\zeropoint
+ \nointerlineskip % really needed
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+%\fi
+ \egroup
+ \ignorespaces}
+
+% pass D
+
+\def\dophaseoneFLOWcellX#1#2%
+ {\!!counta#1\relax
+ \!!countb#2\relax
+ \!!countc\@@FLOWx
+ \!!countd\@@FLOWy
+ \advance\!!countc \@@FLOWnx
+ \advance\!!countd \@@FLOWny
+ \advance\!!countc \minusone
+ \advance\!!countd \minusone
+ \ifnum\!!counta<\@@FLOWx\relax \donefalse
+ \else\ifnum\!!counta>\!!countc \donefalse
+ \else\ifnum\!!countb<\@@FLOWy\relax \donefalse
+ \else\ifnum\!!countb>\!!countd \donefalse
+ \else \donetrue
+ \fi\fi\fi\fi}
+
+\def\dophasetwoFLOWcellX
+ {\advance\!!counta -\@@FLOWx
+ \advance\!!counta \plusone
+ \advance\!!countb -\@@FLOWy
+ \advance\!!countb \plusone
+ \dimen0=\FLOWgridwidth
+ \dimen0=\!!counta\dimen0
+ \advance\dimen0 -\FLOWgridwidth
+ \dimen4=\FLOWgridwidth
+ \advance\dimen4 -\FLOWshapewidth
+ \advance\dimen0 .5\dimen4
+ \dimen2=\FLOWgridheight
+ \dimen2=\!!countb\dimen2
+ \dimen4=\FLOWgridheight
+ \advance\dimen4 -\FLOWshapeheight
+ \advance\dimen2 -.5\dimen4
+ \edef\FLOWdx{\the\dimen0}%
+ \edef\FLOWdy{\the\dimen2}}
+
+\def\positionFLOWzero% assumes \FLOWdx and \FLOWdy are set
+ {\setbox0\hbox{\hskip\FLOWdx\lower\FLOWdy\box0}%
+ \smashbox0\box0
+ \nointerlineskip} % new, needed since we somehow reset that
+
+\def\doFLOWtlabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
+ \setbox0\hbox{\hskip\dimen2\raise\scratchdimen
+ \hbox{\raise\dimen4\hbox{#1{\strut#3}}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWblabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
+ \setbox0\hbox{\hskip\dimen2\raise-\scratchdimen
+ \hbox{#1{\strut#3}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWllabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
+ \setbox0\hbox{\hskip-\scratchdimen\raise\dimen6
+ \hbox{#1{\strut#3}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWrlabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
+ \setbox0\hbox{\hskip\dimen0\hskip\scratchdimen
+ \hbox{\raise\dimen6\hbox{#1{\strut#3}}}}%
+ \positionFLOWzero}
+
+\def\doprocessFLOWcellD#1,#2\end
+ {\dophaseoneFLOWcellX{#1}{#2}%
+ \ifdone
+ \dophasetwoFLOWcellX
+ \doglobal\addtocommalist\FLOWcell\FLOWcells
+ \def\FLOWx{#1}%
+ \def\FLOWy{#2}%
+ \directsetup{flowcell}%
+ \setbox0\hbox
+ {\ifx\FLOWalign\empty\else
+ \setupframed
+ [\c!align=\v!normal,\c!bottom=\vfill,\c!top=\vfill]%
+ \@EA\processallactionsinset\@EA
+ [\FLOWalign]
+ [t=>{\setupframed[\c!bottom=\vfill,\c!top=]},
+ b=>{\setupframed[\c!bottom=,\c!top=\vfill]},
+ l=>{\setupframed[\c!align=\v!right]},
+ r=>{\setupframed[\c!align=\v!left]},
+ m=>{\setupframed[\c!align=\v!middle]},
+ c=>{\setupframed[\c!align=\v!middle]}]%
+ \fi
+ \doifelse\FLOWshape{none} % {\v!none}
+ {\setupframed[\c!offset=\v!overlay]}
+ {\setupframed[\c!offset=\@@FLOSoffset]}%
+ \framed
+ [\c!frame=\v!off,\c!background=flowcell,
+ \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
+ {\FLOWtext}}%
+ \showFLOWhelp0
+ \ifx\FLOWdestination\empty\else
+ \setbox0\hbox
+ {\setupinteraction[\c!color=,\c!contrastcolor=]%
+ \gotobox{\box0}[\FLOWdestination]}%
+ \fi
+ \positionFLOWzero
+ \dimen0=\FLOWshapewidth \dimen2=.5\dimen0
+ \dimen4=\FLOWshapeheight\dimen6=.5\dimen4
+ \boxoffset.5\bodyfontsize
+ \doFLOWtlabel \righttopbox0\tFLOWlabel
+ \doFLOWblabel\rightbottombox0\bFLOWlabel
+ \doFLOWllabel \lefttopbox0\lFLOWlabel
+ \doFLOWrlabel \righttopbox0\rFLOWlabel
+ \doFLOWtlabel \topbox0\tcFLOWlabel % for me only
+ \doFLOWblabel \bottombox0\bcFLOWlabel % for me only
+ \doFLOWllabel \leftbox0\lcFLOWlabel % for me only
+ \doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
+ \ifnum#1=\@@FLOWx\relax \doFLOWllabel \leftbox1\lFLOWexit \fi
+ \ifnum#1=\!!countc \doFLOWrlabel \rightbox1\rFLOWexit \fi
+ \ifnum#2=\@@FLOWy\relax \doFLOWtlabel \topbox1\tFLOWexit \fi
+ \ifnum#2=\!!countd \doFLOWblabel \bottombox1\bFLOWexit \fi
+ \boxoffset\zeropoint
+ \fi}
+
+% For Willy Egger:
+%
+% \startsetups flowcell
+% \definelayer
+% [flowcell]
+% [width=\FLOWshapewidth,
+% height=\FLOWshapeheight]
+% \setlayerframed
+% [flowcell]
+% [preset=rightbottom,offset=1ex]
+% [frame=off]
+% {\tx(\FLOWx,\FLOWy)}
+% \stopsetups
+
+% Pass E
+
+\long\def\startFLOWcellE#1\stopFLOWcell
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \let\doprocessFLOWcell\doprocessFLOWcellE
+ \expandafter\doprocessFLOWcell\FLOWlocation\end}
+
+\def\doprocessFLOWcellE#1,#2\end % redundant
+ {\ifx\FLOWoverlay\empty \else
+ \dophaseoneFLOWcellX{#1}{#2}%
+ \ifdone
+ \dophasetwoFLOWcellX
+ \edef\FLOWdx{\the\dimen0}%
+ \edef\FLOWdy{\the\dimen2}%
+ \setbox0\hbox
+ {\framed
+ [%\c!frame=\v!off,
+ \c!background={\@@FLOWbackground,\FLOWoverlay},
+ \c!backgroundcolor=\@@FLOSbackgroundcolor,
+ \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
+ {}}%
+ \positionFLOWzero
+ \fi
+ \fi}
+
+% Pass F
+
+\def\checkFLOWautofocus
+ {\def\@@FLOWminx{100}\let\@@FLOWminy\@@FLOWminx
+ \def\@@FLOWmaxx {0}\let\@@FLOWmaxy\@@FLOWmaxx
+ \def\@@FLOWabsx {0}\let\@@FLOWabsy\@@FLOWabsx
+ \let\startFLOWcell\startFLOWcellF
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ %\message{AUTOSHAPE 1: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
+ \ifnum\@@FLOWabsx<\@@FLOWmaxx\let\@@FLOWmaxx\@@FLOWabsx\fi
+ \ifnum\@@FLOWabsy<\@@FLOWmaxy\let\@@FLOWmaxy\@@FLOWabsy\fi
+ %\message{AUTOSHAPE 2: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
+ \donetrue
+ \ifnum\@@FLOWminx=100 \donefalse\fi
+ \ifnum\@@FLOWminy=100 \donefalse\fi
+ \ifnum\@@FLOWmaxx=0 \donefalse\fi
+ \ifnum\@@FLOWmaxy=0 \donefalse\fi
+ \doFLOWcheckF\@@FLOWx\@@FLOWminx\@@FLOWmaxx\@@FLOWnx
+ \doFLOWcheckF\@@FLOWy\@@FLOWminy\@@FLOWmaxy\@@FLOWny}
+
+\def\startFLOWcellF#1\stopFLOWcell%
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \expandafter\doFLOWlocationF\FLOWlocation\end}%
+
+\def\doFLOWlocationF#1,#2\end%
+ {\ifnum#1>\@@FLOWabsx\def\@@FLOWabsx{#1}\fi
+ \ifnum#2>\@@FLOWabsy\def\@@FLOWabsy{#2}\fi
+ \ExpandBothAfter\doifinset{\FLOWcell}{\@@FLOWautofocus}
+ {\dodoFLOWlocationF{#1}<-\@@FLOWminx
+ \dodoFLOWlocationF{#1}>+\@@FLOWmaxx
+ \dodoFLOWlocationF{#2}<-\@@FLOWminy
+ \dodoFLOWlocationF{#2}>+\@@FLOWmaxy}}
+
+\def\dodoFLOWlocationF#1#2#3#4%
+ {\ifnum#1#2#4\relax
+ \!!counta=#1\advance\!!counta #31\relax
+ \edef#4{\ifnum\!!counta<1 1\else\the\!!counta\fi}%
+ \fi}
+
+\def\doFLOWcheckF#1#2#3#4%
+ {\ifdone
+ \let#1=#2%
+ \!!counta=#3%
+ \advance\!!counta \plusone\advance\!!counta -#2\relax
+ \ifnum\!!counta<1 \!!counta=1 \fi
+ \edef#4{\the\!!counta}%
+ \else
+ \let#1\!!plusone
+ \let#4\!!zerocount % no {1}
+ \fi}
+
+% \useFLOWchart[name][parent][setting,setting][additional settings]
+% \useFLOWchart[name][parent][additional settings]
+
+\let\currentFLOWchart\empty
+
+\def\useFLOWchart
+ {\doquadrupleempty\douseFLOWchart}
+
+\def\douseFLOWchart[#1][#2][#3][#4]% name parent sets mainsettings
+ {\iffourthargument
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][#4,##1]}%
+ \else
+ \checkparameters[#3]%
+ \ifparameters
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][][#3,##1]}%
+ \else
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][##1]}%
+ \fi
+ \fi}
+
+\def\setgetFLOWchart[#1][#2][#3]%
+ {\def\docommand##1{}% cell line focus ?
+ \processcommalist[#2]\docommand
+ \getFLOWchart[#1][#3]}
+
+\def\doFLOWchart[#1][#2]%
+ {\hbox\bgroup\vbox\bgroup % vmode suppresses spaces
+\def\currentFLOWchart{#1}%
+ \doifundefinedelse{\@FLOW@--#1}
+ {\getFLOWchart[#1][#2]}
+ {\getvalue{\@FLOW@--#1}[#2]}%
+ \egroup\egroup}
+
+\def\FLOWchart%
+ {\dodoubleempty\doFLOWchart}
+
+%D A hook into the help system.
+
+\def\showFLOWhelp#1%
+ {\doifhelpinfo\FLOWhelp
+ {\setbox#1=\hbox
+ {\setbox\scratchbox=\hbox{\lower\@@FLOWdy\hbox
+ {\helpbutton
+ [\c!width=\wd0,\c!color=,\c!height=\@@FLOWdy,\c!frame=\v!no]%
+ [\FLOWhelp]}}%
+ \smashbox\scratchbox
+ \setbox#1=\vbox
+ {\forgetall\offinterlineskip\box#1\box\scratchbox}%
+ \box#1}}}
+
+%D The next section is dedicated to splitting up charts.
+
+\def\getFLOWsize[#1]%
+ {\bgroup\let\dodogetFLOWchart\dogetFLOWsize\FLOWchart[#1]\egroup}
+
+\def\dogetFLOWsize[#1][#2]%
+ {\setbox\scratchbox=\vbox
+ {\globallet\FLOWmaxwidth \!!zerocount
+ \globallet\FLOWmaxheight\!!zerocount
+ \def\getFLOWlocation##1,##2\end
+ {\ifnum0##1>\FLOWmaxwidth \xdef\FLOWmaxwidth {##1}\fi
+ \ifnum0##2>\FLOWmaxheight\xdef\FLOWmaxheight{##2}\fi}%
+ \resetFLOWcell
+ \long\def\startFLOWcell##1\stopFLOWcell
+ {{##1\expandafter\getFLOWlocation\FLOWlocation\end}}%
+ \def\dohandleflowchart[##1][##2]%
+ {\resetFLOWlocation
+ \processFLOWbuffer{##1}}%
+ \getvalue{\@FLOW@-#1}}}
+
+\def\setupFLOWsplit%
+ {\dodoubleargument\getparameters[\@@FLOT]}
+
+\setupFLOWsplit%
+ [\c!nx=3,\c!ny=3,
+ \c!dx=1,\c!dy=1,
+ \c!command=,
+ \c!marking=\v!on,
+ \c!before=,\c!after=]
+
+\def\FLOWsplitx {1}
+\def\FLOWsplity {1}
+\def\FLOWsplitnx{1}
+\def\FLOWsplitny{1}
+
+\def\FLOWcharts%
+ {\dodoubleempty\doFLOWcharts}
+
+%D While splitting, the following variables are available:
+%D
+%D \starttyping
+%D \FLOWsplitnx \FLOWsplitny \FLOWsplitx \FLOWsplity
+%D \stoptyping
+
+\def\doFLOWcharts[#1][#2]%
+ {\bgroup
+ \getFLOWsize[#1]%
+ \dodoFLOWcharts\relax
+ \global\let\FLOWsplitnx\FLOWsplitx
+ \global\let\FLOWsplitny\FLOWsplity
+ \dodoFLOWcharts{\dododoFLOWcharts[#1][#2]}%
+ \egroup}
+
+\def\dodoFLOWcharts#1%
+ {\def\@@FLOTx{1}%
+ \global\let\FLOWsplitx\@@FLOTx
+ \doloop
+ {\def\@@FLOTy{1}%
+ \global\let\FLOWsplity\@@FLOTy
+ \doloop
+ {\bgroup
+ \scratchcounter\FLOWmaxwidth
+ \advance\scratchcounter -\@@FLOTx
+ \advance\scratchcounter \plusone
+ \ifnum\scratchcounter<\@@FLOTnx\edef\@@FLOTnx{\the\scratchcounter}\fi
+ \scratchcounter\FLOWmaxheight
+ \advance\scratchcounter -\@@FLOTy
+ \advance\scratchcounter \plusone
+ \ifnum\scratchcounter<\@@FLOTny\edef\@@FLOTny{\the\scratchcounter}\fi
+ #1% does something with the float, or not
+ \egroup
+ \increment(\@@FLOTy,\@@FLOTny)%
+ \ifnum\@@FLOTy>\FLOWmaxheight
+ \exitloop
+ \else
+ \doglobal\increment\FLOWsplity
+ \decrement(\@@FLOTy,\@@FLOTdy)%
+ \fi}%
+ \increment(\@@FLOTx,\@@FLOTnx)%
+ \ifnum\@@FLOTx>\FLOWmaxwidth
+ \exitloop
+ \else
+ \doglobal\increment\FLOWsplitx
+ \decrement(\@@FLOTx,\@@FLOTdx)%
+ \fi}}
+
+\def\dododoFLOWcharts[#1][#2]%
+ {\bgroup
+ \@@FLOTbefore
+ \doifnot\@@FLOTmarking\v!on{\let\cuthbox\hbox}%
+ \cuthbox
+ {\@@FLOTcommand
+ {\FLOWchart[#1][#2,
+ \c!x=\@@FLOTx,\c!nx=\@@FLOTnx,
+ \c!y=\@@FLOTy,\c!ny=\@@FLOTny]}}%
+ \@@FLOTafter
+ \egroup}
+
+%D An example of splitting is given below:
+%D
+%D \starttyping
+%D \setupFLOWsplit
+%D [nx=5,ny=10,
+%D dx=0,dy=0,
+%D before=,
+%D after=\page]
+%D
+%D \FLOWcharts[mybigflow]
+%D \stoptyping
+%D
+%D Or, one can say:
+%D
+%D \starttyping
+%D \splitfloat
+%D {\placefigure{What a big flowchart this is!}}
+%D {\FLOWcharts[mybigflow]}
+%D \stoptyping
+
+%D \macros
+%D {typeFLOWchart}
+%D
+%D For documentation purposes the following macro is
+%D provided. Watch the use of the first and last line hooks,
+%D which is needed because the start and stop commands are
+%D not part of the buffer.
+
+\def\typeFLOWchart[#1]%
+ {\bgroup
+ \def\dohandleflowchart[##1][##2]{\typeFLOWbuffer{##1}}%
+ \defconvertedargument\firstverbatimfileline{\startFLOWchart[#1]}%
+ \defconvertedargument\lastverbatimfileline {\stopFLOWchart}%
+ \getvalue{\@FLOW@-#1}
+ \egroup}
+
+%D New:
+%D
+%D \starttyping
+%D \setupFLOWcharts[command=\Whow]
+%D
+%D \startFLOWset[convert-en] % [tag][convert-en]
+%D \subFLOWchart[a][x=1,y=1,nx=3,ny=3]
+%D \subFLOWchart[b][x=1,y=2,nx=3,ny=3]
+%D \subFLOWchart[c][x=2,y=1,nx=3,ny=3]
+%D \stopFLOWset
+%D
+%D \def\Whow#1%
+%D {\ifnum\currentFLOWset=1 \framed{Some Chart}\fi}
+%D
+%D \FLOWset[convert-en] % [tag]
+%D
+%D \def\Whow#1%
+%D {\setuphead[state=high]
+%D \startstandardmakeup
+%D \centerbox{#1}
+%D \stopstandardmakeup}
+%D
+%D \FLOWset[convert-en] % [tag]
+%D \stoptyping
+
+\def\startFLOWset
+ {\dodoubleempty\dostartFLOWset}
+
+\def\dostartFLOWset[#1][#2]#3\stopFLOWset % tag name data
+ {\ifsecondargument
+ \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#2}{#3}}%
+ \else
+ \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#1}{#3}}%
+ \fi}
+
+\long\def\dohandleFLOWset#1#2#3% tag name data
+ {\bgroup
+ \def\subFLOWchart
+ {\dodoubleempty\dosubFLOWchart}%
+ \def\dosubFLOWchart[##1][##2]% subtag settings
+ {\ifsecondargument
+ \dodohandleFLOWset{#1}{##1}{#2}{##2}%
+ \else
+ \subFLOWchart[][##1]%
+ \fi}%
+ #3%
+ \egroup}
+
+\def\dodohandleFLOWset#1#2#3#4% tag subtag name settings
+ {\increment\currentFLOWset
+ \bgroup
+ \@@FLOXcommand
+ {\ifnum\currentFLOWset=1 \pagereference[#1]\fi
+ \doifsomething{#2}
+ {\setupreferencing[\c!prefix=]%
+ \pagereference[#1:#2]% -:#1:#2
+ \setupreferencing[\c!prefix=#1:#2]}%
+ \FLOWchart[#3][#4]}%
+ \egroup}
+
+\def\FLOWset[#1]%
+ {\newcounter\currentFLOWset
+ \doifdefinedelse{\@FLOX@#1}
+ {\getvalue{\@FLOX@#1}}
+ {\dodohandleFLOWset{#1}{}{#1}{}}}
+
+\newcounter\currentFLOWset
+
+\setupFLOWsets
+ [\c!command=]
+
+%D This will be an option:
+
+% \def\startFLOWchart%
+% {\dodoubleempty\dostartFLOWchart}
+%
+% \long\def\dostartFLOWchart[#1][#2]#3\stopFLOWchart
+% {\preparenextFLOWchart{#1}{#2}%
+% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
+%
+% \long\def\dodefineFLOWchart[#1][#2]#3%
+% {\preparenextFLOWchart{#1}{#2}%
+% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
+%
+% \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}}
+% \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]}
+
+%D The \XML\ interface:
+
\startXMLdefinitions flowchart
\defineXMLargument [flowchartdefinition]
diff --git a/tex/context/base/m-chart.mkiv b/tex/context/base/m-chart.mkiv
index 4c008a5ee..e55a8c942 100644
--- a/tex/context/base/m-chart.mkiv
+++ b/tex/context/base/m-chart.mkiv
@@ -11,10 +11,2547 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D The \XML\ interface:
+%D This module will be reimplemented as it can be done much more
+%D simple now in mkiv,.
+
+
+% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
+% todo: make mkiv variant
+% todo: use dimexpr/numspr
+
+% will be redone with layers and dimexpr or even better, by just using
+% textext .. a nice example of old code
+
+%D This is an experimental module. Pieces of code will be moved
+%D to other modules. More features are possible but will be
+%D interfaces later.
+%D
+%D When finished this module will be documented. The main macro
+%D is still a rather big one and there is some redundant and
+%D slow code that needs a clean up.
+
+% arrow, dash
+% crossing
+% \goto -> \normalgoto
+% class -> class:name (ref prefix)
+% c, automatisch geen overlap zoeken
+% eind eerder chart connecties
+% relateren aan korps
+% check op bestaan naam, bestaan shape
+% auto als extern figuur
+% subchart
+% pijlen
+% focus
+% ook nog \MPmessage
+% areapath -> krappe vlak
+% clippath -> gehele vlak
+%
+% offset : clip offset
+% breedte : breedte cel
+% hoogte : hoogte cel
+% dx : halve afstand in breedte (grid breedte = breedte + 2dx)
+% dy : halve afstand in hoogte (grid hoogte = hoogte + 2dy)
+% x : x offset (clipping)
+% y : y offset (clipping)
+% nx : minimaal aantal cellen horizontaal
+% ny : minimaal aantal cellen vertikaal
+%
+% shape none en geen equivalent maken
+%
+% kaderkleur achtergrondkleur
+% lijnkleur lijndikte
+% focus focuskaderkleur focusachtergrondkleur
+% richting
+%
+% focus koppelen aan kleur
+
+\unprotect
+
+\definesorting [flowchart] [flowcharts] [\v!none] % no access
+\setupsorting [flowchart] [\c!state=\v!stop] % off by default
+
+\def\@FLOW@{@FLOW@}
+\def\@FLOC@{@FLOC@}
+\def\@FLOX@{@FLOX@}
+
+\def\@@FLOW{@@FLOW}
+\def\@@FLOL{@@FLOL}
+\def\@@FLOS{@@FLOS}
+\def\@@FLOF{@@FLOF}
+\def\@@FLOT{@@FLOT}
+\def\@@FLOX{@@FLOX}
+
+\def\@@MPx {@@MPx}
+\def\@@MPy {@@MPy}
+
+\def\FLOWbufferprefix{flw-}
+
+\def\processFLOWbuffer#1{\getbuffer[\FLOWbufferprefix#1]}
+\def\typeFLOWbuffer #1{\typebuffer[\FLOWbufferprefix#1]}
+
+\def\setFLOWname#1#2% funny hack that makes sure that we get
+ {\bgroup % names that are acceptable for METAPOST
+ \lccode`0=`a\lccode`1=`b\lccode`2=`c\lccode`3=`d\lccode`4=`e%
+ \lccode`5=`f\lccode`6=`g\lccode`7=`h\lccode`8=`i\lccode`9=`j%
+ \lccode` =`\_\lccode`-=`\_\lccode`_=`\_%
+ \lowercase{\gdef#1{#2}}%
+ \egroup}
+
+% een gobble als default is sneller, en dan alleen setten als
+% nodig
+
+\def\resetFLOWcell
+ {% variables
+ \global\let\FLOWname \empty
+ \global\let\FLOWalign \empty
+ \global\let\FLOWshape \empty
+ \global\let\FLOWlocation \empty
+ \global\let\FLOWtext \empty
+ \global\let\FLOWhelp \empty
+ \global\let\FLOWdestination\empty
+ \global\let\FLOWoverlay \empty
+ \global\let\FLOWfocus \empty
+ \global\let\tFLOWlabel \empty
+ \global\let\bFLOWlabel \empty
+ \global\let\lFLOWlabel \empty
+ \global\let\rFLOWlabel \empty
+ \global\let\bcFLOWlabel \empty
+ \global\let\tcFLOWlabel \empty
+ \global\let\lcFLOWlabel \empty
+ \global\let\rcFLOWlabel \empty
+ \global\let\tFLOWexit \empty
+ \global\let\bFLOWexit \empty
+ \global\let\lFLOWexit \empty
+ \global\let\rFLOWexit \empty
+ % commands
+ \let\name \doFLOWname
+ \let\shape \doFLOWshape
+ \let\destination\doFLOWdestination
+ \let\location \doFLOWlocation
+ \let\focus \doFLOWfocus
+ \let\overlay \doFLOWoverlay
+ \let\figure \doFLOWfigure
+ \let\text \doFLOWtext
+ \let\comment \doFLOWcomment
+ \let\label \doFLOWlabel
+ \let\help \doFLOWhelp
+ \let\connection \doFLOWconnection
+ \let\exit \doFLOWexit
+ % convenience commands
+ \let\locate \doFLOWlocate
+ \let\connect \doFLOWconnect}
+
+\let\FLOWcell \s!unknown
+\let\FLOWshape \s!unknown
+\let\FLOWdestination\s!unknown
+\let\FLOWfocus \s!unknown
+\let\FLOWoverlay \empty
+\let\FLOWtext \empty
+
+\def\doFLOWname#1%
+ {\def\FLOWcell{#1}\setFLOWname\FLOWname{name_#1}\ignorespaces}
+
+\def\doFLOWshape#1%
+ {\gdef\FLOWshape{#1}\ignorespaces}
+
+\def\doFLOWdestination#1%
+ {\gdef\FLOWdestination{#1}\ignorespaces}
+
+\def\doFLOWlocation#1%
+ {\setFLOWlocation#1\end\ignorespaces}
+
+\def\doFLOWfocus#1%
+ {\gdef\FLOWfocus{#1}\ignorespaces}
+
+\def\doFLOWoverlay#1%
+ {\gdef\FLOWoverlay{#1}\ignorespaces}
+
+\def\doFLOWfigure#1%
+ {\defineoverlay[\s!dummy][\overlayfigure{#1}]%
+ \overlay\s!dummy}
+
+\def\doFLOWtext
+ {\dosingleempty\dodoFLOWtext}
+
+\def\dodoFLOWtext[#1]% % #2%
+ {\gdef\FLOWalign{#1}\gdef\FLOWtext}% {#2}}
+
+\def\doFLOWcomment[#1]#2%
+ {\ignorespaces\dogobblesingleempty}
+
+\def\doFLOWlabel[#1]#2% wordt dit gebruikt ?
+ {\setgvalue{#1FLOWlabel}{#2}\ignorespaces}
+
+\def\doFLOWhelp#1%
+ {\gdef\FLOWhelp{#1}\ignorespaces}
+
+\def\doFLOWconnection
+ {\dodoubleempty\dodoFLOWconnection}
+
+\def\dodoFLOWconnection[#1][#2]#3%
+ {\ignorespaces}
+
+\def\doFLOWconnect
+ {\connection}
+
+\def\doFLOWlocate
+ {\location}
+
+\def\doFLOWexit[#1]#2%
+ {\setgvalue{#1FLOWexit}{#2}\ignorespaces}
+
+\def\startFLOWchart
+ {\bgroup
+ \let\stopFLOWchart\egroup
+ \obeylines % lelijk, buffers nog eens fatsoeneren
+ \dodoubleempty\dostartFLOWchart}
+
+\def\dostartFLOWchart[#1][#2]%
+ {\preparenextFLOWchart{#1}{#2}%
+ \dostartbuffer[\FLOWbufferprefix\nofFLOWcharts][startFLOWchart][stopFLOWchart]}
+
+\def\defineFLOWchart%
+ {\dodoubleempty\dodefineFLOWchart}
+
+\long\def\dodefineFLOWchart[#1][#2]#3%
+ {\preparenextFLOWchart{#1}{#2}%
+ \setbuffer[\FLOWbufferprefix\nofFLOWcharts]#3\endbuffer}
+
+\def\preparenextFLOWchart#1#2%
+ {\doglobal\increment\nofFLOWcharts
+ \flowchart{#1}%
+ \setxvalue{\@FLOW@-#1}{\noexpand\dohandleflowchart[\nofFLOWcharts][#2]}}
+
+\def\setupFLOWcharts{\dodoubleargument\getparameters[\@@FLOW]}
+\def\setupFLOWlines {\dodoubleargument\getparameters[\@@FLOL]}
+\def\setupFLOWshapes{\dodoubleargument\getparameters[\@@FLOS]}
+\def\setupFLOWfocus {\dodoubleargument\getparameters[\@@FLOF]}
+\def\setupFLOWsets {\dodoubleargument\getparameters[\@@FLOX]}
+
+\setupFLOWcharts
+ [\c!option=,
+ \c!bodyfont=,
+ \c!dot=, % private option
+ \c!width=12\bodyfontsize,
+ \c!height=7\bodyfontsize,
+ \c!maxwidth=,
+ \c!maxheight=,
+ \c!offset=\v!standard, % == auto offset
+ \c!dx=2\bodyfontsize,
+ \c!dy=2\bodyfontsize,
+ \c!nx=0, % 1,
+ \c!ny=0, % 1,
+ \c!x=1,
+ \c!y=1,
+ \c!autofocus=,
+ \c!focus=,
+ \c!background=, % \v!color,
+ \c!backgroundcolor=\s!white,
+ \c!rulethickness=\linewidth,
+ \c!frame=\v!off,
+ \c!framecolor=]
+
+\setupFLOWlines
+ [\c!corner=\v!round,
+ \c!arrow=\v!yes,
+ \c!dash=\v!no,
+ \c!radius=.375\bodyfontsize, % 2.5\c!rulethickness
+ \c!color=FLOWlinecolor,
+ \c!rulethickness=.15\bodyfontsize, % 2pt,
+ \c!offset=\v!none]
+
+\setupFLOWshapes
+ [\c!default=action,
+ \c!framecolor=FLOWframecolor,
+ \c!background=\v!color,
+ \c!backgroundcolor=FLOWbackgroundcolor,
+ \c!backgroundscreen=\@@rsscreen,
+ \c!rulethickness=.15\bodyfontsize, % 2pt,
+ \c!offset=.5\bodyfontsize]
+
+\setupFLOWfocus
+ [\c!framecolor=FLOWfocuscolor,
+ \c!background=\@@FLOSbackground,
+ \c!backgroundcolor=\@@FLOSbackgroundcolor,
+ \c!backgroundscreen=\@@FLOSbackgroundscreen,
+ \c!rulethickness=\@@FLOSrulethickness,
+ \c!offset=\@@FLOSoffset]
+
+\definecolor [FLOWfocuscolor] [s=.2]
+\definecolor [FLOWlinecolor] [s=.5]
+\definecolor [FLOWframecolor] [s=.7]
+\definecolor [FLOWbackgroundcolor] [s=.9]
+
+\newcounter\includeFLOWx
+\newcounter\includeFLOWy
+
+\def\includeFLOWchart
+ {\dodoubleempty\doincludeFLOWchart}
+
+\def\doincludeFLOWchart[#1][#2]%
+ {\pushmacro\includeFLOWx
+ \pushmacro\includeFLOWy
+ \getparameters[FLOWi][x=1,y=1,#2]%
+ \increment(\includeFLOWx,0\FLOWix)\decrement\includeFLOWx
+ \increment(\includeFLOWy,0\FLOWiy)\decrement\includeFLOWy
+ \def\dodoincludeFLOWchart##1%
+ {\doifdefined{\@FLOW@-##1}
+ {\globalpushmacro\dohandleflowchart % was local
+ \gdef\dohandleflowchart[####1][####2]%
+ {\globalpopmacro\dohandleflowchart % was local
+ \resetFLOWlocation
+ \processFLOWbuffer{####1}}%
+ \getvalue{\@FLOW@-##1}}}%
+ \processcommalist[#1]\dodoincludeFLOWchart
+ \popmacro\includeFLOWx
+ \popmacro\includeFLOWy}
+
+\def\resetFLOWlocation
+ {\globallet\lastFLOWx\!!zerocount
+ \globallet\lastFLOWy\!!zerocount}
+
+\def\dosetFLOWlocation[#1#2]#3#4%
+ {\processaction
+ [#1#2]
+ [ +=>\scratchcounter\numexpr#4+ 1+#3\relax,
+ -=>\scratchcounter\numexpr#4- 1+#3\relax,
+ +#2=>\scratchcounter\numexpr#4+#2+#3\relax,
+ -#2=>\scratchcounter\numexpr#4-#2+#3\relax,
+ \s!default=>\scratchcounter\numexpr#4 +#3\relax,
+ \s!unknown=>\scratchcounter\numexpr0#1#2+#3\relax]%
+ \xdef#4{\the\scratchcounter}}
+
+\def\setFLOWlocation#1,#2\end
+ {\dosetFLOWlocation[#1\empty]\includeFLOWx\lastFLOWx
+ \dosetFLOWlocation[#2\empty]\includeFLOWy\lastFLOWy
+ \xdef\FLOWlocation{\lastFLOWx,\lastFLOWy}}
+
+\def\FLOWshapes
+ {node, action, procedure, product, decision, archive,
+ loop, wait, subprocedure, singledocument, multidocument,
+ sub procedure, single document, multi document, up, down,
+ left, right}
+
+\def\FLOWlines
+ {up, down, left, right}
+
+\def\FLOWsetconnect#1%
+ {\donefalse
+ \let\cFLOWfrom\empty
+ \let\cFLOWto\empty
+ \let\zFLOWfrom\!!zerocount
+ \let\zFLOWto\!!zerocount
+ \handletokens#1\with\doFLOWsetconnect
+ \ifx\cFLOWto\empty\let\cFLOWfrom\empty\fi}
+
+\def\doFLOWsetconnect#1%
+ {\ifx #1p%
+ \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
+ \else\ifx#1+%
+ \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
+ \else\ifx#1n%
+ \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
+ \else\ifx#1-%
+ \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
+ \else\ifdone
+ \edef\cFLOWto{\FLOWconnector#1}%
+ \else
+ \edef\cFLOWfrom{\FLOWconnector#1}%
+ \donetrue
+ \fi\fi\fi\fi\fi}
+
+\def\FLOWconnector#1%
+ {\if#1bbottom\else\if#1ttop\else\if#1lleft\else\if#1rright\fi\fi\fi\fi}
+
+\newif\ifFLOWscaling \FLOWscalingtrue
+
+\def\@@FLOW@@offset{\@@FLOWoffset}
+
+\def\getFLOWchart
+ {\dodoubleempty\dogetFLOWchart}
+
+\def\dogetFLOWchart[#1][#2]%
+ {\doifundefinedelse{\@FLOW@-#1}
+ {\writestatus{FLOW}{unknown chart #1}%
+ \framed
+ [\c!width=12\bodyfontsize,\c!height=8\bodyfontsize]
+ {\tttf [chart #1]}}
+ {\dodogetFLOWchart[#1][#2]}}
+
+\def\dodogetFLOWchart[#1][#2]% to be split a bit more
+ {\vbox\bgroup
+ \insidefloattrue
+ \forgetall
+ \dontcomplain
+ % \offinterlineskip % we now explicitly use \nointerlineskip later on
+ \def\dohandleflowchart[##1][##2]%
+ {\def\currentFLOWnumber{##1}%
+ \getparameters[\@@FLOW][##2]}%
+ \getvalue{\@FLOW@-#1}%
+ \getparameters[\@@FLOW][#2]% dubbelop ?
+ \doifsomething{\@@FLOWautofocus}
+ {\checkFLOWautofocus}%
+ %\message{AUTOSHAPE 3: (\@@FLOWx,\@@FLOWy)->(\@@FLOWnx,\@@FLOWny)}\wait
+ \global\let\FLOWwidth \@@FLOWnx
+ \global\let\FLOWheight\@@FLOWny
+ \let\startFLOWcell\startFLOWcellA
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ \ifcase\@@FLOWnx\relax \let\@@FLOWnx\FLOWwidth \fi
+ \ifcase\@@FLOWny\relax \let\@@FLOWny\FLOWheight \fi
+ \doifnothing{\@@FLOWmaxwidth\@@FLOWmaxheight}{\FLOWscalingfalse}%
+ \ifFLOWscaling
+ \doifnothing{\@@FLOWmaxwidth }{\let\@@FLOWmaxwidth \maxdimen}%
+ \doifnothing{\@@FLOWmaxheight}{\let\@@FLOWmaxheight\maxdimen}%
+ \scratchcounter\bodyfontpoints
+ \doloop % NOG FONTSWITCH OM EX EN EM TE LATEN WERKEN
+ {\ifnum\scratchcounter>1 % NU DIMENSIONS IN TERMS OF BODYFONTSIZE
+ \bodyfontsize=\the\scratchcounter pt
+ \dimen0=\@@FLOWmaxwidth
+ \dimen2=\@@FLOWwidth
+ \dimen4=\@@FLOWdx
+ \advance\dimen2 2\dimen4
+ \dimen2=\@@FLOWnx\dimen2
+ \advance\dimen2 2\dimen4
+ \ifdim\dimen2>\dimen0
+ \advance\scratchcounter \minusone
+ \else
+ \dimen0=\@@FLOWmaxheight
+ \dimen2=\@@FLOWheight
+ \dimen4=\@@FLOWdy
+ \advance\dimen2 2\dimen4
+ \dimen2=\@@FLOWny\dimen2
+ \advance\dimen2 2\dimen4
+ \ifdim\dimen2>\dimen0
+ \advance\scratchcounter \minusone
+ \else
+ \exitloop
+ \fi
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ \expanded{\switchtobodyfont[\the\scratchcounter pt]}%
+ \forgetall
+ % \offinterlineskip % needed ?
+ \else\ifx\@@FLOWbodyfont\empty\else
+ \expanded{\switchtobodyfont[\@@FLOWbodyfont]}% \expanded ?
+ \fi\fi
+ \global\let\FLOWcells\empty
+ \dimen0=\@@FLOWwidth
+ \edef\FLOWshapewidth{\the\dimen0}%
+ \dimen2=\@@FLOWdx
+ \advance\dimen0 2\dimen2
+ \edef\FLOWgridwidth{\the\dimen0}%
+ \dimen0=\@@FLOWheight
+ \edef\FLOWshapeheight{\the\dimen0}%
+ \dimen2=\@@FLOWdy
+ \advance\dimen0 2\dimen2
+ \edef\FLOWgridheight{\the\dimen0}%
+ \scratchdimen=\@@FLOSrulethickness
+ \edef\@@FLOSrulethickness{\the\scratchdimen}%
+ \scratchdimen=\@@FLOFrulethickness
+ \edef\@@FLOFrulethickness{\the\scratchdimen}%
+ \scratchdimen=\@@FLOLrulethickness
+ \edef\@@FLOLrulethickness{\the\scratchdimen}%
+ \ifdim\@@FLOLradius<2.5\scratchdimen
+ \scratchdimen=2.5\scratchdimen
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \ifdim\@@FLOLradius>\@@FLOWdx
+ \scratchdimen=\@@FLOWdx
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \ifdim\@@FLOLradius>\@@FLOWdy
+ \scratchdimen=\@@FLOWdy
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \else
+ \scratchdimen=\@@FLOLradius
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \processaction % magic 2.5
+ [\@@FLOWoffset]
+ [ \v!none=>\scratchdimen=-2.5\scratchdimen,
+ \v!overlay=>\scratchdimen=-2.5\scratchdimen,
+ \v!standard=>\scratchdimen=\scratchdimen,
+ \s!unknown=>\scratchdimen=\@@FLOWoffset,
+ \s!default=>\scratchdimen=-2.5\scratchdimen]%
+ \edef\@@FLOW@@offset{\the\scratchdimen}%
+ \forgetall
+ \offinterlineskip
+ \resetMPdrawing
+ \doglobal\newcounter\FLOWcomment
+ \startMPdrawing
+ if unknown context_char : input mp-char.mp ; fi ;
+ grid_width := \FLOWgridwidth ;
+ grid_height := \FLOWgridheight ;
+ shape_width := \FLOWshapewidth ;
+ shape_height := \FLOWshapeheight ;
+ connection_line_width := \@@FLOLrulethickness ;
+ connection_smooth_size := \@@FLOLradius ;
+ connection_arrow_size := \@@FLOLradius ;
+ connection_dash_size := \@@FLOLradius ;
+ currentpicture := nullpicture ;
+ begin_chart(0,\FLOWwidth,\FLOWheight);
+ reverse_y := true ;
+ chart_offset := \@@FLOW@@offset ;
+ \stopMPdrawing
+ \doifelsenothing\@@FLOWbackgroundcolor
+ {\startMPdrawing
+ chart_background_color := white ;
+ \stopMPdrawing}
+ {\startMPdrawing
+ chart_background_color := \MPcolor{\@@FLOWbackgroundcolor} ;
+ \stopMPdrawing}%
+ \doif\@@FLOWoption\v!test
+ {\startMPdrawing
+ show_con_points := true ;
+ show_mid_points := true ;
+ show_all_points := true ;
+ \stopMPdrawing}%
+ \processaction % private
+ [\@@FLOWdot]
+ [ \v!yes=>\startMPdrawing
+ show_con_points := true ;
+ show_mid_points := true ;
+ show_all_points := true ;
+ \stopMPdrawing,
+ \s!unknown=>\startMPdrawing
+ show_\@@FLOWdot_points := true ;
+ \stopMPdrawing]%
+\doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellB
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+\doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellC
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ \startMPdrawing
+ clip_chart(\@@FLOWx,\@@FLOWy,\@@FLOWnx,\@@FLOWny) ;
+ end_chart ;
+ \stopMPdrawing
+ \MPdrawingdonetrue
+ \setbox0\hbox
+ {\MPstaticgraphictrue
+ \MPshiftdrawingfalse
+ \getMPdrawing}%
+ \def\MPmessage##1%
+ {\writestatus{MP charts}{##1}}%
+ \def\MPposition##1##2##3%
+ {\setvalue{\@@MPx##1}{##2}\setvalue{\@@MPy##1}{##3}}%
+ \def\MPclippath##1##2##3##4%
+ {\def\clipMPllx{##1bp}\def\clipMPlly{##2bp}%
+ \def\clipMPurx{##3bp}\def\clipMPury{##4bp}}%
+ \def\MPareapath##1##2##3##4%
+ {\def\areaMPllx{##1bp}\def\areaMPlly{##2bp}%
+ \def\areaMPurx{##3bp}\def\areaMPury{##4bp}}%
+ \getMPdata
+ \doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellD
+ \setbox2\vbox to \ht0
+ {\forgetall % \offinterlineskip
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber\vss}%
+ \setbox2\hbox
+ {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box2}%
+ \wd2\wd0\ht2\ht0\dp2\dp0
+ \let\startFLOWcell\startFLOWcellE
+ \setbox4\vbox to \ht0
+ {\forgetall % \offinterlineskip
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber\vss}%
+ \setbox4\hbox
+ {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box4}%
+ \wd4\wd0\ht4\ht0\dp4\dp0
+ \doifelse\@@FLOWoption\v!test
+ {\setbox6\vbox
+ {\forgetall
+ \vskip\@@FLOW@@offset
+ \hskip\@@FLOW@@offset
+ \basegrid
+ [\c!x=\@@FLOWx,\c!nx=\@@FLOWnx,\c!dx=\withoutpt\FLOWgridwidth,
+ \c!y=\@@FLOWy,\c!ny=\@@FLOWny,\c!dy=\withoutpt\FLOWgridheight,
+ \c!xstep=1,\c!ystep=1,
+ \c!unit=pt,\c!location=\v!middle]}%
+ \wd6\wd0\ht6\ht0\dp6\dp0
+ \setbox8\vbox
+ {\forgetall
+ \offinterlineskip
+ \vskip\@@FLOW@@offset
+ \dostepwiserecurse\@@FLOWy\@@FLOWny\plusone
+ {\vbox to \FLOWgridheight
+ {\vfill
+ \hskip\@@FLOW@@offset
+ \hbox
+ {\dostepwiserecurse\@@FLOWx\@@FLOWnx\plusone
+ {\hbox to \FLOWgridwidth
+ {\hfill
+ \framed
+ [\c!framecolor=red,
+ \c!width=\FLOWshapewidth,
+ \c!height=\FLOWshapeheight]
+ {}%
+ \hfill}}}
+ \vfill}}}%
+ \wd8\wd0\ht8\ht0\dp8\dp0
+ \framed
+ [\c!offset=\v!overlay,\c!framecolor=green]
+ {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2\hskip-\wd6\box6\hskip-\wd8\box8}}}
+ {\framed
+ [\c!offset=\v!overlay,
+ \c!frame=\@@FLOWframe,
+ \c!rulethickness=\@@FLOWrulethickness,
+ \c!framecolor=\@@FLOWframecolor,
+ \c!background=\@@FLOWbackground,
+ \c!backgroundcolor=\@@FLOWbackgroundcolor]
+ {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2}}}%
+ %\message{[\FLOWcells]}\wait
+ \egroup}
+
+% Pass A
+
+\long\def\startFLOWcellA#1\stopFLOWcell%
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \expandafter\getFLOWlocationA\FLOWlocation\end
+ \ignorespaces}
+
+\def\getFLOWlocationA#1,#2\end
+ {\ifnum0#1>\FLOWwidth \xdef\FLOWwidth {#1}\fi
+ \ifnum0#2>\FLOWheight\xdef\FLOWheight{#2}\fi}
+
+% Pass B
+%
+% beware: the - after \@FLOC@ is needed since name can be
+% empty and we don't want to redefine \@FLOC@ itself by
+% mistake
+
+\long\def\startFLOWcellB#1\stopFLOWcell
+ {\resetFLOWcell\ignorespaces#1\unskip
+ \setxvalue{\@FLOC@-\FLOWname}{\FLOWlocation}% kost veel cs's
+ \ifx\FLOWshape\empty
+ \global\let\FLOWshape\@@FLOSdefault
+ \fi
+ \doifnot\FLOWshape{none} % {\v!none}
+ {\ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWshapes}
+ {\edef\FLOWshapetag{shape_\FLOWshape}% beter \expanded
+ \@EA\setFLOWname\@EA\FLOWshapetag\@EA{\FLOWshapetag}}
+ {\doifnumberelse\FLOWshape
+ {\let\FLOWshapetag\FLOWshape}
+ {\let\FLOWshapetag\empty}}%
+ \ifx\FLOWshapetag\empty \else
+ \ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWlines}
+ {\chardef\FLOWstate0 }
+ {\ExpandBothAfter\doifcommonelse{\FLOWcell,\FLOWfocus}{\@@FLOWfocus}
+ {\chardef\FLOWstate1 }
+ {\chardef\FLOWstate2 }}%
+ \startMPdrawing
+ begin_sub_chart ;
+ \ifcase\FLOWstate
+ shape_line_color := \MPcolor{\@@FLOLcolor} ;
+ shape_fill_color := \MPcolor{\@@FLOLcolor} ;
+ shape_line_width := \@@FLOLrulethickness ;
+ \or
+ shape_line_color := \MPcolor{\@@FLOFframecolor} ;
+ shape_fill_color := \MPcolor{\@@FLOFbackgroundcolor} ;
+ shape_line_width := \@@FLOFrulethickness ;
+ \or
+ shape_line_color := \MPcolor{\@@FLOSframecolor} ;
+ shape_fill_color := \MPcolor{\@@FLOSbackgroundcolor} ;
+ shape_line_width := \@@FLOSrulethickness ;
+ \fi
+ %\ifx\FLOWoverlay\empty
+ % peepshape := false ;
+ %\else
+ % peepshape := true ;
+ %\fi
+ peepshape := \ifx\FLOWoverlay\empty false \else true \fi ;
+ new_shape(\FLOWlocation,\FLOWshapetag) ;
+ end_sub_chart ;
+ \stopMPdrawing
+ \fi}%
+ \ignorespaces}
+
+% Pass C
+
+\long\def\startFLOWcellC#1\stopFLOWcell%
+ {\resetFLOWcell
+\pushmacro\lastFLOWx
+\pushmacro\lastFLOWy
+ \ignorespaces#1\unskip % makes sure that vars are set
+\popmacro\lastFLOWy
+\popmacro\lastFLOWx
+ \let\connection\doFLOWconnectionC
+ \ignorespaces#1\unskip}
+
+\def\FLOWorigin{0,0}
+
+\def\doFLOWdisplace[#1,#2,#3]% experiment
+ {dsp_x := #1 ; dsp_y := #2 ;}
+
+\def\doFLOWconnectionC
+ {\dodoubleempty\dodoFLOWconnectionC}
+
+\def\dodoFLOWconnectionC[#1][#2]#3%
+ {\doglobal\increment\FLOWcomment
+ \setFLOWname\otherFLOWname{name_#3}%
+ \doifdefinedelse{\@FLOC@-\FLOWname}
+ {\edef\FLOWfrom{\getvalue{\@FLOC@-\FLOWname}}}
+ {\let \FLOWfrom \FLOWorigin}%
+ \ifx\FLOWfrom\FLOWorigin \else
+ \doifdefinedelse{\@FLOC@-\otherFLOWname}
+ {\edef\FLOWto {\getvalue{\@FLOC@-\otherFLOWname}}}
+ {\let \FLOWto \FLOWorigin}%
+ \ifx\FLOWto\FLOWorigin \else
+ \FLOWsetconnect{#1}%
+ \ifx\cFLOWfrom\empty \else
+ \doifelse\@@FLOLcorner\v!round
+ {\startMPdrawing smooth := true ; \stopMPdrawing}
+ {\startMPdrawing smooth := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLdash\v!yes
+ {\startMPdrawing dashline := true ; \stopMPdrawing}
+ {\startMPdrawing dashline := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLarrow\v!yes
+ {\startMPdrawing arrowtip := true ; \stopMPdrawing}
+ {\startMPdrawing arrowtip := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLoffset\v!none
+ {\startMPdrawing touchshape := true ; \stopMPdrawing}
+ {\startMPdrawing touchshape := false ; \stopMPdrawing}%
+%\doifsomething{#2}
+% {\startMPdrawing
+% \doFLOWdisplace[0#2,0,0]%
+% \stopMPdrawing}%
+ \startMPdrawing
+\doFLOWdisplace[0#2,0,0]%
+ connection_line_color := \MPcolor{\@@FLOLcolor} ;
+ connection_line_width := \@@FLOLrulethickness ;
+ connect_\cFLOWfrom_\cFLOWto (\FLOWfrom,\zFLOWfrom) (\FLOWto,\zFLOWto) ;
+\doFLOWdisplace[0,0,0]%
+ \stopMPdrawing
+ \fi
+ \fi
+ \fi
+ \ignorespaces}
+
+% Pass D
+
+\long\def\startFLOWcellD#1\stopFLOWcell
+ {\resetFLOWcell
+\pushmacro\lastFLOWx
+\pushmacro\lastFLOWy
+ \ignorespaces#1\unskip % presets vars
+\popmacro\lastFLOWy
+\popmacro\lastFLOWx
+ \let\doprocessFLOWcell\doprocessFLOWcellD
+ \expandafter\doprocessFLOWcellD\FLOWlocation\end
+ \let\connection\doFLOWconnectionD
+ \let\comment\doFLOWcommentD
+ \ignorespaces#1\unskip\ignorespaces}
+
+\def\doFLOWconnectionD
+ {\dodoubleempty\dodoFLOWconnectionD}
+
+\def\dodoFLOWconnectionD[#1][#2]#3%
+ {\doglobal\increment\FLOWcomment
+ \ignorespaces}
+
+\def\doFLOWcommentD[#1]#2%
+ {\bgroup
+ \let\FLOW \middlebox
+ \let\FLOWb \bottombox
+ \let\FLOWbl\bottomleftbox
+ \let\FLOWbr\bottomrightbox
+ \let\FLOWt \topbox
+ \let\FLOWtl\topleftbox
+ \let\FLOWtr\toprightbox
+ \let\FLOWl \leftbox
+ \let\FLOWlt\lefttopbox
+ \let\FLOWlb\leftbottombox
+ \let\FLOWr \rightbox
+ \let\FLOWrt\righttopbox
+ \let\FLOWrb\rightbottombox
+ \let\FLOWc \middlebox
+%\ifdefined{FLOW#1}%
+ \ifcase0\getvalue{\@@MPx\FLOWcomment}\getvalue{\@@MPy\FLOWcomment}\relax
+ \else
+ \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp<\areaMPllx\relax\else
+ \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp>\areaMPurx\relax\else
+ \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp<\areaMPlly\relax\else
+ \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp>\areaMPury\relax\else
+ \dimen0=\getvalue{\@@MPx\FLOWcomment}\s!bp
+ \advance\dimen0 -\@@FLOW@@offset
+ \advance\dimen0 -\clipMPllx
+ \dimen2=\clipMPury
+ \advance\dimen2 -\@@FLOW@@offset
+ \advance\dimen2 -\getvalue{\@@MPy\FLOWcomment}\s!bp
+ \setbox\scratchbox\hbox{\strut#2}%
+ \boxoffset.5\bodyfontsize
+ \setbox\scratchbox\hbox{\hskip\dimen0\lower\dimen2\getvalue{FLOW#1}{\box\scratchbox}}%
+ \smashbox\scratchbox
+ \box\scratchbox
+ \boxoffset\zeropoint
+ \nointerlineskip % really needed
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+%\fi
+ \egroup
+ \ignorespaces}
+
+% pass D
+
+\def\dophaseoneFLOWcellX#1#2%
+ {\!!counta#1\relax
+ \!!countb#2\relax
+ \!!countc\@@FLOWx
+ \!!countd\@@FLOWy
+ \advance\!!countc \@@FLOWnx
+ \advance\!!countd \@@FLOWny
+ \advance\!!countc \minusone
+ \advance\!!countd \minusone
+ \ifnum\!!counta<\@@FLOWx\relax \donefalse
+ \else\ifnum\!!counta>\!!countc \donefalse
+ \else\ifnum\!!countb<\@@FLOWy\relax \donefalse
+ \else\ifnum\!!countb>\!!countd \donefalse
+ \else \donetrue
+ \fi\fi\fi\fi}
+
+\def\dophasetwoFLOWcellX
+ {\advance\!!counta -\@@FLOWx
+ \advance\!!counta \plusone
+ \advance\!!countb -\@@FLOWy
+ \advance\!!countb \plusone
+ \dimen0=\FLOWgridwidth
+ \dimen0=\!!counta\dimen0
+ \advance\dimen0 -\FLOWgridwidth
+ \dimen4=\FLOWgridwidth
+ \advance\dimen4 -\FLOWshapewidth
+ \advance\dimen0 .5\dimen4
+ \dimen2=\FLOWgridheight
+ \dimen2=\!!countb\dimen2
+ \dimen4=\FLOWgridheight
+ \advance\dimen4 -\FLOWshapeheight
+ \advance\dimen2 -.5\dimen4
+ \edef\FLOWdx{\the\dimen0}%
+ \edef\FLOWdy{\the\dimen2}}
+
+\def\positionFLOWzero% assumes \FLOWdx and \FLOWdy are set
+ {\setbox0\hbox{\hskip\FLOWdx\lower\FLOWdy\box0}%
+ \smashbox0\box0
+ \nointerlineskip} % new, needed since we somehow reset that
+
+\def\doFLOWtlabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
+ \setbox0\hbox{\hskip\dimen2\raise\scratchdimen
+ \hbox{\raise\dimen4\hbox{#1{\strut#3}}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWblabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
+ \setbox0\hbox{\hskip\dimen2\raise-\scratchdimen
+ \hbox{#1{\strut#3}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWllabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
+ \setbox0\hbox{\hskip-\scratchdimen\raise\dimen6
+ \hbox{#1{\strut#3}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWrlabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
+ \setbox0\hbox{\hskip\dimen0\hskip\scratchdimen
+ \hbox{\raise\dimen6\hbox{#1{\strut#3}}}}%
+ \positionFLOWzero}
+
+\def\doprocessFLOWcellD#1,#2\end
+ {\dophaseoneFLOWcellX{#1}{#2}%
+ \ifdone
+ \dophasetwoFLOWcellX
+ \doglobal\addtocommalist\FLOWcell\FLOWcells
+ \def\FLOWx{#1}%
+ \def\FLOWy{#2}%
+ \directsetup{flowcell}%
+ \setbox0\hbox
+ {\ifx\FLOWalign\empty\else
+ \setupframed
+ [\c!align=\v!normal,\c!bottom=\vfill,\c!top=\vfill]%
+ \@EA\processallactionsinset\@EA
+ [\FLOWalign]
+ [t=>{\setupframed[\c!bottom=\vfill,\c!top=]},
+ b=>{\setupframed[\c!bottom=,\c!top=\vfill]},
+ l=>{\setupframed[\c!align=\v!right]},
+ r=>{\setupframed[\c!align=\v!left]},
+ m=>{\setupframed[\c!align=\v!middle]},
+ c=>{\setupframed[\c!align=\v!middle]}]%
+ \fi
+ \doifelse\FLOWshape{none} % {\v!none}
+ {\setupframed[\c!offset=\v!overlay]}
+ {\setupframed[\c!offset=\@@FLOSoffset]}%
+ \framed
+ [\c!frame=\v!off,\c!background=flowcell,
+ \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
+ {\FLOWtext}}%
+ \showFLOWhelp0
+ \ifx\FLOWdestination\empty\else
+ \setbox0\hbox
+ {\setupinteraction[\c!color=,\c!contrastcolor=]%
+ \gotobox{\box0}[\FLOWdestination]}%
+ \fi
+ \positionFLOWzero
+ \dimen0=\FLOWshapewidth \dimen2=.5\dimen0
+ \dimen4=\FLOWshapeheight\dimen6=.5\dimen4
+ \boxoffset.5\bodyfontsize
+ \doFLOWtlabel \righttopbox0\tFLOWlabel
+ \doFLOWblabel\rightbottombox0\bFLOWlabel
+ \doFLOWllabel \lefttopbox0\lFLOWlabel
+ \doFLOWrlabel \righttopbox0\rFLOWlabel
+ \doFLOWtlabel \topbox0\tcFLOWlabel % for me only
+ \doFLOWblabel \bottombox0\bcFLOWlabel % for me only
+ \doFLOWllabel \leftbox0\lcFLOWlabel % for me only
+ \doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
+ \ifnum#1=\@@FLOWx\relax \doFLOWllabel \leftbox1\lFLOWexit \fi
+ \ifnum#1=\!!countc \doFLOWrlabel \rightbox1\rFLOWexit \fi
+ \ifnum#2=\@@FLOWy\relax \doFLOWtlabel \topbox1\tFLOWexit \fi
+ \ifnum#2=\!!countd \doFLOWblabel \bottombox1\bFLOWexit \fi
+ \boxoffset\zeropoint
+ \fi}
+
+% For Willy Egger:
+%
+% \startsetups flowcell
+% \definelayer
+% [flowcell]
+% [width=\FLOWshapewidth,
+% height=\FLOWshapeheight]
+% \setlayerframed
+% [flowcell]
+% [preset=rightbottom,offset=1ex]
+% [frame=off]
+% {\tx(\FLOWx,\FLOWy)}
+% \stopsetups
+
+% Pass E
+
+\long\def\startFLOWcellE#1\stopFLOWcell
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \let\doprocessFLOWcell\doprocessFLOWcellE
+ \expandafter\doprocessFLOWcell\FLOWlocation\end}
+
+\def\doprocessFLOWcellE#1,#2\end % redundant
+ {\ifx\FLOWoverlay\empty \else
+ \dophaseoneFLOWcellX{#1}{#2}%
+ \ifdone
+ \dophasetwoFLOWcellX
+ \edef\FLOWdx{\the\dimen0}%
+ \edef\FLOWdy{\the\dimen2}%
+ \setbox0\hbox
+ {\framed
+ [%\c!frame=\v!off,
+ \c!background={\@@FLOWbackground,\FLOWoverlay},
+ \c!backgroundcolor=\@@FLOSbackgroundcolor,
+ \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
+ {}}%
+ \positionFLOWzero
+ \fi
+ \fi}
+
+% Pass F
+
+\def\checkFLOWautofocus
+ {\def\@@FLOWminx{100}\let\@@FLOWminy\@@FLOWminx
+ \def\@@FLOWmaxx {0}\let\@@FLOWmaxy\@@FLOWmaxx
+ \def\@@FLOWabsx {0}\let\@@FLOWabsy\@@FLOWabsx
+ \let\startFLOWcell\startFLOWcellF
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ %\message{AUTOSHAPE 1: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
+ \ifnum\@@FLOWabsx<\@@FLOWmaxx\let\@@FLOWmaxx\@@FLOWabsx\fi
+ \ifnum\@@FLOWabsy<\@@FLOWmaxy\let\@@FLOWmaxy\@@FLOWabsy\fi
+ %\message{AUTOSHAPE 2: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
+ \donetrue
+ \ifnum\@@FLOWminx=100 \donefalse\fi
+ \ifnum\@@FLOWminy=100 \donefalse\fi
+ \ifnum\@@FLOWmaxx=0 \donefalse\fi
+ \ifnum\@@FLOWmaxy=0 \donefalse\fi
+ \doFLOWcheckF\@@FLOWx\@@FLOWminx\@@FLOWmaxx\@@FLOWnx
+ \doFLOWcheckF\@@FLOWy\@@FLOWminy\@@FLOWmaxy\@@FLOWny}
+
+\def\startFLOWcellF#1\stopFLOWcell%
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \expandafter\doFLOWlocationF\FLOWlocation\end}%
+
+\def\doFLOWlocationF#1,#2\end%
+ {\ifnum#1>\@@FLOWabsx\def\@@FLOWabsx{#1}\fi
+ \ifnum#2>\@@FLOWabsy\def\@@FLOWabsy{#2}\fi
+ \ExpandBothAfter\doifinset{\FLOWcell}{\@@FLOWautofocus}
+ {\dodoFLOWlocationF{#1}<-\@@FLOWminx
+ \dodoFLOWlocationF{#1}>+\@@FLOWmaxx
+ \dodoFLOWlocationF{#2}<-\@@FLOWminy
+ \dodoFLOWlocationF{#2}>+\@@FLOWmaxy}}
+
+\def\dodoFLOWlocationF#1#2#3#4%
+ {\ifnum#1#2#4\relax
+ \!!counta=#1\advance\!!counta #31\relax
+ \edef#4{\ifnum\!!counta<1 1\else\the\!!counta\fi}%
+ \fi}
+
+\def\doFLOWcheckF#1#2#3#4%
+ {\ifdone
+ \let#1=#2%
+ \!!counta=#3%
+ \advance\!!counta \plusone\advance\!!counta -#2\relax
+ \ifnum\!!counta<1 \!!counta=1 \fi
+ \edef#4{\the\!!counta}%
+ \else
+ \let#1\!!plusone
+ \let#4\!!zerocount % no {1}
+ \fi}
+
+% \useFLOWchart[name][parent][setting,setting][additional settings]
+% \useFLOWchart[name][parent][additional settings]
+
+\let\currentFLOWchart\empty
+
+\def\useFLOWchart
+ {\doquadrupleempty\douseFLOWchart}
+
+\def\douseFLOWchart[#1][#2][#3][#4]% name parent sets mainsettings
+ {\iffourthargument
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][#4,##1]}%
+ \else
+ \checkparameters[#3]%
+ \ifparameters
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][][#3,##1]}%
+ \else
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][##1]}%
+ \fi
+ \fi}
+
+\def\setgetFLOWchart[#1][#2][#3]%
+ {\def\docommand##1{}% cell line focus ?
+ \processcommalist[#2]\docommand
+ \getFLOWchart[#1][#3]}
+
+\def\doFLOWchart[#1][#2]%
+ {\hbox\bgroup\vbox\bgroup % vmode suppresses spaces
+\def\currentFLOWchart{#1}%
+ \doifundefinedelse{\@FLOW@--#1}
+ {\getFLOWchart[#1][#2]}
+ {\getvalue{\@FLOW@--#1}[#2]}%
+ \egroup\egroup}
+
+\def\FLOWchart%
+ {\dodoubleempty\doFLOWchart}
+
+%D A hook into the help system.
+
+\def\showFLOWhelp#1%
+ {\doifhelpinfo\FLOWhelp
+ {\setbox#1=\hbox
+ {\setbox\scratchbox=\hbox{\lower\@@FLOWdy\hbox
+ {\helpbutton
+ [\c!width=\wd0,\c!color=,\c!height=\@@FLOWdy,\c!frame=\v!no]%
+ [\FLOWhelp]}}%
+ \smashbox\scratchbox
+ \setbox#1=\vbox
+ {\forgetall\offinterlineskip\box#1\box\scratchbox}%
+ \box#1}}}
+
+%D The next section is dedicated to splitting up charts.
+
+\def\getFLOWsize[#1]%
+ {\bgroup\let\dodogetFLOWchart\dogetFLOWsize\FLOWchart[#1]\egroup}
+
+\def\dogetFLOWsize[#1][#2]%
+ {\setbox\scratchbox=\vbox
+ {\globallet\FLOWmaxwidth \!!zerocount
+ \globallet\FLOWmaxheight\!!zerocount
+ \def\getFLOWlocation##1,##2\end
+ {\ifnum0##1>\FLOWmaxwidth \xdef\FLOWmaxwidth {##1}\fi
+ \ifnum0##2>\FLOWmaxheight\xdef\FLOWmaxheight{##2}\fi}%
+ \resetFLOWcell
+ \long\def\startFLOWcell##1\stopFLOWcell
+ {{##1\expandafter\getFLOWlocation\FLOWlocation\end}}%
+ \def\dohandleflowchart[##1][##2]%
+ {\resetFLOWlocation
+ \processFLOWbuffer{##1}}%
+ \getvalue{\@FLOW@-#1}}}
+
+\def\setupFLOWsplit%
+ {\dodoubleargument\getparameters[\@@FLOT]}
+
+\setupFLOWsplit%
+ [\c!nx=3,\c!ny=3,
+ \c!dx=1,\c!dy=1,
+ \c!command=,
+ \c!marking=\v!on,
+ \c!before=,\c!after=]
+
+\def\FLOWsplitx {1}
+\def\FLOWsplity {1}
+\def\FLOWsplitnx{1}
+\def\FLOWsplitny{1}
+
+\def\FLOWcharts%
+ {\dodoubleempty\doFLOWcharts}
+
+%D While splitting, the following variables are available:
+%D
+%D \starttyping
+%D \FLOWsplitnx \FLOWsplitny \FLOWsplitx \FLOWsplity
+%D \stoptyping
+
+\def\doFLOWcharts[#1][#2]%
+ {\bgroup
+ \getFLOWsize[#1]%
+ \dodoFLOWcharts\relax
+ \global\let\FLOWsplitnx\FLOWsplitx
+ \global\let\FLOWsplitny\FLOWsplity
+ \dodoFLOWcharts{\dododoFLOWcharts[#1][#2]}%
+ \egroup}
+
+\def\dodoFLOWcharts#1%
+ {\def\@@FLOTx{1}%
+ \global\let\FLOWsplitx\@@FLOTx
+ \doloop
+ {\def\@@FLOTy{1}%
+ \global\let\FLOWsplity\@@FLOTy
+ \doloop
+ {\bgroup
+ \scratchcounter\FLOWmaxwidth
+ \advance\scratchcounter -\@@FLOTx
+ \advance\scratchcounter \plusone
+ \ifnum\scratchcounter<\@@FLOTnx\edef\@@FLOTnx{\the\scratchcounter}\fi
+ \scratchcounter\FLOWmaxheight
+ \advance\scratchcounter -\@@FLOTy
+ \advance\scratchcounter \plusone
+ \ifnum\scratchcounter<\@@FLOTny\edef\@@FLOTny{\the\scratchcounter}\fi
+ #1% does something with the float, or not
+ \egroup
+ \increment(\@@FLOTy,\@@FLOTny)%
+ \ifnum\@@FLOTy>\FLOWmaxheight
+ \exitloop
+ \else
+ \doglobal\increment\FLOWsplity
+ \decrement(\@@FLOTy,\@@FLOTdy)%
+ \fi}%
+ \increment(\@@FLOTx,\@@FLOTnx)%
+ \ifnum\@@FLOTx>\FLOWmaxwidth
+ \exitloop
+ \else
+ \doglobal\increment\FLOWsplitx
+ \decrement(\@@FLOTx,\@@FLOTdx)%
+ \fi}}
+
+\def\dododoFLOWcharts[#1][#2]%
+ {\bgroup
+ \@@FLOTbefore
+ \doifnot\@@FLOTmarking\v!on{\let\cuthbox\hbox}%
+ \cuthbox
+ {\@@FLOTcommand
+ {\FLOWchart[#1][#2,
+ \c!x=\@@FLOTx,\c!nx=\@@FLOTnx,
+ \c!y=\@@FLOTy,\c!ny=\@@FLOTny]}}%
+ \@@FLOTafter
+ \egroup}
+
+%D An example of splitting is given below:
+%D
+%D \starttyping
+%D \setupFLOWsplit
+%D [nx=5,ny=10,
+%D dx=0,dy=0,
+%D before=,
+%D after=\page]
+%D
+%D \FLOWcharts[mybigflow]
+%D \stoptyping
+%D
+%D Or, one can say:
+%D
+%D \starttyping
+%D \splitfloat
+%D {\placefigure{What a big flowchart this is!}}
+%D {\FLOWcharts[mybigflow]}
+%D \stoptyping
+
+%D \macros
+%D {typeFLOWchart}
+%D
+%D For documentation purposes the following macro is
+%D provided. Watch the use of the first and last line hooks,
+%D which is needed because the start and stop commands are
+%D not part of the buffer.
+
+\def\typeFLOWchart[#1]%
+ {\bgroup
+ \def\dohandleflowchart[##1][##2]{\typeFLOWbuffer{##1}}%
+ \defconvertedargument\firstverbatimfileline{\startFLOWchart[#1]}%
+ \defconvertedargument\lastverbatimfileline {\stopFLOWchart}%
+ \getvalue{\@FLOW@-#1}
+ \egroup}
+
+%D New:
+%D
+%D \starttyping
+%D \setupFLOWcharts[command=\Whow]
+%D
+%D \startFLOWset[convert-en] % [tag][convert-en]
+%D \subFLOWchart[a][x=1,y=1,nx=3,ny=3]
+%D \subFLOWchart[b][x=1,y=2,nx=3,ny=3]
+%D \subFLOWchart[c][x=2,y=1,nx=3,ny=3]
+%D \stopFLOWset
+%D
+%D \def\Whow#1%
+%D {\ifnum\currentFLOWset=1 \framed{Some Chart}\fi}
+%D
+%D \FLOWset[convert-en] % [tag]
+%D
+%D \def\Whow#1%
+%D {\setuphead[state=high]
+%D \startstandardmakeup
+%D \centerbox{#1}
+%D \stopstandardmakeup}
+%D
+%D \FLOWset[convert-en] % [tag]
+%D \stoptyping
+
+\def\startFLOWset
+ {\dodoubleempty\dostartFLOWset}
+
+\def\dostartFLOWset[#1][#2]#3\stopFLOWset % tag name data
+ {\ifsecondargument
+ \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#2}{#3}}%
+ \else
+ \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#1}{#3}}%
+ \fi}
+
+\long\def\dohandleFLOWset#1#2#3% tag name data
+ {\bgroup
+ \def\subFLOWchart
+ {\dodoubleempty\dosubFLOWchart}%
+ \def\dosubFLOWchart[##1][##2]% subtag settings
+ {\ifsecondargument
+ \dodohandleFLOWset{#1}{##1}{#2}{##2}%
+ \else
+ \subFLOWchart[][##1]%
+ \fi}%
+ #3%
+ \egroup}
+
+\def\dodohandleFLOWset#1#2#3#4% tag subtag name settings
+ {\increment\currentFLOWset
+ \bgroup
+ \@@FLOXcommand
+ {\ifnum\currentFLOWset=1 \pagereference[#1]\fi
+ \doifsomething{#2}
+ {\setupreferencing[\c!prefix=]%
+ \pagereference[#1:#2]% -:#1:#2
+ \setupreferencing[\c!prefix=#1:#2]}%
+ \FLOWchart[#3][#4]}%
+ \egroup}
+
+\def\FLOWset[#1]%
+ {\newcounter\currentFLOWset
+ \doifdefinedelse{\@FLOX@#1}
+ {\getvalue{\@FLOX@#1}}
+ {\dodohandleFLOWset{#1}{}{#1}{}}}
+
+\newcounter\currentFLOWset
+
+\setupFLOWsets
+ [\c!command=]
+
+%D This will be an option:
+
+% \def\startFLOWchart%
+% {\dodoubleempty\dostartFLOWchart}
+%
+% \long\def\dostartFLOWchart[#1][#2]#3\stopFLOWchart
+% {\preparenextFLOWchart{#1}{#2}%
+% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
+%
+% \long\def\dodefineFLOWchart[#1][#2]#3%
+% {\preparenextFLOWchart{#1}{#2}%
+% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
+%
+% \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}}
+% \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]}
+% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
+% todo: make mkiv variant
+% todo: use dimexpr/numspr
+
+% will be redone with layers and dimexpr or even better, by just using
+% textext .. a nice example of old code
+
+%D This is an experimental module. Pieces of code will be moved
+%D to other modules. More features are possible but will be
+%D interfaces later.
+%D
+%D When finished this module will be documented. The main macro
+%D is still a rather big one and there is some redundant and
+%D slow code that needs a clean up.
+
+% arrow, dash
+% crossing
+% \goto -> \normalgoto
+% class -> class:name (ref prefix)
+% c, automatisch geen overlap zoeken
+% eind eerder chart connecties
+% relateren aan korps
+% check op bestaan naam, bestaan shape
+% auto als extern figuur
+% subchart
+% pijlen
+% focus
+% ook nog \MPmessage
+% areapath -> krappe vlak
+% clippath -> gehele vlak
+%
+% offset : clip offset
+% breedte : breedte cel
+% hoogte : hoogte cel
+% dx : halve afstand in breedte (grid breedte = breedte + 2dx)
+% dy : halve afstand in hoogte (grid hoogte = hoogte + 2dy)
+% x : x offset (clipping)
+% y : y offset (clipping)
+% nx : minimaal aantal cellen horizontaal
+% ny : minimaal aantal cellen vertikaal
+%
+% shape none en geen equivalent maken
+%
+% kaderkleur achtergrondkleur
+% lijnkleur lijndikte
+% focus focuskaderkleur focusachtergrondkleur
+% richting
+%
+% focus koppelen aan kleur
\unprotect
+\definesorting [flowchart] [flowcharts] [\v!none] % no access
+\setupsorting [flowchart] [\c!state=\v!stop] % off by default
+
+\def\@FLOW@{@FLOW@}
+\def\@FLOC@{@FLOC@}
+\def\@FLOX@{@FLOX@}
+
+\def\@@FLOW{@@FLOW}
+\def\@@FLOL{@@FLOL}
+\def\@@FLOS{@@FLOS}
+\def\@@FLOF{@@FLOF}
+\def\@@FLOT{@@FLOT}
+\def\@@FLOX{@@FLOX}
+
+\def\@@MPx {@@MPx}
+\def\@@MPy {@@MPy}
+
+\def\FLOWbufferprefix{flw-}
+
+\def\processFLOWbuffer#1{\getbuffer[\FLOWbufferprefix#1]}
+\def\typeFLOWbuffer #1{\typebuffer[\FLOWbufferprefix#1]}
+
+\def\setFLOWname#1#2% funny hack that makes sure that we get
+ {\bgroup % names that are acceptable for METAPOST
+ \lccode`0=`a\lccode`1=`b\lccode`2=`c\lccode`3=`d\lccode`4=`e%
+ \lccode`5=`f\lccode`6=`g\lccode`7=`h\lccode`8=`i\lccode`9=`j%
+ \lccode` =`\_\lccode`-=`\_\lccode`_=`\_%
+ \lowercase{\gdef#1{#2}}%
+ \egroup}
+
+% een gobble als default is sneller, en dan alleen setten als
+% nodig
+
+\def\resetFLOWcell
+ {% variables
+ \global\let\FLOWname \empty
+ \global\let\FLOWalign \empty
+ \global\let\FLOWshape \empty
+ \global\let\FLOWlocation \empty
+ \global\let\FLOWtext \empty
+ \global\let\FLOWhelp \empty
+ \global\let\FLOWdestination\empty
+ \global\let\FLOWoverlay \empty
+ \global\let\FLOWfocus \empty
+ \global\let\tFLOWlabel \empty
+ \global\let\bFLOWlabel \empty
+ \global\let\lFLOWlabel \empty
+ \global\let\rFLOWlabel \empty
+ \global\let\bcFLOWlabel \empty
+ \global\let\tcFLOWlabel \empty
+ \global\let\lcFLOWlabel \empty
+ \global\let\rcFLOWlabel \empty
+ \global\let\tFLOWexit \empty
+ \global\let\bFLOWexit \empty
+ \global\let\lFLOWexit \empty
+ \global\let\rFLOWexit \empty
+ % commands
+ \let\name \doFLOWname
+ \let\shape \doFLOWshape
+ \let\destination\doFLOWdestination
+ \let\location \doFLOWlocation
+ \let\focus \doFLOWfocus
+ \let\overlay \doFLOWoverlay
+ \let\figure \doFLOWfigure
+ \let\text \doFLOWtext
+ \let\comment \doFLOWcomment
+ \let\label \doFLOWlabel
+ \let\help \doFLOWhelp
+ \let\connection \doFLOWconnection
+ \let\exit \doFLOWexit
+ % convenience commands
+ \let\locate \doFLOWlocate
+ \let\connect \doFLOWconnect}
+
+\let\FLOWcell \s!unknown
+\let\FLOWshape \s!unknown
+\let\FLOWdestination\s!unknown
+\let\FLOWfocus \s!unknown
+\let\FLOWoverlay \empty
+\let\FLOWtext \empty
+
+\def\doFLOWname#1%
+ {\def\FLOWcell{#1}\setFLOWname\FLOWname{name_#1}\ignorespaces}
+
+\def\doFLOWshape#1%
+ {\gdef\FLOWshape{#1}\ignorespaces}
+
+\def\doFLOWdestination#1%
+ {\gdef\FLOWdestination{#1}\ignorespaces}
+
+\def\doFLOWlocation#1%
+ {\setFLOWlocation#1\end\ignorespaces}
+
+\def\doFLOWfocus#1%
+ {\gdef\FLOWfocus{#1}\ignorespaces}
+
+\def\doFLOWoverlay#1%
+ {\gdef\FLOWoverlay{#1}\ignorespaces}
+
+\def\doFLOWfigure#1%
+ {\defineoverlay[\s!dummy][\overlayfigure{#1}]%
+ \overlay\s!dummy}
+
+\def\doFLOWtext
+ {\dosingleempty\dodoFLOWtext}
+
+\def\dodoFLOWtext[#1]% % #2%
+ {\gdef\FLOWalign{#1}\gdef\FLOWtext}% {#2}}
+
+\def\doFLOWcomment[#1]#2%
+ {\ignorespaces\dogobblesingleempty}
+
+\def\doFLOWlabel[#1]#2% wordt dit gebruikt ?
+ {\setgvalue{#1FLOWlabel}{#2}\ignorespaces}
+
+\def\doFLOWhelp#1%
+ {\gdef\FLOWhelp{#1}\ignorespaces}
+
+\def\doFLOWconnection
+ {\dodoubleempty\dodoFLOWconnection}
+
+\def\dodoFLOWconnection[#1][#2]#3%
+ {\ignorespaces}
+
+\def\doFLOWconnect
+ {\connection}
+
+\def\doFLOWlocate
+ {\location}
+
+\def\doFLOWexit[#1]#2%
+ {\setgvalue{#1FLOWexit}{#2}\ignorespaces}
+
+\def\startFLOWchart
+ {\bgroup
+ \let\stopFLOWchart\egroup
+ \obeylines % lelijk, buffers nog eens fatsoeneren
+ \dodoubleempty\dostartFLOWchart}
+
+\def\dostartFLOWchart[#1][#2]%
+ {\preparenextFLOWchart{#1}{#2}%
+ \dostartbuffer[\FLOWbufferprefix\nofFLOWcharts][startFLOWchart][stopFLOWchart]}
+
+\def\defineFLOWchart%
+ {\dodoubleempty\dodefineFLOWchart}
+
+\long\def\dodefineFLOWchart[#1][#2]#3%
+ {\preparenextFLOWchart{#1}{#2}%
+ \setbuffer[\FLOWbufferprefix\nofFLOWcharts]#3\endbuffer}
+
+\def\preparenextFLOWchart#1#2%
+ {\doglobal\increment\nofFLOWcharts
+ \flowchart{#1}%
+ \setxvalue{\@FLOW@-#1}{\noexpand\dohandleflowchart[\nofFLOWcharts][#2]}}
+
+\def\setupFLOWcharts{\dodoubleargument\getparameters[\@@FLOW]}
+\def\setupFLOWlines {\dodoubleargument\getparameters[\@@FLOL]}
+\def\setupFLOWshapes{\dodoubleargument\getparameters[\@@FLOS]}
+\def\setupFLOWfocus {\dodoubleargument\getparameters[\@@FLOF]}
+\def\setupFLOWsets {\dodoubleargument\getparameters[\@@FLOX]}
+
+\setupFLOWcharts
+ [\c!option=,
+ \c!bodyfont=,
+ \c!dot=, % private option
+ \c!width=12\bodyfontsize,
+ \c!height=7\bodyfontsize,
+ \c!maxwidth=,
+ \c!maxheight=,
+ \c!offset=\v!standard, % == auto offset
+ \c!dx=2\bodyfontsize,
+ \c!dy=2\bodyfontsize,
+ \c!nx=0, % 1,
+ \c!ny=0, % 1,
+ \c!x=1,
+ \c!y=1,
+ \c!autofocus=,
+ \c!focus=,
+ \c!background=, % \v!color,
+ \c!backgroundcolor=\s!white,
+ \c!rulethickness=\linewidth,
+ \c!frame=\v!off,
+ \c!framecolor=]
+
+\setupFLOWlines
+ [\c!corner=\v!round,
+ \c!arrow=\v!yes,
+ \c!dash=\v!no,
+ \c!radius=.375\bodyfontsize, % 2.5\c!rulethickness
+ \c!color=FLOWlinecolor,
+ \c!rulethickness=.15\bodyfontsize, % 2pt,
+ \c!offset=\v!none]
+
+\setupFLOWshapes
+ [\c!default=action,
+ \c!framecolor=FLOWframecolor,
+ \c!background=\v!color,
+ \c!backgroundcolor=FLOWbackgroundcolor,
+ \c!backgroundscreen=\@@rsscreen,
+ \c!rulethickness=.15\bodyfontsize, % 2pt,
+ \c!offset=.5\bodyfontsize]
+
+\setupFLOWfocus
+ [\c!framecolor=FLOWfocuscolor,
+ \c!background=\@@FLOSbackground,
+ \c!backgroundcolor=\@@FLOSbackgroundcolor,
+ \c!backgroundscreen=\@@FLOSbackgroundscreen,
+ \c!rulethickness=\@@FLOSrulethickness,
+ \c!offset=\@@FLOSoffset]
+
+\definecolor [FLOWfocuscolor] [s=.2]
+\definecolor [FLOWlinecolor] [s=.5]
+\definecolor [FLOWframecolor] [s=.7]
+\definecolor [FLOWbackgroundcolor] [s=.9]
+
+\newcounter\includeFLOWx
+\newcounter\includeFLOWy
+
+\def\includeFLOWchart
+ {\dodoubleempty\doincludeFLOWchart}
+
+\def\doincludeFLOWchart[#1][#2]%
+ {\pushmacro\includeFLOWx
+ \pushmacro\includeFLOWy
+ \getparameters[FLOWi][x=1,y=1,#2]%
+ \increment(\includeFLOWx,0\FLOWix)\decrement\includeFLOWx
+ \increment(\includeFLOWy,0\FLOWiy)\decrement\includeFLOWy
+ \def\dodoincludeFLOWchart##1%
+ {\doifdefined{\@FLOW@-##1}
+ {\globalpushmacro\dohandleflowchart % was local
+ \gdef\dohandleflowchart[####1][####2]%
+ {\globalpopmacro\dohandleflowchart % was local
+ \resetFLOWlocation
+ \processFLOWbuffer{####1}}%
+ \getvalue{\@FLOW@-##1}}}%
+ \processcommalist[#1]\dodoincludeFLOWchart
+ \popmacro\includeFLOWx
+ \popmacro\includeFLOWy}
+
+\def\resetFLOWlocation
+ {\globallet\lastFLOWx\!!zerocount
+ \globallet\lastFLOWy\!!zerocount}
+
+\def\dosetFLOWlocation[#1#2]#3#4%
+ {\processaction
+ [#1#2]
+ [ +=>\scratchcounter\numexpr#4+ 1+#3\relax,
+ -=>\scratchcounter\numexpr#4- 1+#3\relax,
+ +#2=>\scratchcounter\numexpr#4+#2+#3\relax,
+ -#2=>\scratchcounter\numexpr#4-#2+#3\relax,
+ \s!default=>\scratchcounter\numexpr#4 +#3\relax,
+ \s!unknown=>\scratchcounter\numexpr0#1#2+#3\relax]%
+ \xdef#4{\the\scratchcounter}}
+
+\def\setFLOWlocation#1,#2\end
+ {\dosetFLOWlocation[#1\empty]\includeFLOWx\lastFLOWx
+ \dosetFLOWlocation[#2\empty]\includeFLOWy\lastFLOWy
+ \xdef\FLOWlocation{\lastFLOWx,\lastFLOWy}}
+
+\def\FLOWshapes
+ {node, action, procedure, product, decision, archive,
+ loop, wait, subprocedure, singledocument, multidocument,
+ sub procedure, single document, multi document, up, down,
+ left, right}
+
+\def\FLOWlines
+ {up, down, left, right}
+
+\def\FLOWsetconnect#1%
+ {\donefalse
+ \let\cFLOWfrom\empty
+ \let\cFLOWto\empty
+ \let\zFLOWfrom\!!zerocount
+ \let\zFLOWto\!!zerocount
+ \handletokens#1\with\doFLOWsetconnect
+ \ifx\cFLOWto\empty\let\cFLOWfrom\empty\fi}
+
+\def\doFLOWsetconnect#1%
+ {\ifx #1p%
+ \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
+ \else\ifx#1+%
+ \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
+ \else\ifx#1n%
+ \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
+ \else\ifx#1-%
+ \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
+ \else\ifdone
+ \edef\cFLOWto{\FLOWconnector#1}%
+ \else
+ \edef\cFLOWfrom{\FLOWconnector#1}%
+ \donetrue
+ \fi\fi\fi\fi\fi}
+
+\def\FLOWconnector#1%
+ {\if#1bbottom\else\if#1ttop\else\if#1lleft\else\if#1rright\fi\fi\fi\fi}
+
+\newif\ifFLOWscaling \FLOWscalingtrue
+
+\def\@@FLOW@@offset{\@@FLOWoffset}
+
+\def\getFLOWchart
+ {\dodoubleempty\dogetFLOWchart}
+
+\def\dogetFLOWchart[#1][#2]%
+ {\doifundefinedelse{\@FLOW@-#1}
+ {\writestatus{FLOW}{unknown chart #1}%
+ \framed
+ [\c!width=12\bodyfontsize,\c!height=8\bodyfontsize]
+ {\tttf [chart #1]}}
+ {\dodogetFLOWchart[#1][#2]}}
+
+\def\dodogetFLOWchart[#1][#2]% to be split a bit more
+ {\vbox\bgroup
+ \insidefloattrue
+ \forgetall
+ \dontcomplain
+ % \offinterlineskip % we now explicitly use \nointerlineskip later on
+ \def\dohandleflowchart[##1][##2]%
+ {\def\currentFLOWnumber{##1}%
+ \getparameters[\@@FLOW][##2]}%
+ \getvalue{\@FLOW@-#1}%
+ \getparameters[\@@FLOW][#2]% dubbelop ?
+ \doifsomething{\@@FLOWautofocus}
+ {\checkFLOWautofocus}%
+ %\message{AUTOSHAPE 3: (\@@FLOWx,\@@FLOWy)->(\@@FLOWnx,\@@FLOWny)}\wait
+ \global\let\FLOWwidth \@@FLOWnx
+ \global\let\FLOWheight\@@FLOWny
+ \let\startFLOWcell\startFLOWcellA
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ \ifcase\@@FLOWnx\relax \let\@@FLOWnx\FLOWwidth \fi
+ \ifcase\@@FLOWny\relax \let\@@FLOWny\FLOWheight \fi
+ \doifnothing{\@@FLOWmaxwidth\@@FLOWmaxheight}{\FLOWscalingfalse}%
+ \ifFLOWscaling
+ \doifnothing{\@@FLOWmaxwidth }{\let\@@FLOWmaxwidth \maxdimen}%
+ \doifnothing{\@@FLOWmaxheight}{\let\@@FLOWmaxheight\maxdimen}%
+ \scratchcounter\bodyfontpoints
+ \doloop % NOG FONTSWITCH OM EX EN EM TE LATEN WERKEN
+ {\ifnum\scratchcounter>1 % NU DIMENSIONS IN TERMS OF BODYFONTSIZE
+ \bodyfontsize=\the\scratchcounter pt
+ \dimen0=\@@FLOWmaxwidth
+ \dimen2=\@@FLOWwidth
+ \dimen4=\@@FLOWdx
+ \advance\dimen2 2\dimen4
+ \dimen2=\@@FLOWnx\dimen2
+ \advance\dimen2 2\dimen4
+ \ifdim\dimen2>\dimen0
+ \advance\scratchcounter \minusone
+ \else
+ \dimen0=\@@FLOWmaxheight
+ \dimen2=\@@FLOWheight
+ \dimen4=\@@FLOWdy
+ \advance\dimen2 2\dimen4
+ \dimen2=\@@FLOWny\dimen2
+ \advance\dimen2 2\dimen4
+ \ifdim\dimen2>\dimen0
+ \advance\scratchcounter \minusone
+ \else
+ \exitloop
+ \fi
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ \expanded{\switchtobodyfont[\the\scratchcounter pt]}%
+ \forgetall
+ % \offinterlineskip % needed ?
+ \else\ifx\@@FLOWbodyfont\empty\else
+ \expanded{\switchtobodyfont[\@@FLOWbodyfont]}% \expanded ?
+ \fi\fi
+ \global\let\FLOWcells\empty
+ \dimen0=\@@FLOWwidth
+ \edef\FLOWshapewidth{\the\dimen0}%
+ \dimen2=\@@FLOWdx
+ \advance\dimen0 2\dimen2
+ \edef\FLOWgridwidth{\the\dimen0}%
+ \dimen0=\@@FLOWheight
+ \edef\FLOWshapeheight{\the\dimen0}%
+ \dimen2=\@@FLOWdy
+ \advance\dimen0 2\dimen2
+ \edef\FLOWgridheight{\the\dimen0}%
+ \scratchdimen=\@@FLOSrulethickness
+ \edef\@@FLOSrulethickness{\the\scratchdimen}%
+ \scratchdimen=\@@FLOFrulethickness
+ \edef\@@FLOFrulethickness{\the\scratchdimen}%
+ \scratchdimen=\@@FLOLrulethickness
+ \edef\@@FLOLrulethickness{\the\scratchdimen}%
+ \ifdim\@@FLOLradius<2.5\scratchdimen
+ \scratchdimen=2.5\scratchdimen
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \ifdim\@@FLOLradius>\@@FLOWdx
+ \scratchdimen=\@@FLOWdx
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \ifdim\@@FLOLradius>\@@FLOWdy
+ \scratchdimen=\@@FLOWdy
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \else
+ \scratchdimen=\@@FLOLradius
+ \edef\@@FLOLradius{\the\scratchdimen}%
+ \fi
+ \processaction % magic 2.5
+ [\@@FLOWoffset]
+ [ \v!none=>\scratchdimen=-2.5\scratchdimen,
+ \v!overlay=>\scratchdimen=-2.5\scratchdimen,
+ \v!standard=>\scratchdimen=\scratchdimen,
+ \s!unknown=>\scratchdimen=\@@FLOWoffset,
+ \s!default=>\scratchdimen=-2.5\scratchdimen]%
+ \edef\@@FLOW@@offset{\the\scratchdimen}%
+ \forgetall
+ \offinterlineskip
+ \resetMPdrawing
+ \doglobal\newcounter\FLOWcomment
+ \startMPdrawing
+ if unknown context_char : input mp-char.mp ; fi ;
+ grid_width := \FLOWgridwidth ;
+ grid_height := \FLOWgridheight ;
+ shape_width := \FLOWshapewidth ;
+ shape_height := \FLOWshapeheight ;
+ connection_line_width := \@@FLOLrulethickness ;
+ connection_smooth_size := \@@FLOLradius ;
+ connection_arrow_size := \@@FLOLradius ;
+ connection_dash_size := \@@FLOLradius ;
+ currentpicture := nullpicture ;
+ begin_chart(0,\FLOWwidth,\FLOWheight);
+ reverse_y := true ;
+ chart_offset := \@@FLOW@@offset ;
+ \stopMPdrawing
+ \doifelsenothing\@@FLOWbackgroundcolor
+ {\startMPdrawing
+ chart_background_color := white ;
+ \stopMPdrawing}
+ {\startMPdrawing
+ chart_background_color := \MPcolor{\@@FLOWbackgroundcolor} ;
+ \stopMPdrawing}%
+ \doif\@@FLOWoption\v!test
+ {\startMPdrawing
+ show_con_points := true ;
+ show_mid_points := true ;
+ show_all_points := true ;
+ \stopMPdrawing}%
+ \processaction % private
+ [\@@FLOWdot]
+ [ \v!yes=>\startMPdrawing
+ show_con_points := true ;
+ show_mid_points := true ;
+ show_all_points := true ;
+ \stopMPdrawing,
+ \s!unknown=>\startMPdrawing
+ show_\@@FLOWdot_points := true ;
+ \stopMPdrawing]%
+\doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellB
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+\doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellC
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ \startMPdrawing
+ clip_chart(\@@FLOWx,\@@FLOWy,\@@FLOWnx,\@@FLOWny) ;
+ end_chart ;
+ \stopMPdrawing
+ \MPdrawingdonetrue
+ \setbox0\hbox
+ {\MPstaticgraphictrue
+ \MPshiftdrawingfalse
+ \getMPdrawing}%
+ \def\MPmessage##1%
+ {\writestatus{MP charts}{##1}}%
+ \def\MPposition##1##2##3%
+ {\setvalue{\@@MPx##1}{##2}\setvalue{\@@MPy##1}{##3}}%
+ \def\MPclippath##1##2##3##4%
+ {\def\clipMPllx{##1bp}\def\clipMPlly{##2bp}%
+ \def\clipMPurx{##3bp}\def\clipMPury{##4bp}}%
+ \def\MPareapath##1##2##3##4%
+ {\def\areaMPllx{##1bp}\def\areaMPlly{##2bp}%
+ \def\areaMPurx{##3bp}\def\areaMPury{##4bp}}%
+ \getMPdata
+ \doglobal\newcounter\FLOWcomment
+ \let\startFLOWcell\startFLOWcellD
+ \setbox2\vbox to \ht0
+ {\forgetall % \offinterlineskip
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber\vss}%
+ \setbox2\hbox
+ {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box2}%
+ \wd2\wd0\ht2\ht0\dp2\dp0
+ \let\startFLOWcell\startFLOWcellE
+ \setbox4\vbox to \ht0
+ {\forgetall % \offinterlineskip
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber\vss}%
+ \setbox4\hbox
+ {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box4}%
+ \wd4\wd0\ht4\ht0\dp4\dp0
+ \doifelse\@@FLOWoption\v!test
+ {\setbox6\vbox
+ {\forgetall
+ \vskip\@@FLOW@@offset
+ \hskip\@@FLOW@@offset
+ \basegrid
+ [\c!x=\@@FLOWx,\c!nx=\@@FLOWnx,\c!dx=\withoutpt\FLOWgridwidth,
+ \c!y=\@@FLOWy,\c!ny=\@@FLOWny,\c!dy=\withoutpt\FLOWgridheight,
+ \c!xstep=1,\c!ystep=1,
+ \c!unit=pt,\c!location=\v!middle]}%
+ \wd6\wd0\ht6\ht0\dp6\dp0
+ \setbox8\vbox
+ {\forgetall
+ \offinterlineskip
+ \vskip\@@FLOW@@offset
+ \dostepwiserecurse\@@FLOWy\@@FLOWny\plusone
+ {\vbox to \FLOWgridheight
+ {\vfill
+ \hskip\@@FLOW@@offset
+ \hbox
+ {\dostepwiserecurse\@@FLOWx\@@FLOWnx\plusone
+ {\hbox to \FLOWgridwidth
+ {\hfill
+ \framed
+ [\c!framecolor=red,
+ \c!width=\FLOWshapewidth,
+ \c!height=\FLOWshapeheight]
+ {}%
+ \hfill}}}
+ \vfill}}}%
+ \wd8\wd0\ht8\ht0\dp8\dp0
+ \framed
+ [\c!offset=\v!overlay,\c!framecolor=green]
+ {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2\hskip-\wd6\box6\hskip-\wd8\box8}}}
+ {\framed
+ [\c!offset=\v!overlay,
+ \c!frame=\@@FLOWframe,
+ \c!rulethickness=\@@FLOWrulethickness,
+ \c!framecolor=\@@FLOWframecolor,
+ \c!background=\@@FLOWbackground,
+ \c!backgroundcolor=\@@FLOWbackgroundcolor]
+ {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2}}}%
+ %\message{[\FLOWcells]}\wait
+ \egroup}
+
+% Pass A
+
+\long\def\startFLOWcellA#1\stopFLOWcell%
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \expandafter\getFLOWlocationA\FLOWlocation\end
+ \ignorespaces}
+
+\def\getFLOWlocationA#1,#2\end
+ {\ifnum0#1>\FLOWwidth \xdef\FLOWwidth {#1}\fi
+ \ifnum0#2>\FLOWheight\xdef\FLOWheight{#2}\fi}
+
+% Pass B
+%
+% beware: the - after \@FLOC@ is needed since name can be
+% empty and we don't want to redefine \@FLOC@ itself by
+% mistake
+
+\long\def\startFLOWcellB#1\stopFLOWcell
+ {\resetFLOWcell\ignorespaces#1\unskip
+ \setxvalue{\@FLOC@-\FLOWname}{\FLOWlocation}% kost veel cs's
+ \ifx\FLOWshape\empty
+ \global\let\FLOWshape\@@FLOSdefault
+ \fi
+ \doifnot\FLOWshape{none} % {\v!none}
+ {\ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWshapes}
+ {\edef\FLOWshapetag{shape_\FLOWshape}% beter \expanded
+ \@EA\setFLOWname\@EA\FLOWshapetag\@EA{\FLOWshapetag}}
+ {\doifnumberelse\FLOWshape
+ {\let\FLOWshapetag\FLOWshape}
+ {\let\FLOWshapetag\empty}}%
+ \ifx\FLOWshapetag\empty \else
+ \ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWlines}
+ {\chardef\FLOWstate0 }
+ {\ExpandBothAfter\doifcommonelse{\FLOWcell,\FLOWfocus}{\@@FLOWfocus}
+ {\chardef\FLOWstate1 }
+ {\chardef\FLOWstate2 }}%
+ \startMPdrawing
+ begin_sub_chart ;
+ \ifcase\FLOWstate
+ shape_line_color := \MPcolor{\@@FLOLcolor} ;
+ shape_fill_color := \MPcolor{\@@FLOLcolor} ;
+ shape_line_width := \@@FLOLrulethickness ;
+ \or
+ shape_line_color := \MPcolor{\@@FLOFframecolor} ;
+ shape_fill_color := \MPcolor{\@@FLOFbackgroundcolor} ;
+ shape_line_width := \@@FLOFrulethickness ;
+ \or
+ shape_line_color := \MPcolor{\@@FLOSframecolor} ;
+ shape_fill_color := \MPcolor{\@@FLOSbackgroundcolor} ;
+ shape_line_width := \@@FLOSrulethickness ;
+ \fi
+ %\ifx\FLOWoverlay\empty
+ % peepshape := false ;
+ %\else
+ % peepshape := true ;
+ %\fi
+ peepshape := \ifx\FLOWoverlay\empty false \else true \fi ;
+ new_shape(\FLOWlocation,\FLOWshapetag) ;
+ end_sub_chart ;
+ \stopMPdrawing
+ \fi}%
+ \ignorespaces}
+
+% Pass C
+
+\long\def\startFLOWcellC#1\stopFLOWcell%
+ {\resetFLOWcell
+\pushmacro\lastFLOWx
+\pushmacro\lastFLOWy
+ \ignorespaces#1\unskip % makes sure that vars are set
+\popmacro\lastFLOWy
+\popmacro\lastFLOWx
+ \let\connection\doFLOWconnectionC
+ \ignorespaces#1\unskip}
+
+\def\FLOWorigin{0,0}
+
+\def\doFLOWdisplace[#1,#2,#3]% experiment
+ {dsp_x := #1 ; dsp_y := #2 ;}
+
+\def\doFLOWconnectionC
+ {\dodoubleempty\dodoFLOWconnectionC}
+
+\def\dodoFLOWconnectionC[#1][#2]#3%
+ {\doglobal\increment\FLOWcomment
+ \setFLOWname\otherFLOWname{name_#3}%
+ \doifdefinedelse{\@FLOC@-\FLOWname}
+ {\edef\FLOWfrom{\getvalue{\@FLOC@-\FLOWname}}}
+ {\let \FLOWfrom \FLOWorigin}%
+ \ifx\FLOWfrom\FLOWorigin \else
+ \doifdefinedelse{\@FLOC@-\otherFLOWname}
+ {\edef\FLOWto {\getvalue{\@FLOC@-\otherFLOWname}}}
+ {\let \FLOWto \FLOWorigin}%
+ \ifx\FLOWto\FLOWorigin \else
+ \FLOWsetconnect{#1}%
+ \ifx\cFLOWfrom\empty \else
+ \doifelse\@@FLOLcorner\v!round
+ {\startMPdrawing smooth := true ; \stopMPdrawing}
+ {\startMPdrawing smooth := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLdash\v!yes
+ {\startMPdrawing dashline := true ; \stopMPdrawing}
+ {\startMPdrawing dashline := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLarrow\v!yes
+ {\startMPdrawing arrowtip := true ; \stopMPdrawing}
+ {\startMPdrawing arrowtip := false ; \stopMPdrawing}%
+ \doifelse\@@FLOLoffset\v!none
+ {\startMPdrawing touchshape := true ; \stopMPdrawing}
+ {\startMPdrawing touchshape := false ; \stopMPdrawing}%
+%\doifsomething{#2}
+% {\startMPdrawing
+% \doFLOWdisplace[0#2,0,0]%
+% \stopMPdrawing}%
+ \startMPdrawing
+\doFLOWdisplace[0#2,0,0]%
+ connection_line_color := \MPcolor{\@@FLOLcolor} ;
+ connection_line_width := \@@FLOLrulethickness ;
+ connect_\cFLOWfrom_\cFLOWto (\FLOWfrom,\zFLOWfrom) (\FLOWto,\zFLOWto) ;
+\doFLOWdisplace[0,0,0]%
+ \stopMPdrawing
+ \fi
+ \fi
+ \fi
+ \ignorespaces}
+
+% Pass D
+
+\long\def\startFLOWcellD#1\stopFLOWcell
+ {\resetFLOWcell
+\pushmacro\lastFLOWx
+\pushmacro\lastFLOWy
+ \ignorespaces#1\unskip % presets vars
+\popmacro\lastFLOWy
+\popmacro\lastFLOWx
+ \let\doprocessFLOWcell\doprocessFLOWcellD
+ \expandafter\doprocessFLOWcellD\FLOWlocation\end
+ \let\connection\doFLOWconnectionD
+ \let\comment\doFLOWcommentD
+ \ignorespaces#1\unskip\ignorespaces}
+
+\def\doFLOWconnectionD
+ {\dodoubleempty\dodoFLOWconnectionD}
+
+\def\dodoFLOWconnectionD[#1][#2]#3%
+ {\doglobal\increment\FLOWcomment
+ \ignorespaces}
+
+\def\doFLOWcommentD[#1]#2%
+ {\bgroup
+ \let\FLOW \middlebox
+ \let\FLOWb \bottombox
+ \let\FLOWbl\bottomleftbox
+ \let\FLOWbr\bottomrightbox
+ \let\FLOWt \topbox
+ \let\FLOWtl\topleftbox
+ \let\FLOWtr\toprightbox
+ \let\FLOWl \leftbox
+ \let\FLOWlt\lefttopbox
+ \let\FLOWlb\leftbottombox
+ \let\FLOWr \rightbox
+ \let\FLOWrt\righttopbox
+ \let\FLOWrb\rightbottombox
+ \let\FLOWc \middlebox
+%\ifdefined{FLOW#1}%
+ \ifcase0\getvalue{\@@MPx\FLOWcomment}\getvalue{\@@MPy\FLOWcomment}\relax
+ \else
+ \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp<\areaMPllx\relax\else
+ \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp>\areaMPurx\relax\else
+ \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp<\areaMPlly\relax\else
+ \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp>\areaMPury\relax\else
+ \dimen0=\getvalue{\@@MPx\FLOWcomment}\s!bp
+ \advance\dimen0 -\@@FLOW@@offset
+ \advance\dimen0 -\clipMPllx
+ \dimen2=\clipMPury
+ \advance\dimen2 -\@@FLOW@@offset
+ \advance\dimen2 -\getvalue{\@@MPy\FLOWcomment}\s!bp
+ \setbox\scratchbox\hbox{\strut#2}%
+ \boxoffset.5\bodyfontsize
+ \setbox\scratchbox\hbox{\hskip\dimen0\lower\dimen2\getvalue{FLOW#1}{\box\scratchbox}}%
+ \smashbox\scratchbox
+ \box\scratchbox
+ \boxoffset\zeropoint
+ \nointerlineskip % really needed
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+%\fi
+ \egroup
+ \ignorespaces}
+
+% pass D
+
+\def\dophaseoneFLOWcellX#1#2%
+ {\!!counta#1\relax
+ \!!countb#2\relax
+ \!!countc\@@FLOWx
+ \!!countd\@@FLOWy
+ \advance\!!countc \@@FLOWnx
+ \advance\!!countd \@@FLOWny
+ \advance\!!countc \minusone
+ \advance\!!countd \minusone
+ \ifnum\!!counta<\@@FLOWx\relax \donefalse
+ \else\ifnum\!!counta>\!!countc \donefalse
+ \else\ifnum\!!countb<\@@FLOWy\relax \donefalse
+ \else\ifnum\!!countb>\!!countd \donefalse
+ \else \donetrue
+ \fi\fi\fi\fi}
+
+\def\dophasetwoFLOWcellX
+ {\advance\!!counta -\@@FLOWx
+ \advance\!!counta \plusone
+ \advance\!!countb -\@@FLOWy
+ \advance\!!countb \plusone
+ \dimen0=\FLOWgridwidth
+ \dimen0=\!!counta\dimen0
+ \advance\dimen0 -\FLOWgridwidth
+ \dimen4=\FLOWgridwidth
+ \advance\dimen4 -\FLOWshapewidth
+ \advance\dimen0 .5\dimen4
+ \dimen2=\FLOWgridheight
+ \dimen2=\!!countb\dimen2
+ \dimen4=\FLOWgridheight
+ \advance\dimen4 -\FLOWshapeheight
+ \advance\dimen2 -.5\dimen4
+ \edef\FLOWdx{\the\dimen0}%
+ \edef\FLOWdy{\the\dimen2}}
+
+\def\positionFLOWzero% assumes \FLOWdx and \FLOWdy are set
+ {\setbox0\hbox{\hskip\FLOWdx\lower\FLOWdy\box0}%
+ \smashbox0\box0
+ \nointerlineskip} % new, needed since we somehow reset that
+
+\def\doFLOWtlabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
+ \setbox0\hbox{\hskip\dimen2\raise\scratchdimen
+ \hbox{\raise\dimen4\hbox{#1{\strut#3}}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWblabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
+ \setbox0\hbox{\hskip\dimen2\raise-\scratchdimen
+ \hbox{#1{\strut#3}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWllabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
+ \setbox0\hbox{\hskip-\scratchdimen\raise\dimen6
+ \hbox{#1{\strut#3}}}%
+ \positionFLOWzero}%
+
+\def\doFLOWrlabel#1#2#3%
+ {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
+ \setbox0\hbox{\hskip\dimen0\hskip\scratchdimen
+ \hbox{\raise\dimen6\hbox{#1{\strut#3}}}}%
+ \positionFLOWzero}
+
+\def\doprocessFLOWcellD#1,#2\end
+ {\dophaseoneFLOWcellX{#1}{#2}%
+ \ifdone
+ \dophasetwoFLOWcellX
+ \doglobal\addtocommalist\FLOWcell\FLOWcells
+ \def\FLOWx{#1}%
+ \def\FLOWy{#2}%
+ \directsetup{flowcell}%
+ \setbox0\hbox
+ {\ifx\FLOWalign\empty\else
+ \setupframed
+ [\c!align=\v!normal,\c!bottom=\vfill,\c!top=\vfill]%
+ \@EA\processallactionsinset\@EA
+ [\FLOWalign]
+ [t=>{\setupframed[\c!bottom=\vfill,\c!top=]},
+ b=>{\setupframed[\c!bottom=,\c!top=\vfill]},
+ l=>{\setupframed[\c!align=\v!right]},
+ r=>{\setupframed[\c!align=\v!left]},
+ m=>{\setupframed[\c!align=\v!middle]},
+ c=>{\setupframed[\c!align=\v!middle]}]%
+ \fi
+ \doifelse\FLOWshape{none} % {\v!none}
+ {\setupframed[\c!offset=\v!overlay]}
+ {\setupframed[\c!offset=\@@FLOSoffset]}%
+ \framed
+ [\c!frame=\v!off,\c!background=flowcell,
+ \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
+ {\FLOWtext}}%
+ \showFLOWhelp0
+ \ifx\FLOWdestination\empty\else
+ \setbox0\hbox
+ {\setupinteraction[\c!color=,\c!contrastcolor=]%
+ \gotobox{\box0}[\FLOWdestination]}%
+ \fi
+ \positionFLOWzero
+ \dimen0=\FLOWshapewidth \dimen2=.5\dimen0
+ \dimen4=\FLOWshapeheight\dimen6=.5\dimen4
+ \boxoffset.5\bodyfontsize
+ \doFLOWtlabel \righttopbox0\tFLOWlabel
+ \doFLOWblabel\rightbottombox0\bFLOWlabel
+ \doFLOWllabel \lefttopbox0\lFLOWlabel
+ \doFLOWrlabel \righttopbox0\rFLOWlabel
+ \doFLOWtlabel \topbox0\tcFLOWlabel % for me only
+ \doFLOWblabel \bottombox0\bcFLOWlabel % for me only
+ \doFLOWllabel \leftbox0\lcFLOWlabel % for me only
+ \doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
+ \ifnum#1=\@@FLOWx\relax \doFLOWllabel \leftbox1\lFLOWexit \fi
+ \ifnum#1=\!!countc \doFLOWrlabel \rightbox1\rFLOWexit \fi
+ \ifnum#2=\@@FLOWy\relax \doFLOWtlabel \topbox1\tFLOWexit \fi
+ \ifnum#2=\!!countd \doFLOWblabel \bottombox1\bFLOWexit \fi
+ \boxoffset\zeropoint
+ \fi}
+
+% For Willy Egger:
+%
+% \startsetups flowcell
+% \definelayer
+% [flowcell]
+% [width=\FLOWshapewidth,
+% height=\FLOWshapeheight]
+% \setlayerframed
+% [flowcell]
+% [preset=rightbottom,offset=1ex]
+% [frame=off]
+% {\tx(\FLOWx,\FLOWy)}
+% \stopsetups
+
+% Pass E
+
+\long\def\startFLOWcellE#1\stopFLOWcell
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \let\doprocessFLOWcell\doprocessFLOWcellE
+ \expandafter\doprocessFLOWcell\FLOWlocation\end}
+
+\def\doprocessFLOWcellE#1,#2\end % redundant
+ {\ifx\FLOWoverlay\empty \else
+ \dophaseoneFLOWcellX{#1}{#2}%
+ \ifdone
+ \dophasetwoFLOWcellX
+ \edef\FLOWdx{\the\dimen0}%
+ \edef\FLOWdy{\the\dimen2}%
+ \setbox0\hbox
+ {\framed
+ [%\c!frame=\v!off,
+ \c!background={\@@FLOWbackground,\FLOWoverlay},
+ \c!backgroundcolor=\@@FLOSbackgroundcolor,
+ \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
+ {}}%
+ \positionFLOWzero
+ \fi
+ \fi}
+
+% Pass F
+
+\def\checkFLOWautofocus
+ {\def\@@FLOWminx{100}\let\@@FLOWminy\@@FLOWminx
+ \def\@@FLOWmaxx {0}\let\@@FLOWmaxy\@@FLOWmaxx
+ \def\@@FLOWabsx {0}\let\@@FLOWabsy\@@FLOWabsx
+ \let\startFLOWcell\startFLOWcellF
+ \resetFLOWlocation
+ \processFLOWbuffer\currentFLOWnumber
+ %\message{AUTOSHAPE 1: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
+ \ifnum\@@FLOWabsx<\@@FLOWmaxx\let\@@FLOWmaxx\@@FLOWabsx\fi
+ \ifnum\@@FLOWabsy<\@@FLOWmaxy\let\@@FLOWmaxy\@@FLOWabsy\fi
+ %\message{AUTOSHAPE 2: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
+ \donetrue
+ \ifnum\@@FLOWminx=100 \donefalse\fi
+ \ifnum\@@FLOWminy=100 \donefalse\fi
+ \ifnum\@@FLOWmaxx=0 \donefalse\fi
+ \ifnum\@@FLOWmaxy=0 \donefalse\fi
+ \doFLOWcheckF\@@FLOWx\@@FLOWminx\@@FLOWmaxx\@@FLOWnx
+ \doFLOWcheckF\@@FLOWy\@@FLOWminy\@@FLOWmaxy\@@FLOWny}
+
+\def\startFLOWcellF#1\stopFLOWcell%
+ {\resetFLOWcell
+ \ignorespaces#1\unskip
+ \expandafter\doFLOWlocationF\FLOWlocation\end}%
+
+\def\doFLOWlocationF#1,#2\end%
+ {\ifnum#1>\@@FLOWabsx\def\@@FLOWabsx{#1}\fi
+ \ifnum#2>\@@FLOWabsy\def\@@FLOWabsy{#2}\fi
+ \ExpandBothAfter\doifinset{\FLOWcell}{\@@FLOWautofocus}
+ {\dodoFLOWlocationF{#1}<-\@@FLOWminx
+ \dodoFLOWlocationF{#1}>+\@@FLOWmaxx
+ \dodoFLOWlocationF{#2}<-\@@FLOWminy
+ \dodoFLOWlocationF{#2}>+\@@FLOWmaxy}}
+
+\def\dodoFLOWlocationF#1#2#3#4%
+ {\ifnum#1#2#4\relax
+ \!!counta=#1\advance\!!counta #31\relax
+ \edef#4{\ifnum\!!counta<1 1\else\the\!!counta\fi}%
+ \fi}
+
+\def\doFLOWcheckF#1#2#3#4%
+ {\ifdone
+ \let#1=#2%
+ \!!counta=#3%
+ \advance\!!counta \plusone\advance\!!counta -#2\relax
+ \ifnum\!!counta<1 \!!counta=1 \fi
+ \edef#4{\the\!!counta}%
+ \else
+ \let#1\!!plusone
+ \let#4\!!zerocount % no {1}
+ \fi}
+
+% \useFLOWchart[name][parent][setting,setting][additional settings]
+% \useFLOWchart[name][parent][additional settings]
+
+\let\currentFLOWchart\empty
+
+\def\useFLOWchart
+ {\doquadrupleempty\douseFLOWchart}
+
+\def\douseFLOWchart[#1][#2][#3][#4]% name parent sets mainsettings
+ {\iffourthargument
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][#4,##1]}%
+ \else
+ \checkparameters[#3]%
+ \ifparameters
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][][#3,##1]}%
+ \else
+ \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][##1]}%
+ \fi
+ \fi}
+
+\def\setgetFLOWchart[#1][#2][#3]%
+ {\def\docommand##1{}% cell line focus ?
+ \processcommalist[#2]\docommand
+ \getFLOWchart[#1][#3]}
+
+\def\doFLOWchart[#1][#2]%
+ {\hbox\bgroup\vbox\bgroup % vmode suppresses spaces
+\def\currentFLOWchart{#1}%
+ \doifundefinedelse{\@FLOW@--#1}
+ {\getFLOWchart[#1][#2]}
+ {\getvalue{\@FLOW@--#1}[#2]}%
+ \egroup\egroup}
+
+\def\FLOWchart%
+ {\dodoubleempty\doFLOWchart}
+
+%D A hook into the help system.
+
+\def\showFLOWhelp#1%
+ {\doifhelpinfo\FLOWhelp
+ {\setbox#1=\hbox
+ {\setbox\scratchbox=\hbox{\lower\@@FLOWdy\hbox
+ {\helpbutton
+ [\c!width=\wd0,\c!color=,\c!height=\@@FLOWdy,\c!frame=\v!no]%
+ [\FLOWhelp]}}%
+ \smashbox\scratchbox
+ \setbox#1=\vbox
+ {\forgetall\offinterlineskip\box#1\box\scratchbox}%
+ \box#1}}}
+
+%D The next section is dedicated to splitting up charts.
+
+\def\getFLOWsize[#1]%
+ {\bgroup\let\dodogetFLOWchart\dogetFLOWsize\FLOWchart[#1]\egroup}
+
+\def\dogetFLOWsize[#1][#2]%
+ {\setbox\scratchbox=\vbox
+ {\globallet\FLOWmaxwidth \!!zerocount
+ \globallet\FLOWmaxheight\!!zerocount
+ \def\getFLOWlocation##1,##2\end
+ {\ifnum0##1>\FLOWmaxwidth \xdef\FLOWmaxwidth {##1}\fi
+ \ifnum0##2>\FLOWmaxheight\xdef\FLOWmaxheight{##2}\fi}%
+ \resetFLOWcell
+ \long\def\startFLOWcell##1\stopFLOWcell
+ {{##1\expandafter\getFLOWlocation\FLOWlocation\end}}%
+ \def\dohandleflowchart[##1][##2]%
+ {\resetFLOWlocation
+ \processFLOWbuffer{##1}}%
+ \getvalue{\@FLOW@-#1}}}
+
+\def\setupFLOWsplit%
+ {\dodoubleargument\getparameters[\@@FLOT]}
+
+\setupFLOWsplit%
+ [\c!nx=3,\c!ny=3,
+ \c!dx=1,\c!dy=1,
+ \c!command=,
+ \c!marking=\v!on,
+ \c!before=,\c!after=]
+
+\def\FLOWsplitx {1}
+\def\FLOWsplity {1}
+\def\FLOWsplitnx{1}
+\def\FLOWsplitny{1}
+
+\def\FLOWcharts%
+ {\dodoubleempty\doFLOWcharts}
+
+%D While splitting, the following variables are available:
+%D
+%D \starttyping
+%D \FLOWsplitnx \FLOWsplitny \FLOWsplitx \FLOWsplity
+%D \stoptyping
+
+\def\doFLOWcharts[#1][#2]%
+ {\bgroup
+ \getFLOWsize[#1]%
+ \dodoFLOWcharts\relax
+ \global\let\FLOWsplitnx\FLOWsplitx
+ \global\let\FLOWsplitny\FLOWsplity
+ \dodoFLOWcharts{\dododoFLOWcharts[#1][#2]}%
+ \egroup}
+
+\def\dodoFLOWcharts#1%
+ {\def\@@FLOTx{1}%
+ \global\let\FLOWsplitx\@@FLOTx
+ \doloop
+ {\def\@@FLOTy{1}%
+ \global\let\FLOWsplity\@@FLOTy
+ \doloop
+ {\bgroup
+ \scratchcounter\FLOWmaxwidth
+ \advance\scratchcounter -\@@FLOTx
+ \advance\scratchcounter \plusone
+ \ifnum\scratchcounter<\@@FLOTnx\edef\@@FLOTnx{\the\scratchcounter}\fi
+ \scratchcounter\FLOWmaxheight
+ \advance\scratchcounter -\@@FLOTy
+ \advance\scratchcounter \plusone
+ \ifnum\scratchcounter<\@@FLOTny\edef\@@FLOTny{\the\scratchcounter}\fi
+ #1% does something with the float, or not
+ \egroup
+ \increment(\@@FLOTy,\@@FLOTny)%
+ \ifnum\@@FLOTy>\FLOWmaxheight
+ \exitloop
+ \else
+ \doglobal\increment\FLOWsplity
+ \decrement(\@@FLOTy,\@@FLOTdy)%
+ \fi}%
+ \increment(\@@FLOTx,\@@FLOTnx)%
+ \ifnum\@@FLOTx>\FLOWmaxwidth
+ \exitloop
+ \else
+ \doglobal\increment\FLOWsplitx
+ \decrement(\@@FLOTx,\@@FLOTdx)%
+ \fi}}
+
+\def\dododoFLOWcharts[#1][#2]%
+ {\bgroup
+ \@@FLOTbefore
+ \doifnot\@@FLOTmarking\v!on{\let\cuthbox\hbox}%
+ \cuthbox
+ {\@@FLOTcommand
+ {\FLOWchart[#1][#2,
+ \c!x=\@@FLOTx,\c!nx=\@@FLOTnx,
+ \c!y=\@@FLOTy,\c!ny=\@@FLOTny]}}%
+ \@@FLOTafter
+ \egroup}
+
+%D An example of splitting is given below:
+%D
+%D \starttyping
+%D \setupFLOWsplit
+%D [nx=5,ny=10,
+%D dx=0,dy=0,
+%D before=,
+%D after=\page]
+%D
+%D \FLOWcharts[mybigflow]
+%D \stoptyping
+%D
+%D Or, one can say:
+%D
+%D \starttyping
+%D \splitfloat
+%D {\placefigure{What a big flowchart this is!}}
+%D {\FLOWcharts[mybigflow]}
+%D \stoptyping
+
+%D \macros
+%D {typeFLOWchart}
+%D
+%D For documentation purposes the following macro is
+%D provided. Watch the use of the first and last line hooks,
+%D which is needed because the start and stop commands are
+%D not part of the buffer.
+
+\def\typeFLOWchart[#1]%
+ {\bgroup
+ \def\dohandleflowchart[##1][##2]{\typeFLOWbuffer{##1}}%
+ \defconvertedargument\firstverbatimfileline{\startFLOWchart[#1]}%
+ \defconvertedargument\lastverbatimfileline {\stopFLOWchart}%
+ \getvalue{\@FLOW@-#1}
+ \egroup}
+
+%D New:
+%D
+%D \starttyping
+%D \setupFLOWcharts[command=\Whow]
+%D
+%D \startFLOWset[convert-en] % [tag][convert-en]
+%D \subFLOWchart[a][x=1,y=1,nx=3,ny=3]
+%D \subFLOWchart[b][x=1,y=2,nx=3,ny=3]
+%D \subFLOWchart[c][x=2,y=1,nx=3,ny=3]
+%D \stopFLOWset
+%D
+%D \def\Whow#1%
+%D {\ifnum\currentFLOWset=1 \framed{Some Chart}\fi}
+%D
+%D \FLOWset[convert-en] % [tag]
+%D
+%D \def\Whow#1%
+%D {\setuphead[state=high]
+%D \startstandardmakeup
+%D \centerbox{#1}
+%D \stopstandardmakeup}
+%D
+%D \FLOWset[convert-en] % [tag]
+%D \stoptyping
+
+\def\startFLOWset
+ {\dodoubleempty\dostartFLOWset}
+
+\def\dostartFLOWset[#1][#2]#3\stopFLOWset % tag name data
+ {\ifsecondargument
+ \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#2}{#3}}%
+ \else
+ \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#1}{#3}}%
+ \fi}
+
+\long\def\dohandleFLOWset#1#2#3% tag name data
+ {\bgroup
+ \def\subFLOWchart
+ {\dodoubleempty\dosubFLOWchart}%
+ \def\dosubFLOWchart[##1][##2]% subtag settings
+ {\ifsecondargument
+ \dodohandleFLOWset{#1}{##1}{#2}{##2}%
+ \else
+ \subFLOWchart[][##1]%
+ \fi}%
+ #3%
+ \egroup}
+
+\def\dodohandleFLOWset#1#2#3#4% tag subtag name settings
+ {\increment\currentFLOWset
+ \bgroup
+ \@@FLOXcommand
+ {\ifnum\currentFLOWset=1 \pagereference[#1]\fi
+ \doifsomething{#2}
+ {\setupreferencing[\c!prefix=]%
+ \pagereference[#1:#2]% -:#1:#2
+ \setupreferencing[\c!prefix=#1:#2]}%
+ \FLOWchart[#3][#4]}%
+ \egroup}
+
+\def\FLOWset[#1]%
+ {\newcounter\currentFLOWset
+ \doifdefinedelse{\@FLOX@#1}
+ {\getvalue{\@FLOX@#1}}
+ {\dodohandleFLOWset{#1}{}{#1}{}}}
+
+\newcounter\currentFLOWset
+
+\setupFLOWsets
+ [\c!command=]
+
+%D This will be an option:
+
+% \def\startFLOWchart%
+% {\dodoubleempty\dostartFLOWchart}
+%
+% \long\def\dostartFLOWchart[#1][#2]#3\stopFLOWchart
+% {\preparenextFLOWchart{#1}{#2}%
+% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
+%
+% \long\def\dodefineFLOWchart[#1][#2]#3%
+% {\preparenextFLOWchart{#1}{#2}%
+% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
+%
+% \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}}
+% \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]}
+
\writestatus\m!systems{The chart mkiv xml interface is not yet defined!}
\protect \endinput
diff --git a/tex/context/base/m-chart.tex b/tex/context/base/m-chart.tex
index 5ccf4c2ad..c4e279d54 100644
--- a/tex/context/base/m-chart.tex
+++ b/tex/context/base/m-chart.tex
@@ -11,1274 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
-% todo: make mkiv variant
-% todo: use dimexpr/numspr
-
-% will be redone with layers and dimexpr or even better, by just using
-% textext .. a nice example of old code
-
-%D This is an experimental module. Pieces of code will be moved
-%D to other modules. More features are possible but will be
-%D interfaces later.
-%D
-%D When finished this module will be documented. The main macro
-%D is still a rather big one and there is some redundant and
-%D slow code that needs a clean up.
-
-% arrow, dash
-% crossing
-% \goto -> \normalgoto
-% class -> class:name (ref prefix)
-% c, automatisch geen overlap zoeken
-% eind eerder chart connecties
-% relateren aan korps
-% check op bestaan naam, bestaan shape
-% auto als extern figuur
-% subchart
-% pijlen
-% focus
-% ook nog \MPmessage
-% areapath -> krappe vlak
-% clippath -> gehele vlak
-%
-% offset : clip offset
-% breedte : breedte cel
-% hoogte : hoogte cel
-% dx : halve afstand in breedte (grid breedte = breedte + 2dx)
-% dy : halve afstand in hoogte (grid hoogte = hoogte + 2dy)
-% x : x offset (clipping)
-% y : y offset (clipping)
-% nx : minimaal aantal cellen horizontaal
-% ny : minimaal aantal cellen vertikaal
-%
-% shape none en geen equivalent maken
-%
-% kaderkleur achtergrondkleur
-% lijnkleur lijndikte
-% focus focuskaderkleur focusachtergrondkleur
-% richting
-%
-% focus koppelen aan kleur
-
-\unprotect
-
-\definesorting [flowchart] [flowcharts] [\v!none] % no access
-\setupsorting [flowchart] [\c!state=\v!stop] % off by default
-
-\def\@FLOW@{@FLOW@}
-\def\@FLOC@{@FLOC@}
-\def\@FLOX@{@FLOX@}
-
-\def\@@FLOW{@@FLOW}
-\def\@@FLOL{@@FLOL}
-\def\@@FLOS{@@FLOS}
-\def\@@FLOF{@@FLOF}
-\def\@@FLOT{@@FLOT}
-\def\@@FLOX{@@FLOX}
-
-\def\@@MPx {@@MPx}
-\def\@@MPy {@@MPy}
-
-\def\FLOWbufferprefix{flw-}
-
-\def\processFLOWbuffer#1{\getbuffer[\FLOWbufferprefix#1]}
-\def\typeFLOWbuffer #1{\typebuffer[\FLOWbufferprefix#1]}
-
-\def\setFLOWname#1#2% funny hack that makes sure that we get
- {\bgroup % names that are acceptable for METAPOST
- \lccode`0=`a\lccode`1=`b\lccode`2=`c\lccode`3=`d\lccode`4=`e%
- \lccode`5=`f\lccode`6=`g\lccode`7=`h\lccode`8=`i\lccode`9=`j%
- \lccode` =`\_\lccode`-=`\_\lccode`_=`\_%
- \lowercase{\gdef#1{#2}}%
- \egroup}
-
-% een gobble als default is sneller, en dan alleen setten als
-% nodig
-
-\def\resetFLOWcell
- {% variables
- \global\let\FLOWname \empty
- \global\let\FLOWalign \empty
- \global\let\FLOWshape \empty
- \global\let\FLOWlocation \empty
- \global\let\FLOWtext \empty
- \global\let\FLOWhelp \empty
- \global\let\FLOWdestination\empty
- \global\let\FLOWoverlay \empty
- \global\let\FLOWfocus \empty
- \global\let\tFLOWlabel \empty
- \global\let\bFLOWlabel \empty
- \global\let\lFLOWlabel \empty
- \global\let\rFLOWlabel \empty
- \global\let\bcFLOWlabel \empty
- \global\let\tcFLOWlabel \empty
- \global\let\lcFLOWlabel \empty
- \global\let\rcFLOWlabel \empty
- \global\let\tFLOWexit \empty
- \global\let\bFLOWexit \empty
- \global\let\lFLOWexit \empty
- \global\let\rFLOWexit \empty
- % commands
- \let\name \doFLOWname
- \let\shape \doFLOWshape
- \let\destination\doFLOWdestination
- \let\location \doFLOWlocation
- \let\focus \doFLOWfocus
- \let\overlay \doFLOWoverlay
- \let\figure \doFLOWfigure
- \let\text \doFLOWtext
- \let\comment \doFLOWcomment
- \let\label \doFLOWlabel
- \let\help \doFLOWhelp
- \let\connection \doFLOWconnection
- \let\exit \doFLOWexit
- % convenience commands
- \let\locate \doFLOWlocate
- \let\connect \doFLOWconnect}
-
-\let\FLOWcell \s!unknown
-\let\FLOWshape \s!unknown
-\let\FLOWdestination\s!unknown
-\let\FLOWfocus \s!unknown
-\let\FLOWoverlay \empty
-\let\FLOWtext \empty
-
-\def\doFLOWname#1%
- {\def\FLOWcell{#1}\setFLOWname\FLOWname{name_#1}\ignorespaces}
-
-\def\doFLOWshape#1%
- {\gdef\FLOWshape{#1}\ignorespaces}
-
-\def\doFLOWdestination#1%
- {\gdef\FLOWdestination{#1}\ignorespaces}
-
-\def\doFLOWlocation#1%
- {\setFLOWlocation#1\end\ignorespaces}
-
-\def\doFLOWfocus#1%
- {\gdef\FLOWfocus{#1}\ignorespaces}
-
-\def\doFLOWoverlay#1%
- {\gdef\FLOWoverlay{#1}\ignorespaces}
-
-\def\doFLOWfigure#1%
- {\defineoverlay[\s!dummy][\overlayfigure{#1}]%
- \overlay\s!dummy}
-
-\def\doFLOWtext
- {\dosingleempty\dodoFLOWtext}
-
-\def\dodoFLOWtext[#1]% % #2%
- {\gdef\FLOWalign{#1}\gdef\FLOWtext}% {#2}}
-
-\def\doFLOWcomment[#1]#2%
- {\ignorespaces\dogobblesingleempty}
-
-\def\doFLOWlabel[#1]#2% wordt dit gebruikt ?
- {\setgvalue{#1FLOWlabel}{#2}\ignorespaces}
-
-\def\doFLOWhelp#1%
- {\gdef\FLOWhelp{#1}\ignorespaces}
-
-\def\doFLOWconnection
- {\dodoubleempty\dodoFLOWconnection}
-
-\def\dodoFLOWconnection[#1][#2]#3%
- {\ignorespaces}
-
-\def\doFLOWconnect
- {\connection}
-
-\def\doFLOWlocate
- {\location}
-
-\def\doFLOWexit[#1]#2%
- {\setgvalue{#1FLOWexit}{#2}\ignorespaces}
-
-\def\startFLOWchart
- {\bgroup
- \let\stopFLOWchart\egroup
- \obeylines % lelijk, buffers nog eens fatsoeneren
- \dodoubleempty\dostartFLOWchart}
-
-\def\dostartFLOWchart[#1][#2]%
- {\preparenextFLOWchart{#1}{#2}%
- \dostartbuffer[\FLOWbufferprefix\nofFLOWcharts][startFLOWchart][stopFLOWchart]}
-
-\def\defineFLOWchart%
- {\dodoubleempty\dodefineFLOWchart}
-
-\long\def\dodefineFLOWchart[#1][#2]#3%
- {\preparenextFLOWchart{#1}{#2}%
- \setbuffer[\FLOWbufferprefix\nofFLOWcharts]#3\endbuffer}
-
-\def\preparenextFLOWchart#1#2%
- {\doglobal\increment\nofFLOWcharts
- \flowchart{#1}%
- \setxvalue{\@FLOW@-#1}{\noexpand\dohandleflowchart[\nofFLOWcharts][#2]}}
-
-\def\setupFLOWcharts{\dodoubleargument\getparameters[\@@FLOW]}
-\def\setupFLOWlines {\dodoubleargument\getparameters[\@@FLOL]}
-\def\setupFLOWshapes{\dodoubleargument\getparameters[\@@FLOS]}
-\def\setupFLOWfocus {\dodoubleargument\getparameters[\@@FLOF]}
-\def\setupFLOWsets {\dodoubleargument\getparameters[\@@FLOX]}
-
-\setupFLOWcharts
- [\c!option=,
- \c!bodyfont=,
- \c!dot=, % private option
- \c!width=12\bodyfontsize,
- \c!height=7\bodyfontsize,
- \c!maxwidth=,
- \c!maxheight=,
- \c!offset=\v!standard, % == auto offset
- \c!dx=2\bodyfontsize,
- \c!dy=2\bodyfontsize,
- \c!nx=0, % 1,
- \c!ny=0, % 1,
- \c!x=1,
- \c!y=1,
- \c!autofocus=,
- \c!focus=,
- \c!background=, % \v!color,
- \c!backgroundcolor=\s!white,
- \c!rulethickness=\linewidth,
- \c!frame=\v!off,
- \c!framecolor=]
-
-\setupFLOWlines
- [\c!corner=\v!round,
- \c!arrow=\v!yes,
- \c!dash=\v!no,
- \c!radius=.375\bodyfontsize, % 2.5\c!rulethickness
- \c!color=FLOWlinecolor,
- \c!rulethickness=.15\bodyfontsize, % 2pt,
- \c!offset=\v!none]
-
-\setupFLOWshapes
- [\c!default=action,
- \c!framecolor=FLOWframecolor,
- \c!background=\v!color,
- \c!backgroundcolor=FLOWbackgroundcolor,
- \c!backgroundscreen=\@@rsscreen,
- \c!rulethickness=.15\bodyfontsize, % 2pt,
- \c!offset=.5\bodyfontsize]
-
-\setupFLOWfocus
- [\c!framecolor=FLOWfocuscolor,
- \c!background=\@@FLOSbackground,
- \c!backgroundcolor=\@@FLOSbackgroundcolor,
- \c!backgroundscreen=\@@FLOSbackgroundscreen,
- \c!rulethickness=\@@FLOSrulethickness,
- \c!offset=\@@FLOSoffset]
-
-\definecolor [FLOWfocuscolor] [s=.2]
-\definecolor [FLOWlinecolor] [s=.5]
-\definecolor [FLOWframecolor] [s=.7]
-\definecolor [FLOWbackgroundcolor] [s=.9]
-
-\newcounter\includeFLOWx
-\newcounter\includeFLOWy
-
-\def\includeFLOWchart
- {\dodoubleempty\doincludeFLOWchart}
-
-\def\doincludeFLOWchart[#1][#2]%
- {\pushmacro\includeFLOWx
- \pushmacro\includeFLOWy
- \getparameters[FLOWi][x=1,y=1,#2]%
- \increment(\includeFLOWx,0\FLOWix)\decrement\includeFLOWx
- \increment(\includeFLOWy,0\FLOWiy)\decrement\includeFLOWy
- \def\dodoincludeFLOWchart##1%
- {\doifdefined{\@FLOW@-##1}
- {\globalpushmacro\dohandleflowchart % was local
- \gdef\dohandleflowchart[####1][####2]%
- {\globalpopmacro\dohandleflowchart % was local
- \resetFLOWlocation
- \processFLOWbuffer{####1}}%
- \getvalue{\@FLOW@-##1}}}%
- \processcommalist[#1]\dodoincludeFLOWchart
- \popmacro\includeFLOWx
- \popmacro\includeFLOWy}
-
-\def\resetFLOWlocation
- {\globallet\lastFLOWx\!!zerocount
- \globallet\lastFLOWy\!!zerocount}
-
-\def\dosetFLOWlocation[#1#2]#3#4%
- {\processaction
- [#1#2]
- [ +=>\scratchcounter\numexpr#4+ 1+#3\relax,
- -=>\scratchcounter\numexpr#4- 1+#3\relax,
- +#2=>\scratchcounter\numexpr#4+#2+#3\relax,
- -#2=>\scratchcounter\numexpr#4-#2+#3\relax,
- \s!default=>\scratchcounter\numexpr#4 +#3\relax,
- \s!unknown=>\scratchcounter\numexpr0#1#2+#3\relax]%
- \xdef#4{\the\scratchcounter}}
-
-\def\setFLOWlocation#1,#2\end
- {\dosetFLOWlocation[#1\empty]\includeFLOWx\lastFLOWx
- \dosetFLOWlocation[#2\empty]\includeFLOWy\lastFLOWy
- \xdef\FLOWlocation{\lastFLOWx,\lastFLOWy}}
-
-\def\FLOWshapes
- {node, action, procedure, product, decision, archive,
- loop, wait, subprocedure, singledocument, multidocument,
- sub procedure, single document, multi document, up, down,
- left, right}
-
-\def\FLOWlines
- {up, down, left, right}
-
-\def\FLOWsetconnect#1%
- {\donefalse
- \let\cFLOWfrom\empty
- \let\cFLOWto\empty
- \let\zFLOWfrom\!!zerocount
- \let\zFLOWto\!!zerocount
- \handletokens#1\with\doFLOWsetconnect
- \ifx\cFLOWto\empty\let\cFLOWfrom\empty\fi}
-
-\def\doFLOWsetconnect#1%
- {\ifx #1p%
- \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
- \else\ifx#1+%
- \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
- \else\ifx#1n%
- \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
- \else\ifx#1-%
- \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
- \else\ifdone
- \edef\cFLOWto{\FLOWconnector#1}%
- \else
- \edef\cFLOWfrom{\FLOWconnector#1}%
- \donetrue
- \fi\fi\fi\fi\fi}
-
-\def\FLOWconnector#1%
- {\if#1bbottom\else\if#1ttop\else\if#1lleft\else\if#1rright\fi\fi\fi\fi}
-
-\newif\ifFLOWscaling \FLOWscalingtrue
-
-\def\@@FLOW@@offset{\@@FLOWoffset}
-
-\def\getFLOWchart
- {\dodoubleempty\dogetFLOWchart}
-
-\def\dogetFLOWchart[#1][#2]%
- {\doifundefinedelse{\@FLOW@-#1}
- {\writestatus{FLOW}{unknown chart #1}%
- \framed
- [\c!width=12\bodyfontsize,\c!height=8\bodyfontsize]
- {\tttf [chart #1]}}
- {\dodogetFLOWchart[#1][#2]}}
-
-\def\dodogetFLOWchart[#1][#2]% to be split a bit more
- {\vbox\bgroup
- \insidefloattrue
- \forgetall
- \dontcomplain
- % \offinterlineskip % we now explicitly use \nointerlineskip later on
- \def\dohandleflowchart[##1][##2]%
- {\def\currentFLOWnumber{##1}%
- \getparameters[\@@FLOW][##2]}%
- \getvalue{\@FLOW@-#1}%
- \getparameters[\@@FLOW][#2]% dubbelop ?
- \doifsomething{\@@FLOWautofocus}
- {\checkFLOWautofocus}%
- %\message{AUTOSHAPE 3: (\@@FLOWx,\@@FLOWy)->(\@@FLOWnx,\@@FLOWny)}\wait
- \global\let\FLOWwidth \@@FLOWnx
- \global\let\FLOWheight\@@FLOWny
- \let\startFLOWcell\startFLOWcellA
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \ifcase\@@FLOWnx\relax \let\@@FLOWnx\FLOWwidth \fi
- \ifcase\@@FLOWny\relax \let\@@FLOWny\FLOWheight \fi
- \doifnothing{\@@FLOWmaxwidth\@@FLOWmaxheight}{\FLOWscalingfalse}%
- \ifFLOWscaling
- \doifnothing{\@@FLOWmaxwidth }{\let\@@FLOWmaxwidth \maxdimen}%
- \doifnothing{\@@FLOWmaxheight}{\let\@@FLOWmaxheight\maxdimen}%
- \scratchcounter\bodyfontpoints
- \doloop % NOG FONTSWITCH OM EX EN EM TE LATEN WERKEN
- {\ifnum\scratchcounter>1 % NU DIMENSIONS IN TERMS OF BODYFONTSIZE
- \bodyfontsize=\the\scratchcounter pt
- \dimen0=\@@FLOWmaxwidth
- \dimen2=\@@FLOWwidth
- \dimen4=\@@FLOWdx
- \advance\dimen2 2\dimen4
- \dimen2=\@@FLOWnx\dimen2
- \advance\dimen2 2\dimen4
- \ifdim\dimen2>\dimen0
- \advance\scratchcounter \minusone
- \else
- \dimen0=\@@FLOWmaxheight
- \dimen2=\@@FLOWheight
- \dimen4=\@@FLOWdy
- \advance\dimen2 2\dimen4
- \dimen2=\@@FLOWny\dimen2
- \advance\dimen2 2\dimen4
- \ifdim\dimen2>\dimen0
- \advance\scratchcounter \minusone
- \else
- \exitloop
- \fi
- \fi
- \else
- \exitloop
- \fi}%
- \expanded{\switchtobodyfont[\the\scratchcounter pt]}%
- \forgetall
- % \offinterlineskip % needed ?
- \else\ifx\@@FLOWbodyfont\empty\else
- \expanded{\switchtobodyfont[\@@FLOWbodyfont]}% \expanded ?
- \fi\fi
- \global\let\FLOWcells\empty
- \dimen0=\@@FLOWwidth
- \edef\FLOWshapewidth{\the\dimen0}%
- \dimen2=\@@FLOWdx
- \advance\dimen0 2\dimen2
- \edef\FLOWgridwidth{\the\dimen0}%
- \dimen0=\@@FLOWheight
- \edef\FLOWshapeheight{\the\dimen0}%
- \dimen2=\@@FLOWdy
- \advance\dimen0 2\dimen2
- \edef\FLOWgridheight{\the\dimen0}%
- \scratchdimen=\@@FLOSrulethickness
- \edef\@@FLOSrulethickness{\the\scratchdimen}%
- \scratchdimen=\@@FLOFrulethickness
- \edef\@@FLOFrulethickness{\the\scratchdimen}%
- \scratchdimen=\@@FLOLrulethickness
- \edef\@@FLOLrulethickness{\the\scratchdimen}%
- \ifdim\@@FLOLradius<2.5\scratchdimen
- \scratchdimen=2.5\scratchdimen
- \edef\@@FLOLradius{\the\scratchdimen}%
- \ifdim\@@FLOLradius>\@@FLOWdx
- \scratchdimen=\@@FLOWdx
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \ifdim\@@FLOLradius>\@@FLOWdy
- \scratchdimen=\@@FLOWdy
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \else
- \scratchdimen=\@@FLOLradius
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \processaction % magic 2.5
- [\@@FLOWoffset]
- [ \v!none=>\scratchdimen=-2.5\scratchdimen,
- \v!overlay=>\scratchdimen=-2.5\scratchdimen,
- \v!standard=>\scratchdimen=\scratchdimen,
- \s!unknown=>\scratchdimen=\@@FLOWoffset,
- \s!default=>\scratchdimen=-2.5\scratchdimen]%
- \edef\@@FLOW@@offset{\the\scratchdimen}%
- \forgetall
- \offinterlineskip
- \resetMPdrawing
- \doglobal\newcounter\FLOWcomment
- \startMPdrawing
- if unknown context_char : input mp-char.mp ; fi ;
- grid_width := \FLOWgridwidth ;
- grid_height := \FLOWgridheight ;
- shape_width := \FLOWshapewidth ;
- shape_height := \FLOWshapeheight ;
- connection_line_width := \@@FLOLrulethickness ;
- connection_smooth_size := \@@FLOLradius ;
- connection_arrow_size := \@@FLOLradius ;
- connection_dash_size := \@@FLOLradius ;
- currentpicture := nullpicture ;
- begin_chart(0,\FLOWwidth,\FLOWheight);
- reverse_y := true ;
- chart_offset := \@@FLOW@@offset ;
- \stopMPdrawing
- \doifelsenothing\@@FLOWbackgroundcolor
- {\startMPdrawing
- chart_background_color := white ;
- \stopMPdrawing}
- {\startMPdrawing
- chart_background_color := \MPcolor{\@@FLOWbackgroundcolor} ;
- \stopMPdrawing}%
- \doif\@@FLOWoption\v!test
- {\startMPdrawing
- show_con_points := true ;
- show_mid_points := true ;
- show_all_points := true ;
- \stopMPdrawing}%
- \processaction % private
- [\@@FLOWdot]
- [ \v!yes=>\startMPdrawing
- show_con_points := true ;
- show_mid_points := true ;
- show_all_points := true ;
- \stopMPdrawing,
- \s!unknown=>\startMPdrawing
- show_\@@FLOWdot_points := true ;
- \stopMPdrawing]%
-\doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellB
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
-\doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellC
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \startMPdrawing
- clip_chart(\@@FLOWx,\@@FLOWy,\@@FLOWnx,\@@FLOWny) ;
- end_chart ;
- \stopMPdrawing
- \MPdrawingdonetrue
- \setbox0\hbox
- {\MPstaticgraphictrue
- \MPshiftdrawingfalse
- \getMPdrawing}%
- \def\MPmessage##1%
- {\writestatus{MP charts}{##1}}%
- \def\MPposition##1##2##3%
- {\setvalue{\@@MPx##1}{##2}\setvalue{\@@MPy##1}{##3}}%
- \def\MPclippath##1##2##3##4%
- {\def\clipMPllx{##1bp}\def\clipMPlly{##2bp}%
- \def\clipMPurx{##3bp}\def\clipMPury{##4bp}}%
- \def\MPareapath##1##2##3##4%
- {\def\areaMPllx{##1bp}\def\areaMPlly{##2bp}%
- \def\areaMPurx{##3bp}\def\areaMPury{##4bp}}%
- \getMPdata
- \doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellD
- \setbox2\vbox to \ht0
- {\forgetall % \offinterlineskip
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber\vss}%
- \setbox2\hbox
- {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box2}%
- \wd2\wd0\ht2\ht0\dp2\dp0
- \let\startFLOWcell\startFLOWcellE
- \setbox4\vbox to \ht0
- {\forgetall % \offinterlineskip
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber\vss}%
- \setbox4\hbox
- {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box4}%
- \wd4\wd0\ht4\ht0\dp4\dp0
- \doifelse\@@FLOWoption\v!test
- {\setbox6\vbox
- {\forgetall
- \vskip\@@FLOW@@offset
- \hskip\@@FLOW@@offset
- \basegrid
- [\c!x=\@@FLOWx,\c!nx=\@@FLOWnx,\c!dx=\withoutpt\FLOWgridwidth,
- \c!y=\@@FLOWy,\c!ny=\@@FLOWny,\c!dy=\withoutpt\FLOWgridheight,
- \c!xstep=1,\c!ystep=1,
- \c!unit=pt,\c!location=\v!middle]}%
- \wd6\wd0\ht6\ht0\dp6\dp0
- \setbox8\vbox
- {\forgetall
- \offinterlineskip
- \vskip\@@FLOW@@offset
- \dostepwiserecurse\@@FLOWy\@@FLOWny\plusone
- {\vbox to \FLOWgridheight
- {\vfill
- \hskip\@@FLOW@@offset
- \hbox
- {\dostepwiserecurse\@@FLOWx\@@FLOWnx\plusone
- {\hbox to \FLOWgridwidth
- {\hfill
- \framed
- [\c!framecolor=red,
- \c!width=\FLOWshapewidth,
- \c!height=\FLOWshapeheight]
- {}%
- \hfill}}}
- \vfill}}}%
- \wd8\wd0\ht8\ht0\dp8\dp0
- \framed
- [\c!offset=\v!overlay,\c!framecolor=green]
- {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2\hskip-\wd6\box6\hskip-\wd8\box8}}}
- {\framed
- [\c!offset=\v!overlay,
- \c!frame=\@@FLOWframe,
- \c!rulethickness=\@@FLOWrulethickness,
- \c!framecolor=\@@FLOWframecolor,
- \c!background=\@@FLOWbackground,
- \c!backgroundcolor=\@@FLOWbackgroundcolor]
- {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2}}}%
- %\message{[\FLOWcells]}\wait
- \egroup}
-
-% Pass A
-
-\long\def\startFLOWcellA#1\stopFLOWcell%
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \expandafter\getFLOWlocationA\FLOWlocation\end
- \ignorespaces}
-
-\def\getFLOWlocationA#1,#2\end
- {\ifnum0#1>\FLOWwidth \xdef\FLOWwidth {#1}\fi
- \ifnum0#2>\FLOWheight\xdef\FLOWheight{#2}\fi}
-
-% Pass B
-%
-% beware: the - after \@FLOC@ is needed since name can be
-% empty and we don't want to redefine \@FLOC@ itself by
-% mistake
-
-\long\def\startFLOWcellB#1\stopFLOWcell
- {\resetFLOWcell\ignorespaces#1\unskip
- \setxvalue{\@FLOC@-\FLOWname}{\FLOWlocation}% kost veel cs's
- \ifx\FLOWshape\empty
- \global\let\FLOWshape\@@FLOSdefault
- \fi
- \doifnot\FLOWshape{none} % {\v!none}
- {\ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWshapes}
- {\edef\FLOWshapetag{shape_\FLOWshape}% beter \expanded
- \@EA\setFLOWname\@EA\FLOWshapetag\@EA{\FLOWshapetag}}
- {\doifnumberelse\FLOWshape
- {\let\FLOWshapetag\FLOWshape}
- {\let\FLOWshapetag\empty}}%
- \ifx\FLOWshapetag\empty \else
- \ExpandBothAfter\doifinsetelse{\FLOWshape}{\FLOWlines}
- {\chardef\FLOWstate0 }
- {\ExpandBothAfter\doifcommonelse{\FLOWcell,\FLOWfocus}{\@@FLOWfocus}
- {\chardef\FLOWstate1 }
- {\chardef\FLOWstate2 }}%
- \startMPdrawing
- begin_sub_chart ;
- \ifcase\FLOWstate
- shape_line_color := \MPcolor{\@@FLOLcolor} ;
- shape_fill_color := \MPcolor{\@@FLOLcolor} ;
- shape_line_width := \@@FLOLrulethickness ;
- \or
- shape_line_color := \MPcolor{\@@FLOFframecolor} ;
- shape_fill_color := \MPcolor{\@@FLOFbackgroundcolor} ;
- shape_line_width := \@@FLOFrulethickness ;
- \or
- shape_line_color := \MPcolor{\@@FLOSframecolor} ;
- shape_fill_color := \MPcolor{\@@FLOSbackgroundcolor} ;
- shape_line_width := \@@FLOSrulethickness ;
- \fi
- %\ifx\FLOWoverlay\empty
- % peepshape := false ;
- %\else
- % peepshape := true ;
- %\fi
- peepshape := \ifx\FLOWoverlay\empty false \else true \fi ;
- new_shape(\FLOWlocation,\FLOWshapetag) ;
- end_sub_chart ;
- \stopMPdrawing
- \fi}%
- \ignorespaces}
-
-% Pass C
-
-\long\def\startFLOWcellC#1\stopFLOWcell%
- {\resetFLOWcell
-\pushmacro\lastFLOWx
-\pushmacro\lastFLOWy
- \ignorespaces#1\unskip % makes sure that vars are set
-\popmacro\lastFLOWy
-\popmacro\lastFLOWx
- \let\connection\doFLOWconnectionC
- \ignorespaces#1\unskip}
-
-\def\FLOWorigin{0,0}
-
-\def\doFLOWdisplace[#1,#2,#3]% experiment
- {dsp_x := #1 ; dsp_y := #2 ;}
-
-\def\doFLOWconnectionC
- {\dodoubleempty\dodoFLOWconnectionC}
-
-\def\dodoFLOWconnectionC[#1][#2]#3%
- {\doglobal\increment\FLOWcomment
- \setFLOWname\otherFLOWname{name_#3}%
- \doifdefinedelse{\@FLOC@-\FLOWname}
- {\edef\FLOWfrom{\getvalue{\@FLOC@-\FLOWname}}}
- {\let \FLOWfrom \FLOWorigin}%
- \ifx\FLOWfrom\FLOWorigin \else
- \doifdefinedelse{\@FLOC@-\otherFLOWname}
- {\edef\FLOWto {\getvalue{\@FLOC@-\otherFLOWname}}}
- {\let \FLOWto \FLOWorigin}%
- \ifx\FLOWto\FLOWorigin \else
- \FLOWsetconnect{#1}%
- \ifx\cFLOWfrom\empty \else
- \doifelse\@@FLOLcorner\v!round
- {\startMPdrawing smooth := true ; \stopMPdrawing}
- {\startMPdrawing smooth := false ; \stopMPdrawing}%
- \doifelse\@@FLOLdash\v!yes
- {\startMPdrawing dashline := true ; \stopMPdrawing}
- {\startMPdrawing dashline := false ; \stopMPdrawing}%
- \doifelse\@@FLOLarrow\v!yes
- {\startMPdrawing arrowtip := true ; \stopMPdrawing}
- {\startMPdrawing arrowtip := false ; \stopMPdrawing}%
- \doifelse\@@FLOLoffset\v!none
- {\startMPdrawing touchshape := true ; \stopMPdrawing}
- {\startMPdrawing touchshape := false ; \stopMPdrawing}%
-%\doifsomething{#2}
-% {\startMPdrawing
-% \doFLOWdisplace[0#2,0,0]%
-% \stopMPdrawing}%
- \startMPdrawing
-\doFLOWdisplace[0#2,0,0]%
- connection_line_color := \MPcolor{\@@FLOLcolor} ;
- connection_line_width := \@@FLOLrulethickness ;
- connect_\cFLOWfrom_\cFLOWto (\FLOWfrom,\zFLOWfrom) (\FLOWto,\zFLOWto) ;
-\doFLOWdisplace[0,0,0]%
- \stopMPdrawing
- \fi
- \fi
- \fi
- \ignorespaces}
-
-% Pass D
-
-\long\def\startFLOWcellD#1\stopFLOWcell
- {\resetFLOWcell
-\pushmacro\lastFLOWx
-\pushmacro\lastFLOWy
- \ignorespaces#1\unskip % presets vars
-\popmacro\lastFLOWy
-\popmacro\lastFLOWx
- \let\doprocessFLOWcell\doprocessFLOWcellD
- \expandafter\doprocessFLOWcellD\FLOWlocation\end
- \let\connection\doFLOWconnectionD
- \let\comment\doFLOWcommentD
- \ignorespaces#1\unskip\ignorespaces}
-
-\def\doFLOWconnectionD
- {\dodoubleempty\dodoFLOWconnectionD}
-
-\def\dodoFLOWconnectionD[#1][#2]#3%
- {\doglobal\increment\FLOWcomment
- \ignorespaces}
-
-\def\doFLOWcommentD[#1]#2%
- {\bgroup
- \let\FLOW \middlebox
- \let\FLOWb \bottombox
- \let\FLOWbl\bottomleftbox
- \let\FLOWbr\bottomrightbox
- \let\FLOWt \topbox
- \let\FLOWtl\topleftbox
- \let\FLOWtr\toprightbox
- \let\FLOWl \leftbox
- \let\FLOWlt\lefttopbox
- \let\FLOWlb\leftbottombox
- \let\FLOWr \rightbox
- \let\FLOWrt\righttopbox
- \let\FLOWrb\rightbottombox
- \let\FLOWc \middlebox
-%\ifdefined{FLOW#1}%
- \ifcase0\getvalue{\@@MPx\FLOWcomment}\getvalue{\@@MPy\FLOWcomment}\relax
- \else
- \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp<\areaMPllx\relax\else
- \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp>\areaMPurx\relax\else
- \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp<\areaMPlly\relax\else
- \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp>\areaMPury\relax\else
- \dimen0=\getvalue{\@@MPx\FLOWcomment}\s!bp
- \advance\dimen0 -\@@FLOW@@offset
- \advance\dimen0 -\clipMPllx
- \dimen2=\clipMPury
- \advance\dimen2 -\@@FLOW@@offset
- \advance\dimen2 -\getvalue{\@@MPy\FLOWcomment}\s!bp
- \setbox\scratchbox\hbox{\strut#2}%
- \boxoffset.5\bodyfontsize
- \setbox\scratchbox\hbox{\hskip\dimen0\lower\dimen2\getvalue{FLOW#1}{\box\scratchbox}}%
- \smashbox\scratchbox
- \box\scratchbox
- \boxoffset\zeropoint
- \nointerlineskip % really needed
- \fi
- \fi
- \fi
- \fi
- \fi
-%\fi
- \egroup
- \ignorespaces}
-
-% pass D
-
-\def\dophaseoneFLOWcellX#1#2%
- {\!!counta#1\relax
- \!!countb#2\relax
- \!!countc\@@FLOWx
- \!!countd\@@FLOWy
- \advance\!!countc \@@FLOWnx
- \advance\!!countd \@@FLOWny
- \advance\!!countc \minusone
- \advance\!!countd \minusone
- \ifnum\!!counta<\@@FLOWx\relax \donefalse
- \else\ifnum\!!counta>\!!countc \donefalse
- \else\ifnum\!!countb<\@@FLOWy\relax \donefalse
- \else\ifnum\!!countb>\!!countd \donefalse
- \else \donetrue
- \fi\fi\fi\fi}
-
-\def\dophasetwoFLOWcellX
- {\advance\!!counta -\@@FLOWx
- \advance\!!counta \plusone
- \advance\!!countb -\@@FLOWy
- \advance\!!countb \plusone
- \dimen0=\FLOWgridwidth
- \dimen0=\!!counta\dimen0
- \advance\dimen0 -\FLOWgridwidth
- \dimen4=\FLOWgridwidth
- \advance\dimen4 -\FLOWshapewidth
- \advance\dimen0 .5\dimen4
- \dimen2=\FLOWgridheight
- \dimen2=\!!countb\dimen2
- \dimen4=\FLOWgridheight
- \advance\dimen4 -\FLOWshapeheight
- \advance\dimen2 -.5\dimen4
- \edef\FLOWdx{\the\dimen0}%
- \edef\FLOWdy{\the\dimen2}}
-
-\def\positionFLOWzero% assumes \FLOWdx and \FLOWdy are set
- {\setbox0\hbox{\hskip\FLOWdx\lower\FLOWdy\box0}%
- \smashbox0\box0
- \nointerlineskip} % new, needed since we somehow reset that
-
-\def\doFLOWtlabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
- \setbox0\hbox{\hskip\dimen2\raise\scratchdimen
- \hbox{\raise\dimen4\hbox{#1{\strut#3}}}}%
- \positionFLOWzero}%
-
-\def\doFLOWblabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
- \setbox0\hbox{\hskip\dimen2\raise-\scratchdimen
- \hbox{#1{\strut#3}}}%
- \positionFLOWzero}%
-
-\def\doFLOWllabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
- \setbox0\hbox{\hskip-\scratchdimen\raise\dimen6
- \hbox{#1{\strut#3}}}%
- \positionFLOWzero}%
-
-\def\doFLOWrlabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
- \setbox0\hbox{\hskip\dimen0\hskip\scratchdimen
- \hbox{\raise\dimen6\hbox{#1{\strut#3}}}}%
- \positionFLOWzero}
-
-\def\doprocessFLOWcellD#1,#2\end
- {\dophaseoneFLOWcellX{#1}{#2}%
- \ifdone
- \dophasetwoFLOWcellX
- \doglobal\addtocommalist\FLOWcell\FLOWcells
- \def\FLOWx{#1}%
- \def\FLOWy{#2}%
- \directsetup{flowcell}%
- \setbox0\hbox
- {\ifx\FLOWalign\empty\else
- \setupframed
- [\c!align=\v!normal,\c!bottom=\vfill,\c!top=\vfill]%
- \@EA\processallactionsinset\@EA
- [\FLOWalign]
- [t=>{\setupframed[\c!bottom=\vfill,\c!top=]},
- b=>{\setupframed[\c!bottom=,\c!top=\vfill]},
- l=>{\setupframed[\c!align=\v!right]},
- r=>{\setupframed[\c!align=\v!left]},
- m=>{\setupframed[\c!align=\v!middle]},
- c=>{\setupframed[\c!align=\v!middle]}]%
- \fi
- \doifelse\FLOWshape{none} % {\v!none}
- {\setupframed[\c!offset=\v!overlay]}
- {\setupframed[\c!offset=\@@FLOSoffset]}%
- \framed
- [\c!frame=\v!off,\c!background=flowcell,
- \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
- {\FLOWtext}}%
- \showFLOWhelp0
- \ifx\FLOWdestination\empty\else
- \setbox0\hbox
- {\setupinteraction[\c!color=,\c!contrastcolor=]%
- \gotobox{\box0}[\FLOWdestination]}%
- \fi
- \positionFLOWzero
- \dimen0=\FLOWshapewidth \dimen2=.5\dimen0
- \dimen4=\FLOWshapeheight\dimen6=.5\dimen4
- \boxoffset.5\bodyfontsize
- \doFLOWtlabel \righttopbox0\tFLOWlabel
- \doFLOWblabel\rightbottombox0\bFLOWlabel
- \doFLOWllabel \lefttopbox0\lFLOWlabel
- \doFLOWrlabel \righttopbox0\rFLOWlabel
- \doFLOWtlabel \topbox0\tcFLOWlabel % for me only
- \doFLOWblabel \bottombox0\bcFLOWlabel % for me only
- \doFLOWllabel \leftbox0\lcFLOWlabel % for me only
- \doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
- \ifnum#1=\@@FLOWx\relax \doFLOWllabel \leftbox1\lFLOWexit \fi
- \ifnum#1=\!!countc \doFLOWrlabel \rightbox1\rFLOWexit \fi
- \ifnum#2=\@@FLOWy\relax \doFLOWtlabel \topbox1\tFLOWexit \fi
- \ifnum#2=\!!countd \doFLOWblabel \bottombox1\bFLOWexit \fi
- \boxoffset\zeropoint
- \fi}
-
-% For Willy Egger:
-%
-% \startsetups flowcell
-% \definelayer
-% [flowcell]
-% [width=\FLOWshapewidth,
-% height=\FLOWshapeheight]
-% \setlayerframed
-% [flowcell]
-% [preset=rightbottom,offset=1ex]
-% [frame=off]
-% {\tx(\FLOWx,\FLOWy)}
-% \stopsetups
-
-% Pass E
-
-\long\def\startFLOWcellE#1\stopFLOWcell
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \let\doprocessFLOWcell\doprocessFLOWcellE
- \expandafter\doprocessFLOWcell\FLOWlocation\end}
-
-\def\doprocessFLOWcellE#1,#2\end % redundant
- {\ifx\FLOWoverlay\empty \else
- \dophaseoneFLOWcellX{#1}{#2}%
- \ifdone
- \dophasetwoFLOWcellX
- \edef\FLOWdx{\the\dimen0}%
- \edef\FLOWdy{\the\dimen2}%
- \setbox0\hbox
- {\framed
- [%\c!frame=\v!off,
- \c!background={\@@FLOWbackground,\FLOWoverlay},
- \c!backgroundcolor=\@@FLOSbackgroundcolor,
- \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
- {}}%
- \positionFLOWzero
- \fi
- \fi}
-
-% Pass F
-
-\def\checkFLOWautofocus
- {\def\@@FLOWminx{100}\let\@@FLOWminy\@@FLOWminx
- \def\@@FLOWmaxx {0}\let\@@FLOWmaxy\@@FLOWmaxx
- \def\@@FLOWabsx {0}\let\@@FLOWabsy\@@FLOWabsx
- \let\startFLOWcell\startFLOWcellF
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- %\message{AUTOSHAPE 1: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
- \ifnum\@@FLOWabsx<\@@FLOWmaxx\let\@@FLOWmaxx\@@FLOWabsx\fi
- \ifnum\@@FLOWabsy<\@@FLOWmaxy\let\@@FLOWmaxy\@@FLOWabsy\fi
- %\message{AUTOSHAPE 2: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
- \donetrue
- \ifnum\@@FLOWminx=100 \donefalse\fi
- \ifnum\@@FLOWminy=100 \donefalse\fi
- \ifnum\@@FLOWmaxx=0 \donefalse\fi
- \ifnum\@@FLOWmaxy=0 \donefalse\fi
- \doFLOWcheckF\@@FLOWx\@@FLOWminx\@@FLOWmaxx\@@FLOWnx
- \doFLOWcheckF\@@FLOWy\@@FLOWminy\@@FLOWmaxy\@@FLOWny}
-
-\def\startFLOWcellF#1\stopFLOWcell%
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \expandafter\doFLOWlocationF\FLOWlocation\end}%
-
-\def\doFLOWlocationF#1,#2\end%
- {\ifnum#1>\@@FLOWabsx\def\@@FLOWabsx{#1}\fi
- \ifnum#2>\@@FLOWabsy\def\@@FLOWabsy{#2}\fi
- \ExpandBothAfter\doifinset{\FLOWcell}{\@@FLOWautofocus}
- {\dodoFLOWlocationF{#1}<-\@@FLOWminx
- \dodoFLOWlocationF{#1}>+\@@FLOWmaxx
- \dodoFLOWlocationF{#2}<-\@@FLOWminy
- \dodoFLOWlocationF{#2}>+\@@FLOWmaxy}}
-
-\def\dodoFLOWlocationF#1#2#3#4%
- {\ifnum#1#2#4\relax
- \!!counta=#1\advance\!!counta #31\relax
- \edef#4{\ifnum\!!counta<1 1\else\the\!!counta\fi}%
- \fi}
-
-\def\doFLOWcheckF#1#2#3#4%
- {\ifdone
- \let#1=#2%
- \!!counta=#3%
- \advance\!!counta \plusone\advance\!!counta -#2\relax
- \ifnum\!!counta<1 \!!counta=1 \fi
- \edef#4{\the\!!counta}%
- \else
- \let#1\!!plusone
- \let#4\!!zerocount % no {1}
- \fi}
-
-% \useFLOWchart[name][parent][setting,setting][additional settings]
-% \useFLOWchart[name][parent][additional settings]
-
-\let\currentFLOWchart\empty
-
-\def\useFLOWchart
- {\doquadrupleempty\douseFLOWchart}
-
-\def\douseFLOWchart[#1][#2][#3][#4]% name parent sets mainsettings
- {\iffourthargument
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][#4,##1]}%
- \else
- \checkparameters[#3]%
- \ifparameters
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][][#3,##1]}%
- \else
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][##1]}%
- \fi
- \fi}
-
-\def\setgetFLOWchart[#1][#2][#3]%
- {\def\docommand##1{}% cell line focus ?
- \processcommalist[#2]\docommand
- \getFLOWchart[#1][#3]}
-
-\def\doFLOWchart[#1][#2]%
- {\hbox\bgroup\vbox\bgroup % vmode suppresses spaces
-\def\currentFLOWchart{#1}%
- \doifundefinedelse{\@FLOW@--#1}
- {\getFLOWchart[#1][#2]}
- {\getvalue{\@FLOW@--#1}[#2]}%
- \egroup\egroup}
-
-\def\FLOWchart%
- {\dodoubleempty\doFLOWchart}
-
-%D A hook into the help system.
-
-\def\showFLOWhelp#1%
- {\doifhelpinfo\FLOWhelp
- {\setbox#1=\hbox
- {\setbox\scratchbox=\hbox{\lower\@@FLOWdy\hbox
- {\helpbutton
- [\c!width=\wd0,\c!color=,\c!height=\@@FLOWdy,\c!frame=\v!no]%
- [\FLOWhelp]}}%
- \smashbox\scratchbox
- \setbox#1=\vbox
- {\forgetall\offinterlineskip\box#1\box\scratchbox}%
- \box#1}}}
-
-%D The next section is dedicated to splitting up charts.
-
-\def\getFLOWsize[#1]%
- {\bgroup\let\dodogetFLOWchart\dogetFLOWsize\FLOWchart[#1]\egroup}
-
-\def\dogetFLOWsize[#1][#2]%
- {\setbox\scratchbox=\vbox
- {\globallet\FLOWmaxwidth \!!zerocount
- \globallet\FLOWmaxheight\!!zerocount
- \def\getFLOWlocation##1,##2\end
- {\ifnum0##1>\FLOWmaxwidth \xdef\FLOWmaxwidth {##1}\fi
- \ifnum0##2>\FLOWmaxheight\xdef\FLOWmaxheight{##2}\fi}%
- \resetFLOWcell
- \long\def\startFLOWcell##1\stopFLOWcell
- {{##1\expandafter\getFLOWlocation\FLOWlocation\end}}%
- \def\dohandleflowchart[##1][##2]%
- {\resetFLOWlocation
- \processFLOWbuffer{##1}}%
- \getvalue{\@FLOW@-#1}}}
-
-\def\setupFLOWsplit%
- {\dodoubleargument\getparameters[\@@FLOT]}
-
-\setupFLOWsplit%
- [\c!nx=3,\c!ny=3,
- \c!dx=1,\c!dy=1,
- \c!command=,
- \c!marking=\v!on,
- \c!before=,\c!after=]
-
-\def\FLOWsplitx {1}
-\def\FLOWsplity {1}
-\def\FLOWsplitnx{1}
-\def\FLOWsplitny{1}
-
-\def\FLOWcharts%
- {\dodoubleempty\doFLOWcharts}
-
-%D While splitting, the following variables are available:
-%D
-%D \starttyping
-%D \FLOWsplitnx \FLOWsplitny \FLOWsplitx \FLOWsplity
-%D \stoptyping
-
-\def\doFLOWcharts[#1][#2]%
- {\bgroup
- \getFLOWsize[#1]%
- \dodoFLOWcharts\relax
- \global\let\FLOWsplitnx\FLOWsplitx
- \global\let\FLOWsplitny\FLOWsplity
- \dodoFLOWcharts{\dododoFLOWcharts[#1][#2]}%
- \egroup}
-
-\def\dodoFLOWcharts#1%
- {\def\@@FLOTx{1}%
- \global\let\FLOWsplitx\@@FLOTx
- \doloop
- {\def\@@FLOTy{1}%
- \global\let\FLOWsplity\@@FLOTy
- \doloop
- {\bgroup
- \scratchcounter\FLOWmaxwidth
- \advance\scratchcounter -\@@FLOTx
- \advance\scratchcounter \plusone
- \ifnum\scratchcounter<\@@FLOTnx\edef\@@FLOTnx{\the\scratchcounter}\fi
- \scratchcounter\FLOWmaxheight
- \advance\scratchcounter -\@@FLOTy
- \advance\scratchcounter \plusone
- \ifnum\scratchcounter<\@@FLOTny\edef\@@FLOTny{\the\scratchcounter}\fi
- #1% does something with the float, or not
- \egroup
- \increment(\@@FLOTy,\@@FLOTny)%
- \ifnum\@@FLOTy>\FLOWmaxheight
- \exitloop
- \else
- \doglobal\increment\FLOWsplity
- \decrement(\@@FLOTy,\@@FLOTdy)%
- \fi}%
- \increment(\@@FLOTx,\@@FLOTnx)%
- \ifnum\@@FLOTx>\FLOWmaxwidth
- \exitloop
- \else
- \doglobal\increment\FLOWsplitx
- \decrement(\@@FLOTx,\@@FLOTdx)%
- \fi}}
-
-\def\dododoFLOWcharts[#1][#2]%
- {\bgroup
- \@@FLOTbefore
- \doifnot\@@FLOTmarking\v!on{\let\cuthbox\hbox}%
- \cuthbox
- {\@@FLOTcommand
- {\FLOWchart[#1][#2,
- \c!x=\@@FLOTx,\c!nx=\@@FLOTnx,
- \c!y=\@@FLOTy,\c!ny=\@@FLOTny]}}%
- \@@FLOTafter
- \egroup}
-
-%D An example of splitting is given below:
-%D
-%D \starttyping
-%D \setupFLOWsplit
-%D [nx=5,ny=10,
-%D dx=0,dy=0,
-%D before=,
-%D after=\page]
-%D
-%D \FLOWcharts[mybigflow]
-%D \stoptyping
-%D
-%D Or, one can say:
-%D
-%D \starttyping
-%D \splitfloat
-%D {\placefigure{What a big flowchart this is!}}
-%D {\FLOWcharts[mybigflow]}
-%D \stoptyping
-
-%D \macros
-%D {typeFLOWchart}
-%D
-%D For documentation purposes the following macro is
-%D provided. Watch the use of the first and last line hooks,
-%D which is needed because the start and stop commands are
-%D not part of the buffer.
-
-\def\typeFLOWchart[#1]%
- {\bgroup
- \def\dohandleflowchart[##1][##2]{\typeFLOWbuffer{##1}}%
- \defconvertedargument\firstverbatimfileline{\startFLOWchart[#1]}%
- \defconvertedargument\lastverbatimfileline {\stopFLOWchart}%
- \getvalue{\@FLOW@-#1}
- \egroup}
-
-%D New:
-%D
-%D \starttyping
-%D \setupFLOWcharts[command=\Whow]
-%D
-%D \startFLOWset[convert-en] % [tag][convert-en]
-%D \subFLOWchart[a][x=1,y=1,nx=3,ny=3]
-%D \subFLOWchart[b][x=1,y=2,nx=3,ny=3]
-%D \subFLOWchart[c][x=2,y=1,nx=3,ny=3]
-%D \stopFLOWset
-%D
-%D \def\Whow#1%
-%D {\ifnum\currentFLOWset=1 \framed{Some Chart}\fi}
-%D
-%D \FLOWset[convert-en] % [tag]
-%D
-%D \def\Whow#1%
-%D {\setuphead[state=high]
-%D \startstandardmakeup
-%D \centerbox{#1}
-%D \stopstandardmakeup}
-%D
-%D \FLOWset[convert-en] % [tag]
-%D \stoptyping
-
-\def\startFLOWset
- {\dodoubleempty\dostartFLOWset}
-
-\def\dostartFLOWset[#1][#2]#3\stopFLOWset % tag name data
- {\ifsecondargument
- \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#2}{#3}}%
- \else
- \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#1}{#3}}%
- \fi}
-
-\long\def\dohandleFLOWset#1#2#3% tag name data
- {\bgroup
- \def\subFLOWchart
- {\dodoubleempty\dosubFLOWchart}%
- \def\dosubFLOWchart[##1][##2]% subtag settings
- {\ifsecondargument
- \dodohandleFLOWset{#1}{##1}{#2}{##2}%
- \else
- \subFLOWchart[][##1]%
- \fi}%
- #3%
- \egroup}
-
-\def\dodohandleFLOWset#1#2#3#4% tag subtag name settings
- {\increment\currentFLOWset
- \bgroup
- \@@FLOXcommand
- {\ifnum\currentFLOWset=1 \pagereference[#1]\fi
- \doifsomething{#2}
- {\setupreferencing[\c!prefix=]%
- \pagereference[#1:#2]% -:#1:#2
- \setupreferencing[\c!prefix=#1:#2]}%
- \FLOWchart[#3][#4]}%
- \egroup}
-
-\def\FLOWset[#1]%
- {\newcounter\currentFLOWset
- \doifdefinedelse{\@FLOX@#1}
- {\getvalue{\@FLOX@#1}}
- {\dodohandleFLOWset{#1}{}{#1}{}}}
-
-\newcounter\currentFLOWset
-
-\setupFLOWsets
- [\c!command=]
-
-%D This will be an option:
-
-% \def\startFLOWchart%
-% {\dodoubleempty\dostartFLOWchart}
-%
-% \long\def\dostartFLOWchart[#1][#2]#3\stopFLOWchart
-% {\preparenextFLOWchart{#1}{#2}%
-% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
-%
-% \long\def\dodefineFLOWchart[#1][#2]#3%
-% {\preparenextFLOWchart{#1}{#2}%
-% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
-%
-% \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}}
-% \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]}
+%D This file will become obsolete.
\loadmarkfile{m-chart}
diff --git a/tex/context/base/m-chemic.tex b/tex/context/base/m-chemic.tex
deleted file mode 100644
index 7bacf4a90..000000000
--- a/tex/context/base/m-chemic.tex
+++ /dev/null
@@ -1,17 +0,0 @@
-%D \module
-%D [ file=ppchtex (m-chemic),
-%D version=1997.03.19,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=\PPCHTEX\ (Plain Pictex Context cHemie \TEX),
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten},
-%D suggestions={Tobias Burnus, Dirk Kuypers \& 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.
-
-\loadmarkfile{m-chemic}
-
-\endinput
diff --git a/tex/context/base/m-database.lua b/tex/context/base/m-database.lua
index ffaafa2f3..acfa9a47a 100644
--- a/tex/context/base/m-database.lua
+++ b/tex/context/base/m-database.lua
@@ -31,17 +31,17 @@ function buffers.database.process(settings)
else
data = buffers.raw(settings.database)
end
-local function sprint(c,...)
- tex.sprint(tex.ctxcatcodes,[[\tt\bgroup]])
- tex.sprint(tex.vrbcatcodes,...)
- tex.sprint(tex.ctxcatcodes,[[\egroup\crlf]])
-end
-
+--~ local function sprint(c,...)
+--~ tex.sprint(tex.ctxcatcodes,[[\tt\bgroup]])
+--~ tex.sprint(tex.vrbcatcodes,...)
+--~ tex.sprint(tex.ctxcatcodes,[[\egroup\crlf]])
+--~ end
if data and #data > 0 then
local separatorchar, quotechar, commentchar = settings.separator, settings.quotechar, settings.commentchar
local before, after = settings.before or "", settings.after or ""
local first, last = settings.first or "", settings.last or ""
local left, right = settings.left or "", settings.right or ""
+ local setups = settings.setups or ""
local command = settings.command
separatorchar = (not separatorchar and ",") or separators[separatorchar] or separatorchar
local separator = type(separatorchar) == "string" and lpegS(separatorchar) or separatorchar
@@ -68,18 +68,14 @@ end
local result, r = { }, 0 -- we collect as this is nicer in tracing
local list = lpegmatch(splitter,line)
if not found then
- local setups = settings.setups or ""
- if setups == "" then
- sprint(ctxcatcodes,"\\begingroup")
- else
+ if setups ~= "" then
sprint(ctxcatcodes,"\\begingroup\\setups[",setups,"]")
end
sprint(ctxcatcodes,before)
- found = true
end
r = r + 1 ; result[r] = first
for j=1,#list do
- result[#result+1] = left
+ r = r + 1 ; result[r] = left
if command == "" then
r = r + 1 ; result[r] = list[j]
else
@@ -96,7 +92,9 @@ end
end
if found then
sprint(ctxcatcodes,after)
- sprint(ctxcatcodes,"\\endgroup")
+ if setups ~= "" then
+ sprint(ctxcatcodes,"\\endgroup")
+ end
end
else
-- message
diff --git a/tex/context/base/m-database.mkiv b/tex/context/base/m-database.mkiv
index 21be4365a..d89185c10 100644
--- a/tex/context/base/m-database.mkiv
+++ b/tex/context/base/m-database.mkiv
@@ -18,7 +18,7 @@
\unprotect
-\ifdefined \installparameterhandler \else \input mult-aux.mkiv \fi
+% \ifdefined \installparameterhandler \else \input mult-aux.mkiv \fi
\def\c!first {first}
\def\c!last {last}
diff --git a/tex/context/base/m-graph.mkii b/tex/context/base/m-graph.mkii
index db7538e98..69d1d3d57 100644
--- a/tex/context/base/m-graph.mkii
+++ b/tex/context/base/m-graph.mkii
@@ -69,4 +69,163 @@
enddef ;
\stopMPinclusions
-\endinput
+\doifnotmode {demo} {\endinput}
+
+%D You need to have the data files in your path,
+%D otherwise the run is aborted.
+
+\doiffileelse {agepop91.d} {} {\writestatus{graph}{no data files found}\wait\end}
+
+%D The test:
+
+\starttext
+
+\startMPpage
+draw begingraph(3in,2in);
+ gdraw "agepop91.d";
+ endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(3in,2in);
+ gdraw "agepop91.d" plot btex$\bullet$etex;
+ endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(3in,2in);
+ glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+ glabel.bot(btex Age in years etex, OUT);
+ gdraw "agepopm.d";
+ endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(3in,2in);
+ glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+ glabel.bot(btex Age in years etex, OUT);
+ setrange(origin, whatever,whatever);
+ gdraw "agepopm.d";
+ endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(2.3in,2in);
+ setcoords(log,log);
+ glabel.lft(btex Seconds etex,OUT);
+ glabel.bot(btex Matrix size etex,
+ OUT);
+ gdraw "matmul.d" dashed evenly;
+ glabel.ulft(btex Standard etex,8);
+ gdraw "matmul.d";
+ glabel.lrt(btex Strassen etex,7);
+ endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(6.5cm,4.5cm);
+ setrange(80,0, 90,whatever);
+ glabel.bot(btex Year etex, OUT);
+ glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
+ \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
+ gdraw "lead.d" withpen pencircle scaled 1.5pt;
+ autogrid(,otick.lft);
+ setcoords(linear,linear);
+ setrange(80,0, 90,whatever);
+ glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
+ \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
+ gdraw "lead.d";
+ autogrid(otick.bot,otick.rt);
+ endgraph;
+\stopMPpage
+
+\stoptext
+
+% No longer needed, since John will fix it.
+%
+% %D For the moment we need the following patch. Adam T. Lindsay
+% %D found out that the following code produced an error:
+% %D
+% %D \starttyping
+% %D \startMPcode
+% %D draw begingraph(130mm,35mm);
+% %D setrange(0,0,10,22000);
+% %D glabel.lft(btex {correct 0--22000} etex rotated 90, OUT);
+% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
+% %D endgraph;
+% %D \stopMPcode
+% %D
+% %D \startMPcode
+% %D draw begingraph(130mm,35mm);
+% %D setrange(0,50,10,22000);
+% %D glabel.lft(btex {wrong 50--22000} etex rotated 90, OUT);
+% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
+% %D endgraph;
+% %D \stopMPcode
+% %D
+% %D \startMPcode
+% %D draw begingraph(130mm,35mm);
+% %D setrange(0,110,10,30000);
+% %D glabel.lft(btex {failed 110--22000} etex rotated 90, OUT);
+% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
+% %D endgraph;
+% %D \stopMPcode
+% %D \stoptyping
+% %D
+% %D The bug is a rather nasty one and needs some tweaking in
+% %D the low level graph code. John Hobby suggested for the
+% %D moment to initialize \type {setrange} as follows:
+% %D
+% %D \starttyping
+% %D setrange(0,0,"22000","22000")
+% %D \stoptyping
+% %D
+% %D Folowing this suggesion, I provide the following
+% %D extension:
+
+% def begingraph(expr w, h) =
+% begingroup
+% save X_, Y_, Gfin_, Gcur_, Gcbb_, Gneedgr_, Gneedfr_, Gdidsc_;
+% save Gdpic_, Gppic_, Ggl_, Garw_;
+% picture Gfin_, Gcur_, Gcbb_, Gdpic_, Gppic_, Ggl_[];
+% boolean Gneedgr_, Gneedfr_, Gdidsc_;
+% Gfin_ = nullpicture;
+% Gcur_ = nullpicture;
+% Gcbb_ = nullpicture;
+% X_.ctyp = Y_.ctyp = linear;
+% Z_.gdim = (w,h);
+% X_.sc = Y_.sc = 0;
+% Gneedgr_ = true;
+% Gneedfr_ = true;
+% Gdidsc_ = false;
+% Gdpic_ = nullpicture;
+% Garw_ = 0;
+% scantokens everybegingraph ;
+% enddef;
+%
+% boolean fixsetrange ; fixsetrange := true ;
+%
+% vardef dosetrange(text t) =
+% interim warningcheck:=0;
+% save r_; r_=0;
+% string r_[]s;
+% for x_=
+% for p_=t: if pair p_: xpart p_, ypart fi p_, endfor:
+% r_[incr r_] if string x_: s fi = x_;
+% if r_>2:
+% Gsetr_ if r_=3: X_(Gxcvlin_) else: Y_(Gycvlin_) fi(
+% r_[r_-2] if unknown r_[r_-2]: s fi, x_);
+% fi
+% exitif r_=4;
+% endfor
+% enddef;
+%
+% vardef setrange(text t) =
+% if fixsetrange : dosetrange(0,0,20000,20000) ; fi ;
+% dosetrange(t) ;
+% enddef ;
+%
+% if unknown everybegingraph :
+% string everybegingraph ;
+% % everybegingraph := "setrange(0,0,20000,20000)" ;
+% fi ;
diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv
index c92234884..837bdf888 100644
--- a/tex/context/base/m-graph.mkiv
+++ b/tex/context/base/m-graph.mkiv
@@ -60,4 +60,71 @@
% enddef;
\stopMPinclusions
-\endinput
+\doifnotmode {demo} {\endinput}
+
+\doiffileelse {agepop91.d} {} {\writestatus{graph}{no data files found}\wait\end}
+
+%D The test:
+
+\starttext
+
+\startMPpage
+draw begingraph(3in,2in);
+ gdraw "agepop91.d";
+endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(3in,2in);
+ gdraw "agepop91.d" plot btex$\bullet$etex;
+endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(3in,2in);
+ glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+ glabel.bot(btex Age in years etex, OUT);
+ gdraw "agepopm.d";
+endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(3in,2in);
+ glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+ glabel.bot(btex Age in years etex, OUT);
+ setrange(origin, whatever,whatever);
+ gdraw "agepopm.d";
+endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(2.3in,2in);
+ setcoords(log,log);
+ glabel.lft(btex Seconds etex,OUT);
+ glabel.bot(btex Matrix size etex,
+ OUT);
+ gdraw "matmul.d" dashed evenly;
+ glabel.ulft(btex Standard etex,8);
+ gdraw "matmul.d";
+ glabel.lrt(btex Strassen etex,7);
+endgraph;
+\stopMPpage
+
+\startMPpage
+draw begingraph(6.5cm,4.5cm);
+ setrange(80,0, 90,whatever);
+ glabel.bot(btex Year etex, OUT);
+ glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
+ \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
+ gdraw "lead.d" withpen pencircle scaled 1.5pt;
+ autogrid(,otick.lft);
+ setcoords(linear,linear);
+ setrange(80,0, 90,whatever);
+ glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
+ \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
+ gdraw "lead.d";
+ autogrid(otick.bot,otick.rt);
+endgraph;
+\stopMPpage
+
+\stoptext
diff --git a/tex/context/base/m-graph.tex b/tex/context/base/m-graph.tex
deleted file mode 100644
index 6f71cca3c..000000000
--- a/tex/context/base/m-graph.tex
+++ /dev/null
@@ -1,175 +0,0 @@
-%D \module
-%D [ file=m-graph,
-%D version=2000.08.06,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=\METAPOST\ graph module support,
-%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.
-
-\loadmarkfile{m-graph}
-
-\doifnotmode {demo} {\endinput}
-
-%D You need to have the data files in your path,
-%D otherwise the run is aborted.
-
-\doiffileelse {agepop91.d} {} {\writestatus{graph}{no data files found}\wait\end}
-
-%D The test:
-
-\starttext
-
-\startMPpage
-draw begingraph(3in,2in);
- gdraw "agepop91.d";
- endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(3in,2in);
- gdraw "agepop91.d" plot btex$\bullet$etex;
- endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(3in,2in);
- glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
- glabel.bot(btex Age in years etex, OUT);
- gdraw "agepopm.d";
- endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(3in,2in);
- glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
- glabel.bot(btex Age in years etex, OUT);
- setrange(origin, whatever,whatever);
- gdraw "agepopm.d";
- endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(2.3in,2in);
- setcoords(log,log);
- glabel.lft(btex Seconds etex,OUT);
- glabel.bot(btex Matrix size etex,
- OUT);
- gdraw "matmul.d" dashed evenly;
- glabel.ulft(btex Standard etex,8);
- gdraw "matmul.d";
- glabel.lrt(btex Strassen etex,7);
- endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(6.5cm,4.5cm);
- setrange(80,0, 90,whatever);
- glabel.bot(btex Year etex, OUT);
- glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
- \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
- gdraw "lead.d" withpen pencircle scaled 1.5pt;
- autogrid(,otick.lft);
- setcoords(linear,linear);
- setrange(80,0, 90,whatever);
- glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
- \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
- gdraw "lead.d";
- autogrid(otick.bot,otick.rt);
- endgraph;
-\stopMPpage
-
-\stoptext
-
-% No longer needed, since John will fix it.
-%
-% %D For the moment we need the following patch. Adam T. Lindsay
-% %D found out that the following code produced an error:
-% %D
-% %D \starttyping
-% %D \startMPcode
-% %D draw begingraph(130mm,35mm);
-% %D setrange(0,0,10,22000);
-% %D glabel.lft(btex {correct 0--22000} etex rotated 90, OUT);
-% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
-% %D endgraph;
-% %D \stopMPcode
-% %D
-% %D \startMPcode
-% %D draw begingraph(130mm,35mm);
-% %D setrange(0,50,10,22000);
-% %D glabel.lft(btex {wrong 50--22000} etex rotated 90, OUT);
-% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
-% %D endgraph;
-% %D \stopMPcode
-% %D
-% %D \startMPcode
-% %D draw begingraph(130mm,35mm);
-% %D setrange(0,110,10,30000);
-% %D glabel.lft(btex {failed 110--22000} etex rotated 90, OUT);
-% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
-% %D endgraph;
-% %D \stopMPcode
-% %D \stoptyping
-% %D
-% %D The bug is a rather nasty one and needs some tweaking in
-% %D the low level graph code. John Hobby suggested for the
-% %D moment to initialize \type {setrange} as follows:
-% %D
-% %D \starttyping
-% %D setrange(0,0,"22000","22000")
-% %D \stoptyping
-% %D
-% %D Folowing this suggesion, I provide the following
-% %D extension:
-
-% def begingraph(expr w, h) =
-% begingroup
-% save X_, Y_, Gfin_, Gcur_, Gcbb_, Gneedgr_, Gneedfr_, Gdidsc_;
-% save Gdpic_, Gppic_, Ggl_, Garw_;
-% picture Gfin_, Gcur_, Gcbb_, Gdpic_, Gppic_, Ggl_[];
-% boolean Gneedgr_, Gneedfr_, Gdidsc_;
-% Gfin_ = nullpicture;
-% Gcur_ = nullpicture;
-% Gcbb_ = nullpicture;
-% X_.ctyp = Y_.ctyp = linear;
-% Z_.gdim = (w,h);
-% X_.sc = Y_.sc = 0;
-% Gneedgr_ = true;
-% Gneedfr_ = true;
-% Gdidsc_ = false;
-% Gdpic_ = nullpicture;
-% Garw_ = 0;
-% scantokens everybegingraph ;
-% enddef;
-%
-% boolean fixsetrange ; fixsetrange := true ;
-%
-% vardef dosetrange(text t) =
-% interim warningcheck:=0;
-% save r_; r_=0;
-% string r_[]s;
-% for x_=
-% for p_=t: if pair p_: xpart p_, ypart fi p_, endfor:
-% r_[incr r_] if string x_: s fi = x_;
-% if r_>2:
-% Gsetr_ if r_=3: X_(Gxcvlin_) else: Y_(Gycvlin_) fi(
-% r_[r_-2] if unknown r_[r_-2]: s fi, x_);
-% fi
-% exitif r_=4;
-% endfor
-% enddef;
-%
-% vardef setrange(text t) =
-% if fixsetrange : dosetrange(0,0,20000,20000) ; fi ;
-% dosetrange(t) ;
-% enddef ;
-%
-% if unknown everybegingraph :
-% string everybegingraph ;
-% % everybegingraph := "setrange(0,0,20000,20000)" ;
-% fi ;
diff --git a/tex/context/base/m-pstricks.tex b/tex/context/base/m-pstricks.tex
deleted file mode 100644
index 28bc9f30f..000000000
--- a/tex/context/base/m-pstricks.tex
+++ /dev/null
@@ -1,16 +0,0 @@
-%D \module
-%D [ file=m-pstricks,
-%D version=1997.01.15,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=\PSTRICKS\ Connections,
-%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.
-
-\loadmarkfile{m-pstricks}
-
-\endinput
diff --git a/tex/context/base/m-punk.mkiv b/tex/context/base/m-punk.mkiv
index 46225d4ea..dc7692144 100644
--- a/tex/context/base/m-punk.mkiv
+++ b/tex/context/base/m-punk.mkiv
@@ -19,7 +19,7 @@
\startluacode
local concat = table.concat
local chardata = characters.data
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
fonts.mp = fonts.mp or { }
diff --git a/tex/context/base/m-punk.tex b/tex/context/base/m-punk.tex
deleted file mode 100644
index fe7ec85cc..000000000
--- a/tex/context/base/m-punk.tex
+++ /dev/null
@@ -1,3 +0,0 @@
-% this file will disasppear but we need it as it is still in tex live
-
-\loadmarkfile{m-punk}
diff --git a/tex/context/base/math-ext.lua b/tex/context/base/math-ext.lua
index d65f70245..428bdad0a 100644
--- a/tex/context/base/math-ext.lua
+++ b/tex/context/base/math-ext.lua
@@ -30,9 +30,9 @@ function extras.add(unicode,t)
end
function extras.copy(tfmdata)
- local math_parameters = tfmdata.math_parameters
+ local mathparameters = tfmdata.mathparameters
local MathConstants = tfmdata.MathConstants
- if (math_parameters and next(math_parameters)) or (MathConstants and next(MathConstants)) then
+ if (mathparameters and next(mathparameters)) or (MathConstants and next(MathConstants)) then
local characters = tfmdata.characters
for unicode, extradesc in next, mathdata do
-- always, because in an intermediate step we can have a non math font
diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua
index b4f7556c6..b4716d06a 100644
--- a/tex/context/base/math-ini.lua
+++ b/tex/context/base/math-ini.lua
@@ -369,11 +369,11 @@ local hvars = table.tohash {
}
function mathematics.scaleparameters(t,tfmtable,delta,hdelta,vdelta)
- local math_parameters = tfmtable.math_parameters
- if math_parameters and next(math_parameters) then
+ local mathparameters = tfmtable.mathparameters
+ if mathparameters and next(mathparameters) then
delta = delta or 1
hdelta, vdelta = hdelta or delta, vdelta or delta
- local _, mp = mathematics.dimensions(math_parameters)
+ local _, mp = mathematics.dimensions(mathparameters)
for name, value in next, mp do
if name == "RadicalDegreeBottomRaisePercent" then
mp[name] = value
diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua
index 51df84e6f..e8eea1666 100644
--- a/tex/context/base/math-noa.lua
+++ b/tex/context/base/math-noa.lua
@@ -70,10 +70,21 @@ local left_fence_code = 1
local function process(start,what,n,parent)
if n then n = n + 1 else n = 0 end
while start do
+ local id = start.id
if trace_processing then
- report_noads("%s%s",rep(" ",n or 0),tostring(start))
+ local margin = rep(" ",n or 0)
+ local detail = tostring(start)
+ if id == math_noad then
+ report_noads("%s%s (class: %s)",margin,detail,noadcodes[start.subtype] or "?")
+ elseif id == math_char then
+ local char = start.char
+ local fam = start.fam
+ local font = font_of_family(fam)
+ report_noads("%s%s (family: %s, font: %s, char: %s, shape: %s)",margin,detail,fam,font,char,utfchar(char))
+ else
+ report_noads("%s%s",margin,detail)
+ end
end
- local id = start.id
local proc = what[id]
if proc then
local done, newstart = proc(start,what,n,parent or start.prev)
@@ -137,7 +148,7 @@ end
local remapalphabets = mathematics.remapalphabets
local fcs = fonts.colors.set
--- we can have a global famdata == fonts.famdata and chrdata == fonts.chrdata
+-- we can have a global famdata == fonts.famdata
--~ This does not work out well, as there are no fallbacks. Ok, we could
--~ define a poor mans simplify mechanism.
@@ -454,6 +465,17 @@ function builders.kernel.mlist_to_hlist(head,style,penalties)
return mlist_to_hlist(head,style,penalties), true
end
+--~ function builders.kernel.mlist_to_hlist(head,style,penalties)
+--~ print("!!!!!!! BEFORE",penalties)
+--~ for n in node.traverse(head) do print(n) end
+--~ print("!!!!!!!")
+--~ head = mlist_to_hlist(head,style,penalties)
+--~ print("!!!!!!! AFTER")
+--~ for n in node.traverse(head) do print(n) end
+--~ print("!!!!!!!")
+--~ return head, true
+--~ end
+
tasks.new (
"math",
{
diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua
index e222c6002..504c841fa 100644
--- a/tex/context/base/math-vfu.lua
+++ b/tex/context/base/math-vfu.lua
@@ -369,19 +369,21 @@ function fonts.basecopy(tfmtable,name)
end
local reported = { }
-local reverse -- index -> unicode
+local reverse = { } -- index -> unicode
-function fonts.vf.math.define(specification,set)
- if not reverse then
- reverse = { }
- for k, v in next, mathencodings do
- local r = { }
- for u, i in next, v do
- r[i] = u
- end
- reverse[k] = r
- end
+setmetatable ( reverse, { __index = function(t,name)
+ if trace_virtual then
+ report_virtual("initializing math vector '%s'",name)
end
+ local m, r = mathencodings[name], { }
+ for u, i in next, m do
+ r[i] = u
+ end
+ reverse[name] = r
+ return r
+end } )
+
+function fonts.vf.math.define(specification,set)
local name = specification.name -- symbolic name
local size = specification.size -- given size
local fnt, lst, main = { }, { }, nil
@@ -437,7 +439,7 @@ function fonts.vf.math.define(specification,set)
end
-- beware, fnt[1] is already passed to tex (we need to make a simple copy then .. todo)
main = fonts.basecopy(fnt[1],name)
- main.name, main.fonts, main.virtualized, main.math_parameters = name, lst, true, { }
+ main.name, main.fonts, main.virtualized, main.mathparameters = name, lst, true, { }
local characters, descriptions = main.characters, main.descriptions
local mp = main.parameters
if mp then
@@ -451,7 +453,7 @@ function fonts.vf.math.define(specification,set)
elseif ss.optional and fonts.vf.math.optional then
-- skip, redundant
else
- local mm, fp = main.math_parameters, fs.parameters
+ local mm, fp = main.mathparameters, fs.parameters
if mm and fp and mp then
if ss.extension then
mm.math_x_height = fp.x_height or 0 -- math_x_height height of x
@@ -490,7 +492,7 @@ function fonts.vf.math.define(specification,set)
local offset = 0xFF000
local vector = mathencodings[vectorname]
local rotcev = reverse[vectorname]
- if vector then
+ if vector and rotcev then
local fc, fd, si = fs.characters, fs.descriptions, shared[s]
local skewchar = ss.skewchar
for unicode, index in next, vector do
@@ -658,6 +660,8 @@ function fonts.vf.math.define(specification,set)
end
end
end
+ else
+ report_virtual("error in loading %s: problematic vector %s",name,vectorname)
end
end
mathematics.extras.copy(main) --not needed here (yet)
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index d1f4b422f..eec9d71be 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -840,9 +840,8 @@
\def\douseMPlibrary#1%
{\ifcsname\c!file\f!metapostprefix#1\endcsname\else
\letvalueempty{\c!file\f!metapostprefix#1}%
- \makeshortfilename[\truefilename{\f!metapostprefix#1}]%
\startreadingfile
- \readsysfile\shortfilename{\showmessage\m!metapost1{#1}}\donothing
+ \readsysfile{\truefilename{\f!metapostprefix#1}}{\showmessage\m!metapost1{#1}}\donothing
\stopreadingfile
\fi}
@@ -1044,8 +1043,8 @@
%D Usage:
%D
%D \starttyping
-%D \defineproperty[one][layer][state=start]
-%D \defineproperty[two][layer][state=stop]
+%D \defineviewerlayer[one][state=start]
+%D \defineviewerlayer[two][state=stop]
%D
%D \startuseMPgraphic{step-1}
%D fill fullcircle scaled 10cm withcolor red ;
@@ -1055,8 +1054,8 @@
%D fill fullcircle scaled 5cm withcolor green ;
%D \stopuseMPgraphic
%D
-%D \setlayer[mp]{\property[one]{\useMPgraphic{step-1}}}
-%D \setlayer[mp]{\property[two]{\useMPgraphic{step-2}}}
+%D \setlayer[mp]{\viewerlayer[one]{\useMPgraphic{step-1}}}
+%D \setlayer[mp]{\viewerlayer[two]{\useMPgraphic{step-2}}}
%D
%D \ruledhbox{\flushlayer[mp]}
%D \stoptyping
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index 5b3503d98..affbee64c 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -510,6 +510,7 @@
\definesystemvariable {ep} % ExternfiguurPreset
\definesystemvariable {eq} % EQalign
\definesystemvariable {er} % external resources
+\definesystemvariable {et} % EffecT
\definesystemvariable {ex} % ExterneFiguren
\definesystemvariable {fa} % font feature
\definesystemvariable {fc} % FramedContent
@@ -574,6 +575,7 @@
\definesystemvariable {ln} % LijNen
\definesystemvariable {lo} % LOgos
\definesystemvariable {lt} % LiTeratuur
+\definesystemvariable {lr} % LayeR
\definesystemvariable {ls} % languageScript
\definesystemvariable {ly} % LaYout
\definesystemvariable {ma} % MargeAchtergrond
diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua
index 275e2ba43..1eb42d95e 100644
--- a/tex/context/base/node-aux.lua
+++ b/tex/context/base/node-aux.lua
@@ -74,6 +74,14 @@ nodes.set_attributes = set_attributes
nodes.set_unset_attributes = set_unset_attributes
nodes.unset_attributes = unset_attributes
+nodes.setattribute = set_attribute
+nodes.unsetattribute = unset_attribute
+nodes.hasattribute = has_attribute
+
+nodes.setattributes = set_attributes
+nodes.setunsetattributes = set_unset_attributes
+nodes.unsetattributes = unset_attributes
+
-- history:
--
-- local function cp_skipable(a,id) -- skipable nodes at the margins during character protrusion
diff --git a/tex/context/base/node-dum.lua b/tex/context/base/node-dum.lua
index b04204740..512748151 100644
--- a/tex/context/base/node-dum.lua
+++ b/tex/context/base/node-dum.lua
@@ -29,10 +29,6 @@ local new_node = node.new
local glyph_code = nodecodes.glyph
--- fonts
-
-local fontdata = fonts.ids or { }
-
function nodes.simple_font_handler(head)
-- lang.hyphenate(head)
head = nodes.handlers.characters(head)
@@ -48,7 +44,7 @@ if tex.attribute[0] ~= 0 then
texio.write_nl("log","!")
texio.write_nl("log","! Attribute 0 is reserved for ConTeXt's font feature management and has to be")
texio.write_nl("log","! set to zero. Also, some attributes in the range 1-255 are used for special")
- texio.write_nl("log","! purposed so setting them at the TeX end might break the font handler.")
+ texio.write_nl("log","! purposes so setting them at the TeX end might break the font handler.")
texio.write_nl("log","!")
tex.attribute[0] = 0 -- else no features
@@ -59,36 +55,41 @@ nodes.handlers.protectglyphs = node.protect_glyphs
nodes.handlers.unprotectglyphs = node.unprotect_glyphs
function nodes.handlers.characters(head)
- local usedfonts, done, prevfont = { }, false, nil
- for n in traverse_id(glyph_code,head) do
- local font = n.font
- if font ~= prevfont then
- prevfont = font
- local used = usedfonts[font]
- if not used then
- local tfmdata = fontdata[font]
- if tfmdata then
- local shared = tfmdata.shared -- we need to check shared, only when same features
- if shared then
- local processors = shared.processes
- if processors and #processors > 0 then
- usedfonts[font] = processors
- done = true
+ local fontdata = fonts.identifiers
+ if fontdata then
+ local usedfonts, done, prevfont = { }, false, nil
+ for n in traverse_id(glyph_code,head) do
+ local font = n.font
+ if font ~= prevfont then
+ prevfont = font
+ local used = usedfonts[font]
+ if not used then
+ local tfmdata = fontdata[font] --
+ if tfmdata then
+ local shared = tfmdata.shared -- we need to check shared, only when same features
+ if shared then
+ local processors = shared.processes
+ if processors and #processors > 0 then
+ usedfonts[font] = processors
+ done = true
+ end
end
end
end
end
end
- end
- if done then
- for font, processors in next, usedfonts do
- for i=1,#processors do
- local h, d = processors[i](head,font,0)
- head, done = h or head, done or d
+ if done then
+ for font, processors in next, usedfonts do
+ for i=1,#processors do
+ local h, d = processors[i](head,font,0)
+ head, done = h or head, done or d
+ end
end
end
+ return head, true
+ else
+ return head, false
end
- return head, true
end
-- helper
diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua
index f7668415d..5c1cc9ad5 100644
--- a/tex/context/base/node-fin.lua
+++ b/tex/context/base/node-fin.lua
@@ -411,7 +411,8 @@ local function stacked(namespace,attribute,head,default) -- no triggering, no in
done = done or ok
end
end
- elseif default then
+--~ elseif default then
+ elseif default > 0 then
--
elseif current > 0 then
head = insert_node_before(head,stack,copy_node(nsnone))
diff --git a/tex/context/base/node-fnt.lua b/tex/context/base/node-fnt.lua
index 399cd8642..2eceb5dae 100644
--- a/tex/context/base/node-fnt.lua
+++ b/tex/context/base/node-fnt.lua
@@ -18,16 +18,16 @@ local report_fontrun = logs.new("font run")
local nodes, node = nodes, node
-fonts = fonts or { }
-fonts.tfm = fonts.tfm or { }
-fonts.ids = fonts.ids or { }
+fonts = fonts or { }
+fonts.tfm = fonts.tfm or { }
+fonts.identifiers = fonts.identifiers or { }
local traverse_id = node.traverse_id
local has_attribute = node.has_attribute
local starttiming = statistics.starttiming
local stoptiming = statistics.stoptiming
local nodecodes = nodes.nodecodes
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local handlers = nodes.handlers
local glyph_code = nodecodes.glyph
@@ -60,7 +60,7 @@ function handlers.characters(head)
local font, attr = n.font, has_attribute(n,0) or 0
report_run("font %03i dynamic %03i glyph %s",font,attr,utf.char(n.char))
else
- report_run("[%s]",node.type(n.id))
+ report_run("[%s]",nodecodes[n.id])
end
n = n.next
end
diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua
index e4380a4ea..a55ea284d 100644
--- a/tex/context/base/node-inj.lua
+++ b/tex/context/base/node-inj.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['node-inj'] = {
license = "see context related readme files"
}
--- tricky ... fonts.ids is not yet defined .. to be solved (maybe general tex ini)
+-- tricky ... fonts.identifiers is not yet defined .. to be solved (maybe general tex ini)
-- This is very experimental (this will change when we have luatex > .50 and
-- a few pending thingies are available. Also, Idris needs to make a few more
@@ -21,18 +21,18 @@ local report_injections = logs.new("injections")
local attributes, nodes, node = attributes, nodes, node
-fonts = fonts or { }
-fonts.tfm = fonts.tfm or { }
-fonts.ids = fonts.ids or { }
+fonts = fonts or { }
+fonts.tfm = fonts.tfm or { }
+fonts.identifiers = fonts.identifiers or { }
-nodes.injections = nodes.injections or { }
-local injections = nodes.injections
+nodes.injections = nodes.injections or { }
+local injections = nodes.injections
-local fontdata = fonts.ids
-local nodecodes = nodes.nodecodes
-local glyph_code = nodecodes.glyph
-local nodepool = nodes.pool
-local newkern = nodepool.kern
+local fontdata = fonts.identifiers
+local nodecodes = nodes.nodecodes
+local glyph_code = nodecodes.glyph
+local nodepool = nodes.pool
+local newkern = nodepool.kern
local traverse_id = node.traverse_id
local unset_attribute = node.unset_attribute
diff --git a/tex/context/base/node-mig.mkiv b/tex/context/base/node-mig.mkiv
index cd731b96f..3047ac3af 100644
--- a/tex/context/base/node-mig.mkiv
+++ b/tex/context/base/node-mig.mkiv
@@ -49,12 +49,13 @@
\def\automigratemarks {\the\everyautomigratemarks}
\appendtoks
- \let\postponenotes\relax
- \enableexperiments[inserts.migrate]%
+ \let\postponenotes\relax
+ \enableexperiments[inserts.migrate]%
\to \everyautomigratefootnotes
\appendtoks
- \enableexperiments[marks.migrate]%
+ \writestatus\m!systems{migration of marks is normally not needed}%
+ \enableexperiments[marks.migrate]%
\to \everyautomigratemarks
\protect
diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua
index 0a0cd0dc1..e636abaef 100644
--- a/tex/context/base/node-res.lua
+++ b/tex/context/base/node-res.lua
@@ -20,7 +20,6 @@ local copy_node = node.copy
local free_node = node.free
local free_list = node.flush_list
local new_node = node.new
-local node_type = node.type
nodes.pool = nodes.pool or { }
local pool = nodes.pool
@@ -204,7 +203,7 @@ function pool.leftmarginkern(glyph,width)
if not glyph then
logs.fatal("nodes","invalid pointer to left margin glyph node")
elseif glyph.id ~= glyph_code then
- logs.fatal("nodes","invalid node type %s for left margin glyph node",node_type(glyph))
+ logs.fatal("nodes","invalid node type %s for left margin glyph node",nodecodes[glyph])
else
n.glyph = glyph
end
@@ -219,7 +218,7 @@ function pool.rightmarginkern(glyph,width)
if not glyph then
logs.fatal("nodes","invalid pointer to right margin glyph node")
elseif glyph.id ~= glyph_code then
- logs.fatal("nodes","invalid node type %s for right margin glyph node",node_type(p))
+ logs.fatal("nodes","invalid node type %s for right margin glyph node",nodecodes[p])
else
n.glyph = glyph
end
diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua
index 51a7b4d3a..991e08d93 100644
--- a/tex/context/base/node-rul.lua
+++ b/tex/context/base/node-rul.lua
@@ -73,7 +73,7 @@ local hpack_nodes = node.hpack
local dimenfactor = fonts.dimenfactor
local texwrite = tex.write
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local variables = interfaces.variables
local nodecodes = nodes.nodecodes
diff --git a/tex/context/base/node-ser.lua b/tex/context/base/node-ser.lua
index f90741aac..9c968670c 100644
--- a/tex/context/base/node-ser.lua
+++ b/tex/context/base/node-ser.lua
@@ -17,7 +17,6 @@ local nodes, node = nodes, node
local traverse = node.traverse
local node_fields = node.fields
-local node_type = node.type
local nodecodes = nodes.nodecodes
@@ -88,7 +87,7 @@ function nodes.astable(n,sparse) -- not yet ok
end
end
end
- t.type = node_type(n.id)
+ t.type = nodecodes[n.id]
return t
end
@@ -119,7 +118,7 @@ local function totable(n,flat,verbose)
end
end
if verbose then
- tt.type = node_type(tt.id)
+ tt.type = nodecodes[tt.id]
end
return tt
end
diff --git a/tex/context/base/node-spl.lua b/tex/context/base/node-spl.lua
index a942d3cdb..e90146bf9 100644
--- a/tex/context/base/node-spl.lua
+++ b/tex/context/base/node-spl.lua
@@ -75,7 +75,7 @@ local starttiming = statistics.starttiming
local stoptiming = statistics.stoptiming
local process_characters = nodes.handlers.characters
local inject_kerns = nodes.injections.handler
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local parbuilders = builders.paragraphs
parbuilders.solutions = parbuilders.solutions or { }
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua
index d41089e6c..ff038a816 100644
--- a/tex/context/base/node-tra.lua
+++ b/tex/context/base/node-tra.lua
@@ -24,9 +24,12 @@ nodes = nodes or { }
local fonts, nodes, node, context = fonts, nodes, node, context
-fonts.tfm = fonts.tfm or { }
-fonts.ids = fonts.ids or { }
-fonts.chr = fonts.chr or { }
+fonts.tfm = fonts.tfm or { }
+fonts.identifiers = fonts.identifiers or { }
+fonts.characters = fonts.characters or { }
+
+local fontdata = fonts.identifiers
+local fontchar = fonts.characters
nodes.tracers = nodes.tracers or { }
local tracers = nodes.tracers
@@ -49,12 +52,8 @@ local step_tracers = tracers.steppers
local copy_node_list = node.copy_list
local hpack_node_list = node.hpack
local free_node_list = node.flush_list
-local node_type = node.type
local traverse_nodes = node.traverse
-local fontdata = fonts.ids
-local fontchar = fonts.chr
-
local nodecodes = nodes.nodecodes
local whatcodes = nodes.whatcodes
local skipcodes = nodes.skipcodes
@@ -287,7 +286,7 @@ function step_tracers.codes(i,command)
elseif id == whatsit_code and (c.subtype == localpar_code or c.subtype == dir_code) then
context("[%s]",c.dir)
else
- context("[%s]",node_type(id))
+ context("[%s]",nodecodes[id])
end
c = c.next
end
@@ -371,7 +370,7 @@ function nodes.handlers.checkforleaks(sparse)
local l = { }
local q = node.usedlist()
for p in traverse(q) do
- local s = table.serialize(nodes.astable(p,sparse),node_type(p.id))
+ local s = table.serialize(nodes.astable(p,sparse),nodecodes[p.id])
l[s] = (l[s] or 0) + 1
end
node.flush_list(q)
@@ -402,13 +401,13 @@ local function tosequence(start,stop,compact)
if compact then
t[#t+1] = "|"
else
- t[#t+1] = node_type(id)
+ t[#t+1] = nodecodes[id]
end
else
if compact then
t[#t+1] = "[]"
else
- t[#t+1] = node_type(id)
+ t[#t+1] = nodecodes[id]
end
end
if start == stop then
@@ -463,9 +462,9 @@ function nodes.idstostring(head,tail)
last_n = last_n + 1
else
if last_n > 1 then
- t[#t+1] = format("[%s*%s]",last_n,node_type(last_id) or "?")
+ t[#t+1] = format("[%s*%s]",last_n,nodecodes[last_id] or "?")
else
- t[#t+1] = format("[%s]",node_type(last_id) or "?")
+ t[#t+1] = format("[%s]",nodecodes[last_id] or "?")
end
last_id, last_n = id, 1
end
@@ -476,9 +475,9 @@ function nodes.idstostring(head,tail)
if not last_id then
t[#t+1] = "no nodes"
elseif last_n > 1 then
- t[#t+1] = format("[%s*%s]",last_n,node_type(last_id) or "?")
+ t[#t+1] = format("[%s*%s]",last_n,nodecodes[last_id] or "?")
else
- t[#t+1] = format("[%s]",node_type(last_id) or "?")
+ t[#t+1] = format("[%s]",nodecodes[last_id] or "?")
end
return concat(t," ")
end
@@ -497,9 +496,9 @@ end
--~ last_n = last_n + 1
--~ else
--~ if last_n > 1 then
---~ t[#t+1] = format("[%s*%s]",last_n,node_type(last_id) or "?")
+--~ t[#t+1] = format("[%s*%s]",last_n,nodecodes[last_id] or "?")
--~ else
---~ t[#t+1] = format("[%s]",node_type(last_id) or "?")
+--~ t[#t+1] = format("[%s]",nodecodes[last_id] or "?")
--~ end
--~ last_id, last_n = id, 1
--~ end
@@ -511,9 +510,9 @@ end
--~ if not last_id then
--~ t[#t+1] = "no nodes"
--~ elseif last_n > 1 then
---~ t[#t+1] = format("[%s*%s]",last_n,node_type(last_id) or "?")
+--~ t[#t+1] = format("[%s*%s]",last_n,nodecodes[last_id] or "?")
--~ else
---~ t[#t+1] = format("[%s]",node_type(last_id) or "?")
+--~ t[#t+1] = format("[%s]",nodecodes[last_id] or "?")
--~ end
--~ return table.concat(table.reversed(t)," ")
--~ end
@@ -578,54 +577,63 @@ nodes.showboxes = showboxes
local threshold = 65536
-local function toutf(list,result,stopcriterium)
- for n in traverse_nodes(list) do
- local id = n.id
- if id == glyph_code then
- local components = n.components
- if components then
- toutf(components,result)
- else
- local c = n.char
- local fc = fontchar[n.font]
- if fc then
- local u = fc[c].tounicode
- if u then
- for s in gmatch(u,"....") do
- result[#result+1] = utfchar(tonumber(s,16))
+local function toutf(list,result,nofresult,stopcriterium)
+ if list then
+ for n in traverse_nodes(list) do
+ local id = n.id
+ if id == glyph_code then
+ local components = n.components
+ if components then
+ result, nofresult = toutf(components,result,nofresult)
+ else
+ local c = n.char
+ local fc = fontchar[n.font]
+ if fc then
+ local u = fc[c].tounicode
+ if u then
+ for s in gmatch(u,"....") do
+ nofresult = nofresult + 1
+ result[nofresult] = utfchar(tonumber(s,16))
+ end
+ else
+ nofresult = nofresult + 1
+ result[nofresult] = utfchar(c)
end
else
- result[#result+1] = utfchar(c)
+ nofresult = nofresult + 1
+ result[nofresult] = utfchar(c)
end
- else
- result[#result+1] = utfchar(c)
+ end
+ elseif id == disc_code then
+ result, nofresult = toutf(n.replace,result,nofresult)
+ elseif id == hlist_code or id == vlist_code then
+--~ if nofresult > 0 and result[nofresult] ~= " " then
+--~ nofresult = nofresult + 1
+--~ result[nofresult] = " "
+--~ end
+ result, nofresult = toutf(n.list,result,nofresult)
+ elseif id == glue_code and n.subtype == userskip_code and n.spec.width > threshold then
+ if nofresult > 0 and result[nofresult] ~= " " then
+ nofresult = nofresult + 1
+ result[nofresult] = " "
+ end
+ elseif id == kern_code and n.kern > threshold then
+ if nofresult > 0 and result[nofresult] ~= " " then
+ nofresult = nofresult + 1
+ result[nofresult] = " "
end
end
- elseif id == disc_code then
- toutf(n.replace,result)
- elseif id == hlist_code or id == vlist_code then
- if #result > 0 and result[#result] ~= " " then
- result[#result+1] = " "
- end
- toutf(n.list,result)
- elseif id == glue_code and n.subtype == userskip_code and n.spec.width > threshold then
- if #result > 0 and result[#result] ~= " " then
- result[#result+1] = " "
- end
- elseif id == kern_code and n.kern > threshold then
- if #result > 0 and result[#result] ~= " " then
- result[#result+1] = " "
+ if n == stopcriterium then
+ break
end
end
- if n == stopcriterium then
- break
- end
end
- return result
+ return result, nofresult
end
function nodes.toutf(list,stopcriterium)
- return concat(toutf(list,{},stopcriterium))
+ local result, nofresult = toutf(list,{},0,stopcriterium)
+ return concat(result)
end
-- might move elsewhere
diff --git a/tex/context/base/norm-ptx.tex b/tex/context/base/norm-ptx.tex
index 8f911d874..352a884f0 100644
--- a/tex/context/base/norm-ptx.tex
+++ b/tex/context/base/norm-ptx.tex
@@ -11,6 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+%D Eventually most of these will be disabled in \MKIV.
+
\let \normalefcode = \efcode
\let \normalexpanded = \expanded
\let \normalifincsname = \ifincsname
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index 66ab776b9..1327e796b 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -814,6 +814,15 @@
\setuplayout[\c!method=\v!normal]
+\def\docolumnpagebodymarks#1#2#3#4% first last column box
+ {\ifnum#3=#1\relax
+ \dosynchronizemarking[\number#3,\v!column:\number#3,\v!first,\v!column:\v!first][#4]%
+ \else\ifnum#3=#2\relax
+ \dosynchronizemarking[\number#3,\v!column:\number#3,\v!last, \v!column:\v!last ][#4]%
+ \else
+ \dosynchronizemarking[\number#3,\v!column:\number#3 ][#4]%
+ \fi\fi}
+
\def\buildpagebody#1#2%
{\ifsavepagebody\global\setbox\savedpagebody\fi
\vbox
@@ -821,10 +830,11 @@
% \forgetall % igv problemen, check: \boxmaxdepth\maxdimen
\boxmaxdepth\maxdimen % new
\dontcomplain
+ % marks get done here
+ \dosynchronizemarking[\v!page][#2]%
% the following plugin uses and sets pagebox; beware: this
% will change and is for my (hh) personal experiments
- \executeifdefined{\??ly\c!method\@@lymethod}%
- {\getvalue{\??ly\c!method\v!normal}}#1#2%
+ \executeifdefined{\??ly\c!method\@@lymethod}{\getvalue{\??ly\c!method\v!normal}}#1#2%
% the finishing touch
\ifcase\pageornamentstate
\addpagebackground \pagebox
@@ -893,8 +903,7 @@
\prependtoks \let\nextbox\nestednextbox \to \everybeforepagebody
\def\dopagebody#1#2%
- {%\getallmarks % now in following token register
- \the\everybeforepagebody
+ {\the\everybeforepagebody
\starttextproperties
% \setnextsubpageno % nog eens: als in pagina (tbv standaard opmaak)
\dontshowboxes % dan hier blokkeren en verderop resetten
@@ -1020,9 +1029,9 @@
\penalty-\!!tenthousand % untested ! ! \column
\fi \fi}
-\let\resetcurrentsectionmarks\relax
-
-% was: \resetsectionmarks\firstsection, zie \handlepagebreak
+\ifdefined\resetcurrentstructuremarkswithpage \else
+ \let\resetcurrentstructuremarkswithpage\relax
+\fi
\def\page{\pagebreak} % the short form of \pagebreak (mult-com one)
@@ -1164,20 +1173,20 @@
\installpagebreakhandler \v!left
{\ejectinsert
\gotonextpageX % will become \gotonextpage
- \doifbothsidesoverruled{}{\resetcurrentsectionmarks\ejectdummypage}{}}
+ \doifbothsidesoverruled{}{\resetcurrentstructuremarkswithpage\ejectdummypage}{}}
\installpagebreakhandler \v!right
{\ejectinsert
\gotonextpageX % will become \gotonextpage
- \doifbothsidesoverruled{}{}{\resetcurrentsectionmarks\ejectdummypage}}
+ \doifbothsidesoverruled{}{}{\resetcurrentstructuremarkswithpage\ejectdummypage}}
\installpagebreakhandler \v!even
{\page
- \doifoddpageelse{\resetcurrentsectionmarks\ejectdummypage}\donothing}
+ \doifoddpageelse{\resetcurrentstructuremarkswithpage\ejectdummypage}\donothing}
\installpagebreakhandler \v!odd
{\page
- \doifoddpageelse\donothing{\resetcurrentsectionmarks\ejectdummypage}}
+ \doifoddpageelse\donothing{\resetcurrentstructuremarkswithpage\ejectdummypage}}
\installpagebreakhandler \v!quadruple % not yet ok inside columnsets
{\ifdoublesided
diff --git a/tex/context/base/page-mak.mkiv b/tex/context/base/page-mak.mkiv
index f43734230..52834b2aa 100644
--- a/tex/context/base/page-mak.mkiv
+++ b/tex/context/base/page-mak.mkiv
@@ -78,8 +78,6 @@
\newtoks\everymakeup
-\appendtoks \postponemarks \to \everymakeup
-
\let\currentmakeup\empty
\unexpanded\def\startmakeup
@@ -109,7 +107,6 @@
\def\donostopmakeup
{\egroup
- \flushmarks % new, here, else empty pages
\page
\egroup}
@@ -139,7 +136,6 @@
\makeupparameter\c!bottom
\doifsomething{\makeupparameter\c!color}{\stopcolor}%
\egroup
- \flushmarks % new, here, else empty pages
\doflushmakeup
\egroup
\calculatehsizes
diff --git a/tex/context/base/page-mar.mkiv b/tex/context/base/page-mar.mkiv
index 6a1691a00..12814ffbf 100644
--- a/tex/context/base/page-mar.mkiv
+++ b/tex/context/base/page-mar.mkiv
@@ -688,7 +688,7 @@
\to \collectedmargintexts}
\def\doflushmargincontents % plural
- {\ifcase\margintextcollected\else
+ {\ifconditional\margintextcollected
\expandafter\flushmargincontentsindeed
\fi}
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index b7efb8782..0a57b9e41 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -604,6 +604,8 @@
\setmaxcolumndimensions
\dohandleallcolumns
{\mkprocesscolumncontents\currentcolumnbox}%
+ \dohandleallcolumns
+ {\docolumnpagebodymarks\plusone\nofcolumns\mofcolumns\currentcolumnbox}%
\postprocesscolumns
\dohandleallcolumns % \hbox i.v.m. \showcomposition
{\global\setbox\currentcolumnbox\hbox to \localcolumnwidth
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index f2e11e8a0..465918449 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -133,28 +133,6 @@
%D \stoptext
%D \stoptyping
-% not ok yet, for column sets we need a special case: within a column we
-% need to bubble-up the marks; the indirectness permits overloading here
-
-\let\saveOTRSETmark \refreshsavedmark
-\let\bubbleOTRSETmark\bubblesavedmark
-\let\resetOTRSETmark \resetsavedmark
-\let\presetOTRSETmark\presetsavedmark
-
-\def\doregisterOTRSETmarks#1{\saveOTRSETmark [#1][\number\mofcolumns]}
-\def\dobubbleOTRSETmarks #1{\bubbleOTRSETmark[#1][\number\mofcolumns]}
-\def\doresetOTRSETmarks #1{\resetOTRSETmark [#1][\recurselevel]}
-\def\dopresetOTRSETmarks #1{\presetOTRSETmark[#1][\recurselevel]}
-
-\def\registerOTRSETmarks
- {\processcommacommand[\alldefinedmarks]\doregisterOTRSETmarks}
-\def\bubbleOTRSETmarks
- {\processcommacommand[\alldefinedmarks]\dobubbleOTRSETmarks}
-\def\resetOTRSETmarks
- {\dorecurse\nofcolumns{\processcommacommand[\alldefinedmarks]\doresetOTRSETmarks}}
-\def\presetOTRSETmarks
- {\dorecurse\nofcolumns{\processcommacommand[\alldefinedmarks]\dopresetOTRSETmarks}}
-
%D test case of Vit Zika (context list):
%D
%D \starttyping
@@ -459,6 +437,7 @@
\vss
\fi}%
\wd\scratchbox\localcolumnwidth % \textwidth
+ \docolumnpagebodymarks{#1}{#2}\recurselevel\scratchbox
\ifcase\columndirection
\hskip\OTRSETgetparameter\c!distance\recurselevel\box\scratchbox
\else
@@ -512,7 +491,6 @@
\def\OTRSETdoflush
{\ifcollectingcontent
- \registerOTRSETmarks
\global\mofcolumns\plusone
\else
\OTRSETdofinalflush
@@ -524,7 +502,6 @@
\OTRSETinitializecolumns
%\OTRSETdoflushfloats
\OTRSETstartnextpage
-\presetOTRSETmarks
\initializecolumntextareas
\fi}
@@ -861,9 +838,7 @@
{\OTRSETsetfreecells\mofcolumns\columnlastcell
\ifsomefreecolumncells
% okay
- \bubbleOTRSETmarks % not robust because we reenter
\else
- \registerOTRSETmarks % not robust because we reenter
\global\advance\mofcolumns \plusone
\ifnum\mofcolumns>\nofcolumns
\OTRSETdoflush
@@ -1634,7 +1609,6 @@
{\increment\columnsetlevel\relax
\globallet\localcolumnmaxcells\!!zerocount
\global\setfalse\OTRSETfinish
- \resetOTRSETmarks
\ifnum\columnsetlevel=\plusone
\bgroup
\saveinterlinespace
@@ -1762,7 +1736,6 @@
\fi
\vfill
\eject
-\registerOTRSETmarks
% brr, may result in empty page after nicely fit text
% or if left, then lost of first column only text
\ifnum\mofcolumns>\plusone
diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv
index 69ef8c270..dc516a94e 100644
--- a/tex/context/base/page-txt.mkiv
+++ b/tex/context/base/page-txt.mkiv
@@ -305,7 +305,8 @@
\setvalue{\??tk::\v!nomarking}#1#2%
{\bgroup
\resettextlinestatus#1%
- \let\dogetmarking\nogetmarking
+ \settrue\inhibitgetmarking
+ \let\dogetmarking\nogetmarking % obsolete in new marking mechanism
\doplacelayouttextline#1#2%
\egroup}
@@ -503,79 +504,6 @@
\def\ignoredlinebreak{\unskip\space\ignorespaces}
-% \def\doplacelayouttextline#1#2%
-% {\ifdim#2>\zeropoint\relax % prevents pagenumbers when zero height
-% \goleftonpage
-% \hbox
-% {\setbox\scratchpagebox\vbox to #2
-% {\vsize#2\relax
-% \normalbaselines
-% \let\\\ignoredlinebreak
-% \let\crlf\ignoredlinebreak
-% \csname\??tk#1\c!before\endcsname
-% \doifbothsidesoverruled
-% {\dodoplacelayouttextline#1\c!lefttext \c!middletext\c!righttext\zerocount\plusone}
-% {\dodoplacelayouttextline#1\c!lefttext \c!middletext\c!righttext\zerocount\plusone}
-% {\dodoplacelayouttextline#1\c!righttext\c!middletext\c!lefttext \plusone\zerocount}%
-% \csname\??tk#1\c!after\endcsname
-% \kern\zeropoint}% keep the \dp, beware of \vtops, never change this!
-% \dp\scratchpagebox\zeropoint
-% \box\scratchpagebox}%
-% \vskip-#2\relax
-% \fi}
-%
-% \def\dodoplacelayouttextline#1#2#3#4#5#6% \hsize toegevoegd, \hss's niet meer wijzigen
-% {\hbox
-% {\ifdim\leftedgewidth>\zeropoint
-% \dododoplacelayouttextline\leftedgewidth#1\v!edge
-% {\hss\csname\??tk#1\v!edge#2\endcsname}%
-% \hskip\leftedgedistance
-% \fi
-% \ifdim\leftmarginwidth>\zeropoint
-% \dododoplacelayouttextline\leftmarginwidth#1\v!margin
-% {\hbox to \leftmarginwidth
-% {\hss\csname\??tk#1\v!margin#2\endcsname}%
-% \hskip-\leftmarginwidth
-% \hbox to \leftmarginwidth
-% {\hss\ifcase#5\or\csname\??tk#1\v!margin\c!margintext\endcsname\fi}}%
-% \hskip\leftmargindistance
-% \fi
-% \ifdim\makeupwidth>\zeropoint
-% \dododoplacelayouttextline\makeupwidth{#1}\v!text
-% {\hbox to \makeupwidth
-% {\ifcase#5\or\@@nmpre{\csname\??tk#1\v!text\c!marginedgetext\endcsname}\fi
-% \csname\??tk#1\v!text#2\endcsname\hss}%
-% \hskip-\makeupwidth
-% \hbox to \makeupwidth
-% {\hss\csname\??tk#1\v!text#3\endcsname\hss}%
-% \hskip-\makeupwidth
-% \hbox to \makeupwidth
-% {\hss\csname\??tk#1\v!text#4\endcsname
-% \ifcase#6\or\@@nmpos{\csname\??tk#1\v!text\c!marginedgetext\endcsname}\fi}}%
-% \fi
-% \ifdim\rightmarginwidth>\zeropoint
-% \hskip\rightmargindistance
-% \dododoplacelayouttextline\rightmarginwidth{#1}\v!margin
-% {\hbox to \rightmarginwidth
-% {\csname\??tk#1\v!margin#4\endcsname\hss}%
-% \hskip-\rightmarginwidth
-% \hbox to \rightmarginwidth
-% {\ifcase#6\or\csname\??tk#1\v!margin\c!margintext\endcsname\fi\hss}}%
-% \fi
-% \ifdim\rightedgewidth>\zeropoint
-% \hskip\rightedgedistance
-% \dododoplacelayouttextline\rightedgewidth{#1}\v!edge
-% {\csname\??tk#1\v!edge#4\endcsname\hss}%
-% \fi}}
-%
-% \def\dododoplacelayouttextline#1#2#3#4%
-% {\vbox % to \vsize
-% {\hsize#1\relax
-% \csname\??tk#2#3\c!before\endcsname
-% \setlayoutcomponentattribute#2#3%
-% \hbox \layoutcomponentboxattribute to #1{#4}%
-% \csname\??tk#2#3\c!after\endcsname}}
-
\def\doplacelayouttextline#1#2%
{\let\currentlayouttextline#1%
\ifdim#2>\zeropoint\relax % prevents pagenumbers when zero height
diff --git a/tex/context/base/prop-eff.mkiv b/tex/context/base/prop-eff.mkiv
deleted file mode 100644
index 7207b9df4..000000000
--- a/tex/context/base/prop-eff.mkiv
+++ /dev/null
@@ -1,46 +0,0 @@
-%D \module
-%D [ file=prop-eff,
-%D version=2004.05.29, % some code moved from private modules
-%D title=\CONTEXT\ Property Macros,
-%D subtitle=Effects,
-%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 Property Macros / Effects}
-
-\unprotect
-
-%D Special font effects.
-
-\setupproperty
- [\s!effect]
- [\c!rulethickness=\zeropoint,
- \c!stretch=0]
-
-\defineproperty [\v!inner] [\s!effect] [\c!rulethickness=.25pt]
-\defineproperty [\v!outer] [\s!effect] [\c!rulethickness=.25pt]
-\defineproperty [\v!both] [\s!effect] [\c!rulethickness=.25pt]
-\defineproperty [\v!normal] [\s!effect]
-\defineproperty [\v!hidden] [\s!effect]
-
-\defineproperty [\v!stretch] [\s!effect] [\c!stretch=1]
-
-\def\mktriggereffect#1%
- {\dotriggereffect{#1}{\propertyparameter{#1}\c!stretch}{\propertyparameter{#1}\c!rulethickness}}
-
-\definepropertyhandler \v!normal {\mktriggereffect\v!normal}
-\definepropertyhandler \v!inner {\mktriggereffect\v!inner }
-\definepropertyhandler \v!outer {\mktriggereffect\v!outer }
-\definepropertyhandler \v!both {\mktriggereffect\v!both }
-\definepropertyhandler \v!hidden {\mktriggereffect\v!hidden}
-\definepropertyhandler \v!stretch{\mktriggereffect\v!normal}
-
-\unexpanded\def\starteffectproperty{\mktriggereffect\currentproperty}
-\unexpanded\def\stopeffectproperty {\mktriggereffect\v!normal }
-
-\protect \endinput
diff --git a/tex/context/base/prop-ini.mkiv b/tex/context/base/prop-ini.mkiv
index ada358f6d..a122e8bb4 100644
--- a/tex/context/base/prop-ini.mkiv
+++ b/tex/context/base/prop-ini.mkiv
@@ -13,33 +13,32 @@
\writestatus{loading}{ConTeXt Property Macros / Initialization}
-%D Welcome to the third alternative of this yet undocumented module,
-%D which means that there is no public interface yet!
+%D This module is replaced by dedicated mechanisms. Originally properties were
+%D a sort of attributes in \MKII, but now we do things different anyway. We keep
+%D a surrogate mechanism around for compatibility reasons but even this will
+%D become obsolete some day.
\unprotect
-\newcount\propertylevel
+\def\propertyobsoletemessage
+ {\writestatus\m!systems{properties are obsolete, use dedicated commands}%
+ \glet\propertyobsoletemessage\donothing}
-\def\currentpropertylevel {\csname\??py:l:\currentpropertytype\endcsname} % counter
-\def\previouspropertylevel{\csname\??py:p:\currentpropertytype\endcsname} % counter
+\setvalue{\??py:d:\v!layer }[#1][#2][#3]{\defineviewerlayer[#1][#3]}
+\setvalue{\??py:d:\s!effect }[#1][#2][#3]{\defineeffect [#1][#3]}
+\setvalue{\??py:d:\v!negative}[#1][#2][#3]{}
-\def\currentproperty {\csname\??py:c:\number\currentpropertylevel \endcsname} % string
-\def\previousproperty {\csname\??py:c:\number\previouspropertylevel\endcsname} % string
-
-% more efficient:
-
-\def\currentproperty {\csname\??py:c:\number\propertylevel\endcsname} % string
-\def\currentpropertytype {\csname\??py\currentproperty\c!type\endcsname}
+\unexpanded\def\defineproperty
+ {\dotripleempty\dodefineproperty}
-\def\docheckproperty % watch the s instead of e
- {\csname\s!check\currentpropertytype property\endcsname
- \global\expandafter\let\csname\??py\s!check\currentproperty\endcsname\empty}
+\def\dodefineproperty[#1][#2][#3]%
+ {\propertyobsoletemessage
+ \setevalue{\??py#1\c!type}{#2}%
+ \getvalue{\??py:d:#2}[#1][#2][#3]}
-\def\checkproperty[#1]%
- {\bgroup
- \def\currentproperty{#1}%
- \csname\??py\s!check\currentproperty\endcsname
- \egroup}
+\setvalue{\??py:s:\v!layer }#1{\let\dostopproperty\stopviewerlayer\startviewerlayer[#1]}
+\setvalue{\??py:s:\s!effect }#1{\let\dostopproperty\stopeffect \starteffect [#1]}
+\setvalue{\??py:s:\v!negative}#1{\let\dostopproperty\stopnegative \startnegative }
\unexpanded\def\property[#1]%
{\groupedcommand{\dostartproperty{#1}}\dostopproperty}
@@ -50,101 +49,12 @@
\unexpanded\def\stopproperty
{\dostopproperty}
-\def\dostartgproperty
- {\begingroup\dostartproperty}
-
-\def\dostopgproperty
- {\dostopproperty\endgroup}
-
-\def\dostartproperty#1% evt pack: {current}{level}{
- {\global\advance\propertylevel\plusone
- \@EAEAEA\xdef\currentproperty{#1}%
- \global\advance\previouspropertylevel\plusone
- \global\advance\currentpropertylevel\plusone
- \csname\??py\s!check\currentproperty\endcsname
- \csname\s!start\currentpropertytype\s!property\endcsname}
-
-\def\dostopproperty
- {\csname\s!stop\currentpropertytype\s!property\endcsname
- \global\advance\currentpropertylevel\minusone
- \global\advance\previouspropertylevel\minusone
- \global\advance\propertylevel\minusone}
-
-\unexpanded\def\defineproperty
- {\dotripleempty\dodefineproperty}
-
-\def\dodefineproperty[#1]%
- {\ifcsname\??py#1\c!global\endcsname
- \expandafter\nododefineproperty
- \else
- \expandafter\dododefineproperty
- \fi[#1]}
-
-% due to initializations/counters, definitions are always global
-%
-% global : yes : ungrouped
-% no : grouped
-% method : command : define commands
-% none : no commands
-
-\def\dododefineproperty[#1][#2][#3]% global ! ! !
- {\getgparameters[\??py#1][\c!global=\v!no,\c!type=#2,\c!method=\v!none,#3]% global ! ! ! !
- \ifcsname\??py:l:#2\endcsname \else
- \expandafter\newcount\csname\??py:l:#2\endcsname % current level
- \expandafter\newcount\csname\??py:p:#2\endcsname % previous level
- \global\csname\??py:p:#2\endcsname\minusone
- \global\expandafter\let\csname\??py:c:0\endcsname\empty
- \fi
- \letgvalue{\??py\s!check#1}\docheckproperty
- \doifelsevalue{\??py#1\c!method}\v!command
- {\doifelsevalue{\??py#1\c!global}\v!yes
- {\setugvalue{\e!start#1}{\dostartproperty{#1}}%
- \setugvalue{\e!stop #1}{\dostopproperty}}%
- {\setugvalue{\e!start#1}{\dostartgproperty{#1}}%
- \setugvalue{\e!stop #1}{\dostopgproperty}}}%
- {\doifelsevalue{\??py#1\c!global}\v!yes
- {\setugvalue{\e!start#2}[##1]{\dostartproperty{##1}}%
- \setugvalue{\e!stop #2}{\dostopproperty}}%
- {\setugvalue{\e!start#2}[##1]{\dostartgproperty{##1}}%
- \setugvalue{\e!stop #2}{\dostopgproperty}}}}
-
-\def\nododefineproperty[#1][#2][#3]%
- {}
-
-\def\doifelseproperty#1{\doifdefinedelse{\??py#1\c!global}}
-
-\unexpanded\def\setupproperty
- {\dodoubleempty\dosetupproperty}
-
-\def\dosetupproperty[#1][#2]% local
- {\ifsecondargument
- \getparameters[\??py#1][#2]%
- \else
- \getparameters[\??py][#1]%
- \fi}
-
-\letvalueempty{\??py\s!empty}
-
-% beware, normally \*parameter concerns the current one
-
-\def\propertyparameter#1#2% expands to #1 when not defined (see \define...)
- {\csname\??py
- \ifcsname\??py#1#2\endcsname
- #1#2%
- \else\ifcsname\??py\csname\??py#1\c!type\endcsname#2\endcsname
- \csname\??py#1\c!type\endcsname#2%
- \else
- \s!empty
- \fi\fi
- \endcsname}
-
-\def\currentpropertyparameter % self and class
- {\propertyparameter\currentproperty}
-
-\def\checkedpropertyparameter#1% only self
- {\ifcsname\??py\currentproperty#1\endcsname\csname\??py\currentproperty#1\endcsname\fi}
+\unexpanded\def\dostartproperty#1%
+ {\pushmacro\dostopproperty
+ \getvalue{\??py:s:\getvalue{\??py#1\c!type}}{#1}}
-\unexpanded\def\definepropertyhandler#1{\setvalue{\??py*#1}}
-\def\propertyhandler #1{\getvalue{\??py*#1}}
+\unexpanded\def\dostopproperty
+ {\dostopproperty
+ \popmacro\dostopproperty}
\protect \endinput
diff --git a/tex/context/base/prop-lay.mkiv b/tex/context/base/prop-lay.mkiv
deleted file mode 100644
index 7d9d17870..000000000
--- a/tex/context/base/prop-lay.mkiv
+++ /dev/null
@@ -1,140 +0,0 @@
-%D \module
-%D [ file=prop-lay,
-%D version=2003.04.20,
-%D title=\CONTEXT\ Property Macros,
-%D subtitle=Layers,
-%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 Property Macros / Layers}
-
-%D Highly experimental, will probably change/evolve. Also, quite certainly
-%D we will no longer share code between mkii and mkiv.
-
-% test, nesting is somewhat special with layers
-%
-% \defineproperty[hans][layer]
-% \defineproperty[ton] [layer]
-% \setupheadertexts[no layer]
-% 1\startproperty[hans]2\startproperty[ton]3\stopproperty4\stopproperty5
-
-\unprotect
-
-% will be redone ... no longer using property mechanism (less clashes)
-
-\let\currentviewerlayer\empty
-
-\appendtoks
- \let\currentviewerlayer\empty
-\to \everypagebody
-
-\unexpanded\def\startlayerproperty
- {\pushmacro\currentviewerlayer % grouped (used in interaction)
- \let\currentlayerproperty\currentproperty % can be cross group
- \dotriggerviewerlayer\currentlayerproperty}
-
-\unexpanded\def\stoplayerproperty
- {\popmacro\currentviewerlayer % grouped (used in interaction)
- \let\currentlayerproperty\previousproperty % can be cross group
- \dotriggerviewerlayer\currentlayerproperty}
-
-\def\checklayerproperty % could be made more clever
- {\registerviewerlayer\currentproperty\currentproperty
- \ctxlua{backends.codeinjections.defineviewerlayer{
- tag = "\currentproperty",
- title = "\checkedpropertyparameter\c!title\currentproperty",
- visible = "\checkedpropertyparameter\c!state\v!start",
- kind = 0, % 1 == frozen
- printable = "\checkedpropertyparameter\v!printable\v!yes" % v! looks wrong
- }}}
-
-%D \starttext
-%D
-%D \setuppapersize[S4][S4]
-%D \setuplayout[middle]
-%D \setupcolors[state=start]
-%D \setupinteraction[state=start,color=,contrastcolor=]
-%D
-%D \defineproperty [L1] [layer] [title=layer 1]
-%D \defineproperty [L2] [layer] [title=layer 2]
-%D
-%D \button{HIDE L1}[HideLayer{L1}]
-%D \button{VIDE L1}[VideLayer{L1}]
-%D \button{TOGGLE L1}[ToggleLayer{L1}]
-%D
-%D \button{HIDE L2}[HideLayer{L2}]
-%D \button{VIDE L2}[VideLayer{L2}]
-%D \button{TOGGLE L2}[ToggleLayer{L2}]
-%D
-%D \noheaderandfooterlines \centerbox{\startoverlay
-%D {\definedfont[Mono at 150pt]%
-%D \startproperty[L1]\red TEST\stopproperty}
-%D {\definedfont[Mono at 150pt]%
-%D \startproperty[L2]\green TEST\stopproperty}
-%D \stopoverlay} \page
-%D
-%D \noheaderandfooterlines \centerbox{\startoverlay
-%D {\definedfont[Mono at 15pt]%
-%D \goto{\startproperty[L1]\red TEST\stopproperty}[CloseDocument]}
-%D {\definedfont[Mono at 15pt]%
-%D \goto{\startproperty[L2]\green TEST\stopproperty}[CloseDocument]}
-%D \stopoverlay} \page
-%D
-%D \startproperty[L1]
-%D level 1 \startproperty[L2]level 2 \stopproperty level 1
-%D \stopproperty
-%D
-%D \startproperty[L1]
-%D level 1 \page \startproperty[L2]level 2 \stopproperty level 1
-%D \stopproperty
-%D
-%D \stoptext
-
-\def\doinitializelayoutcomponent#1#2%
- {\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(attributes.viewerlayers.register('#1:#2',true))}\relax}%
- \expandafter\glet\csname\??ly>#1:#2\endcsname\layoutcomponentboxattribute}
-
-\def\dosetlayoutcomponentattribute#1#2% make this faster
- {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??ly>#1:#2\endcsname
- \ifx\layoutcomponentboxattribute\relax
- \doinitializelayoutcomponent{#1}{#2}% get rid of { }
- \fi}
-
-\def\doresetlayoutcomponentattribute
- {\let\layoutcomponentboxattribute\empty}
-
-\let\setlayoutcomponentattribute \gobbletwoarguments
-\let\resetlayoutcomponentattribute\relax
-\let\layoutcomponentboxattribute \empty
-
-\def\showlayoutcomponents
- {\ctxlua{attributes.viewerlayers.enable()}%
- \let\setlayoutcomponentattribute \dosetlayoutcomponentattribute
- \let\resetlayoutcomponentattribute\doresetlayoutcomponentattribute}
-
-\protect \endinput
-
-% \starttext
-% \showlayoutcomponents
-% \setupinteraction[state=start]
-% \setupheadertexts[{\goto{page 1}[page(2)]}]
-% test \setlayoutcomponentattribute{test}{aap}\hbox \layoutcomponentboxattribute \bgroup aap
-% \setlayoutcomponentattribute{test}{noot}\hbox \layoutcomponentboxattribute \bgroup noot
-% \setlayoutcomponentattribute{test}{mies}\hbox \layoutcomponentboxattribute \bgroup mies
-% \egroup noot \egroup aap \egroup
-% test \setlayoutcomponentattribute{test}{hans}\hbox \layoutcomponentboxattribute \bgroup aap \hbox{!} aap\egroup
-% test \page test \page
-% \stoptext
-
diff --git a/tex/context/base/prop-neg.mkiv b/tex/context/base/prop-neg.mkiv
deleted file mode 100644
index 37e45833c..000000000
--- a/tex/context/base/prop-neg.mkiv
+++ /dev/null
@@ -1,40 +0,0 @@
-%D \module
-%D [ file=prop-neg,
-%D version=2004.05.29, % some code moved from private modules
-%D title=\CONTEXT\ Property Macros,
-%D subtitle=Negation,
-%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 Property Macros / Negation}
-
-\unprotect
-
-% D Overprint cum suis.
-%
-% \defineproperty[\v!overprint][\s!overprint] [\c!method=\v!command]
-% \defineproperty[\v!knockout] [\s!overprint] [\c!method=\v!command]
-%
-% \definepropertyhandler \v!overprint {\dotriggeroverprint\v!overprint}
-% \definepropertyhandler \v!knockout {\dotriggeroverprint\v!knockout }
-%
-% \unexpanded\def\startoverprintproperty{\dotriggeroverprint\v!overprint}
-% \unexpanded\def\stopoverprintproperty {\dotriggeroverprint\v!knockout }
-
-%D Negative cum suis.
-
-\defineproperty [\v!negative] [\s!negative] [\c!method=\v!command]
-\defineproperty [\v!positive] [\s!negative] [\c!method=\v!command]
-
-\definepropertyhandler \v!negative {\dotriggernegative\v!negative}
-\definepropertyhandler \v!positive {\dotriggernegative\v!positive}
-
-\unexpanded\def\startnegativeproperty{\dotriggernegative\v!negative}
-\unexpanded\def\stopnegativeproperty {\dotriggernegative\v!positive}
-
-\protect \endinput
diff --git a/tex/context/base/s-fnt-10.tex b/tex/context/base/s-fnt-10.tex
index 56f2decb4..612845fc2 100644
--- a/tex/context/base/s-fnt-10.tex
+++ b/tex/context/base/s-fnt-10.tex
@@ -1,4 +1,4 @@
-%D \module
+fonts.identifiers%D \module
%D [ file=s-fnt-01,
%D version=2006.10.10, % guess
%D title=\CONTEXT\ Style File,
@@ -15,7 +15,7 @@
local format, sprint = string.format, tex.sprint
function fonts.otf.show_all()
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
if tfmdata and tfmdata.shared then
local NC, NR, char = context.NC, context.NR, context.char
local otfdata = tfmdata.shared.otfdata
@@ -34,7 +34,7 @@ function fonts.otf.show_all()
end
function fonts.show_all()
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
if tfmdata then
local NC, NR, HL, char, bold, tttf = context.NC, context.NR, context.HL, context.char, context.bold, context.tttf
local chars = tfmdata.characters
@@ -100,7 +100,7 @@ function fonts.show_all()
end
function fonts.show_glyphs()
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
if tfmdata then
for k, v in ipairs(table.sortedkeys(tfmdata.characters)) do
if v >=0 then
diff --git a/tex/context/base/s-fnt-23.tex b/tex/context/base/s-fnt-23.tex
index d2d6f4af5..35973d27e 100644
--- a/tex/context/base/s-fnt-23.tex
+++ b/tex/context/base/s-fnt-23.tex
@@ -17,7 +17,7 @@
local last_data = nil
local format = string.format
function fonts.otf.show_shape(n)
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
last_data = tfmdata
local charnum = tonumber(n)
if not charnum then
@@ -194,7 +194,7 @@
end
end
function fonts.otf.show_all_shapes(start,stop)
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
last_data = tfmdata
start, stop = start or "\\startTEXpage\\gobbleoneargument", stop or "\\stopTEXpage"
local unicodes, indices, descriptions = tfmdata.unicodes, tfmdata.indices, tfmdata.descriptions
@@ -208,7 +208,7 @@
end
end
function fonts.otf.show_shape_field(unicode,name)
- local tfmdata = last_data or fonts.ids[font.current()]
+ local tfmdata = last_data or fonts.identifiers[font.current()]
local d = tfmdata.descriptions[unicode]
if d then
if name == "unicode" then
diff --git a/tex/context/base/s-fnt-25.tex b/tex/context/base/s-fnt-25.tex
index f04b31c28..fc78ddfda 100644
--- a/tex/context/base/s-fnt-25.tex
+++ b/tex/context/base/s-fnt-25.tex
@@ -80,13 +80,13 @@ local format, lower = string.format, string.lower
function document.showmathfont(id,slot)
local data = characters.data
- local tfmdata = fonts.ids[id]
+ local tfmdata = fonts.identifiers[id]
local characters = tfmdata.characters
local sorted = (slot and { slot }) or table.sortedkeys(characters)
local virtual, names = tfmdata.type == "virtual", { }
if virtual then
for k, v in ipairs(tfmdata.fonts) do
- local name = fonts.ids[v.id].name
+ local name = fonts.identifiers[v.id].name
names[k] = (name and file.basename(name)) or v.id
end
end
diff --git a/tex/context/base/s-fnt-29.tex b/tex/context/base/s-fnt-29.tex
index 857591085..c09a8f85e 100644
--- a/tex/context/base/s-fnt-29.tex
+++ b/tex/context/base/s-fnt-29.tex
@@ -15,7 +15,7 @@
function fonts.tracers.shapes() -- todo: ranges
local NC, NR = context.NC, context.NR
- local chrs = fonts.ids[font.current()].characters
+ local chrs = fonts.identifiers[font.current()].characters
context.starttabulate { "|l|c|c|c|c|l|" }
context.FL()
NC() context("unicode")
diff --git a/tex/context/base/s-map-10.tex b/tex/context/base/s-map-10.mkii
index 865132f97..865132f97 100644
--- a/tex/context/base/s-map-10.tex
+++ b/tex/context/base/s-map-10.mkii
diff --git a/tex/context/base/s-map-10.mkiv b/tex/context/base/s-map-10.mkiv
new file mode 100644
index 000000000..03d74fe36
--- /dev/null
+++ b/tex/context/base/s-map-10.mkiv
@@ -0,0 +1,463 @@
+%D \module
+%D [file=s-map-se,
+%D version=2005.02.03,
+%D title=\CONTEXT\ Style File,
+%D subtitle=\MAPS\ basis stijl,
+%D author={Hans Hagen, Taco Hoekwater and Siep Kroonenberg},
+%D date=\currentdate,
+%D copyright={NTG / MAPS}]
+
+% This module re-implements the MAPS style for use with the Context macro
+% package. The original MAPS layout was designed and implemented in
+% LaTeX by Taco Hoekwater and Siep Kroonenberg.
+%
+% This variant is cleaned up for \MKIV. Some more cleanup is possible.
+%
+% Three layouts:
+%
+% 1. two columns
+% 2. one column, with wide outer margins (option onecolumn)
+% 3. one column, with wide left margin (option asym)
+%
+% A mode nosubsub defines only two levels of sectioning. If you
+% don't need more and use the two-column layout, then this option
+% will probably improve the looks of your paper.
+%
+% The default is twocolumns.
+
+\doifmode {asym} {\enablemode[onecolumn]} % implies onecolumn
+
+\definebodyfontenvironment [7pt] [interlinespace=8pt, big=8pt, small=6pt]
+\definebodyfontenvironment [8pt] [interlinespace=9pt, big=9pt, small=7pt, x=6pt]
+\definebodyfontenvironment [9pt] [interlinespace=10pt,big=10pt,small=8pt, x=7pt,script=6pt]
+\definebodyfontenvironment [10pt][interlinespace=11pt,big=11pt,small=9pt, x=8pt,script=7pt,a=11pt]
+\definebodyfontenvironment [11pt][interlinespace=11pt,big=11pt,small=10pt,x=9pt,script=8pt]
+\definebodyfontenvironment [14pt][interlinespace=14pt,big=24pt,small=11pt,x=10pt]
+\definebodyfontenvironment [24pt][interlinespace=24pt,big=24pt,small=14pt,x=11pt]
+\definebodyfontenvironment [22pt][interlinespace=24pt,big=22pt,small=14pt,x=14pt]
+\definebodyfontenvironment [30pt][interlinespace=30pt,big=30pt,small=26pt,x=26pt]
+
+\definefontfeature [default] [default] [protrusion=pure]
+
+\definetypeface [maps] [rm] [serif] [libertine] [default]
+\definetypeface [maps] [ss] [sans] [default] [default] [rscale=0.95]
+\definetypeface [maps] [tt] [mono] [inconsolata] [default] [rscale=0.92]
+\definetypeface [maps] [mm] [math] [euler] [default] [rscale=0.9]
+
+\setupbodyfont[maps,10pt,rm]
+
+\setupinterlinespace
+ [line=11pt]
+
+\setupalign
+ [hanging]
+
+\setupindenting
+ [yes,next,11pt]
+
+% It is easy to do the shift toward the spine when assembling the
+% volume with LaTeX pdfpages.
+
+% eh ... why not use backspace ?
+
+\definepapersize [maps]
+ [width=595.3bp, % 21cm
+ height=756bp] % 10.5in
+
+\setuppapersize
+ [maps]
+ [maps] % oversized
+
+\setuplayout
+ [topspace=40pt,
+ height=688pt,
+ header=33pt,
+ margin=106pt,
+ leftmargindistance=11pt,
+ rightmargindistance=11pt]
+
+\setupblank
+ [5.5pt]
+
+\setuppagenumbering
+ [location=]
+
+\definetyping [widetyping]
+
+\setupheader [style=\ss]
+\setupfooter [style=\ss]
+
+\def\AuHead{\MapsRunningAuthor}
+\def\TiHead{\ifnum\pageno=\MapsPage\relax\MapsRunningAuthor\else\MapsRunningTitle\fi}
+
+\setupheads
+ [sectionnumber=no,
+ align=flushleft]
+
+\def\hfonti {\ssbfa}
+\def\hfontii {\ssbf}
+\def\hfontiii{\rm\it}
+
+\def\runin#1#2{#2.}
+
+\doifmodeelse {nosubsub} {
+
+ \setuphead [section]
+ [style=\hfontii,
+ before={\blank[line]},
+ after=]
+
+ \setuphead [subsection]
+ [style=\hfontiii,
+ before={\blank[halfline]}%
+ command=\runin,
+ alternative=text,
+ distance=6pt]
+
+} {
+
+ \setuphead [section]
+ [style=\hfonti,
+ before={\blank[line]},
+ after={\blank[halfline]}]
+
+ \setuphead [subsection]
+ [style=\hfontii,
+ before={\blank[halfline]},
+ after=]
+
+ \setuphead [subsubsection]
+ [style=\hfontiii,
+ before={\blank[halfline]},
+ command=\runin,
+ alternative=text,
+ distance=6pt]
+
+}
+
+\doifmodeelse {nosubsub} {
+
+ \setuphead [subject]
+ [style=\hfontii,
+ before={\blank[halfline]},
+ after=]
+
+ \setuphead [subsubject]
+ [style=\hfontiii,
+ command=\runin,
+ alternative=text,
+ before={\blank[halfline]}]
+
+} {
+
+ \setuphead [subject]
+ [style=\hfonti,
+ before={\blank},
+ after={\blank[halfline]}]
+
+ \setuphead [subsubject]
+ [style=\hfontii,
+ before={\blank[halfline]},
+ after=]
+
+ \setuphead [subsubsubject]
+ [style=\hfontiii,
+ command=\runin,
+ alternative=text,
+ before={\blank[halfline]}]
+
+}
+
+\setupfloats
+ [location=center,
+ before=\ss] % brrr
+
+\setupcaptions
+ [headstyle=\ss,
+ style=\ssx,
+ stopper=.,
+ distance=6pt,
+ inbetween={\blank[halfline]}]
+
+% \def\ChkBox
+% {\definedfont[file:stmary10]{\char "40}} % doesnt work
+
+\def\ChkBox
+ {\hbox
+ {\boxrulewidth=.4pt
+ \raise.2ex\ruledvbox{\phantom{\vrule width .85ex height .85ex}}}}
+
+\definesymbol [1][\ChkBox]
+
+\setupitemize[1][packed]
+
+\setupitemize [each]
+ [indentnext=no,
+ align=right,
+ width=1em,
+ distance=0pt]
+
+% an outer form of itemize that does not indent the paragraph.
+
+% \startitemize[width=1sp,#1]
+% \let\doitem\item
+% \def\item{\doitem[]\hbox{}\kern12pt\rightskip=0pt}%
+
+\defineitemgroup
+ [outeritemize]
+
+\setupitemgroup
+ [outeritemize]
+ [width=1sp,
+ distance=12pt]
+
+\setupenumerations
+ [indentnext=no]
+
+\setupdescriptions
+ [indentnext=no]
+
+% \unexpanded\def\smalltyping % ? ? ? ?
+% {\switchtobodyfont[tt]%
+% \parindent=0pt}
+
+% typing:
+% - prettyverbatim is NOT the default
+% - smaller size
+
+\setuptyping
+ [% style=\smalltyping,
+ option=none,
+ indentnext=no]
+
+\def\footnum#1{#1.}
+
+\setupfootnotes
+ [location=none,
+ width=\textwidth,
+ before=,
+ numbercommand=\footnum]
+
+\setupfootnotedefinition
+ [location=serried,
+ before=,
+ after=,
+ distance=0.5em]
+
+\setuptabulate
+ [before=\blank,
+ inner=\ss,
+ after=\blank]
+
+\def\startIntroEntry#1%
+ {\startlinecorrection
+ \bgroup
+ \setupalign[right]
+ \setuptolerance[verytolerant]
+ \setupindenting[no]
+ \noindent
+ \switchtobodyfont[9pt]%
+ \setuplocalinterlinespace[line=10pt]%
+ \parfillskip 0pt plus 1fill
+ \rightskip6pt plus 1fill
+ \ss
+ \bgroup
+ \bf
+ #1%
+ \par
+ \egroup
+ \ignorespaces}
+
+\def\stopIntroEntry
+ {\par
+ \egroup
+ \stoplinecorrection
+ \blank[line]}
+
+\unexpanded\def\defineIntroEntry[#1][#2][#3]%
+ {\setvalue{start#1}{\startIntroEntry{#2}}%
+ \setvalue {stop#1}{\stopIntroEntry#3}}
+
+\defineIntroEntry[Keywords][Keywords][]
+\defineIntroEntry[Abstract][Abstract][]
+
+% article parameters (other fields and defaults)
+%
+% we can use setups instead (with a set key)
+
+\def\MapsBibData[#1]%
+ {\getparameters [Maps]
+ [SubTitle=,
+ RunningAuthor=,
+ RunningTitle=,
+ Email=,
+ Address=,
+ Page=1,
+ Title=,
+ Author=,
+ Period=VOORJAAR,
+ Number=40,
+ Year=2010,
+ #1]%
+ \doifinstringelse{oorjaar}{\MapsPeriod}{\def\MapsPeriod{VOORJAAR}}{}%
+ \doifinstringelse{pring} {\MapsPeriod}{\def\MapsPeriod{VOORJAAR}}{}%
+ \doifinstringelse{ajaar} {\MapsPeriod}{\def\MapsPeriod{NAJAAR}} {}%
+ \doifinstringelse{utumn} {\MapsPeriod}{\def\MapsPeriod{NAJAAR}} {}%
+ \doifnothing\MapsRunningAuthor
+ {\global\let\MapsRunningAuthor\MapsAuthor}%
+ \doifnothing\MapsRunningTitle
+ {\global\let\MapsRunningTitle\MapsTitle}}
+
+\def\dostartArticle[#1]%
+ {\MapsBibData[#1]
+ \pageno=\MapsPage
+ \count0=\MapsPage
+ \setuppagenumber[number=\MapsPage]
+ \startbaselinecorrection
+ \bgroup
+ \hsize = 457pt
+ \let\\\crlf
+ \blank[29pt,force]
+ \switchtobodyfont[ss,30pt]
+ \setupalign[right]
+ \bgroup
+ \noindent
+ \MapsTitle
+ \par
+ \blank[6pt]
+ \egroup
+ \ifx\MapsSubTitle\empty \else
+ \bgroup
+ \switchtobodyfont[ss,22pt]\noindent
+ \advance \rightskip 0pt plus 2em
+ \MapsSubTitle
+ \par
+ \egroup
+ \fi
+ \doifmodeelse{newstyle}{\blank[22pt]}{\blank[30pt]}
+ \egroup
+ \setupalign[width]
+ \switchtobodyfont[rm,10pt]
+ \doifmode{newstyle}{\noindent\MapsAuthor\blank[line]}
+ \stopbaselinecorrection
+ \doifnotmode {onecolumn} {
+ \startcolumns
+ \hyphenpenalty1000
+ } {
+ \clubpenalty10000
+ \widowpenalty10000
+ }
+ \fi}
+
+\definecolumnset
+ [mapsset]
+ [n=2,
+ grid=on]
+
+\def\startArticle
+ {\dosingleempty\dostartArticle}
+
+\def\signArticle
+ {\blank
+ \let\\\crlf
+ \noindent
+ \switchtobodyfont[ss,9pt]%
+ \MapsAuthor
+ \doifsomething{\MapsAddress}{\crlf\MapsAddress}%
+ \doifsomething{\MapsEmail} {\crlf\MapsEmail}%
+ \switchtobodyfont[10pt]%
+ \def\signArticle{}}
+
+\def\stopArticle
+ {\par
+ \signArticle
+ \doifnotmode {onecolumn} {
+ \stopcolumns
+ }
+ \page}
+
+\installpagebreakhandler{last}{}
+
+\doifmodeelse {onecolumn} {
+
+ \setuplayout[width=340pt]
+
+ \doifmodeelse {asym} {% one col, asymmetric
+
+ \setuplayout[backspace=187.3pt]%
+ \setuptyping [widetyping][oddmargin=-117pt]
+ \setuppagenumbering [alternative={singlesided,doublesided}]
+ \setupheadertexts
+ [{\hbox{}\hskip-117pt\TiHead}]
+ [{\cap{\MapsPeriod\ \MapsYear}\quad\bf \pagenumber\hskip-30pt\hbox{}}]
+ [{\hbox{}\hskip-147pt{\bf \pagenumber}\quad \cap {maps\ \MapsNumber}}]
+ [\AuHead]
+ \setupfootertexts
+
+ } { % one col, symmetric
+
+ \setuplayout[backspace=70.3pt]
+ \setuppagenumbering [alternative=doublesided]
+ \setuptyping[blank=halfline]
+ \setupheadertexts
+ [\TiHead]
+ [{\cap{\MapsPeriod\ \MapsYear}\quad\bf \pagenumber\hskip-147pt\hbox{}}]
+ [{\hbox{}\hskip-147pt{\bf \pagenumber}\quad \cap {maps\ \MapsNumber}}]
+ [\AuHead]
+ \setupfootertexts
+
+ }
+
+} { % two col
+
+ \setuplayout[width=457pt]
+ \setupcolumns[n=2,tolerance=verytolerant,distance=11pt]
+ \setuplayout[backspace=70.3pt,grid=yes]
+ \setuppagenumbering [alternative=doublesided]
+ \setuptyping[blank=halfline]
+ \setupheadertexts
+ [\TiHead]
+ [{\cap{\MapsPeriod\ \MapsYear}\quad\bf \pagenumber\hskip-30pt\hbox{}}]
+ [{\hbox{}\hskip-30pt{\bf \pagenumber}\quad \cap {maps\ \MapsNumber}}]
+ [\AuHead]
+ \setupfootertexts
+
+}
+
+\def\fulltextwidth{457pt}
+
+\unexpanded\def\startdescription
+ {\blank
+ \startnarrower[left]
+ \def\sym##1{\par\noindent\hbox{\bf\kern-16pt\relax##1}\hskip12pt\relax}}
+
+\unexpanded\def\stopdescription
+ {\stopnarrower
+ \blank
+ \noindentation}
+
+\frenchspacing
+
+\setuptolerance
+ [tolerant]
+
+% tb compatible
+
+\unexpanded\def\ConTeXt {Con{\TeX}t}
+\unexpanded\def\CONTEXT {\ConTeXt}
+\unexpanded\def\METAFONT {Metafont}
+\unexpanded\def\METAPOST {MetaPost}
+\unexpanded\def\POSTSCRIPT{PostScript}
+\unexpanded\def\XeTeX {X\lower.5ex\hbox{\kern-.1em\mirror{E}}\kern-.1667em\TeX}
+
+\unexpanded\def\LaTeX
+ {{\setbox\scratchbox\hbox{L}%
+ \scratchdimen\ht\scratchbox
+ \setbox\scratchbox\hbox{\switchtobodyfont[script]A}%
+ L\kern-.55\wd\scratchbox
+ \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}%
+ \kern-.2\wd\scratchbox\TeX}}
+
+\unexpanded\def\acro#1{{\switchtobodyfont[9pt]#1}}
+
+\endinput
diff --git a/tex/context/base/s-pre-30.tex b/tex/context/base/s-pre-30.mkii
index 2a3899c92..2a3899c92 100644
--- a/tex/context/base/s-pre-30.tex
+++ b/tex/context/base/s-pre-30.mkii
diff --git a/tex/context/base/s-pre-30.mkiv b/tex/context/base/s-pre-30.mkiv
new file mode 100644
index 000000000..c3b524047
--- /dev/null
+++ b/tex/context/base/s-pre-30.mkiv
@@ -0,0 +1,257 @@
+%D \module
+%D [ file=s-pre-30,
+%D version=2006.04.25,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 30,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\usemodule[streams]
+
+\setuppapersize
+ [S6] [S6]
+
+\setupbodyfont
+ [12pt,tt]
+
+\definemeasure[bleed][6pt]
+
+\definecolor[maincolor-3][r=.5,g=.2,b=.2]
+\definecolor[maincolor-1][r=.2,g=.5,b=.2]
+\definecolor[maincolor-2][r=.2,g=.2,b=.5]
+
+\definecolor[pagecolor] [s=.5]
+\definecolor[resultcolor][s=1,t=.85,a=1]
+\definecolor[maincolor] [maincolor-3]
+
+\definecolorgroup
+ [maingroup]
+ [.5:.2:.2,
+ .2:.5:.2,
+ .2:.2:.5]
+
+\definecolorgroup
+ [resultgroup]
+ [1:.85:.85,
+ .85:1:.85,
+ .85:.85:1]
+
+\def\CurrentColor{1}
+
+\definecolor[maincolor] [maingroup:\CurrentColor]
+\definecolor[resultcolor][resultgroup:\CurrentColor]
+
+\def\NextColor{\ifnum\CurrentColor=3 \def\CurrentColor{1}\else\doglobal\increment\CurrentColor\fi}
+
+\setuplayout
+ [backspace=\measure{bleed},
+ topspace=30pt,
+ bottomdistance=\measure{bleed},
+ bottom=\dimexpr30pt-\measure{bleed}\relax,
+ header=0pt,
+ footer=0pt,
+ topdistance=\measure{bleed},
+ top=\dimexpr30pt-\measure{bleed}\relax,
+ width=middle,
+ height=middle]
+
+\setuptop
+ [before=\vfill,
+ after=\vfill,
+ strut=yes]
+
+\setupbackgrounds
+ [text]
+ [backgroundoffset=\measure{bleed},
+ background=color,
+ backgroundcolor=maincolor]
+
+\setupbackgrounds
+ [page]
+ [background=color,
+ backgroundcolor=pagecolor]
+
+\setupcolors
+ [state=start,
+ textcolor=white]
+
+\setuphead
+ [chapter]
+ [style=\ttd]
+
+\setuphead
+ [section]
+ [style=\ttd]
+
+\defineviewerlayer
+ [result]
+ [state=stop]
+
+\definelayer
+ [result]
+
+\setuplayer
+ [result]
+ [width=\textwidth,
+ height=\textheight]
+
+\setupbackgrounds
+ [text]
+ [background={color,toggle,foreground,result}]
+
+\setupinteraction
+ [state=start,
+ click=no,
+ menu=on,
+ color=white,
+ contrastcolor=white,
+ closepageaction=HideLayer{result},
+ openpageaction=HideLayer{result}]
+
+% We add a dummy color switch so that each page has at least one
+% transparency; else acrobat will render the pages differently
+% bug in 6 and 7).
+
+\startinteractionmenu[bottom]
+% \color[resultcolor]{ }%
+ \hfill
+ \got [content] content \\
+ \got [previouspage] previous \\
+ \got [nextpage] next \\
+ \got [ToggleLayer{result}] result \\
+ \got [CloseDocument] close \\
+\stopinteractionmenu
+
+\setuphead
+ [section]
+ [placehead=no,
+ incrementnumber=list]
+
+\setuplist
+ [section]
+ [alternative=f]
+
+\defineoverlay
+ [toggle]
+ [\overlaybutton{ToggleLayer{result}}]
+
+\definestreamlayer
+ [resultstream]
+
+\startsetups streamlayer:resultstream:flush
+ \setlayer
+ [result]
+ [preset=middlebottom,
+ hoffset=\measure{bleed},
+% voffset=-\measure{bleed}]
+ voffset=\measure{bleed}]
+ {\startviewerlayer[result]%
+% \framed
+% [offset=overlay,
+% frame=off,
+% background=color,
+% backgroundoffset=1\dimexpr\measure{bleed}\relax,
+% backgroundcolor=maincolor]
+ {\framed
+ [offset=overlay,
+ frame=off,
+ foregroundcolor=maincolor,
+ background=color,
+ backgroundoffset=1\dimexpr\measure{bleed}\relax,
+ backgroundcolor=resultcolor]
+ {\tightlayer[\currentstreamlayer]}}
+ \stopviewerlayer}
+\stopsetups
+
+\startsetups show-definition
+ \subject{definition}
+ \typebuffer
+ \getbuffer
+ \page
+\stopsetups
+
+\startsetups show-result
+ \startstreamlayer[resultstream]
+ \subject{result}
+ \getbuffer
+ \stopstreamlayer
+ \placestreamlayer[resultstream]
+ \page
+\stopsetups
+
+\startsetups show-usage
+ \subject{usage}
+ \typebuffer
+ \startstreamlayer[resultstream]
+ \subject{result}
+ \getbuffer
+ \stopstreamlayer
+ \placestreamlayer[resultstream]
+ \page
+\stopsetups
+
+\startsetups show-usage-lines
+ \subject{usage}
+ \typebuffer
+ \startstreamlayer[resultstream]
+ \subject{result}
+ \startlines
+ \getbuffer
+ \stoplines
+ \stopstreamlayer
+ \placestreamlayer[resultstream]
+ \page
+\stopsetups
+
+\startsetups show-contents
+ \startcolumns[n=3]
+ \placelist[section][criterium=text]
+ \stopcolumns
+ \pagereference[content]
+ \page
+ \NextColor
+\stopsetups
+
+\def\TitlePage#1%
+ {\title{#1}
+ \setups{show-contents}}
+
+\def\StartSample#1%
+ {\starttext
+ \page
+ \section{#1}
+ \setuptoptexts[][\processedfile\enspace:\enspace\lowercase{#1}]}
+
+\def\StopSample
+ {\page
+ \setuptoptexts[][]
+ \stoptext
+ \NextColor}
+
+\endinput
+
+\usemodule[pre-30]
+
+% \TitlePage{Howling to the moon}
+
+\StartSample{Basics}
+
+\startbuffer
+\lua{a = 1.5 ; b = 1.8 ; c = a*b ; tex.print(c) ;}
+
+\startlua
+ a = 1
+ b = 2
+ c = a*b
+ tex.print(c)
+\stoplua
+\stopbuffer
+
+\setups{show-usage}
+
+\StopSample
diff --git a/tex/context/base/s-pre-60.tex b/tex/context/base/s-pre-60.mkii
index f12b98b06..4df3e8a61 100644
--- a/tex/context/base/s-pre-60.tex
+++ b/tex/context/base/s-pre-60.mkii
@@ -62,36 +62,20 @@
\def\NextStepLayer {step:\the\numexpr\StepCounter+1\relax}
\def\FirstStepLayer{step:1}
-\startmode[mkiv]
-
- \def\StartStep
- {\startproperty[\StepLayer]%
- \ignorespaces}
-
- \def\StopStep
- {\removeunwantedspaces
- \stopproperty}
-
-\stopmode
-
-\startnotmode[mkiv]
-
- \def\StartStep
- {\ifvmode
- \scratchskip\lastskip
- \vskip-\scratchskip
- \startproperty[\StepLayer]%
- \vskip\scratchskip
- \else
- \startproperty[\StepLayer]%
- \fi
- \ignorespaces}
-
- \def\StopStep
- {\removeunwantedspaces
- \stopproperty}
-
-\stopnotmode
+\def\StartStep
+ {\ifvmode
+ \scratchskip\lastskip
+ \vskip-\scratchskip
+ \startproperty[\StepLayer]%
+ \vskip\scratchskip
+ \else
+ \startproperty[\StepLayer]%
+ \fi
+ \ignorespaces}
+
+\def\StopStep
+ {\removeunwantedspaces
+ \stopproperty}
\def\StartSteps{\iftrialtypesetting\else\ResetStep\NextStep\StartStep\fi}
\def\StopSteps {\iftrialtypesetting\else\StopStep \PrevStep \fi}
diff --git a/tex/context/base/s-pre-60.mkiv b/tex/context/base/s-pre-60.mkiv
new file mode 100644
index 000000000..2ceb23773
--- /dev/null
+++ b/tex/context/base/s-pre-60.mkiv
@@ -0,0 +1,132 @@
+%D \module
+%D [ file=s-pre-60,
+%D version=2004.03.15,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 60,
+%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.
+
+\startmode[paper,print]
+ \let\StartSteps\relax
+ \let\StopSteps \relax
+ \let\FlushStep \relax
+ \let\ResetStep \relax
+ \let\StartBusy \relax
+ \let\StopBusy \relax
+ \endinput
+\stopmode
+
+\newcounter\StepCounter
+\newcounter\StepMaximum
+
+\useJSscripts[stp]
+
+\startsetups[set-stepper]
+
+ \ifnum\getvariable{stepper}{nofsteps}>\StepMaximum
+
+ \dostepwiserecurse {\numexpr\StepMaximum+1\relax} {\getvariable{stepper}{nofsteps}} {1} {
+ \doifnotmode{nosteps,nostep} {
+ \expanded{\defineviewerlayer[step:\recurselevel][state=stop]}
+ }
+ }
+
+ \xdef\StepMaximum{\getvariable{stepper}{nofsteps}}
+
+ \fi
+
+\stopsetups
+
+\setvariables
+ [stepper]
+ [set=\setups{set-stepper},
+ nofsteps=50]
+
+\defineviewerlayer[step:busy][state=start]
+
+\definereference [SetupStepper] [JS(SetupStepper{step,\StepMaximum})]
+\definereference [ResetStepper] [JS(ResetStepper)]
+\definereference [CheckStepper] [JS(CheckStepper{\StepCounter})]
+\definereference [InvokeStepper] [JS(InvokeStepper)]
+
+% todo: roll back blank
+
+\def\ResetStep {\doglobal\newcounter\StepCounter}
+\def\NextStep {\doglobal\increment \StepCounter}
+\def\PrevStep {\doglobal\decrement \StepCounter}
+
+\def\StepLayer {step:\StepCounter}
+\def\NextStepLayer {step:\the\numexpr\StepCounter+1\relax}
+\def\FirstStepLayer{step:1}
+
+\def\StartStep {\startviewerlayer[\StepLayer]\ignorespaces}
+\def\StopStep {\removeunwantedspaces\stopviewerlayer}
+\def\StartSteps {\iftrialtypesetting\else\ResetStep\NextStep\StartStep\fi}
+\def\StopSteps {\iftrialtypesetting\else\StopStep \PrevStep \fi}
+\def\FlushStep {\iftrialtypesetting\else\StopStep \NextStep\StartStep\fi}
+
+\def\StartBusy {\startviewerlayer[step:busy]\ignorespaces}
+\def\StopBusy {\removeunwantedspaces\stopviewerlayer}
+
+\appendtoks
+ \ResetStep
+\to \everyaftershipout
+
+\setupinteraction
+ [%openaction=SetupStepper,
+ closeaction=ResetStepper,
+ openpageaction=CheckStepper,
+ closepageaction=ResetStepper]
+
+\defineoverlay[invoke][\overlaybutton{InvokeStepper}]
+
+\setupbackgrounds
+ [text]
+ [background=invoke]
+
+% bonus
+
+\useMPlibrary[nav]
+
+\definepalet
+ [navplus]
+ [attach=interactioncolor,
+ comment=interactioncolor]
+
+\setupcomment
+ [symbol={comment-normal,comment-down},
+ textlayer=\StepLayer,
+ option=buffer,
+ height=\textheight,
+ width=\textwidth,
+ margin=0pt]
+
+\setupattachments
+ [symbol={attach-normal,attach-down},
+ textlayer=\StepLayer]
+
+%D Handy:
+
+\def\StartLocalSteps{\ResetStep}
+\def\StopLocalSteps {}
+
+\def\StartLocalStep {\NextStep\StartStep}
+\def\StopLocalStep {\StopStep}
+
+%D used as (given some definitions):
+%D
+%D \starttyping
+%D \StartLocalSteps
+%D \startcombination[both]
+%D {\StartLocalStep\placestreamlayer[left]\StopLocalStep} {}
+%D {\StartLocalStep\placestreamlayer[right]\StopLocalStep} {}
+%D \stopcombination
+%D \StopLocalSteps
+%D \stoptyping
+
+\endinput
diff --git a/tex/context/base/s-pre-71.tex b/tex/context/base/s-pre-71.mkii
index db65c8e28..db65c8e28 100644
--- a/tex/context/base/s-pre-71.tex
+++ b/tex/context/base/s-pre-71.mkii
diff --git a/tex/context/base/s-pre-71.mkiv b/tex/context/base/s-pre-71.mkiv
new file mode 100644
index 000000000..a23d1950f
--- /dev/null
+++ b/tex/context/base/s-pre-71.mkiv
@@ -0,0 +1,213 @@
+% engine=luatex
+
+%D \module
+%D [ file=s-pre-71,
+%D version=2008.08.05,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 71,
+%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.
+
+%D I might improve this module so consider it experimental.
+
+% \enablemode[numbers]
+% \enablemode[paper]
+
+\usemodule[pre-60,abr-02]
+
+\setupinteraction[state=start,click=off]
+
+\definepapersize[wide][width=900pt,height=600pt]
+
+\setuppapersize[wide][wide]
+
+\setuplayout[page]
+
+% \setupbodyfont[15pt]
+
+\usetypescriptfile[type-hgz]
+\usetypescript[palatino-informal]
+\setupbodyfont[palatino-informal,15pt]
+
+\setupsorting[logo][style=]
+
+\startnotmode[paper]
+ \setupbackgrounds[page][background=color,backgroundcolor=black]
+\stopnotmode
+
+\TransparencyHack
+
+\definelayer[page][width=\paperwidth,height=\paperheight]
+
+\definecolor[TopicColor-1][r=.3,g=.4,b=.5]
+\definecolor[TopicColor-2][r=.3,g=.5,b=.4]
+\definecolor[TopicColor-3][r=.4,g=.3,b=.5]
+\definecolor[TopicColor-4][r=.4,g=.5,b=.3]
+\definecolor[TopicColor-5][r=.5,g=.3,b=.4]
+\definecolor[TopicColor-6][r=.5,g=.4,b=.3]
+\definecolor[TopicColor-7][r=.35,g=.35,b=.6]
+\definecolor[TopicColor-8][r=.6,g=.35,b=.35]
+\definecolor[TopicColor-9][r=.35,g=.6,b=.35]
+
+\definecolor[TopicColor-0][t=.5,a=1,s=.5]
+\definecolor[TopicColor] [s=1]
+
+\setupcolors[state=start]
+\setupcolors[textcolor=TopicColor]
+
+\startluacode
+ local locations = {
+ 'lefttop',
+ 'middletop',
+ 'righttop',
+ 'middleleft',
+ 'middle',
+ 'middleright',
+ 'leftbottom',
+ 'middlebottom',
+ 'rightbottom',
+ }
+ local done, current, previous, n = table.tohash(locations,false), 0, 0, 0
+ function document.reset_locations()
+ done, current, previous, n = table.tohash(locations,false), 0, 0, 0
+ end
+ function document.next_location(loc)
+ previous = current
+ n = n + 1
+ loc = loc and loc ~= "" and tonumber(loc)
+ while true do
+ current = loc or math.random(1,#locations)
+ if not done[current] then
+ done[current] = true
+ break
+ end
+ end
+ end
+ function document.current_location()
+ tex.print(locations[current] or "")
+ end
+ function document.previous_location()
+ tex.print(locations[previous] or "")
+ end
+ function document.current_n()
+ tex.print(tostring(current))
+ end
+ function document.previous_n()
+ tex.print(tostring(previous))
+ end
+ function document.step()
+ tex.print(tostring(n))
+ end
+\stopluacode
+
+\def\StartTopics
+ {\startstandardmakeup
+ \ctxlua{document.reset_locations()}
+ \doifnotmode{paper}{\StartLocalSteps}}
+
+\def\StopTopics
+ {\doifnotmode{paper}{\StopLocalSteps}
+ \flushlayer[page]
+ \stopstandardmakeup}
+
+\def\StartTopic
+ {\dosingleempty\doStartTopic}
+
+\def\doStartTopic[#1]%
+ {\doifnotmode{paper}{\NextStep}
+ \ctxlua{document.next_location("#1")}
+ \startnotmode[paper]
+ \doifnothing{#1}
+ {\ifcase\ctxlua{document.previous_n()}\else
+ \setlayer
+ [page]
+ [preset=\ctxlua{document.previous_location()}]
+ \bgroup
+ \doifnotmode{paper}{\startviewerlayer[\StepLayer]}%
+ \framed
+ [offset=20pt,
+ strut=no,
+ align=normal,
+ frame=off,
+ height=\dimexpr\paperheight/3\relax,
+ width=\dimexpr\paperwidth/3\relax,
+ background=color,
+ backgroundcolor=TopicColor-0]
+ {}%
+ \doifnotmode{paper}{\stopviewerlayer}%
+ \egroup
+ \fi}
+ \stopnotmode
+ \setlayer
+ [page]
+ [preset=\ctxlua{document.current_location()}]
+ \bgroup
+ \doifnotmode{paper}{\startviewerlayer[\StepLayer]}%
+ \framed
+ [offset=20pt,
+ strut=no,
+ align=\expdoifelse{#1}{}{normal}{middle,lohi},
+ align=\expdoifelse{#1}{}{flushleft,verytolerant}{middle,lohi},
+ frame=off,
+ height=\dimexpr\paperheight/3\relax,
+ width=\dimexpr\paperwidth/3\relax,
+ background=color,
+ backgroundcolor=TopicColor-\ctxlua{document.current_n()}]
+ \bgroup
+ \ignorespaces}
+
+\def\StopTopic
+ {\removeunwantedspaces
+ \egroup
+ \doifnotmode{paper}{\stopviewerlayer}%
+ \egroup
+ \startmode[numbers]
+ \setlayerframed
+ [page]
+ [preset=\ctxlua{document.current_location()}]
+ [height=\dimexpr\paperheight/3\relax,
+ width=\dimexpr\paperwidth/3\relax,
+ frame=off,
+ foregroundstyle=\bfa,
+ align={flushright,low}]
+ {\doifnotmode{paper}{\startviewerlayer[\StepLayer]}%
+ \ctxlua{document.step()}\kern\strutdepth
+ \doifnotmode{paper}{\stopviewerlayer}}
+ \stopmode}
+
+\logo [METAPOST] {MetaPost}
+
+\definefont[TitleFont][SansBold at 60pt]
+\definefont[TempFont] [SansBold at 12pt]
+
+\let\StartText\starttext
+\let\StopText \stoptext
+
+\doifnotmode{demo}{\endinput}
+
+\starttext
+
+\StartTopics
+ \StartTopic[1] A \StopTopic
+ \StartTopic[5] B \StopTopic
+ \StartTopic[9] C \StopTopic
+\StopTopics
+
+\StartTopics
+ \StartTopic A \StopTopic
+ \StartTopic B \StopTopic
+ \StartTopic C \StopTopic
+ \StartTopic D \StopTopic
+ \StartTopic E \StopTopic
+ \StartTopic F \StopTopic
+ \StartTopic G \StopTopic
+ \StartTopic H \StopTopic
+ \StartTopic I \StopTopic
+\StopTopics
+
+\stoptext
diff --git a/tex/context/base/scrp-ini.lua b/tex/context/base/scrp-ini.lua
index b543053af..11ffd02f8 100644
--- a/tex/context/base/scrp-ini.lua
+++ b/tex/context/base/scrp-ini.lua
@@ -32,7 +32,7 @@ local state = attributes.private('state')
local preproc = attributes.private('preproc')
local prestat = attributes.private('prestat')
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local fcs = fonts.colors.set
local fcr = fonts.colors.reset
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua
index 9e29398cc..a856f4cab 100644
--- a/tex/context/base/spac-ver.lua
+++ b/tex/context/base/spac-ver.lua
@@ -646,7 +646,7 @@ local function nodes_to_string(head)
local current, t = head, { }
while current do
local id = current.id
- local ty = node.type(id)
+ local ty = nodecodes[id]
if id == penalty_code then
t[#t+1] = format("%s:%s",ty,current.penalty)
elseif id == glue_code then
@@ -680,7 +680,7 @@ local function trace_info(message, where, what)
end
local function trace_node(what)
- local nt = node.type(what.id)
+ local nt = nodecodes[what.id]
local tl = trace_list[#trace_list]
if tl and tl[1] == "node" then
trace_list[#trace_list] = { "node", tl[2] .. " + " .. nt }
@@ -1160,7 +1160,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
end
show_tracing(head)
if oldhead ~= head then
- trace_info("head has been changed from '%s' to '%s'",node.type(oldhead.id),node.type(head.id))
+ trace_info("head has been changed from '%s' to '%s'",nodecodes[oldhead.id],nodecodes[head.id])
end
end
return head, true
diff --git a/tex/context/base/strc-def.mkiv b/tex/context/base/strc-def.mkiv
index 190764424..e386902e0 100644
--- a/tex/context/base/strc-def.mkiv
+++ b/tex/context/base/strc-def.mkiv
@@ -258,6 +258,7 @@
%\c!indentnext=\v!no,
\c!continue=\v!no,
\c!page=\v!right,
+ \c!marking=\v!page,
\c!header=,
\c!style=\tfc,
\c!distance=.75em,
diff --git a/tex/context/base/strc-ini.mkiv b/tex/context/base/strc-ini.mkiv
index c2d882f7c..8575889e8 100644
--- a/tex/context/base/strc-ini.mkiv
+++ b/tex/context/base/strc-ini.mkiv
@@ -17,10 +17,6 @@
\unprotect
-% \def\zerosection{0}
-% \def\resetsectionmarks{}
-% \setuppagenumbering
-
% maybe use structurecomponent more consistently as name below
% segments: 0:100 2:3 chapter:subsection 3 (=self+2) (alternative: sectionset)
diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua
index d2e2b0352..0ea352656 100644
--- a/tex/context/base/strc-mar.lua
+++ b/tex/context/base/strc-mar.lua
@@ -6,9 +6,538 @@ if not modules then modules = { } end modules ['strc-mar'] = {
license = "see context related readme files"
}
-local structures = structures
-local marks = structures.marks
-local lists = structures.lists
+-- todo: cleanup stack (structures.marks.reset(v_all) also does the job)
+
+local insert, concat = table.insert, table.concat
+local tostring, next, setmetatable, rawget = tostring, next, setmetatable, rawget
+local lpegmatch = lpeg.match
+
+local nodecodes = nodes.nodecodes
+local glyph_code = nodecodes.glyph
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+
+local hasattribute = nodes.hasattribute
+local traversenodes = node.traverse
+local texsetattribute = tex.setattribute
+local texbox = tex.box
+
+local a_marks = attributes.private('marks')
+
+local trace_marks_set = false trackers.register("marks.set", function(v) trace_marks_set = v end)
+local trace_marks_get = false trackers.register("marks.get", function(v) trace_marks_get = v end)
+local trace_marks_all = false trackers.register("marks.detail", function(v) trace_marks_all = v end)
+
+local report_marks = logs.new("marks")
+
+local variables = interfaces.variables
+local v_first = variables.first
+local v_last = variables.last
+local v_previous = variables.previous
+local v_next = variables.next
+local v_firstpage = variables.firstpage
+local v_lastpage = variables.lastpage
+local v_previouspage = variables.previouspage
+local v_nextpage = variables.nextpage
+local v_current = variables.current
+local v_default = variables.default
+local v_page = variables.page
+local v_all = variables.all
+
+local structures = structures
+local marks = structures.marks
+local lists = structures.lists
+
+local settings_to_array = utilities.parsers.settings_to_array
+
+marks.data = marks.data or { }
+
+storage.register("structures/marks/data", marks.data, "structures.marks.data")
+
+local data = marks.data
+local stack, topofstack = { }, 0
+
+local ranges = {
+ [v_page] = {
+ first = 0,
+ last = 0,
+ },
+}
+
+local function resolve(t,k)
+ if k then
+ if trace_marks_set or trace_marks_get then
+ report_marks("undefined: name=%s",k)
+ end
+ local crap = { autodefined = true }
+ t[k] = crap
+ return crap
+ else
+ -- weird: k is nil
+ end
+end
+
+setmetatable(data, { __index = resolve} )
+
+function marks.exists(name)
+ return rawget(data,name) ~= nil
+end
+
+-- identify range
+
+local function sweep(head,first,last)
+ for n in traversenodes(head) do
+ local id = n.id
+ if id == glyph_code then
+ local a = hasattribute(n,a_marks)
+ if not a then
+ -- next
+ elseif first == 0 then
+ first, last = a, a
+ elseif a > last then
+ last = a
+ end
+ elseif id == hlist_code or id == vlist_code then
+ local list = n.list
+ if list then
+ first, last = sweep(list, first, last)
+ end
+ end
+ end
+ return first, last
+end
+
+local classes = { }
+
+setmetatable(classes, { __index = function(t,k) local s = settings_to_array(k) t[k] = s return s end } )
+
+function marks.synchronize(class,n)
+ local box = texbox[n]
+ if box then
+ local first, last = sweep(box.list,0,0)
+ local classlist = classes[class]
+ for i=1,#classlist do
+ local class = classlist[i]
+ local range = ranges[class]
+ if not range then
+ range = { }
+ ranges[class] = range
+ end
+ range.first, range.last = first, last
+ if trace_marks_get or trace_marks_set then
+ report_marks("synchronize: class=%s, first=%s, last=%s",class,range.first,range.last)
+ end
+ end
+ elseif trace_marks_get or trace_marks_set then
+ report_marks("synchronize: class=%s, box=%s, no content",class,n)
+ end
+end
+
+-- define etc
+
+local function resolve(t,k)
+ if k == "fullchain" then
+ local fullchain = { }
+ local chain = t.chain
+ while chain and chain ~= "" do
+ insert(fullchain,1,chain)
+ chain = data[chain].chain
+ end
+ t[k] = fullchain
+ return fullchain
+ elseif k == "chain" then
+ t[k] = ""
+ return ""
+ elseif k == "reset" or k == "set" then
+ t[k] = 0
+ return 0
+ elseif k == "parent" then
+ t[k] = false
+ return false
+ end
+end
+
+function marks.define(name,settings)
+ settings = settings or { }
+ data[name] = settings
+ local parent = settings.parent
+ if parent == nil or parent == "" then
+ settings.parent = false
+ else
+ local dp = data[parent]
+ if not dp then
+ setting.parent = false
+ elseif dp.parent then
+ setting.parent = dp.parent
+ end
+ end
+ setmetatable(settings, { __index = resolve } )
+end
+
+for k, v in next, data do
+ setmetatable(v, { __index = resolve } ) -- runtime loaded table
+end
+
+function marks.relate(name,chain)
+ local dn = data[name]
+ if dn and not dn.parent then
+ if chain and chain ~= "" then
+ dn.chain = chain
+ local dc = data[chain]
+ if dc then
+ local children = dc.children
+ if not children then
+ children = { }
+ dc.children = children
+ end
+ children[#children+1] = name
+ end
+ elseif trace_marks_set then
+ report_marks("invalid relation: name=%s, chain=%s",name,chain or "-")
+ end
+ end
+end
+
+local function resetchildren(new,name)
+ local dn = data[name]
+ if dn and not dn.parent then
+ local children = dn.children
+ if children then
+ for i=1,#children do
+ local ci = children[i]
+ new[ci] = false
+ if trace_marks_set then
+ report_marks("reset: parent=%s, child=%s",name,ci)
+ end
+ resetchildren(new,ci)
+ end
+ end
+ end
+end
+
+function marks.set(name,value)
+ local dn = data[name]
+ if dn then
+ local child = name
+ local parent = dn.parent
+ if parent then
+ name = parent
+ dn = data[name]
+ end
+ dn.set = topofstack
+ local top = stack[topofstack]
+ local new = { }
+ if top then
+ for k, v in next, top do
+ local d = data[k]
+ local r = d.reset
+ local s = d.set
+ if r <= topofstack and s < r then
+ new[k] = false
+ else
+ new[k] = v
+ end
+ end
+ end
+ resetchildren(new,name)
+ new[name] = value
+ topofstack = topofstack + 1
+ stack[topofstack] = new
+ if trace_marks_set then
+ if name == child then
+ report_marks("set: name=%s, index=%s, value=%s",name,topofstack,value)
+ else
+ report_marks("set: parent=%s, child=%s, index=%s, value=%s",parent,child,topofstack,value)
+ end
+ end
+ tex.setattribute("global",a_marks,topofstack)
+ end
+end
+
+local function reset(name)
+ if v_all then
+ if trace_marks_set then
+ report_marks("reset: all")
+ end
+ stack = { }
+ for name, dn in next, data do
+ local parent = dn.parent
+ if parent then
+ dn.reset = 0
+ dn.set = 0
+ end
+ end
+ else
+ local dn = data[name]
+ if dn then
+ local parent = dn.parent
+ if parent then
+ name = parent
+ dn = data[name]
+ end
+ if trace_marks_set then
+ report_marks("reset: name=%s, index=%s",name,topofstack)
+ end
+ dn.reset = topofstack
+ local children = dn.children
+ if children then
+ for i=1,#children do
+ local ci = children[i]
+ reset(ci)
+ end
+ end
+ end
+ end
+end
+
+marks.reset = reset
+
+function marks.get(n,name,value)
+ local dn = data[name]
+ if dn then
+ name = dn.parent or name
+ local top = stack[n]
+ if top then
+ context(top[name])
+ end
+ end
+end
+
+function marks.show(first,last)
+ if first and last then
+ for k=first,last do
+ local v = stack[k]
+ if v then
+ report_marks("% 4i: %s",k,table.sequenced(v))
+ end
+ end
+ else
+ for k, v in table.sortedpairs(stack) do
+ report_marks("% 4i: %s",k,table.sequenced(v))
+ end
+ end
+end
+
+local function resolve(name,first,last,strict,quitonfalse,notrace)
+ local dn = data[name]
+ if dn then
+ local child = name
+ local parent = dn.parent
+ name = parent or child
+ dn = data[name]
+ local step, method
+ if first > last then
+ step, method = -1, "bottom-up"
+ else
+ step, method = 1, "top-down"
+ end
+ if trace_marks_get and not notrace then
+ report_marks("request: strategy=%s, name=%s, parent=%s, strict=%s",method,child,parent or "",tostring(strict or false))
+ end
+ if trace_marks_all and not notrace then
+ marks.show(first,last)
+ end
+ local r = dn.reset
+ local s = dn.set
+ if first <= last and first <= r then
+ if trace_marks_get and not notrace then
+ report_marks("reset: name=%s, reset=%s, index=%s",name,r,first)
+ end
+ elseif first >= last and last <= r then
+ if trace_marks_get and not notrace then
+ report_marks("reset: name=%s, reset=%s, index=%s",name,r,last)
+ end
+ elseif not stack[first] or not stack[last] then
+ if trace_marks_get and not notrace then
+ -- a previous or next method can give an out of range, which is valid
+ report_marks("out of range: name=%s, reset=%s, index=%s",name,r,first)
+ end
+ elseif strict then
+ local top = stack[first]
+ local fullchain = dn.fullchain
+ if not fullchain or #fullchain == 0 then
+ return resolve(name,first,last)
+ else
+ if trace_marks_get and not notrace then
+ report_marks("found chain: %s",concat(fullchain," => "))
+ end
+ local chaindata, chainlength = { }, #fullchain
+ for i=1,chainlength do
+ local cname = fullchain[i]
+ if data[cname].set > 0 then
+ local value = resolve(cname,first,last,false,false,true)
+ if value == "" then
+ if trace_marks_get and not notrace then
+ report_marks("quit chain: name=%s, reset=%s, start=%s",name,r,first)
+ end
+ return ""
+ else
+ chaindata[i] = value
+ end
+ end
+ end
+ if trace_marks_get and not notrace then
+ report_marks("chain list: %s",concat(chaindata," => "))
+ end
+ local value, index, found = resolve(name,first,last,false,false,true)
+ if value ~= "" then
+ for i=1,chainlength do
+ local cname = fullchain[i]
+ if data[cname].set > 0 and chaindata[i] ~= found[cname] then
+ if trace_marks_get and not notrace then
+ report_marks("empty in chain: name=%s, reset=%s, index=%s",name,r,first)
+ end
+ return ""
+ end
+ end
+ if trace_marks_get and not notrace then
+ report_marks("found: name=%s, reset=%s, start=%s, index=%s, value=%s",name,r,first,index,value)
+ end
+ return value, index, found
+ elseif trace_marks_get and not notrace then
+ report_marks("not found: name=%s, reset=%s",name,r)
+ end
+ end
+ else
+ for i=first,last,step do
+ local current = stack[i]
+ local value = current and current[name]
+ if value == nil then
+ -- search on
+ elseif value == false then
+ if quitonfalse then
+ return ""
+ end
+ elseif value == true then
+ if trace_marks_get and not notrace then
+ report_marks("quit: name=%s, reset=%s, start=%s, index=%s",name,r,first,i)
+ end
+ return ""
+ elseif value ~= "" then
+ if trace_marks_get and not notrace then
+ report_marks("found: name=%s, reset=%s, start=%s, index=%s, value=%s",name,r,first,i,value)
+ end
+ return value, i, current
+ end
+ end
+ if trace_marks_get and not notrace then
+ report_marks("not found: name=%s, reset=%s",name,r)
+ end
+ end
+ end
+ return ""
+end
+
+-- todo: column:first column:last
+
+local methods = { }
+
+local function doresolve(name,range,swap,df,dl,strict)
+ local range = ranges[range] or ranges[v_page]
+ local first, last = range.first, range.last
+ if trace_marks_get then
+ report_marks("resolve: name=%s, range=%s, swap=%s, first=%s, last=%s, df=%s, dl=%s, strict=%s",
+ name,range,tostring(swap or false),first,last,df,dl,tostring(strict or false))
+ end
+ if swap then
+ first, last = last + df, first + dl
+ else
+ first, last = first + df, last + dl
+ end
+ return resolve(name,first,last,strict)
+end
+
+methods[v_previous] = function(name,range) return doresolve(name,range,false,-1,0,true ) end
+methods[v_previouspage] = function(name,range) return doresolve(name,range,false,-1,0,false) end
+methods[v_first] = function(name,range) return doresolve(name,range,false, 0,0,true ) end
+methods[v_firstpage] = function(name,range) return doresolve(name,range,false, 0,0,false) end
+methods[v_last] = function(name,range) return doresolve(name,range,true , 0,0,true ) end
+methods[v_lastpage] = function(name,range) return doresolve(name,range,true , 0,0,false) end
+methods[v_next] = function(name,range) return doresolve(name,range,true , 0,1,true ) end
+methods[v_nextpage] = function(name,range) return doresolve(name,range,true , 0,1,false) end
+
+methods[v_current] = function(name,range) -- range is ignored here
+ local top = stack[#topofstack]
+ return top and top[name] or ""
+end
+
+local function fetched(name,range,method)
+ local value = (methods[method] or methods[v_first])(name,range) or ""
+ if not trace_marks_get then
+ -- no report
+ elseif value == "" then
+ report_marks("nothing fetched: name=%s, range=%s, method=%s",name,range,method)
+ else
+ report_marks("marking fetched: name=%s, range=%s, method=%s, value=%s",name,range,method)
+ end
+ return value or ""
+end
+
+-- can be used at the lua end:
+
+marks.fetched = fetched
+
+-- this will move to a separate runtime modules
+
+marks.tracers = marks.tracers or { }
+
+function marks.tracers.showtable()
+ context.starttabulate { "|l|l|l|lp|lp|" }
+ context.tabulaterowbold("name","parent","chain","children","fullchain")
+ context.ML()
+ for k, v in table.sortedpairs(data) do
+ local parent, chain, children, fullchain = v.parent or "", v.chain or "", v.children or { }, v.fullchain or { }
+ table.sort(children) -- in-place but harmless
+ context.tabulaterowtyp(k,parent,chain,concat(children," "),concat(fullchain," "))
+ end
+ context.stoptabulate()
+end
+
+-- pushing to context:
+
+local separator = context.nested.markingseparator
+local command = context.nested.markingcommand
+local ctxconcat = context.concat
+
+local function fetchonemark(name,range,method)
+ context(command(name,fetched(name,range,method)))
+end
+
+local function fetchtwomarks(name,range)
+ ctxconcat( {
+ command(name,fetched(name,range,v_first)),
+ command(name,fetched(name,range,v_last)),
+ }, separator(name))
+end
+
+local function fetchallmarks(name,range)
+ ctxconcat( {
+ command(name,fetched(name,range,v_previous)),
+ command(name,fetched(name,range,v_first)),
+ command(name,fetched(name,range,v_last)),
+ }, separator(name))
+end
+
+function marks.fetch(name,range,method) -- chapter page first | chapter column:1 first
+ if trace_marks_get then
+ report_marks("marking asked: name=%s, range=%s, method=%s",name,range,method)
+ end
+ if method == "" or method == v_default then
+ fetchonemark(name,range,v_first)
+ elseif method == v_both then
+ fetchtwomarks(name,range)
+ elseif method == v_all then
+ fetchallmarks(name,range)
+ else
+ fetchonemark(name,range,method)
+ end
+end
+
+function marks.fetchonemark (name,range,method) fetchonemark (name,range,method) end
+function marks.fetchtwomarks(name,range) fetchtwomarks(name,range ) end
+function marks.fetchallmarks(name,range) fetchallmarks(name,range ) end
+
+-- here we have a few helpers
function marks.title(tag,n)
lists.savedtitle(tag,n,"marking")
diff --git a/tex/context/base/strc-mar.mkiv b/tex/context/base/strc-mar.mkiv
index bb87051e0..23c1239a4 100644
--- a/tex/context/base/strc-mar.mkiv
+++ b/tex/context/base/strc-mar.mkiv
@@ -17,479 +17,161 @@
\unprotect
-%D Old stuff.
-
-\newtoks \listofmarks
-
-\let \getmarks \gobbleoneargument
-\let \getallmarks \relax
-\let \getsplitmarks \gobbleoneargument
-\let \getallsplitmarks \relax
-
-%D \macros
-%D {expandmarks}
+%D Synchronizing marks is a rather tricky and messy business. When
+%D setting a mark, a node is added to the list in order for to \TEX\
+%D be able to figure out the 3 current marks when a page is made
+%D (last mark on previous page, first on current page, last on
+%D current page; in \LUATEX\ we might at one point have the first on
+%D the next page as well).
%D
-%D We can force expansion of marks with the following switch.
-
-% Synchronizing marks is a rather tricky and messy business. When
-% setting a mark, a node is added to the list in order for to \TEX\
-% be able to figure out the 3 current marks when a page is made
-% (last mark on previous page, first on current page, last on
-% current page; in \LUATEX\ we might at one point have the first on
-% the next page as well).
-
-% Resetting a mark is not easy. An empty one will not erase the last
-% one on the previous page for instance. In \LUATEX\ we can clear a
-% marks state register with \type {\clearmarks} but since this is an
-% immediate operation it might have unwanted side effects when \TEX\
-% has collected several pages of text and finishing off these pages
-% uses marks.
-
-% In \MKIV\ we provide a model that permits some control over the
-% way marks are used. It is not entirely compatible with \MKII\ but
-% in practice this is not a real problem. Quality has a price.
-
-% In fact we define multiple marks per visible mark and define
-% additional ones on the fly. This has some price in terms of used
-% mark registers but given the way that we fill marks in \MKIV\
-% their accumulated content is not really the issue. Also,
-% periodically we cleanup any leftovers.
-
-\newif\ifexpandmarks \expandmarkstrue
-
-\def\marksomecs #1#2{\csname\string#1:m:\number#2\endcsname}
-\def\markautocs #1{\csname\string#1:m:\number\csname\string#1:s\endcsname\endcsname}
-\def\markmaincs #1{\csname\string#1:m\endcsname}
-\def\markresetcs #1{\csname\string#1:r\endcsname}
-\def\markstatecs #1{\csname\string#1:s\endcsname}
-\def\markcurrentcs#1{\csname\string#1:c\endcsname}
-\def\marktokscs #1{\csname\string#1:t\endcsname}
-
-\def\renewmarks#1%
- {\ifx#1\relax
- % \writestatus\m!systems{defining low level mark: \string#1}%
- \newmarks#1%
- \else
- \clearmarks#1%
- \fi}
-
-\unexpanded\def\definenewmark#1%
- {\ifcsname\string#1:m\endcsname\else
- \@EA\@EA\@EA\newcount \markstatecs #1\global\markstatecs#1\plusone
- \@EA\@EA\@EA\renewmarks\markautocs #1%
- \@EA\@EA\@EA\renewmarks\markmaincs #1%
- \@EA\@EA\@EA\renewmarks\markresetcs #1%
- \@EA\@EA\@EA\newtoks \marktokscs #1%
- \@EA\@EA\@EA\let \markcurrentcs#1\empty
- \listofmarks\expandafter{\the\listofmarks\checkmark#1}%
- \fi}
-
-\long\def\setmark#1#2% marks expand
- {\@EA\@EA\@EA\xdef \markcurrentcs#1{\ifexpandmarks#2\else\normalunexpanded{#2}\fi}%
- \marks\markautocs #1{\ifexpandmarks#2\else\normalunexpanded{#2}\fi}% we could expand current one level
- \marks\markmaincs #1{\ifexpandmarks#2\else\normalunexpanded{#2}\fi}% we could expand current one level
- \marks\markresetcs #1{\number\markstatecs#1}}
-
-\def\resetmark#1%
- {\global\advance\markstatecs#1\plusone
- \@EA\@EA\@EA\glet\markcurrentcs#1\empty
- \@EA\@EA\@EA\renewmarks\markautocs#1%
- \the\marktokscs#1\relax}
-
-\def\addmarkreset#1#2%
- {\global\marktokscs#2\@EA{\the\marktokscs#2\resetmark#1}}
-
-% already there: \prependtoks \getallmarks \to \everybeforepagebody
-%
-% \def\getallmarks{\the\listofmarks}
-
-\let\checkmark\gobbleoneargument
-
-\prependtoks \clearmarkswhenemptypage \to \everybeforepagebody
-
-\def\clearmarkswhenemptypage
- {\iffalse % check if page is empty
- \clearallmarks
- \fi}
-
-\def\clearallmarks
- {\let\checkmark\clearmarkchain
- \the\listofmarks
- \let\checkmark\gobbleoneargument}
-
-\def\clearmarkchain#1%
- {\@EA\@EA\@EA\clearmarks\markmaincs#1%
- \@EA\@EA\@EA\clearmarks\markresetcs#1%
- \@EA\doclearmarkchain\@EA{\number\csname\string#1:s\endcsname}#1%
- \@EA\@EA\@EA\glet\markcurrentcs#1\empty
- \global\markstatecs#1\plusone}
-
-\def\doclearmarkchain#1#2%
- {\@EA\@EA\@EA\clearmarks\marksomecs#1{#2}%
- \@EA\doclearmarkchain\@EA#1\@EA{\number\numexpr#2+\minusone}}
-
-% Fetching (expandable versions, so no intermediate counter):
-
-\def\currenttopmarknumber #1{\number0\topmarks \markresetcs#1}
-\def\currentfirstmarknumber#1{\number0\firstmarks\markresetcs#1}
-\def\currentbotmarknumber #1{\number0\botmarks \markresetcs#1}
-
-\def\checkedcurrentmarkrange#1{[\currenttopmarknumber#1,\currentfirstmarknumber#1,\currentbotmarknumber#1]}
-
-\def\checkedcurrentmarks{\markcurrentcs} % #1 shared current mark
-
-\let\currentsplitfirstmarknumber\currentfirstmarknumber
-\let\currentsplittopmarknumber \currenttopmarknumber
-\let\currentsplitbotmarknumber \currentbotmarknumber
-\let\normalsplittopmarks \normaltopmarks
-
-\def\uncheckedautotopmark {\normaltopmarks \markautocs} % #1
-\def\uncheckedautofirstmark {\normalfirstmarks \markautocs} % #1
-\def\uncheckedautobotmark {\normalbotmarks \markautocs} % #1
-\def\uncheckedautosplittopmark {\normalsplittopmarks \markautocs} % #1
-\def\uncheckedautosplitfirstmark {\normalsplitfirstmarks\markautocs} % #1
-\def\uncheckedautosplitbotmark {\normalsplitbotmarks \markautocs} % #1
-
-\def\uncheckedmaintopmark {\normaltopmarks \markmaincs} % #1
-\def\uncheckedmainfirstmark {\normalfirstmarks \markmaincs} % #1
-\def\uncheckedmainbotmark {\normalbotmarks \markmaincs} % #1
-\def\uncheckedmainsplittopmark {\normalsplittopmarks \markmaincs} % #1
-\def\uncheckedmainsplitfirstmark {\normalsplitfirstmarks\markmaincs} % #1
-\def\uncheckedmainsplitbotmark {\normalsplitbotmarks \markmaincs} % #1
-
-\def\checkedpagetopmarks #1{\ifcase\currentbotmarknumber #1\else\normaltopmarks \marksomecs#1{\currentbotmarknumber #1}\fi}
-\def\checkedpagefirstmarks #1{\ifcase\currentbotmarknumber #1\else\normalfirstmarks \marksomecs#1{\currentbotmarknumber #1}\fi}
-\def\checkedpagebotmarks #1{\ifcase\currentbotmarknumber #1\else\normalbotmarks \marksomecs#1{\currentbotmarknumber #1}\fi}
-\def\checkedpagesplittopmarks #1{\ifcase\currentsplitbotmarknumber #1\else\normalsplittopmarks \marksomecs#1{\currentsplitbotmarknumber #1}\fi}
-\def\checkedpagesplitfirstmarks#1{\ifcase\currentsplitbotmarknumber #1\else\normalsplitfirstmarks\marksomecs#1{\currentsplitbotmarknumber #1}\fi}
-\def\checkedpagesplitbotmarks #1{\ifcase\currentsplitbotmarknumber #1\else\normalsplitbotmarks \marksomecs#1{\currentsplitbotmarknumber #1}\fi}
-
-\def\checkedfulltopmarks #1{\ifcase\currenttopmarknumber #1\else\normaltopmarks \marksomecs#1{\currenttopmarknumber #1}\fi}
-\def\checkedfullfirstmarks #1{\ifcase\currentfirstmarknumber #1\else\normalfirstmarks \marksomecs#1{\currentfirstmarknumber #1}\fi}
-\def\checkedfullbotmarks #1{\ifcase\currentbotmarknumber #1\else\normalbotmarks \marksomecs#1{\currentbotmarknumber #1}\fi}
-\def\checkedfullsplittopmarks #1{\ifcase\currentsplittopmarknumber #1\else\normalsplittopmarks \marksomecs#1{\currentsplittopmarknumber #1}\fi}
-\def\checkedfullsplitfirstmarks#1{\ifcase\currentsplitfirstmarknumber#1\else\normalsplitfirstmarks\marksomecs#1{\currentsplitfirstmarknumber#1}\fi}
-\def\checkedfullsplitbotmarks #1{\ifcase\currentsplitbotmarknumber #1\else\normalsplitbotmarks \marksomecs#1{\currentsplitbotmarknumber #1}\fi}
-
-% Interface macros:
-
-\def\getcurrentmark {\checkedcurrentmarks }
-\def\gettopmark {\checkedfulltopmarks }
-\def\getfirstmark {\checkedfullfirstmarks }
-\def\getbotmark {\checkedfullbotmarks }
-\def\getsplittopmark {\checkedfullsplittopmarks }
-\def\getsplitfirstmark {\checkedfullsplitfirstmarks}
-\def\getsplitbotmark {\checkedfullsplitbotmarks }
-
-\def\getbottommark {\getbotmark}
-\def\getsplitbottommark{\getsplitbotmark}
-
-%D Some of these will go away (in the process of rewriting).
-
-\let \newmark \definenewmark
-\let \newpersistentmark \newmarks
-\let \normalsetmark \setmark
-\let \rawnewmark \newmarks
-\let \rawdefinemark \newmarks
-\let \rawsetmark \normalmarks
-\let \rawgettopmark \normaltopmarks
-\let \rawgetfirstmark \normalfirstmarks
-\let \rawgetbotmark \normalbotmarks
-\let \rawgetsplitbotmark \normalsplitbotmarks
-\let \rawgetsplitfirstmark \normalsplitfirstmarks
-\let \rawgetsplittopmark \normalsplitfirstmarks
-
-\let \noninterferingmarks \relax % old color interference related hack
-
-%D Next comes the layer around the previous mechanism.
+%D Resetting a mark is not easy. An empty one will not erase the last
+%D one on the previous page for instance. In \LUATEX\ we can clear a
+%D marks state register with \type {\clearmarks} but since this is an
+%D immediate operation it might have unwanted side effects when \TEX\
+%D has collected several pages of text and finishing off these pages
+%D uses marks.
%D
-%D Parameters
+%D In \MKIV\ we provide an alternative model that permits some more
+%D control over the way marks are used. It is not entirely compatible
+%D with \MKII\ or previous \MKIV\ implementations but in practice this
+%D is not a real problem. It's also easier now to extend this mechanism.
-\def\markingparameter #1#2{\csname\domarkingparameter{\??mk#1}#2\endcsname}
-\def\domarkingparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\@EA\domarkingparentparameter\csname#1\s!parent\endcsname#2\fi}
-\def\domarkingparentparameter#1#2{\ifx#1\relax\s!empty\else\domarkingparameter#1#2\fi}
-\def\markingcoupling #1{\ifcsname\??mk#1\c!coupling\endcsname\@EA\markingcoupling\csname\??mk#1\c!coupling\endcsname\else#1\fi}
+\definesystemattribute[marks]
-\let\mainmarking\markingcoupling % compatibility
+\let\currentmarking\empty
-\def\doifelsemarking#1%
- {\ifcsname\??mk#1\c!coupling\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
+\def\markingparameter #1{\csname\domarkingparameter{\??mk\currentmarking}#1\endcsname}
+\def\namedmarkingparameter #1#2{\csname\domarkingparameter{\??mk#1}#2\endcsname}
+\def\domarkingparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\domarkingparentparameter\csname#1\s!parent\endcsname#2\fi}
+\def\domarkingparentparameter#1#2{\ifx#1\relax\s!empty\else\domarkingparameter#1#2\fi}
-\def\dowithmarkcommandone#1#2% \command {mark}
- {\expandafter#1\csname\??mk:\markingcoupling{#2}\endcsname}
+% \def\markingparameterhash #1{\domarkingparameterhash{\??mk\currentmarking}#1}
+% \def\domarkingparameterhash #1#2{\ifcsname#1#2\endcsname#1\else\expandafter\domarkingparentparameterhash\csname#1\s!parent\endcsname#2\fi}
+% \def\domarkingparentparameterhash#1#2{\ifx#1\relax\else\domarkingparameterhash#1#2\fi}
+%
+% \def\detokenizedmarkingparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??mk\currentmarking#1\endcsname}}
+%
+% \def\dosetmarkingattributes#1#2% style color
+% {\edef\fontattributehash {\markingparameterhash#1}%
+% \edef\colorattributehash{\markingparameterhash#2}%
+% \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
+% \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
-\def\dowithmarkcommandtwo#1#2#3% \command {mark} {mark}
- {\expandafter#1\csname\??mk:\markingcoupling{#2}\expandafter\endcsname\csname\??mk:\markingcoupling{#3}\endcsname}
+\newconditional\inhibitgetmarking
+\newconditional\inhibitsetmarking
+\newtoks \everymarking
\unexpanded\def\setupmarking
{\dodoubleargument\dosetupmarking}
\def\dosetupmarking[#1][#2]%
- {\def\docommand##1{\getparameters[\??mk##1][#2]}%
- \processcommalist[#1]\docommand}
-
-%D The filtercommand key is used to hook in a filtering command. Users are
-%D adviced not to misuse this key.
-
-\getparameters
- [\??mk]
- [\c!expansion=\v!no, % saves a macro
- \c!separator={\space\emdash\space},
- \c!limittext=\@@kolimittext,
- \c!filtercommand=\firstofoneargument,
- \c!state=\v!start]
-
-\let\alldefinedmarks\empty
-
-\unexpanded\def\definemarking
- {\dodoubleempty\dodefinemarking}
-
-\def\dodefinemarking[#1][#2]%
- {\doifelsenothing{#2}\donormaldefinemarking\docloneddefinemarking[#1][#2]}
-
-\def\donormaldefinemarking[#1][#2]% #2 empty
- {\ifcsname\??mk#1\s!parent\endcsname
- % already defined
- \else
- \letgvalue{\??mk#1\s!parent}\??mk
- \dowithmarkcommandone\newmark{#1}%
- \doglobal\addtocommalist{#2}\alldefinedmarks
- \ifproductionrun\showmessage\m!systems{13}{#1,[#1]}\fi
- \fi}
-
-\def\docloneddefinemarking[#1][#2]%
- {\ifcsname\??mk#1\s!parent\endcsname \else \ifcsname\??mk#2\s!parent\endcsname
- \doifnot{#1}{#2}%
- {\setxvalue{\??mk#1\s!parent}{\??mk#2}%
- \setxvalue{\??mk#1\c!coupling}{#2}%
- \ifproductionrun\showmessage\m!systems{13}{#1,[#2]}\fi}%
- \fi \fi}
-
-\def\decouplemarking[#1]%
- {\letbeundefined{\??mk#1\c!coupling}}
+ {\ifsecondargument
+ \def\docommand##1{\getparameters[\??mk##1][#2]}%
+ \processcommalist[#1]\docommand
+ \else
+ \getparameters[\??mk][#1]%
+ \fi}
-\def\couplemarking[#1]#2[#3]% couple 1 to 2 (this macro is not really needed)
- {\setvalue{\??mk#1\c!coupling}{#3}}
+% management
-\def\relatemarking[#1]#2[#3]% define 1 as child of 2
- {\dowithmarkcommandtwo\addmarkreset{#1}{#3}}
+\unexpanded\def\definemarking {\dodoubleempty \dodefinemarking}
+\unexpanded\def\relatemarking {\dodoubleempty \dorelatemarking}
+\unexpanded\def\setmarking {\dosingleargument\dosetmarking } \let\marking\setmarking
+\unexpanded\def\resetmarking {\dosingleargument\doresetmarking }
+\unexpanded\def\synchronizemarking{\dodoubleargument\dosynchronizemarking }
-\unexpanded\def\definerawmarking[#1]%
- {\dododefinemarking[#1][#1]%
- \getgparameters[\??mk#1][\c!limittext=]} % global !
+\def\dodefinemarking[#1][#2]% marking parent
+ {\doifelsenothing{#2}
+ {\ctxlua{structures.marks.define("#1")}%
+ \getparameters[\??mk#1][\s!parent=\??mk]}
+ {\ctxlua{structures.marks.define("#1",{ parent = "#2" })}%
+ \getparameters[\??mk#1][\s!parent=\??mk#2]}}
-% \decouplemarking[#1]% % no coupling with sections
+\def\dorelatemarking[#1][#2]%
+ {\ctxlua{structures.marks.relate("#1","#2")}}
-\def\fastresetmarker#1%
- {\ifcsname\??mk#1\s!parent\endcsname
- \dowithmarkcommandone\resetmark{#1}%
+\def\dosetmarking[#1]#2%
+ {\ifconditional\inhibitsetmarking
+ % nothing
+ \else
+ \doifelse{\namedmarkingparameter{#1}\c!expansion}\v!yes
+ {\ctxlua{structures.marks.set("#1",\!!bs#2\!!es)}}
+ {\ctxlua{structures.marks.set("#1",\!!bs\detokenize{#2}\!!es)}}%
\fi}
-\def\fastresetmarkerlist[#1]%
- {\normalexpanded{\noexpand\rawprocesscommalist[#1]}\fastresetmarker}
-
-\def\resetmarking
- {\dosingleargument\doresetmarking}
-
\def\doresetmarking[#1]%
- {\processcommalist[#1]\fastresetmarker}
-
-%D Used elsewhere:
-
-\let\nomarking\empty
+ {\ctxlua{structures.marks.reset("#1")}}
-%D Basic fetching:
-
-\letvalue{\??mk::\??mk::\v!previous}\firstoffourarguments
-\letvalue{\??mk::\??mk::\v!first }\secondoffourarguments
-\letvalue{\??mk::\??mk::\v!last }\thirdoffourarguments
-\letvalue{\??mk::\??mk::\v!current }\fourthoffourarguments
-
-\letvalue{\??mk\??mk\v!previous}\gettopmark
-\letvalue{\??mk\??mk\v!first }\getfirstmark
-\letvalue{\??mk\??mk\v!last }\getbotmark
-\letvalue{\??mk\??mk\v!current }\getcurrentmark
-
-\letvalue{\??mk\??mk\v!column:\v!first}\getsplitfirstmark
-\letvalue{\??mk\??mk\v!column:\v!last }\getsplitbottommark
-
-\def\fetchmark[#1]#2[#3]% % expandable / never use \unexpanded
- {\ifcsname\??mk::#1\endcsname % saved mark
- \markingparameter{#1}\c!filtercommand{\csname\??mk::\??mk::#3\@EA\@EA\@EA\endcsname\csname\??mk::#1\endcsname}%
- \else\ifcsname\??mk#1\s!parent\endcsname % real mark
- \markingparameter{#1}\c!filtercommand{\expandafter\dowithmarkcommandone\csname\??mk\??mk#3\endcsname{#1}}%
- \fi\fi}
+\def\doifelsemarking#1%
+ {\ctxlua{commands.testcase(structures.marks.exists("#1"))}}
-\def\fetchtwomarks[#1]%
- {\dofetchtwomarks[#1][#1]}
+\def\dosynchronizemarking[#1][#2]% class boxnumber (some day also name), maybe second argument table
+ {\ifvoid#2\else\ctxlua{structures.marks.synchronize("#1",\number#2)}\fi}
-\def\fetchallmarks[#1]%
- {\dofetchallmarks[#1][#1]}
+% \appendtoks
+% \dosynchronizemarking[\v!page][\normalpagebox]%
+% \to \everybeforepagebody
-\def\dofetchtwomarks[#1][#2]% class class:tag
- {\doifsomething{\fetchmark[#2][\v!first]}
- {\fetchmark[#2][\v!first]%
- \doifsomething{\fetchmark[#2][\v!last]}
- {\doifnot{\fetchmark[#2][\v!first]}{\fetchmark[#2][\v!last]}
- {\markingparameter{#1}\c!separator\fetchmark[#2][\v!last]}}}}
+% defaults
-\def\dofetchallmarks[#1][#2]%
- {\doifsomething{\fetchmark[#2][\v!first]}
- {\doifsomething{\fetchmark[#2][\v!previous]}
- {\doifnot{\fetchmark[#2][\v!previous]}{\fetchmark[#2][\v!first]}
- {\fetchmark[#2][\v!previous]\markingparameter{#1}\c!separator}}}%
- \fetchtwomarks[#1][#2]}
+\setupmarking
+ [\c!expansion=\v!no,
+ \c!separator=\space\emdash\space,
+ \c!filtercommand=\firstofoneargument,
+ \c!state=\v!start]
-% \newtoks \everymarking
+% fetching, regular interface
-% \def\Interesting{\doifmodeelse{*\v!marking}{Interesting}{Boring}}
-% \setupheadertexts[chapter]
-% \starttext
-% \chapter{This Is \Interesting}
-% \stoptext
+\unexpanded\def\getmarking
+ {\ifconditional\inhibitgetmarking
+ \expandafter\dotripleargument\expandafter\nogetmarking
+ \else
+ \expandafter\dotripleargument\expandafter\dogetmarking
+ \fi}
-\def\markingnomarking#1{\splitsequence{\markingparameter{#1}\c!limittext}} % #2
+\def\nogetmarking[#1][#2][#3]%
+ {}
\def\dogetmarking[#1][#2][#3]%
- {\doif{\markingparameter{#1}\c!state}\v!start
- {\bgroup
+ {\doif{\namedmarkingparameter{#1}\c!state}\v!start
+ {\begingroup
\setsystemmode\v!marking
\the\everymarking
- \def\nomarking{\markingnomarking{#1}}% just for good old times, might disappear
\ifthirdargument
- \dodogetmarking{#3}{#1}{#1:#2}{#3}%
+ \ctxlua{structures.marks.fetch("#1","#2","#3")}%
\else
- \dodogetmarking{#2}{#1}{#1}{#2}%
+ \ctxlua{structures.marks.fetch("#1","\v!page","#2")}%
\fi
- \egroup}}
-
-\def\dodogetmarking#1#2#3#4% to be made faster
- {\processaction % slow
- [#1]
- [ \v!both=>{\dofetchtwomarks[#2][#3]},
- \v!all=>{\dofetchallmarks[#2][#3]},
- \s!default=>{\fetchmark[#3][\v!first]},
- \s!unknown=>{\fetchmark[#3][#4]}]}
-
-\def\nogetmarking[#1][#2][#3]%
- {}
-
-\unexpanded\def\getmarking
- {\dotripleargument\dogetmarking}
-
-\let\setsomemark\setmark
-
-\def\setmarking
- {\dosingleargument\dosetmarking}
-
-\def\dosetmarking[#1]#2%
- {\ifcsname\??mk#1\s!parent\endcsname
- \begingroup
- \doifelse{\markingparameter{#1}\c!expansion}\v!yes\expandmarkstrue\expandmarksfalse
- \dowithmarkcommandone\setsomemark{#1}{#2}%
- \endgroup
- \fi}
-
-\let\marking\setmarking
+ \endgroup}}
-% to be adapted for mkiv:
-%
-% this version can be used when a page is built up in steps without
-% feedback of the otr'd list to the mvl (i.e.\ a page made of pages,
-% as in column sets where content is buffered)
+% the fetchers are fully expandable: [name][method]
-% reset at begin
-% preset before page
-% bubble in column
-% refresh at end
+\def\fetchmark[#1]#2[#3]{\ifconditional\inhibitgetmarking\else\ctxlua{structures.marks.fetchonemark ("#1","\v!page","#2")}\fi}
+\def\fetchtwomarks [#1]{\ifconditional\inhibitgetmarking\else\ctxlua{structures.marks.fetchtwomarks("#1","\v!page")}\fi}
+\def\fetchallmarks [#1]{\ifconditional\inhibitgetmarking\else\ctxlua{structures.marks.fetchallmarks("#1","\v!page")}\fi}
-% marks is a kind of toks, so maybe we need a low level \the\marks
-%
-% use \normalunexpanded here
-
-\def\refreshsavedmark[#1][#2]% mark tag (packing saves many hash entries)
- {\setxvalue{\??mk::#1:#2}%
- {{\@EA\ifx\csname\??mk::#1:pp\endcsname\relax
- % empty
- \else
- \csname\??mk::#1:pp\endcsname
- \fi}%
- {\@EA\ifx\csname\??mk::#1:ff\endcsname\relax
- \fetchmark[#1][\v!first]%
- \else
- \csname\??mk::#1:ff\endcsname
- \fi}%
- {\fetchmark[#1][\v!last]}%
- {\fetchmark[#1][\v!current]}}%
- \setxvalue{\??mk::#1:pp}{\fetchmark[#1][\v!first]}%
- \letgvalue{\??mk::#1:ff}\relax
- }
-
-\def\bubblesavedmark[#1][#2]% no packing (not now, maybe make a six-pack later)
- {\@EA\ifx\csname\??mk::#1:ff\endcsname\relax
- \setxvalue{\??mk::#1:ff}{\fetchmark[#1][\v!first]}%
- \fi}
-
-\def\resetsavedmark[#1][#2]% mark tag
- {\doifelsenothing{\fetchmark[#1][\v!previous]}
- {\letgvalue{\??mk::#1:pp}\relax}
- {\setxvalue{\??mk::#1:pp}{\fetchmark[#1][\v!previous]}}%
- \doifelsenothing{\fetchmark[#1][\v!first]}
- {\letgvalue{\??mk::#1:ff}\relax}
- {\setxvalue{\??mk::#1:ff}{\fetchmark[#1][\v!first]}}%
- \letgvalue{\??mk::#1:#2}\emptysavedmark}
-
-\def\presetsavedmark[#1][#2]% mark tag
- {\letgvalue{\??mk::#1:#2}\emptysavedmark}
-
-\def\emptysavedmark{{}{}{}{}}
-
-% new (can be used in column sets)
-%
-% \getsavedmarking[M][previous]
-% \getsavedmarking[M][first]
-% \getsavedmarking[M][last]
+% also fully expandable but here we have: [name][range][method]
-\def\getsavedmarking
- {\dodoubleargument\dogetsavedmarking}
+\def\fetchmarking[#1]#2[#3]#4[#5]{\ifconditional\inhibitgetmarking\else\ctxlua{structures.marks.fetchonemark ("#1","#3","#5")}\fi}
+\def\fetchtwomarkings [#1]#2[#3]{\ifconditional\inhibitgetmarking\else\ctxlua{structures.marks.fetchtwomarks("#1","#3")}\fi}
+\def\fetchallmarkings [#1]#2[#3]{\ifconditional\inhibitgetmarking\else\ctxlua{structures.marks.fetchallmarks("#1","#3")}\fi}
-\def\dogetsavedmarking[#1][#2]%
- {\doifelse{#2}\v!previous
- {\getmarking[#1][1][\v!previous]}
- {\doifelse{#2}\v!first
- {\getmarking[#1][1][\v!first]}
- {\getmarking[#1][\v!last]}}}
+\def\markingseparator#1{\namedmarkingparameter{#1}\c!separator}
+\def\markingcommand #1{\namedmarkingparameter{#1}\c!filtercommand}
-%D And then \unknown\ we had a chaptertitle packaged in a
-%D makeup environment. And we don't want to loose marks there!
-
-\newbox\collectedmarks
-
-\def\flushmarks % use with care to avoid empty pages
- {\ifvoid\collectedmarks\else\unhbox\collectedmarks\fi}
-
-\def\postponemarks
- {\let\setsomemark\postponemark}
-
-\def\postponemark#1#2%
- {\global\setbox\collectedmarks\hbox{\unhbox\collectedmarks\setmark{#1}{#2}}}
+%D Experimental:
+%D
+%D \starttyping
+%D \definemarking[boxmark]
+%D
+%D \setbox0\ruledvbox{
+%D \marking[boxmark]{tufte} \input tufte \par
+%D \marking[boxmark]{ward} \input ward \par
+%D }
+%D
+%D \synchronizemarking[zerobox][0] \box0
+%D
+%D marks: (\getmarking[boxmark][zerobox][first],\getmarking[boxmark][zerobox][last])
+%D \stoptyping
\protect \endinput
-
-% todo: make it work in balancing
-%
-% \definemarking[vers][]
-% \setupheadertexts
-% [\doiftext{\getmarking[vers][first]}
-% {\doiftextelse{\getmarking[vers][column:last]}
-% {\getmarking[vers][first] -- \getmarking[vers][column:last]}
-% {\getmarking[vers][first]}}]
-% \starttext
-% \startcolumns[n=2,balance=no]
-% \dorecurse{10}{\normalexpanded{\noexpand\marking[vers]{\recurselevel}} \recurselevel:\dorecurse{4}{\input ward } \endgraf}
-% \stopcolumns
-% \stoptext
diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv
index 19930591d..552f19d86 100644
--- a/tex/context/base/strc-ref.mkiv
+++ b/tex/context/base/strc-ref.mkiv
@@ -1847,7 +1847,6 @@
\definereference [\v!HideField ] [action(hide)]
\definereference [\v!ShowField ] [action(show)]
\definereference [\v!GotoPage ] [action(gotopage)]
-\definereference [\v!GotoPage ] [action(gotopage)]
\definereference [\v!Query ] [action(query)]
\definereference [\v!QueryAgain ] [action(queryagain)]
\definereference [\v!FitWidth ] [action(fitwidth)]
@@ -1855,6 +1854,10 @@
\definereference [\v!ShowThumbs ] [action(thumbnails)]
\definereference [\v!ShowBookmarks ] [action(bookmarks)]
+\definereference [\v!HideLayer ] [action(hidelayer)]
+\definereference [\v!VideLayer ] [action(videlayer)]
+\definereference [\v!ToggleLayer ] [action(togglelayer)]
+
\definereference [\v!firstpage] [page(firstpage)]
\definereference [\v!previouspage] [page(previouspage)]
\definereference [\v!nextpage] [page(nextpage)]
diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv
index c78f0413e..5737fc165 100644
--- a/tex/context/base/strc-ren.mkiv
+++ b/tex/context/base/strc-ren.mkiv
@@ -71,25 +71,23 @@
\fi
\dontconvertfont}
-\def\doplaceheadtextcomponent#1#2%
+\def\doplaceheadtextcomponent#1%
{\begingroup
\setupheadcomponentfont\c!textstyle\c!textcolor
- % \ifcase\headtimingmode#1\fi % can introduce cr
\structureheadparameter\c!commandbefore
\placeheadmargintexts
\ifcsname\??nh\currentstructurehead\c!deeptextcommand\endcsname
\expandafter\let\expandafter\deepstructuretitlecommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname
\fi
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
- % struts can be nilled with \setnostrut, the \hbox prevents break
- \structureheadparameter\c!textcommand{\setstrut\begstrut\ifcase\headtimingmode\hbox{#1}\fi#2\endstrut}%
+ % struts can be nilled with \setnostrut
+ \structureheadparameter\c!textcommand{\setstrut\begstrut#1\endstrut}%
\xdef\localheadheight {\the\strutht}%
\xdef\localheaddepth {\the\strutdp}%
\xdef\localheadlineheight{\the\lineheight}%
% == \globallet\localheaddepth\strutdepth
\else
- \ifcase\headtimingmode#1\fi
- \structureheadparameter\c!textcommand{#2}%
+ \structureheadparameter\c!textcommand{#1}%
\fi
\structureheadparameter\c!commandafter
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
@@ -97,19 +95,18 @@
\fi
\endgroup}
-\def\doplaceheadnumbercomponent#1#2%
+\def\doplaceheadnumbercomponent#1%
{\begingroup
\setupheadcomponentfont\c!numberstyle\c!numbercolor
- % \getvalue{\??ko\currentstructurehead\c!commandbefore}% strange, why here? moved 21/11/2005
\placeheadmargintexts
\ifcsname\??nh\currentstructurehead\c!deepnumbercommand\endcsname
\expandafter\let\expandafter\deepstructurenumbercommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname
\fi
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
% can be nilled with \setnostrut
- \structureheadparameter\c!numbercommand{\setstrut\begstrut#2\endstrut}%
+ \structureheadparameter\c!numbercommand{\setstrut\begstrut#1\endstrut}%
\else
- \structureheadparameter\c!numbercommand{#2}%
+ \structureheadparameter\c!numbercommand{#1}%
\fi
\endgroup}
@@ -149,45 +146,38 @@
% maybe auto: backreference when given, else list
\fi\fi}
-\def\doplacestructureheadtext#1#2#3% nodes, text, endstuff
+\unexpanded\def\placestructureheadtext
{\beginheadplacement
+ \setstructureheadmarking
\doresettructureheadnumbercontent
\ifconditional\structureheadleaveempty
- \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute to \zeropoint{#1}%
+ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute to \zeropoint{}%
\makestrutofbox\sectionheadbox
\else
\docheckstructureheadreference
\setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute
{\dosetlocalgridsnapping{\structureheadparameter\c!internalgrid}%
\doresettructureheadnumbercontent
- \ifcase\headtimingmode\or#1\fi % outerside font determines distance
\dosetfontattribute{\??nh\currentstructurehead}\c!style % but we don't want color to influence user command, todo: get the if-else out of it
- \structureheadparameter\c!command{}{\doplaceheadtextcomponent{#1}{#2}}}%
+ \structureheadparameter\c!command{}{\doplaceheadtextcomponent\getstructureheadtitle}}%
\fi
- \endheadplacement{#3}}
+ \endheadplacement{\getstructureheadsyncs}}
-\def\doplacestructureheadnumbertext#1#2#3#4% nodes number text nodes
+\unexpanded\def\placestructureheadnumbertext
{\beginheadplacement
- \doiftextelse{#2}\dosettructureheadnumbercontent\doresettructureheadnumbercontent
+ \setstructureheadmarking
+ \doiftextelse{\getstructureheadnumber}\dosettructureheadnumbercontent\doresettructureheadnumbercontent
\ifconditional\structureheadleaveempty
- \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute to \zeropoint{#1}%
+ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute to \zeropoint{}%
\makestrutofbox\sectionheadbox
\else % = needed
\docheckstructureheadreference
\setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute
{\dosetlocalgridsnapping{\structureheadparameter\c!internalgrid}%
- \ifcase\headtimingmode\or#1\fi
\dosetfontattribute{\??nh\currentstructurehead}\c!style
- \structureheadparameter\c!command{\doplaceheadnumbercomponent{#1}{#2}}{\doplaceheadtextcomponent{#1}{#3}}}%
+ \structureheadparameter\c!command{\doplaceheadnumbercomponent\getstructureheadnumber}{\doplaceheadtextcomponent\getstructureheadtitle}}%
\fi
- \endheadplacement{#4}}
-
-
-\unexpanded\def\placestructureheadnumbertext
- {\doplacestructureheadnumbertext\empty\getstructureheadnumber\getstructureheadtitle\getstructureheadsyncs}
-
-\unexpanded\def\placestructureheadtext
- {\doplacestructureheadtext\empty\getstructureheadtitle\getstructureheadsyncs}
+ \endheadplacement{\getstructureheadsyncs}}
\unexpanded\def\placestructureheadempty
{\hbox \structureheadattribute {\getstructureheadsyncs}}
@@ -243,7 +233,7 @@
\iflocation
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
\else
- \noninterferingmarks
+ % obsolete: \noninterferingmarks
\fi
\fi
\resetinteractionparameter\c!style
diff --git a/tex/context/base/strc-sbe.mkiv b/tex/context/base/strc-sbe.mkiv
index 75d78d48b..e9d8d9c1a 100644
--- a/tex/context/base/strc-sbe.mkiv
+++ b/tex/context/base/strc-sbe.mkiv
@@ -56,9 +56,13 @@
\setvalue {\e!start#2}{\startstructureblock[#1]}%
\setvalue {\e!stop #2}{\stopstructureblock}}
+\ifdefined \resetallstructuremarks \else
+ \let\resetallstructuremarks\relax
+\fi
+
\appendtoks
\doifsomething{\structureblockparameter\c!page}{\page[\structureblockparameter\c!page]}%
-% TODO \resetsectionmarks\zerosection
+ \resetallstructuremarks
\getstructureblockenvironment\currentstructureblock
\structureblockparameter\c!before % don't move
\dostarttagged\t!division\currentstructureblock
@@ -68,7 +72,7 @@
\structureblockparameter\c!after % don't move
\doifsomething{\structureblockparameter\c!page}{\page[\structureblockparameter\c!page]}%
\dostoptagged
-% TODO \resetsectionmarks\zerosection
+ \resetallstructuremarks
\to \everyafterstructureblock
\def\dosetupstructureblock[#1]%
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index f872043cb..0d1cd17a6 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -78,28 +78,36 @@
\let\laststructuresectionname\empty
+\let\resetallstructuremarks \relax
+\let\resetcurrentstructuremarks \relax
+\let\resetcurrentstructuremarkswithpage\relax
+
+\def\resetallstructuremarks {\resetmarking[\v!section-1]} % will become option
+\def\resetcurrentstructuremarks {\resetmarking[\laststructuresectionname]} % will become option
+%def\resetcurrentstructuremarkswithpage{\resetmarking[\laststructuresectionname]} % will become option
+
\unexpanded\def\definestructuresection[#1]%
- {\doifundefined{\??nh#1}
- {\global\advance\maxstructuredepth\plusone
- \setevalue{\??nh#1\c!level}{\the\maxstructuredepth}%
- \setstructurelevel{#1}{\the\maxstructuredepth}%
- %\letvalueempty{\??nh#1\c!marking}% ?
- %\writestatus{structure}{#1\ifx\laststructuresectionname\empty\else\space->\space\laststructuresectionname\fi}%
- \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\laststructuresectionname]}%
- % this is a rather practical default that we don't want to be part of the parent chain
- % lookup mechanism; it's also mkii compativle; this might become \everystructureheaddefine
- \getparameters[\??nh#1]
- [ \c!textstyle=\structureheadparameterstrict\c!style,
- \c!textcolor=\structureheadparameterstrict\c!color,
- \c!numberstyle=\structureheadparameterstrict\c!style,
- \c!numbercolor=\structureheadparameterstrict\c!color]%
- % so far for these default inheritances
- \definemarking[#1]%
- \ifnum\maxstructuredepth>\plusone
- %\normalexpanded{\noexpand\couplemarking[#1][\laststructuresectionname]}% so, the child inherits settings from the parent
- \normalexpanded{\noexpand\relatemarking[#1][\laststructuresectionname]}% so, the parent will reset the child
- \fi
- \xdef\laststructuresectionname{#1}}}
+ {\ifcsname\??nh#1\endcsname
+ % rather fatal error
+ \else
+ \global\advance\maxstructuredepth\plusone
+ \setevalue{\??nh#1\c!level}{\the\maxstructuredepth}%
+ \setstructurelevel{#1}{\the\maxstructuredepth}%
+ \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\laststructuresectionname]}%
+ % this is a rather practical default that we don't want to be part of the parent chain
+ % lookup mechanism; it's also mkii compativle; this might become \everystructureheaddefine
+ \getparameters[\??nh#1]
+ [ \c!textstyle=\structureheadparameterstrict\c!style,
+ \c!textcolor=\structureheadparameterstrict\c!color,
+ \c!numberstyle=\structureheadparameterstrict\c!style,
+ \c!numbercolor=\structureheadparameterstrict\c!color]%
+ % so far for these default inheritances
+ \definemarking[#1]%
+ \ifnum\maxstructuredepth>\plusone
+ \normalexpanded{\noexpand\relatemarking[#1][\laststructuresectionname]}% so, the parent will reset the child
+ \fi
+ \xdef\laststructuresectionname{#1}%
+ \fi}
\unexpanded\def\setupstructuresection
{\dotripleempty\dosetupstructuresection}
@@ -173,25 +181,28 @@
\edef\currentstructureheaddefault{\structureheadparameter\c!default}%
\edef\currentstructureheadsection{\structureheadparameter\c!section}%
\edef\currentstructureheadparent
- {\??nh
- \ifx\currentstructurehead\currentstructureheaddefault
+ {\ifx\currentstructurehead\currentstructureheaddefault
\currentstructureheadsection
\else\ifx\currentstructureheaddefault\empty
\currentstructureheadsection
\else
\currentstructureheaddefault
\fi\fi}%
- \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\currentstructureheadparent]}% \setevalue{\??nh#1\s!parent}{\currentstructureheadparent}%
- \ifx\currentstructureheadsection\empty
- %\writestatus{structure}{#1->\currentstructureheadparent}%
- \else
- %\writestatus{structure}{#1->\currentstructureheadparent\space(\currentstructureheadsection)}%
- % todo: filtercommand
- \definemarking[#1][\currentstructureheadsection]%
- \definemarking[#1\v!number][#1]%
- \setupmarking[#1][\c!filtercommand=\sectionheadmarkingtitle{#1}]%
- \setupmarking[#1\c!number][\c!filtercommand=\sectionheadmarkingnumber{#1}]%
- \fi
+ \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\currentstructureheadparent]}%
+ % or just \setevalue{\??nh#1\s!parent}{\??nh\currentstructureheadparent}%
+% \ifx\currentstructureheadsection\empty
+% \definemarking[#1]%
+% \setupmarking[#1][\c!filtercommand=\sectionheadmarkingtitle{#1}]%
+% \else
+% \definemarking[#1][\currentstructureheadsection]%
+% \definemarking[#1\v!number][#1]%
+% \setupmarking[#1][\c!filtercommand=\sectionheadmarkingtitle{#1}]%
+% \setupmarking[#1\c!number][\c!filtercommand=\sectionheadmarkingnumber{#1}]%
+% \fi
+ \definemarking[#1] [\currentstructureheadsection]%
+ \definemarking[#1\v!number][\currentstructureheadsection]%
+ \setupmarking [#1] [\c!filtercommand=\sectionheadmarkingtitle {#1}]%
+ \setupmarking [#1\c!number][\c!filtercommand=\sectionheadmarkingnumber{#1}]%
\doifundefined{\??li#1}{\definelist[#1][\c!prefix=\v!no]}% definestructurelist ?
\the\everystructureheadsetup}
@@ -205,7 +216,9 @@
{\getparameters[\??nh#1][\c!label=#1]%
\doifundefined{\??li#1}{\definelist[#1][\c!prefix=\v!no]}}% definestructurelist ?
{\getparameters[\??nh#1][\s!parent=\??nh#2,\c!label=#1,\c!coupling=#2]%
- \definemarking[#1][#2]%
+% \definemarking[#1] [#2]%
+% \definemarking[#1\v!number][#2\c!number]%
+ \definemarking[#1] [#2]%
\definemarking[#1\v!number][#2\c!number]%
\doifundefined{\??li#1}{\definelist[#1][#2][\c!prefix=\v!no]}}% definestructurelist ?
\the\everystructureheadsetup}
@@ -407,9 +420,11 @@
\unexpanded\def\thestructureheadsynchonization
{\pagetype[\currentstructureheadcoupling]% hm also number
- \normalexpanded{\noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}}%
\currentstructuresynchronize}
+\unexpanded\def\setstructureheadmarking
+ {\normalexpanded{\noexpand\setmarking[\currentstructurehead]{\currentstructurelistnumber}}}
+
% \unexpanded\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo
% \def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode!
% \unexpanded\def\fullstructureheadtitle{\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}}
@@ -602,15 +617,18 @@
% typesetting
\unexpanded\def\placestructureheadnumbertext % dummy, will be overloaded
- {\getstructureheadnumber/\getstructureheadtitle
+ {\setstructureheadmarking
+ \getstructureheadnumber/\getstructureheadtitle
\getstructureheadsyncs}
\unexpanded\def\placestructureheadtext % dummy, will be overloaded
- {\getstructureheadtitle
+ {\setstructureheadmarking
+ \getstructureheadtitle
\getstructureheadsyncs}
\unexpanded\def\placestructureheadempty % dummy, will be overloaded
- {\getstructureheadsyncs}
+ {\setstructureheadmarking
+ \getstructureheadsyncs}
\unexpanded\def\placestructureheadhidden
{\setxvalue{\currentstructurehead:sync}%
@@ -709,9 +727,16 @@
{\doifsomething{\structureheadparameter#2}{\expanded{\setuplayouttext[#1][\c!state=\structureheadparameter#2]}}}
\donothing}
+\setvalue{\??nh:\??mk:n:\v!page }{}
+\setvalue{\??nh:\??mk:n:\v!reset}{\resetcurrentstructuremarks}
+\setvalue{\??nh:\??mk:y:\v!page }{\resetcurrentstructuremarks}
+\setvalue{\??nh:\??mk:y:\v!reset}{\resetcurrentstructuremarks}
+
\def\docheckstructureheadlayout
- {\doifsomething{\structureheadparameter\c!page}
+ {\doifelsenothing{\structureheadparameter\c!page}
+ {\getvalue{\??nh:\??mk:n:\structureheadparameter\c!marking}}
{\page[\structureheadparameter\c!page]%
+ \getvalue{\??nh:\??mk:y:\structureheadparameter\c!marking}%
\dodocheckstructureheadlayout\v!header\c!header
\dodocheckstructureheadlayout\v!text \c!text
\dodocheckstructureheadlayout\v!footer\c!footer}}
diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua
index b95d72d7f..500443f7d 100644
--- a/tex/context/base/supp-fil.lua
+++ b/tex/context/base/supp-fil.lua
@@ -155,7 +155,7 @@ end
-- modules can only have a tex or mkiv suffix or can have a specified one
local prefixes = { "m", "p", "s", "x", "t" }
-local suffixes = { "tex", "mkiv" }
+local suffixes = { "mkiv", "tex" } -- what about cld
local modstatus = { }
local function usemodule(name,hasscheme)
@@ -173,7 +173,7 @@ local function usemodule(name,hasscheme)
report_modules("checking suffix driven file '%s'",name)
end
foundname = commands.readfilename(name,false,true) or ""
- else
+ elseif true then
for i=1,#suffixes do
local fullname = file.addsuffix(name,suffixes[i])
if trace_modules then
@@ -184,6 +184,35 @@ local function usemodule(name,hasscheme)
break
end
end
+ else
+ -- -- we don't want a tex file for each mkiv file so we do some checking
+ -- local foundtexname = commands.readfilename(file.addsuffix(name,"tex"), false,true) or ""
+ -- local foundmkivname = commands.readfilename(file.addsuffix(name,"mkiv"),false,true) or ""
+ -- if foundtexfile ~= "" and foundmkivfile ~= "" then
+ -- if file.dirname(foundtexname) == file.dirname(foundmkivname) then
+ -- foundname = foundtexname -- we assume that this (shared) file loads the mkiv file
+ -- if trace_modules then
+ -- report_modules("using tex file for module '%s' (mkiv file on same dir)",name)
+ -- end
+ -- else
+ -- foundname = foundmkivname -- we assume that the tex file is an old one someplace else
+ -- if trace_modules then
+ -- report_modules("using mkiv file for module '%s' (tex file on other dir)",name)
+ -- end
+ -- end
+ -- elseif foundtexfile ~= "" then
+ -- foundname = foundtexname
+ -- if trace_modules then
+ -- report_modules("using tex file for module '%s'",name)
+ -- end
+ -- elseif foundmkivfile ~= "" then
+ -- foundname = foundmkivname
+ -- if trace_modules then
+ -- report_modules("using mkiv file for module '%s'",name)
+ -- end
+ -- else
+ -- -- nothing
+ -- end
end
if foundname ~= "" then
if trace_modules then
diff --git a/tex/context/base/symb-ini.mkiv b/tex/context/base/symb-ini.mkiv
index f4f6bdd79..3b7e55d4a 100644
--- a/tex/context/base/symb-ini.mkiv
+++ b/tex/context/base/symb-ini.mkiv
@@ -263,9 +263,8 @@
%D \showsetup{usesymbols}
\def\dousesymbols#1%
- {\makeshortfilename[\truefilename{\f!symbolprefix#1}]%
- \startreadingfile
- \readsysfile\shortfilename
+ {\startreadingfile
+ \readsysfile{\truefilename{\f!symbolprefix#1}}
{\showmessage\m!symbols1{#1}}
\donothing
\stopreadingfile}
diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv
index 01b483a7e..c45a4f178 100644
--- a/tex/context/base/tabl-tab.mkiv
+++ b/tex/context/base/tabl-tab.mkiv
@@ -1472,7 +1472,7 @@
\let\LR\TableLR
\let\AR\TableAR}
-\def\TableSR
+\unexpanded\def\TableSR
{\ifTABLEgrayline \else
\ifnum\TABLEaction=\TABLEfirstrow
\writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
@@ -1485,7 +1485,7 @@
\checkTABLErow\SR
\endTABLErow\TABLEseparaterow\TABLErowfactor\TABLErowfactor}
-\def\TableFR
+\unexpanded\def\TableFR
{\ifTABLEgrayline \else
\ifnum\TABLEaction=\TABLEmidrow
\writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}%
@@ -1496,7 +1496,7 @@
\checkTABLErow\FR
\endTABLErow\TABLEfirstrow\TABLErowfactor\TABLErowzero}
-\def\TableMR
+\unexpanded\def\TableMR
{\ifTABLEgrayline \else
\ifnum\TABLEaction=\TABLErule
\writestatus\m!TABLE{change \string\MR\space into \string\FR/\string\SR}%
@@ -1507,7 +1507,7 @@
\checkTABLErow\MR
\endTABLErow\TABLEmidrow00}
-\def\TableLR
+\unexpanded\def\TableLR
{\ifTABLEgrayline \else
\ifnum\TABLEaction=\TABLErule
\writestatus\m!TABLE{change \string\LR\space into \string\FR/\string\SR}%
@@ -1576,7 +1576,7 @@
%D check takes care of the first and mid rows, the chuck macro
%D |<|how about that name|>| handles the last row.
-\def\TableAR
+\unexpanded\def\TableAR
{\ifTABLEgraydone
\globalletempty\checkTABLEautorow
\globalletempty\chuckTABLEautorow
@@ -1721,7 +1721,7 @@
\let\VT\TableVT
\let\VN\TableVN}
-\def\TableVL
+\unexpanded\def\TableVL
{\checkTABLEautorow
\nextTABLEgrayline
\ifnum\currentTABLEcolumn>\maxTABLEcolumn
@@ -1764,10 +1764,10 @@
% \HL
% \stoptable
-\def\TableVS {\VN1}
-\def\TableVD {\VN2}
-\def\TableVT {\VN3}
-\def\TableVN#1{\gdef\@VLn{#1}\VL}
+\unexpanded\def\TableVS {\VN1}
+\unexpanded\def\TableVD {\VN2}
+\unexpanded\def\TableVT {\VN3}
+\unexpanded\def\TableVN#1{\gdef\@VLn{#1}\VL}
\def\resetVLvalues
{\dostepwiserecurse\zerocount\maxTABLEcolumn\plusone
@@ -1776,7 +1776,7 @@
\letgvalueempty{eVL\recurselevel}}%
\global\currentTABLEcolumn\zerocount}
-\def\TableVC
+\unexpanded\def\TableVC
{\checkTABLEautorow
\nextTABLEgrayline
\ifnum\currentTABLEcolumn>\maxTABLEcolumn
@@ -1805,7 +1805,7 @@
{\getvalue{eVC\the\currentTABLEcolumn}}%
\doTableVL}
-\def\TableHL
+\unexpanded\def\TableHL
{\ifnum\currentTABLEcolumn>\maxTABLEcolumn
\chuckTABLEautorow
\else\ifnum\currentTABLEcolumn=\zerocount
@@ -1850,7 +1850,7 @@
\let\startHLcommand\empty
\let\stopHLcommand \empty
-\def\TableHC
+\unexpanded\def\TableHC
{\complexorsimpleTable{HC}}
\def\complexTableHC[#1]%
@@ -1884,7 +1884,7 @@
\let\MC\TableNC
\let\LC\TableNC}
-\def\TableNL
+\unexpanded\def\TableNL
{\complexorsimpleTable{NL}}
\def\complexTableNL[#1]%
@@ -1899,7 +1899,7 @@
\vskip\ht0
\nobreak}}
-\def\TableNR
+\unexpanded\def\TableNR
{\ifnum\currentTABLEcolumn>\maxTABLEcolumn
\global\currentTABLEcolumn\zerocount
\normalTABLElineending
@@ -1911,7 +1911,7 @@
{\nobreak
\setTABLEaction\TABLEunknown}}
-\def\TableNC
+\unexpanded\def\TableNC
{\checkTABLEautorow
\nextTABLEgrayline
\ifnum\currentTABLEcolumn>\maxTABLEcolumn
@@ -1964,7 +1964,7 @@
\global\TABLEdivisiontrue
\fi}
-\def\TableDL
+\unexpanded\def\TableDL
{\checkTABLEdivision
\complexorsimpleTable{DL}}
@@ -2004,13 +2004,13 @@
%\globalletempty\stopHLcommand
\fi}
-\def\TableDV
+\unexpanded\def\TableDV
{\TableDCV\normalTABLEsimplebar}
-\def\TableDC
+\unexpanded\def\TableDC
{\TableDCV\normalTABLEquote}
-\def\TableDCV#1%
+\unexpanded\def\TableDCV#1%
{\checkTABLEdivision
\checkTABLEautorow
\ifnum\currentTABLEcolumn>\maxTABLEcolumn
@@ -2021,7 +2021,7 @@
#1%
\fi}
-\def\TableDR
+\unexpanded\def\TableDR
{\ifnum\currentTABLEcolumn<\maxTABLEcolumn % silent recovery
%\setTABLEerror\TABLEmissingcolumn % some day warning
%\handleTABLEerror
@@ -2070,7 +2070,7 @@
{\global\TABLEcr\plusone}
{\global\TABLEcr\plustwo}}
-\def\TableBC
+\unexpanded\def\TableBC
{\ifTABLEgrayline
\normalTABLEquote
\else
@@ -2086,7 +2086,7 @@
{\addtoTABLEgrayline{\BC}%
\gobbleTableBCL}
-\def\TableBL
+\unexpanded\def\TableBL
{\TABLEnoalign\bgroup
\globallet\nextTABLEgrayline\executeTABLEgrayline
\globalletempty\TABLEgrayline % new
@@ -2106,7 +2106,7 @@
{\analyzeTABLEcr[#1]%
\handleTABLEcr}
-\def\TableBR#1%
+\unexpanded\def\TableBR#1%
{\TABLEnoalign
{\globallet\nextTABLEgrayline\executeTABLEgrayline
\checkTABLEgrayline#1\BR
@@ -2153,7 +2153,7 @@
{\dodoanalyzeTABLEcr[#2,#1,#3]}
{\dodoanalyzeTABLEcr[\ifTABLEgrayline1\else\maxTABLEcolumn\fi,#1,#2]}}
-\def\TableCL
+\unexpanded\def\TableCL
{\TABLEnoalign\bgroup
\globallet\nextTABLEgrayline\executeTABLEgrayline
\globalletempty\TABLEgrayline % new
@@ -2173,7 +2173,7 @@
{\analyzeTABLEcrl{c}[#1]%
\handleTABLEcr}
-\def\TableRL
+\unexpanded\def\TableRL
{\TABLEnoalign\bgroup
\globallet\nextTABLEgrayline\executeTABLEgrayline
\globalletempty\TABLEgrayline % new
@@ -2264,7 +2264,7 @@
\doPostTableGL
#2}
-\def\TableBACKGROUND
+\unexpanded\def\TableBACKGROUND
{\TableBR}
\def\simpleTableRASTER #1{\docomplexTableRASTER[1]#1}
@@ -2272,8 +2272,8 @@
\def\simpleTableCOLOR {\docomplexTableCOLOR [1]}
\def\complexTableCOLOR [#1]{\docomplexTableCOLOR [#1]}
-\def\TableRASTER{\complexorsimpleTable{RASTER}}
-\def\TableCOLOR {\complexorsimpleTable{COLOR}}
+\unexpanded\def\TableRASTER{\complexorsimpleTable{RASTER}}
+\unexpanded\def\TableCOLOR {\complexorsimpleTable{COLOR}}
\def\addtoTABLEgrayline#1%
{\TABLEgraytoks\expandafter{\TABLEgrayline}%
diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua
index f4e152b14..49dfcf74d 100644
--- a/tex/context/base/trac-set.lua
+++ b/tex/context/base/trac-set.lua
@@ -36,7 +36,7 @@ function setters.initialize(filename,name,values) -- filename only for diagnosti
data = data.data
if data then
for key, value in next, values do
- key = gsub(key,"_",".")
+ -- key = gsub(key,"_",".")
value = is_boolean(value,value)
local functions = data[key]
if functions then
@@ -63,6 +63,7 @@ function setters.initialize(filename,name,values) -- filename only for diagnosti
end
end
end
+ return true
end
end
end
@@ -297,3 +298,27 @@ end
if directives and environment and environment.engineflags.directives then
d_enable(environment.engineflags.directives)
end
+
+-- here
+
+if texconfig then
+
+ local function set(k,v)
+ v = tonumber(v)
+ if v then
+--~ print(k,v)
+ texconfig[k] = v
+ end
+ end
+
+ directives.register("luatex.expanddepth", function(v) set("expand_depth",v) end)
+ directives.register("luatex.hashextra", function(v) set("hash_extra",v) end)
+ directives.register("luatex.nestsize", function(v) set("nest_size",v) end)
+ directives.register("luatex.maxinopen", function(v) set("max_in_open",v) end)
+ directives.register("luatex.maxprintline", function(v) set("max_print_line",v) end)
+ directives.register("luatex.maxstrings", function(v) set("max_strings",v) end)
+ directives.register("luatex.paramsize", function(v) set("param_size",v) end)
+ directives.register("luatex.savesize", function(v) set("save_size",v) end)
+ directives.register("luatex.stacksize", function(v) set("stack_size",v) end)
+
+end
diff --git a/tex/context/base/typo-cap.lua b/tex/context/base/typo-cap.lua
index 6e244b9b9..eee5208a4 100644
--- a/tex/context/base/typo-cap.lua
+++ b/tex/context/base/typo-cap.lua
@@ -20,6 +20,7 @@ local has_attribute = node.has_attribute
local unset_attribute = node.unset_attribute
local set_attribute = node.set_attribute
local traverse_id = node.traverse_id
+local copy_node = node.copy
local texattribute = tex.attribute
@@ -35,8 +36,8 @@ local userskip_code = skipcodes.userskip
local tasks = nodes.tasks
-local fontdata = fonts.ids
-local fontchar = fonts.chr
+local fontdata = fonts.identifiers
+local fontchar = fonts.characters
local chardata = characters.data
typesetters = typesetters or { }
diff --git a/tex/context/base/typo-dir.lua b/tex/context/base/typo-dir.lua
index 931e6c90c..006c184c6 100644
--- a/tex/context/base/typo-dir.lua
+++ b/tex/context/base/typo-dir.lua
@@ -51,8 +51,8 @@ local new_textdir = nodepool.textdir
local beginmath_code = mathcodes.beginmath
local endmath_code = mathcodes.endmath
-local fontdata = fonts.ids
-local fontchar = fonts.chr
+local fontdata = fonts.identifiers
+local fontchar = fonts.characters
local chardata = characters.data
local chardirs = characters.directions -- maybe make a special mirror table
@@ -381,7 +381,7 @@ function directions.process(namespace,attribute,start) -- todo: make faster
end
else
if trace_directions then
- list[#list+1] = format("node %s (subtype %s)",node.type(id),current.subtype)
+ list[#list+1] = format("node %s (subtype %s)",nodecodes[id],current.subtype)
end
if finish then
finish_auto_before()
diff --git a/tex/context/base/typo-rep.lua b/tex/context/base/typo-rep.lua
index bdeb813ba..5519207e2 100644
--- a/tex/context/base/typo-rep.lua
+++ b/tex/context/base/typo-rep.lua
@@ -25,7 +25,7 @@ local has_attribute = node.has_attribute
local chardata = characters.data
local collected = false
local attribute = attributes.private("stripping")
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local tasks = nodes.tasks
local nodecodes = nodes.nodecodes
diff --git a/tex/context/base/util-seq.lua b/tex/context/base/util-seq.lua
index 14c425dfc..028d0cf8d 100644
--- a/tex/context/base/util-seq.lua
+++ b/tex/context/base/util-seq.lua
@@ -151,20 +151,20 @@ return function(head%s)
return head, done
end]]
-function sequencers.nodeprocessor(t,n)
+function sequencers.nodeprocessor(t,nofarguments)
local list, order, kind, gskip, askip = t.list, t.order, t.kind, t.gskip, t.askip
local vars, calls, args, n = { }, { }, nil, 0
- if n == 0 then
+ if nofarguments == 0 then
args = ""
- elseif n == 1 then
+ elseif nofarguments == 1 then
args = ",one"
- elseif n == 2 then
+ elseif nofarguments == 2 then
args = ",one,two"
- elseif n == 3 then
+ elseif nofarguments == 3 then
args = ",one,two,three"
- elseif n == 4 then
+ elseif nofarguments == 4 then
args = ",one,two,three,four"
- elseif n == 5 then
+ elseif nofarguments == 5 then
args = ",one,two,three,four,five"
else
args = ",..."
@@ -189,6 +189,6 @@ function sequencers.nodeprocessor(t,n)
end
end
local processor = format(template,concat(vars,"\n"),args,concat(calls,"\n"))
---~ print(processor)
+ -- print(processor)
return processor
end
diff --git a/tex/context/base/x-chemml.tex b/tex/context/base/x-chemml.tex
deleted file mode 100644
index 65d33b5ec..000000000
--- a/tex/context/base/x-chemml.tex
+++ /dev/null
@@ -1,16 +0,0 @@
-%D \module
-%D [ file=m-chemml,
-%D version=2001.09.12,
-%D title=\CONTEXT\ XML Modules,
-%D subtitle=Loading CHEMML Filters,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE / 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.
-
-\loadmarkfile{x-chemml}
-
-\endinput
diff --git a/tex/context/base/x-mathml.tex b/tex/context/base/x-mathml.tex
deleted file mode 100644
index 8ad493eeb..000000000
--- a/tex/context/base/x-mathml.tex
+++ /dev/null
@@ -1,16 +0,0 @@
-%D \module
-%D [ file=x-mathml,
-%D version=1999.12.20,
-%D title=\CONTEXT\ XML Modules,
-%D subtitle=Loading \MATHML\ Filters,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE / 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.
-
-\loadmarkfile{x-mathml}
-
-\endinput
diff --git a/tex/context/base/x-newcml.tex b/tex/context/base/x-newcml.mkii
index 76d69ed51..76d69ed51 100644
--- a/tex/context/base/x-newcml.tex
+++ b/tex/context/base/x-newcml.mkii
diff --git a/tex/context/base/x-newmme.tex b/tex/context/base/x-newmme.mkii
index 5e17ea7a4..5e17ea7a4 100644
--- a/tex/context/base/x-newmme.tex
+++ b/tex/context/base/x-newmme.mkii
diff --git a/tex/context/base/x-newmml.tex b/tex/context/base/x-newmml.tex
deleted file mode 100644
index 9eb994021..000000000
--- a/tex/context/base/x-newmml.tex
+++ /dev/null
@@ -1,16 +0,0 @@
-%D \module
-%D [ file=x-newmml,
-%D version=2005.06.10, % 1999.12.20,
-%D title=\CONTEXT\ XML Macros,
-%D subtitle=MathML Renderer,
-%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.
-
-\loadmarkfile{x-newmml}
-
-\endinput
diff --git a/tex/context/base/x-newmmo.tex b/tex/context/base/x-newmmo.mkii
index c3b56cc16..c3b56cc16 100644
--- a/tex/context/base/x-newmmo.tex
+++ b/tex/context/base/x-newmmo.mkii
diff --git a/tex/context/base/x-newpml.tex b/tex/context/base/x-newpml.mkii
index d69231e3f..d69231e3f 100644
--- a/tex/context/base/x-newpml.tex
+++ b/tex/context/base/x-newpml.mkii
diff --git a/tex/context/base/x-physml.tex b/tex/context/base/x-physml.tex
deleted file mode 100644
index 10768db51..000000000
--- a/tex/context/base/x-physml.tex
+++ /dev/null
@@ -1,16 +0,0 @@
-%D \module
-%D [ file=m-physml,
-%D version=2001.09.04,
-%D title=\CONTEXT\ XML Modules,
-%D subtitle=Loading PHYSML Filters,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE / 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.
-
-\loadmarkfile{x-physml}
-
-\endinput
diff --git a/tex/context/base/x-res-50.tex b/tex/context/base/x-res-50.mkii
index 6fa1a3e4f..6fa1a3e4f 100644
--- a/tex/context/base/x-res-50.tex
+++ b/tex/context/base/x-res-50.mkii
diff --git a/tex/context/base/x-res-50.mkiv b/tex/context/base/x-res-50.mkiv
new file mode 100644
index 000000000..f29b1d61e
--- /dev/null
+++ b/tex/context/base/x-res-50.mkiv
@@ -0,0 +1,427 @@
+%D \module
+%D [ file=x-res-50,
+%D version=2004.02.18,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Multimedia Presentation,
+%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.
+
+%D This is a preliminary module, using a preliminary xml media format that
+%D looks as follows (record is embedded in resource library element):
+%D
+%D \starttyping
+%D <rl:mediaclip label="sample 1">
+%D <rl:name>Sample One</rl:name>
+%D <rl:mime>application/x-shockwave-flash</rl:mime>
+%D <rl:file>http://localhost/mb.swf</rl:file>
+%D <rl:width>8cm</rl:width>
+%D <rl:height>6cm</rl:height>
+%D <rl:text>Nothing special to be said.</rl:text>
+%D <rl:picture>cow.pdf</rl:picture>
+%D </rl:mediaclip>
+%D
+%D <rl:mediaclip label="sample 2">
+%D <rl:name>Sample Two</rl:name>
+%D <rl:mime>audio/mpeg</rl:mime>
+%D <rl:file>mb.mp3</rl:file>
+%D <rl:picture>mb.jpg</rl:picture>
+%D </rl:mediaclip>
+%D \stoptyping
+%D
+%D \starttyping
+%D texexec --pdf --use=med-show yourfile.xml
+%D \stoptyping
+%D
+%D Bonus:
+%D
+%D \starttyping
+%D --arg="url=http://localhost:8881/e:/media"
+%D \stoptyping
+
+% output=pdftex
+
+% \nopdfcompression
+
+% bugs in recognizing embedded stream cq. player
+% bugs in layers + hide/vide
+% bugs in save javascripts
+% bugs all over the place
+
+% in principe kan menu overal hetzelfde zijn als we via JS per pagina de clip var zetten,
+% hoewel, misschien zal het menu gaan afhangen van de soort clip
+
+% viewerlayer (eigenschap) aan framed en layer
+
+\usemodule[meta-dum] \usemodule[contml] \autoXMLnamespace [context]
+
+\doifelsevariable{environment}{url}
+ {\setvariables[mediaclip][url=\getvariable{environment}{url}/]}
+ {\setvariables[mediaclip][url=]}
+
+\startmode [silent]
+
+ \setvariables[mediaclip:option][start=]
+
+\stopmode
+
+\startnotmode [silent]
+
+ \setvariables[mediaclip:option][start=auto]
+
+\stopnotmode
+
+\chardef\XMLtokensreduction=1 \dontcomplain % \showframe \pdfcompresslevel=0
+
+\setuppapersize
+ [S6][S6]
+
+\definemeasure [GapSize] [\dimexpr( 15pt)]
+\definemeasure [EdgeWidth] [\dimexpr(100pt)]
+\definemeasure [TextWidth] [\dimexpr(.5\textwidth)]
+\definemeasure [RenderingWidth] [\dimexpr(\textwidth)]
+\definemeasure [RenderingHeight] [\dimexpr(\textheight)]
+
+% \XMLflush{rl:ratio}\dimexpr(.75\textwidth),
+
+\setuplayout
+ [backspace=\measure{GapSize},
+ topspace=\measure{GapSize},
+ header=0pt,
+ footer=0pt,
+ margin=0pt,
+ edgedistance=2\measure{GapSize},
+ rightedge=\measure{EdgeWidth},
+ bottomdistance=2\measure{GapSize},
+ bottom=2\measure{GapSize},
+ height=fit,
+ width=fit]
+
+\setupinteraction
+ [state=start,
+ color=lightgray,
+ contrastcolor=lightgray,
+ openaction=PresetFields,
+ closeaction=ForgetChanges,
+ menu=on,
+ click=no]
+
+\setupinteractionscreen
+ [option=max]
+
+\setupcolors
+ [state=start]
+
+\usetypescript
+ [palatino][texnansi]
+
+\setupbodyfont
+ [palatino]
+
+\definecolor[darkgray] [s=.2]
+\definecolor[mediumgray][s=.5]
+\definecolor[lightgray] [s=.8]
+\definecolor[transgray] [s=1,t=.9,a=1]
+
+\setupbackgrounds
+ [page]
+ [backgroundoffset=\measure{GapSize},
+ background={color,pagebutton},
+ backgroundcolor=black]
+
+\definelayer
+ [main]
+ [width=\textwidth,
+ height=\textheight]
+
+\definelayer
+ [extra]
+ [width=\rightedgewidth,
+ height=\bottomheight]
+
+\setupbackgrounds
+ [text]
+ [backgroundoffset=0pt,
+ background=main]
+
+\setupbackgrounds
+ [bottom][rightedge]
+ [backgroundoffset=0pt,
+ background=extra]
+
+% java scripts
+
+\startJSpreamble {handy} used now
+
+ function ForgetChanges ()
+ { this.dirty = false }
+
+ function PresetFields ()
+ { this.syncAnnotScan() }
+
+\stopJSpreamble
+
+\definereference[PresetFields] [JS(PresetFields)]
+\definereference[ForgetChanges][JS(ForgetChanges)]
+
+% layers
+
+\defineviewerlayer [menulayer] [title=menulayer]
+\defineviewerlayer [textlayer] [title=textlayer,state=stop]
+\defineviewerlayer [datalayer] [title=datalayer,state=stop]
+
+\setupfield
+ [rollbutton]
+ [fieldlayer=menulayer]
+
+\setupfield
+ [rollbutton]
+ [option=auto]
+
+\definepalet
+ [rollover]
+ [n=darkgray,
+ r=lightgray,
+ d=darkgray]
+
+% list
+
+\definelist
+ [clips]
+ [expansion=yes,
+ criterium=text,
+ alternative=f]
+
+% navigation
+
+\defineoverlay[pagebutton][\overlaybutton{HideLayer{textlayer},HideLayer{datalayer},ToggleLayer{menulayer}}]
+\defineoverlay[textbutton][\overlaybutton{HideLayer{textlayer},HideLayer{datalayer}}]
+\defineoverlay[databutton][\overlaybutton{HideLayer{textlayer},HideLayer{datalayer}}]
+
+% clips
+
+\defineXMLenvironment
+ [rl:mediaclip]
+ {\setups[mediaclip:start]}
+ {\setups[mediaclip:stop]}
+
+\newcounter\MediaClip
+
+\startsetups[mediaclip:start]
+
+ \bgroup \startXMLignore
+
+ % no \startstandardmakeup here since we need the dsta in the menuconstruction
+
+ \defineXMLsave [rl:name]
+ \defineXMLsave [rl:visualization]
+ \defineXMLsave [rl:file]
+ \defineXMLsave [rl:mime]
+ \defineXMLsave [rl:picture] [backgroundcolor=lightgray]
+
+ \defineXMLsavecontent [rl:text] {No additional info.}
+ \defineXMLsavecontent [rl:width] {\measure{RenderingWidth}}
+ \defineXMLsavecontent [rl:height] {\measure{RenderingHeight}}
+ \defineXMLsavecontent [rl:aspect] {1}
+
+\stopsetups
+
+\startsetups[mediaclip:stop]
+
+ \startstandardmakeup
+
+ \doifXMLdataelse{rl:file}
+ {\setups[mediaclip:file:yes]}
+ {}
+
+ \doifXMLdataelse{rl:picture}
+ {\doifelse{\XMLflush{rl:picture}}{self}
+ {\setups[mediaclip:picture:self]}
+ {\setups[mediaclip:picture:yes]}}
+ {\setups[mediaclip:picture:no]}
+
+ \doifXMLdata{rl:text}
+ {\setups[mediaclip:text]}
+
+ \setlayerframed
+ [extra]
+ [preset=rightbottom]
+ [frame=off,offset=overlay,width=fit,background=databutton,align=left]
+ {\startviewerlayer[datalayer]\setups[mediaclip:data]\stopviewerlayer}
+
+ \doifXMLdataelse{rl:name}
+ {\writetolist[clips]{}{\XMLflush{rl:name}}}
+ {\writetolist[clips]{}{\XMLpar{rl:mediaclip}{label}{unknown}}}
+
+ \stopstandardmakeup
+
+ \stopXMLignore \egroup
+
+\stopsetups
+
+\setuptabulate
+ [before=,
+ after=]
+
+\def\rlCleanupFileName#1%
+ {\bgroup
+ \def\cleanup##1##2{\ifnum##1##2=20 \space\else\char\octnumber{##1##2}\fi}%
+ \defineactivecharacter 37 {\cleanup}%
+ \scantokens{#1}%
+ \egroup}
+
+\startsetups[mediaclip:data]
+
+ \noindent \buttonframed
+ [framecolor=lightgray,
+ foregroundcolor=lightgray]
+ {\bf\expanded{\rlCleanupFileName{\XMLflush{rl:file}}}}
+
+ \vskip.75\measure{GapSize}
+
+ \noindent \buttonframed
+ [framecolor=lightgray,
+ foregroundcolor=lightgray]
+ {\bf\XMLflush{rl:mime}}
+
+\stopsetups
+
+\startsetups[mediaclip:picture:self]
+
+ \definerenderingwindow
+ [mediaclip]
+ [width=\XMLflush{rl:width},
+ height=\XMLflush{rl:height},
+ frame=off,
+ openpageaction=StartCurrentRendering,
+ closepageaction=StopCurrentRendering]
+
+ \setlayer
+ [main]
+ {\placerenderingwindow[mediaclip][mediaclip-\MediaClip]}
+
+\stopsetups
+
+\startsetups[mediaclip:picture:yes]
+
+ \setlayer
+ [main]
+ {\externalfigure
+ [\XMLflush{rl:picture}]
+ [background=color,
+ backgroundcolor=\XMLpar{rl:picture}{backgroundcolor}{lightgray},
+ factor=max,
+ width=\XMLflush{rl:width},
+ height=\XMLflush{rl:height}]}
+
+\stopsetups
+
+\startsetups[mediaclip:picture:no]
+
+ \setlayer
+ [main]
+ {\externalfigure
+ [dummy]
+ [width=\XMLflush{rl:width},
+ height=\XMLflush{rl:height}]}
+
+\stopsetups
+
+\startsetups[mediaclip:file:yes]
+
+ \doglobal\increment\MediaClip
+
+ \useexternalrendering
+ [mediaclip-\MediaClip]
+ [\XMLflush{rl:mime}]
+ [\getvariable{mediaclip}{url}\XMLflush{rl:file}]
+ [\getvariable{mediaclip:option}{start}]
+
+\stopsetups
+
+\defineinteractionmenu
+ [navigation] [right]
+
+\defineinteractionmenu
+ [control] [bottom]
+
+\setupinteractionmenu
+ [navigation,control]
+ [state=start,
+ frame=on,
+ middle=\hskip.5\measure{GapSize},
+ inbetween=\vskip.5\measure{GapSize}]
+
+\setupinteractionmenu
+ [right,bottom]
+ [distance=overlay]
+
+\startinteractionmenu [navigation]
+ \rob [HideLayer{textlayer},FirstPage] First Page \\
+ \rob [HideLayer{textlayer},PreviousPage] Previous Page \\
+ \rob [HideLayer{textlayer},NextPage] Next Page \\
+ \rob [HideLayer{textlayer},LastPage] Last Page \\
+ \rob [HideLayer{textlayer},clips] List Of Clips \\
+ \rob [ForgetChanges,CloseDocument] Close Document \\
+\stopinteractionmenu
+
+\startinteractionmenu [control]
+ \rob [StartRendering{mediaclip-\MediaClip}] Start \\
+ \rob [StopRendering{mediaclip-\MediaClip}] Stop \\
+ \rob [PauseRendering{mediaclip-\MediaClip}] Pause \\
+ \rob [ResumeRendering{mediaclip-\MediaClip}] Resume \\
+ \rob [ToggleLayer{datalayer}] Info \\
+ \doifXMLdata{rl:text}{\rob [HideLayer{datalayer},ToggleLayer{textlayer}] Text \\}
+\stopinteractionmenu
+
+\startsetups[mediaclip:text]
+
+ \setlayer
+ [extra]
+ [preset=rightbottom]
+ {\startviewerlayer[textlayer]
+ \framed
+ [align=normal,
+ frame=off,
+ width=\measure{TextWidth},
+ foregroundcolor=darkgray,
+ background={color,textbutton},
+ backgroundcolor=lightgray]
+ {\XMLflush{rl:text}}
+ \stopviewerlayer}
+
+\stopsetups
+
+\setupcolors[textcolor=lightgray]
+
+\startsetups [library:start]
+
+ \starttext
+
+ \setupinteractionmenu[control][state=stop]
+
+ \title[clips]{List of Media Clips}
+
+ \placelist[clips] \page
+
+ \setupinteractionmenu[control][state=start]
+
+\stopsetups
+
+\startsetups [library:stop]
+
+ \stoptext
+
+\stopsetups
+
+\defineXMLenvironment [rl:resourcelibrary]
+ {\setups[library:start]}
+ {\setups[library:stop]}
+
+\doifelsenothing{\inputfilename}
+ {\processXMLfile{mediaclient.xml}}
+ {\processXMLfile{\inputfilename}}
diff --git a/tex/context/base/x-set-11.tex b/tex/context/base/x-set-11.tex
deleted file mode 100644
index 920fd7426..000000000
--- a/tex/context/base/x-set-11.tex
+++ /dev/null
@@ -1,110 +0,0 @@
-%D \module
-%D [ file=x-set-11,
-%D version=2004.10.31,
-%D remark=setupx.tex: 1998.07.20 and later,
-%D title=\CONTEXT\ Setup Definitions,
-%D subtitle=Macro Definitions,
-%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.
-
-\loadmarkfile{x-set-11}
-
-\endinput
-
-% Old code, a mixture of loading in mkiv and processing in mkii.
-
-\startluacode
- do
- document = document or { }
-
- document.setups = {
- loaded = { },
- root = nil,
- used = { },
- }
-
- function document.setups.load(filename)
- filename = resolvers.find_file(filename) or ""
- if filename ~= "" and not document.setups.loaded[filename] then
- local loaded = xml.load(filename)
- if loaded then
- if document.setups.root then
- xml.inject(document.setups.root,"/",loaded)
- else
- document.setups.root = loaded
- end
- document.setups.loaded[filename] = true
- end
- end
- end
- function document.setups.name(ek)
- local at = ek.at
- local name = at.name
- if at.type == 'environment' then
- name = "start" .. name
- end
- if at.variant then
- name = name .. ":" .. at.variant
- end
- if at.generated == "yes" then
- name = name .. "*"
- end
- return name:lower()
- end
- function document.setups.show(name)
- if document.setups.root then
- local name = name:gsub("[<>]","")
- local setup = xml.first(document.setups.root,"cd:command[@name='" .. name .. "']")
- document.setups.used[#document.setups.used+1] = setup
- xml.sprint(setup)
- end
- end
- function document.setups.showused()
- if document.setups.root and next(document.setups.used) then
- for k,v in ipairs(table.sortedkeys(document.setups.used)) do
- xml.sprint(document.setups.used[v])
- end
- end
- end
- function document.setups.showall()
- if document.setups.root then
- local list = { }
- xml.each_element(document.setups.root,"cd:command", function(r,d,t)
- local ek = d[t]
- list[document.setups.name(ek)] = ek
- end )
- for k,v in ipairs(table.sortedkeys(list)) do
- xml.sprint(list[v])
- end
- end
- end
- function document.setups.resolve(name)
- if document.setups.root then
- local e = xml.filter(document.setups.root,string.format("cd:define[@name='%s']/text()",name))
- if e then
- xml.sprint(e)
- end
- end
- end
- end
-\stopluacode
-
-\def\mkloadsetups #1{\ctxlua{document.setups.load("#1")}}
-\def\mkshowsetup #1{\ctxlua{document.setups.show("#1")}}
-\def\mkshowusedsetups {\bgroup\enableXML\ctxlua{document.setups.showused()}\egroup}
-\def\mkshowallsetups {\bgroup\enableXML\ctxlua{document.setups.showall ()}\egroup}
-
-\def\mkshowsetup #1{\bgroup\enableXML\ctxlua{document.setups.show("#1")}\egroup}
-
-\defineXMLenvironmentsave [cd:define] [name=]
- {}
-
-\defineXMLsingular [cd:resolve] [name=]
- {\enableXML\ignorespaces\ctxlua{document.setups.resolve("\XMLop{name}")}}
-
-\endinput
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 2f3ad7e85..795ddb515 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 11/03/10 19:42:18
+-- merge date : 11/12/10 18:22:36
do -- begin closure to overcome local limits and interference
@@ -285,11 +285,6 @@ end
patterns.textline = content
---~ local p = lpeg.splitat("->",false) print(match(p,"oeps->what->more")) -- oeps what more
---~ local p = lpeg.splitat("->",true) print(match(p,"oeps->what->more")) -- oeps what->more
---~ local p = lpeg.splitat("->",false) print(match(p,"oeps")) -- oeps
---~ local p = lpeg.splitat("->",true) print(match(p,"oeps")) -- oeps
-
local splitters_s, splitters_m = { }, { }
local function splitat(separator,single)
@@ -311,6 +306,11 @@ end
lpeg.splitat = splitat
+--~ local p = splitat("->",false) print(match(p,"oeps->what->more")) -- oeps what more
+--~ local p = splitat("->",true) print(match(p,"oeps->what->more")) -- oeps what->more
+--~ local p = splitat("->",false) print(match(p,"oeps")) -- oeps
+--~ local p = splitat("->",true) print(match(p,"oeps")) -- oeps
+
local cache = { }
function lpeg.split(separator,str)
@@ -2089,6 +2089,13 @@ end
--~ end
--~ end
+-- for myself:
+
+function file.strip(name,dir)
+ local b, a = match(name,"^(.-)" .. dir .. "(.*)$")
+ return a ~= "" and a or name
+end
+
end -- closure
do -- begin closure to overcome local limits and interference
@@ -2699,10 +2706,6 @@ local new_node = node.new
local glyph_code = nodecodes.glyph
--- fonts
-
-local fontdata = fonts.ids or { }
-
function nodes.simple_font_handler(head)
-- lang.hyphenate(head)
head = nodes.handlers.characters(head)
@@ -2718,7 +2721,7 @@ if tex.attribute[0] ~= 0 then
texio.write_nl("log","!")
texio.write_nl("log","! Attribute 0 is reserved for ConTeXt's font feature management and has to be")
texio.write_nl("log","! set to zero. Also, some attributes in the range 1-255 are used for special")
- texio.write_nl("log","! purposed so setting them at the TeX end might break the font handler.")
+ texio.write_nl("log","! purposes so setting them at the TeX end might break the font handler.")
texio.write_nl("log","!")
tex.attribute[0] = 0 -- else no features
@@ -2729,36 +2732,41 @@ nodes.handlers.protectglyphs = node.protect_glyphs
nodes.handlers.unprotectglyphs = node.unprotect_glyphs
function nodes.handlers.characters(head)
- local usedfonts, done, prevfont = { }, false, nil
- for n in traverse_id(glyph_code,head) do
- local font = n.font
- if font ~= prevfont then
- prevfont = font
- local used = usedfonts[font]
- if not used then
- local tfmdata = fontdata[font]
- if tfmdata then
- local shared = tfmdata.shared -- we need to check shared, only when same features
- if shared then
- local processors = shared.processes
- if processors and #processors > 0 then
- usedfonts[font] = processors
- done = true
+ local fontdata = fonts.identifiers
+ if fontdata then
+ local usedfonts, done, prevfont = { }, false, nil
+ for n in traverse_id(glyph_code,head) do
+ local font = n.font
+ if font ~= prevfont then
+ prevfont = font
+ local used = usedfonts[font]
+ if not used then
+ local tfmdata = fontdata[font] --
+ if tfmdata then
+ local shared = tfmdata.shared -- we need to check shared, only when same features
+ if shared then
+ local processors = shared.processes
+ if processors and #processors > 0 then
+ usedfonts[font] = processors
+ done = true
+ end
end
end
end
end
end
- end
- if done then
- for font, processors in next, usedfonts do
- for i=1,#processors do
- local h, d = processors[i](head,font,0)
- head, done = h or head, done or d
+ if done then
+ for font, processors in next, usedfonts do
+ for i=1,#processors do
+ local h, d = processors[i](head,font,0)
+ head, done = h or head, done or d
+ end
end
end
+ return head, true
+ else
+ return head, false
end
- return head, true
end
-- helper
@@ -2820,7 +2828,7 @@ if not modules then modules = { } end modules ['node-inj'] = {
license = "see context related readme files"
}
--- tricky ... fonts.ids is not yet defined .. to be solved (maybe general tex ini)
+-- tricky ... fonts.identifiers is not yet defined .. to be solved (maybe general tex ini)
-- This is very experimental (this will change when we have luatex > .50 and
-- a few pending thingies are available. Also, Idris needs to make a few more
@@ -2835,18 +2843,18 @@ local report_injections = logs.new("injections")
local attributes, nodes, node = attributes, nodes, node
-fonts = fonts or { }
-fonts.tfm = fonts.tfm or { }
-fonts.ids = fonts.ids or { }
+fonts = fonts or { }
+fonts.tfm = fonts.tfm or { }
+fonts.identifiers = fonts.identifiers or { }
-nodes.injections = nodes.injections or { }
-local injections = nodes.injections
+nodes.injections = nodes.injections or { }
+local injections = nodes.injections
-local fontdata = fonts.ids
-local nodecodes = nodes.nodecodes
-local glyph_code = nodecodes.glyph
-local nodepool = nodes.pool
-local newkern = nodepool.kern
+local fontdata = fonts.identifiers
+local nodecodes = nodes.nodecodes
+local glyph_code = nodecodes.glyph
+local nodepool = nodes.pool
+local newkern = nodepool.kern
local traverse_id = node.traverse_id
local unset_attribute = node.unset_attribute
@@ -3293,14 +3301,18 @@ fontloader.totable = fontloader.to_table
fonts = fonts or { }
--- we will also have des and fam hashes
+-- beware, some already defined
--- beware, soem alreadyu defined
+fonts.identifiers = mark(fonts.identifiers or { }) -- fontdata
+-----.characters = mark(fonts.characters or { }) -- chardata
+-----.csnames = mark(fonts.csnames or { }) -- namedata
+-----.quads = mark(fonts.quads or { }) -- quaddata
-fonts.ids = mark(fonts.ids or { }) fonts.identifiers = fonts.ids -- aka fontdata
-fonts.chr = mark(fonts.chr or { }) fonts.characters = fonts.chr -- aka chardata
-fonts.qua = mark(fonts.qua or { }) fonts.quads = fonts.qua -- aka quaddata
-fonts.css = mark(fonts.css or { }) fonts.csnames = fonts.css -- aka namedata
+--~ fonts.identifiers[0] = { -- nullfont
+--~ characters = { },
+--~ descriptions = { },
+--~ name = "nullfont",
+--~ }
fonts.tfm = fonts.tfm or { }
fonts.vf = fonts.vf or { }
@@ -3309,15 +3321,7 @@ fonts.pfb = fonts.pfb or { }
fonts.otf = fonts.otf or { }
fonts.privateoffset = 0xF0000 -- 0x10FFFF
-fonts.verbose = false -- more verbose cache tables
-
-fonts.ids[0] = { -- nullfont
- characters = { },
- descriptions = { },
- name = "nullfont",
-}
-
-fonts.chr[0] = { }
+fonts.verbose = false -- more verbose cache tables (will move to context namespace)
fonts.methods = fonts.methods or {
base = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } },
@@ -3426,7 +3430,7 @@ fonts.initializers.common = fonts.initializers.common or { }
local set_attribute = node.set_attribute
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local nodecodes = nodes.nodecodes
local disc_code = nodecodes.disc
@@ -3692,7 +3696,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
end
-- status
local isvirtual = tfmtable.type == "virtual" or tfmtable.virtualized
- local hasmath = (tfmtable.math_parameters ~= nil and next(tfmtable.math_parameters) ~= nil) or (tfmtable.MathConstants ~= nil and next(tfmtable.MathConstants) ~= nil)
+ local hasmath = (tfmtable.mathparameters ~= nil and next(tfmtable.mathparameters) ~= nil) or (tfmtable.MathConstants ~= nil and next(tfmtable.MathConstants) ~= nil)
local nodemode = tfmtable.mode == "node"
local hasquality = tfmtable.auto_expand or tfmtable.auto_protrude
local hasitalic = tfmtable.has_italic
@@ -3718,7 +3722,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
t.fonts = table.fastcopy(tfmtable.fonts) -- hm also at the end
end
local tp = t.parameters
- local mp = t.math_parameters
+ local mp = t.mathparameters
local tfmp = tfmtable.parameters -- let's check for indexes
--
tp.slant = (tfmp.slant or tfmp[1] or 0)
@@ -5602,7 +5606,7 @@ fonts.otf = fonts.otf or { }
local otf = fonts.otf
local tfm = fonts.tfm
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local chardata = characters and characters.data -- not used
otf.features = otf.features or { }
@@ -6952,7 +6956,7 @@ actions["check metadata"] = function(data,filename,raw)
data.map = nil
end
-local private_math_parameters = {
+local private_mathparameters = {
"FractionDelimiterSize",
"FractionDelimiterDisplayStyleSize",
}
@@ -6960,8 +6964,8 @@ local private_math_parameters = {
actions["check math parameters"] = function(data,filename,raw)
local mathdata = data.metadata.math
if mathdata then
- for m=1,#private_math_parameters do
- local pmp = private_math_parameters[m]
+ for m=1,#private_mathparameters do
+ local pmp = private_mathparameters[m]
if not mathdata[pmp] then
if trace_loading then
report_otf("setting math parameter '%s' to 0", pmp)
@@ -7174,7 +7178,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
local unicodes = luatex.unicodes -- names to unicodes
local indices = luatex.indices
local mode = data.mode or "base"
- local characters, parameters, math_parameters, descriptions = { }, { }, { }, { }
+ local characters, parameters, mathparameters, descriptions = { }, { }, { }, { }
local designsize = metadata.designsize or metadata.design_size or 100
if designsize == 0 then
designsize = 100
@@ -7189,7 +7193,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
if metadata.math then
-- parameters
for name, value in next, metadata.math do
- math_parameters[name] = value
+ mathparameters[name] = value
end
-- we could use a subset
for u, char in next, characters do
@@ -7304,7 +7308,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
return {
characters = characters,
parameters = parameters,
- math_parameters = math_parameters,
+ mathparameters = mathparameters,
descriptions = descriptions,
indices = indices,
unicodes = unicodes,
@@ -7487,7 +7491,7 @@ local report_otf = logs.new("load otf")
local fonts = fonts
local otf = fonts.otf
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
otf.features = otf.features or { }
otf.features.default = otf.features.default or { }
@@ -8238,7 +8242,7 @@ local markonce = true
local cursonce = true
local kernonce = true
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
otf.features.process = { }
@@ -10784,7 +10788,7 @@ local has_attribute = node.has_attribute
local traverse_id = node.traverse_id
local traverse_node_list = node.traverse
-local fontdata = fonts.ids
+local fontdata = fonts.identifiers
local state = attributes.private('state')
local categories = characters and characters.categories or { } -- sorry, only in context
@@ -14983,7 +14987,8 @@ if not modules then modules = { } end modules ['font-def'] = {
license = "see context related readme files"
}
-local format, concat, gmatch, match, find, lower = string.format, table.concat, string.gmatch, string.match, string.find, string.lower
+local concat = table.concat
+local format, gmatch, match, find, lower, gsub = string.format, string.gmatch, string.match, string.find, string.lower, string.gsub
local tostring, next = tostring, next
local lpegmatch = lpeg.match
@@ -15006,13 +15011,11 @@ default loader that only handles <l n='tfm'/>.</p>
local fonts = fonts
local tfm = fonts.tfm
local vf = fonts.vf
-local fontcsnames = fonts.csnames
fonts.used = allocate()
tfm.readers = tfm.readers or { }
tfm.fonts = allocate()
-tfm.internalized = allocate() -- internal tex numbers
local readers = tfm.readers
local sequence = allocate { 'otf', 'ttf', 'afm', 'tfm' }
@@ -15102,9 +15105,12 @@ end
definers.getspecification = getspecification
-function definers.registersplit(symbol,action)
+function definers.registersplit(symbol,action,verbosename)
addspecifier(symbol)
variants[symbol] = action
+ if verbosename then
+ variants[verbosename] = action
+ end
end
function definers.makespecification(specification, lookup, name, sub, method, detail, size)
@@ -15315,7 +15321,8 @@ function tfm.read(specification)
if not tfmtable then
local forced = specification.forced or ""
if forced ~= "" then
- tfmtable = readers[lower(forced)](specification)
+ local reader = readers[lower(forced)]
+ tfmtable = reader and reader(specification)
if not tfmtable then
report_define("forced type %s of %s not found",forced,specification.name)
end
@@ -15368,17 +15375,17 @@ function tfm.readanddefine(name,size) -- no id
local hash = tfm.hashinstance(specification)
local id = definers.registered(hash)
if not id then
- local fontdata = tfm.read(specification)
- if fontdata then
- fontdata.hash = hash
- id = font.define(fontdata)
- definers.register(fontdata,id)
- tfm.cleanuptable(fontdata)
+ local tfmdata = tfm.read(specification)
+ if tfmdata then
+ tfmdata.hash = hash
+ id = font.define(tfmdata)
+ definers.register(tfmdata,id)
+ tfm.cleanuptable(tfmdata)
else
id = 0 -- signal
end
end
- return fonts.ids[id], id
+ return fonts.identifiers[id], id
end
--[[ldx--
@@ -15466,6 +15473,16 @@ function readers.afm(specification,method)
return tfmtable
end
+function readers.pfb(specification,method) -- only called when forced
+ local original = specification.specification
+ if trace_loading then
+ report_afm("using afm reader for '%s'",original)
+ end
+ specification.specification = gsub(original,"%.pfb",".afm")
+ specification.forced = "afm"
+ return readers.afm(specification,method)
+end
+
-- maybe some day a set of names
local function check_otf(forced,specification,suffix,what)
@@ -15545,31 +15562,29 @@ not gain much. By the way, passing id's back to in the callback was
introduced later in the development.</p>
--ldx]]--
-local lastdefined = nil -- we don't want this one to end up in s-tra-02
+local lastdefined = nil -- we don't want this one to end up in s-tra-02
+local internalized = { }
function definers.current() -- or maybe current
return lastdefined
end
-function definers.register(fontdata,id)
- if fontdata and id then
- local hash = fontdata.hash
- if not tfm.internalized[hash] then
+function definers.register(tfmdata,id) -- will be overloaded
+ if tfmdata and id then
+ local hash = tfmdata.hash
+ if not internalized[hash] then
if trace_defining then
- report_define("loading at 2 id %s, hash: %s",id or "?",hash or "?")
+ report_define("registering font, id: %s, hash: %s",id or "?",hash or "?")
end
- fonts.identifiers[id] = fontdata
- fonts.characters [id] = fontdata.characters
- fonts.quads [id] = fontdata.parameters and fontdata.parameters.quad
- -- todo: extra functions, e.g. setdigitwidth etc in list
- tfm.internalized[hash] = id
+ fonts.identifiers[id] = tfmdata
+ internalized[hash] = id
end
end
end
-function definers.registered(hash)
- local id = tfm.internalized[hash]
- return id, id and fonts.ids[id]
+function definers.registered(hash) -- will be overloaded
+ local id = internalized[hash]
+ return id, id and fonts.identifiers[id]
end
local cache_them = false
@@ -15602,49 +15617,45 @@ function definers.read(specification,size,id) -- id can be optional, name can al
specification = definers.resolve(specification)
local hash = tfm.hashinstance(specification)
if cache_them then
- local fontdata = containers.read(fonts.cache,hash) -- for tracing purposes
+ local tfmdata = containers.read(fonts.cache,hash) -- for tracing purposes
end
- local fontdata = definers.registered(hash) -- id
- if not fontdata then
+ local tfmdata = definers.registered(hash) -- id
+ if not tfmdata then
if specification.features.vtf and specification.features.vtf.preset then
- fontdata = tfm.make(specification)
+ tfmdata = tfm.make(specification)
else
- fontdata = tfm.read(specification)
- if fontdata then
- tfm.checkvirtualid(fontdata)
+ tfmdata = tfm.read(specification)
+ if tfmdata then
+ tfm.checkvirtualid(tfmdata)
end
end
if cache_them then
- fontdata = containers.write(fonts.cache,hash,fontdata) -- for tracing purposes
+ tfmdata = containers.write(fonts.cache,hash,tfmdata) -- for tracing purposes
end
- if fontdata then
- fontdata.hash = hash
- fontdata.cache = "no"
+ if tfmdata then
+ tfmdata.hash = hash
+ tfmdata.cache = "no"
if id then
- definers.register(fontdata,id)
+ definers.register(tfmdata,id)
end
end
end
- lastdefined = fontdata or id -- todo ! ! ! ! !
- if not fontdata then -- or id?
+ lastdefined = tfmdata or id -- todo ! ! ! ! !
+ if not tfmdata then -- or id?
report_define( "unknown font %s, loading aborted",specification.name)
- elseif trace_defining and type(fontdata) == "table" then
+ elseif trace_defining and type(tfmdata) == "table" then
report_define("using %s font with id %s, name:%s size:%s bytes:%s encoding:%s fullname:%s filename:%s",
- fontdata.type or "unknown",
- id or "?",
- fontdata.name or "?",
- fontdata.size or "default",
- fontdata.encodingbytes or "?",
- fontdata.encodingname or "unicode",
- fontdata.fullname or "?",
- file.basename(fontdata.filename or "?"))
- end
- local cs = specification.cs
- if cs then
- fontcsnames[cs] = fontdata -- new (beware: locals can be forgotten)
+ tfmdata.type or "unknown",
+ id or "?",
+ tfmdata.name or "?",
+ tfmdata.size or "default",
+ tfmdata.encodingbytes or "?",
+ tfmdata.encodingname or "unicode",
+ tfmdata.fullname or "?",
+ file.basename(tfmdata.filename or "?"))
end
statistics.stoptiming(fonts)
- return fontdata
+ return tfmdata
end
function vf.find(name)
@@ -15675,7 +15686,7 @@ end
--ldx]]--
callbacks.register('define_font' , definers.read, "definition of fonts (tfmtable preparation)")
-callbacks.register('find_vf_file', vf.find , "locating virtual fonts, insofar needed") -- not that relevant any more
+callbacks.register('find_vf_file', vf.find, "locating virtual fonts, insofar needed") -- not that relevant any more
end -- closure
@@ -15780,7 +15791,7 @@ local function colonized(specification) -- xetex mode
return specification
end
-definers.registersplit(":",colonized)
+definers.registersplit(":",colonized,"cryptic")
end -- closure
@@ -16063,7 +16074,7 @@ end
-- bonus
function fonts.otf.nametoslot(name)
- local tfmdata = fonts.ids[font.current()]
+ local tfmdata = fonts.identifiers[font.current()]
if tfmdata and tfmdata.shared then
local otfdata = tfmdata.shared.otfdata
local unicode = otfdata.luatex.unicodes[name]
diff --git a/tex/generic/context/luatex-fonts.lua b/tex/generic/context/luatex-fonts.lua
index 4cfe8b945..5fffecb47 100644
--- a/tex/generic/context/luatex-fonts.lua
+++ b/tex/generic/context/luatex-fonts.lua
@@ -51,21 +51,18 @@ loadmodule('luatex-fonts-merged.lua',true) -- you might comment this line
if fonts then
- -- We're using the merged version. That one could be outdated so
- -- remove it from your system when you want to use the files from
- -- from the ConTeXt tree, or keep your copy of the merged version
- -- up to date.
-
- texio.write_nl("log",[[
-
-I am using the merged version of 'luatex-fonts.lua' here. If
-you run into problems or experience unexpected behaviour, and
-if you have ConTeXt installed you can try to delete the file
-'luatex-font-merged.lua' as I might then use the possibly
-updated libraries. The merged version is not supported as it
-is a frozen instance.
+ if not fonts._merge_loaded_message_done_ then
+ texio.write_nl("log", "!")
+ texio.write_nl("log", "! I am using the merged version of 'luatex-fonts.lua' here. If")
+ texio.write_nl("log", "! you run into problems or experience unexpected behaviour, and")
+ texio.write_nl("log", "! if you have ConTeXt installed you can try to delete the file")
+ texio.write_nl("log", "! 'luatex-font-merged.lua' as I might then use the possibly")
+ texio.write_nl("log", "! updated libraries. The merged version is not supported as it")
+ texio.write_nl("log", "! is a frozen instance.")
+ texio.write_nl("log", "!")
+ end
- ]])
+ fonts._merge_loaded_message_done_ = true
else
@@ -93,7 +90,9 @@ else
-- We do need some basic node support although the following
-- modules contain a little bit of code that is not used. It's
- -- not worth weeding.
+ -- not worth weeding. Beware, in node-dum some functions use
+ -- fonts.* tables, not that nice but I don't want two dummy
+ -- files. Some day I will sort this out (no problem in context).
loadmodule('node-dum.lua')
loadmodule('node-inj.lua') -- will be replaced (luatex >= .70)