summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/anch-bck.mkvi26
-rw-r--r--tex/context/base/anch-pgr.mkiv5
-rw-r--r--tex/context/base/anch-pos.lua811
-rw-r--r--tex/context/base/anch-pos.mkiv147
-rw-r--r--tex/context/base/anch-snc.mkiv20
-rw-r--r--tex/context/base/buff-imp-mp.lua22
-rw-r--r--tex/context/base/buff-par.mkiv2
-rw-r--r--tex/context/base/char-def.lua2
-rw-r--r--tex/context/base/colo-grp.mkiv2
-rw-r--r--tex/context/base/cont-fil.mkiv1
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv11
-rw-r--r--tex/context/base/context-version.pdfbin4073 -> 4064 bytes
-rw-r--r--tex/context/base/context-version.pngbin104962 -> 104373 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv17
-rw-r--r--tex/context/base/core-env.mkiv16
-rw-r--r--tex/context/base/core-ini.mkiv89
-rw-r--r--tex/context/base/core-uti.lua2
-rw-r--r--tex/context/base/data-tex.lua22
-rw-r--r--tex/context/base/font-con.lua16
-rw-r--r--tex/context/base/font-ctx.lua170
-rw-r--r--tex/context/base/font-def.lua11
-rw-r--r--tex/context/base/font-gds.lua33
-rw-r--r--tex/context/base/font-ini.mkvi2
-rw-r--r--tex/context/base/font-set.mkvi8
-rw-r--r--tex/context/base/java-imp-rhh.mkiv34
-rw-r--r--tex/context/base/java-ini.lua4
-rw-r--r--tex/context/base/lpdf-ano.lua4
-rw-r--r--tex/context/base/lpdf-fld.lua286
-rw-r--r--tex/context/base/m-visual.mkii (renamed from tex/context/base/m-visual.tex)1
-rw-r--r--tex/context/base/m-visual.mkiv252
-rw-r--r--tex/context/base/math-act.lua94
-rw-r--r--tex/context/base/math-def.mkiv2
-rw-r--r--tex/context/base/math-ini.lua31
-rw-r--r--tex/context/base/math-ini.mkiv35
-rw-r--r--tex/context/base/math-noa.lua12
-rw-r--r--tex/context/base/meta-pag.mkiv77
-rw-r--r--tex/context/base/mlib-pdf.lua8
-rw-r--r--tex/context/base/mlib-pps.lua29
-rw-r--r--tex/context/base/mult-aux.mkiv25
-rw-r--r--tex/context/base/mult-de.mkii3
-rw-r--r--tex/context/base/mult-def.lua20
-rw-r--r--tex/context/base/mult-en.mkii3
-rw-r--r--tex/context/base/mult-fr.mkii3
-rw-r--r--tex/context/base/mult-it.mkii3
-rw-r--r--tex/context/base/mult-low.lua18
-rw-r--r--tex/context/base/mult-nl.mkii5
-rw-r--r--tex/context/base/mult-pe.mkii3
-rw-r--r--tex/context/base/mult-ro.mkii3
-rw-r--r--tex/context/base/mult-sys.mkiv3
-rw-r--r--tex/context/base/node-aux.lua2
-rw-r--r--tex/context/base/node-ref.lua13
-rw-r--r--tex/context/base/node-tsk.lua82
-rw-r--r--tex/context/base/pack-lyr.mkiv2
-rw-r--r--tex/context/base/pack-rul.mkiv105
-rw-r--r--tex/context/base/page-brk.mkiv20
-rw-r--r--tex/context/base/page-flt.mkiv7
-rw-r--r--tex/context/base/page-ini.mkiv369
-rw-r--r--tex/context/base/page-lay.mkiv20
-rw-r--r--tex/context/base/page-mis.mkiv2
-rw-r--r--tex/context/base/page-mul.mkiv723
-rw-r--r--tex/context/base/page-not.mkiv8
-rw-r--r--tex/context/base/page-one.mkiv386
-rw-r--r--tex/context/base/page-otr.mkvi288
-rw-r--r--tex/context/base/page-plg.mkiv27
-rw-r--r--tex/context/base/page-set.mkiv207
-rw-r--r--tex/context/base/page-sid.mkiv58
-rw-r--r--tex/context/base/page-spr.mkiv2
-rw-r--r--tex/context/base/page-str.mkiv2
-rw-r--r--tex/context/base/page-txt.mkvi20
-rw-r--r--tex/context/base/scrn-fld.mkvi12
-rw-r--r--tex/context/base/scrn-ini.mkvi28
-rw-r--r--tex/context/base/scrn-wid.lua4
-rw-r--r--tex/context/base/scrn-wid.mkvi8
-rw-r--r--tex/context/base/spac-ver.lua2
-rw-r--r--tex/context/base/spac-ver.mkiv45
-rw-r--r--tex/context/base/status-files.pdfbin24217 -> 24294 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin166315 -> 171613 bytes
-rw-r--r--tex/context/base/status-mkiv.lua28
-rw-r--r--tex/context/base/strc-con.lua (renamed from tex/context/base/strc-des.lua)4
-rw-r--r--tex/context/base/strc-con.mkvi886
-rw-r--r--tex/context/base/strc-des.mkiv1175
-rw-r--r--tex/context/base/strc-des.mkvi196
-rw-r--r--tex/context/base/strc-enu.mkvi371
-rw-r--r--tex/context/base/strc-flt.mkvi587
-rw-r--r--tex/context/base/strc-ind.mkiv123
-rw-r--r--tex/context/base/strc-lab.mkiv96
-rw-r--r--tex/context/base/strc-lnt.mkvi (renamed from tex/context/base/strc-lnt.mkiv)5
-rw-r--r--tex/context/base/strc-lst.lua93
-rw-r--r--tex/context/base/strc-lst.mkvi53
-rw-r--r--tex/context/base/strc-mar.lua6
-rw-r--r--tex/context/base/strc-not.lua116
-rw-r--r--tex/context/base/strc-not.mkiv1423
-rw-r--r--tex/context/base/strc-not.mkvi1660
-rw-r--r--tex/context/base/strc-ref.lua21
-rw-r--r--tex/context/base/strc-ref.mkvi2
-rw-r--r--tex/context/base/strc-sec.mkiv2
-rw-r--r--tex/context/base/strc-tag.mkiv307
-rw-r--r--tex/context/base/supp-box.mkiv33
-rw-r--r--tex/context/base/syst-pln.mkiv2
-rw-r--r--tex/context/base/tabl-tbl.mkiv17
-rw-r--r--tex/context/base/tabl-xtb.lua23
-rw-r--r--tex/context/base/tabl-xtb.mkvi2
-rw-r--r--tex/context/base/type-imp-buy.mkiv37
-rw-r--r--tex/context/base/type-imp-cow.mkiv (renamed from tex/context/base/type-cow.mkiv)0
-rw-r--r--tex/context/base/type-imp-ghz.mkiv (renamed from tex/context/base/type-ghz.mkiv)0
-rw-r--r--tex/context/base/type-imp-hgz.mkiv (renamed from tex/context/base/type-hgz.mkiv)0
-rw-r--r--tex/context/base/type-imp-informal.mkiv (renamed from tex/context/base/type-buy.mkiv)34
-rw-r--r--tex/context/base/type-imp-latinmodern.mkiv88
-rw-r--r--tex/context/base/type-imp-lmnames.mkiv5
-rw-r--r--tex/context/base/type-imp-osx.mkiv (renamed from tex/context/base/type-mac.mkiv)26
-rw-r--r--tex/context/base/type-ini.mkvi6
-rw-r--r--tex/context/base/type-msw.mkiv1
-rw-r--r--tex/context/base/type-set.mkiv11
-rw-r--r--tex/context/base/type-win.mkiv118
-rw-r--r--tex/context/base/typo-mar.lua101
-rw-r--r--tex/context/base/typo-mar.mkiv12
-rw-r--r--tex/context/base/util-seq.lua112
-rw-r--r--tex/context/fonts/lm.lfg7
-rw-r--r--tex/context/interface/cont-nl.xml6
-rw-r--r--tex/context/interface/keys-cs.xml3
-rw-r--r--tex/context/interface/keys-de.xml3
-rw-r--r--tex/context/interface/keys-en.xml3
-rw-r--r--tex/context/interface/keys-fr.xml3
-rw-r--r--tex/context/interface/keys-it.xml3
-rw-r--r--tex/context/interface/keys-nl.xml5
-rw-r--r--tex/context/interface/keys-pe.xml3
-rw-r--r--tex/context/interface/keys-ro.xml3
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua29
130 files changed, 7529 insertions, 5160 deletions
diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi
index a20a25468..7dd190657 100644
--- a/tex/context/base/anch-bck.mkvi
+++ b/tex/context/base/anch-bck.mkvi
@@ -81,8 +81,6 @@
\def\MPeself {e:\MPvar{self}}
\def\MPwself {w:\MPvar{self}}
\def\MPparanchor {p:\number\MPparcounter}
-\def\MPl #tag{\MPplus{#tag}20} % slot 2 default 0
-\def\MPr #tag{\MPplus{#tag}30} % slot 3 default 0
\def\textbackgroundoverlay#tag{\iflocalpositioning\v!local\else\v!text\fi#tag}
\def\MPanchornumber {\iflocalpositioning\the\localpositionnumber\else\the\realpageno\fi}
@@ -359,7 +357,7 @@
\ifx#par\relax
\makeupwidth % \textwidth
\else
- \MPw\MPparanchor-\MPl\MPparanchor-\MPr\MPparanchor
+ \MPw\MPparanchor-\MPleftskip\MPparanchor-\MPrightskip\MPparanchor
\fi
\fi
\relax}
@@ -500,7 +498,7 @@
\stopuseMPgraphic
\startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete
- \MPparcounter\MPv\MPbself{1}\zerocount\relax
+ \MPparcounter\MPn\MPbself\relax
\directsetup{mpos:par:variant:\doifpositionelse\MPwself{w}{b}}
\MPpositiongraphic{mpos:par}{}%
\stopMPpositionmethod
@@ -517,7 +515,7 @@
\startsetups mpos:par:variant:b
\startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius}
- initialize_par(\MPpos\MPbself,\MPpos\MPeself,\MPpos\textanchor,\MPpos\MPparanchor,\MPvv\MPparanchor{0pt,0pt,0pt,0pt,0,0pt}) ;
+ initialize_par(\MPpos\MPbself,\MPpos\MPeself,\MPpos\textanchor,\MPpos\MPparanchor,\MPpardata\MPparanchor) ;
\includeMPgraphic{mpos:par:setup} ;
\includeMPgraphic{mpos:par:extra} ;
\includeMPgraphic{\MPvar{mp}} ;
@@ -544,12 +542,23 @@
endgroup ;
\stopuseMPgraphic
+% we can flush 5 in one call (saved 4 lua calls) .. brrr wself .. will change
+
+% \def\MPposset#1{\ctxcommand{MPposset("#1")}}
+
\startMPpositionmethod{mpos:par:columnset}
- \MPparcounter\MPv\MPbself{1}\zerocount\relax
+ \MPparcounter\MPn\MPbself\relax
+\def\regionanchor{\MPr\MPbself}%
+\ifx\regionanchor\empty
+ \regionpositioningfalse
+\else
+ \regionpositioningtrue
+\fi
\startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius}
\includeMPgraphic{mpos:par:setup} ;
\includeMPgraphic{mpos:par:extra} ;
- prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself,\MPpos\MPparanchor,\MPvv\MPparanchor{0pt,0pt,0pt,0pt,0,0pt}) ;
+ prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself,\MPpos\MPparanchor,\MPpardata\MPparanchor) ;
+ % prepare_multi_pars(\MPposset{\MPvar{self}}) ;
relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos
\includeMPgraphic{\MPvar{mp}} ;
\stopMPpositiongraphic
@@ -566,7 +575,8 @@
%D We need to treat floats in a special way.
\startMPinitializations
- local_multi_par_area:=\iflocalpositioning true\else false\fi;
+ local_multi_par_area:=\iflocalpositioning true\else false\fi;
+ use_multi_par_region:=\ifregionpositioning true\else false\fi;
\stopMPinitializations
%D As an example we define a grid background:
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 8c47581f3..8b586c5b2 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -121,8 +121,9 @@
%D The next macros do some housekeeping.
-\def\pageanchor{page:0} % for the moment only one pagesize
-\def\textanchor{text:\the\realpageno}
+\def\pageanchor {page:0} % for the moment only one pagesize
+\def\textanchor {text:\the\realpageno}
+\def\regionanchor{region:0} % placeholder
%D The first version of this module implemented head and tail
%D anchors. Currently we stick to just one anchor and derive
diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua
index bd766fa2b..60fc985a2 100644
--- a/tex/context/base/anch-pos.lua
+++ b/tex/context/base/anch-pos.lua
@@ -12,17 +12,30 @@ can we store much more information in <l n='lua'/> but it's also
more efficient.</p>
--ldx]]--
--- to be considered: store as numbers instead of string
+-- plus (extra) is obsolete but we will keep it for a while
+
-- maybe replace texsp by our own converter (stay at the lua end)
-- eventually mp will have large numbers so we can use sp there too
local tostring = tostring
-local concat, format, gmatch = table.concat, string.format, string.gmatch
+local concat, format, gmatch, match = table.concat, string.format, string.gmatch, string.match
+local rawget = rawget
local lpegmatch = lpeg.match
+local insert, remove = table.insert, table.remove
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
-local texsp, texcount = tex.sp, tex.count
+local texsp, texcount, texbox, texdimen, texsetcount = tex.sp, tex.count, tex.box, tex.dimen, tex.setcount
----- texsp = string.todimen -- because we cache this is much faster but no rounding
+local setmetatableindex = table.setmetatableindex
+
+local variables = interfaces.variables
+
+local v_text = variables.text
+local v_column = variables.column
+
+local new_latelua = nodes.pool.latelua
+local find_tail = node.slide
+
local pt = number.dimenfactors.pt
local pts = number.pts
@@ -45,176 +58,573 @@ end
job.register('job.positions.collected', tobesaved, initializer)
-function jobpositions.setraw(name,val)
- tobesaved[name] = val
+local regions = { }
+local nofregions = 0
+local region = nil
+local nofcolumns = 0
+local column = nil
+local nofpages = nil
+
+-- beware ... we're not sparse here as lua will reserve slots for the nilled
+
+local function setdim(name,w,h,d,extra) -- will be used when we move to sp allover
+ local x = pdf.h
+ local y = pdf.v
+ if x == 0 then x = nil end
+ if y == 0 then y = nil end
+ if w == 0 then w = nil end
+ if h == 0 then h = nil end
+ if d == 0 then d = nil end
+ if extra == "" then extra = nil end
+ -- todo: sparse
+ tobesaved[name] = {
+ p = texcount.realpageno,
+ x = x,
+ y = y,
+ w = w,
+ h = h,
+ d = d,
+ e = extra,
+ r = region,
+ c = column,
+ }
+end
+
+local function setall(name,p,x,y,w,h,d,extra)
+ if x == 0 then x = nil end
+ if y == 0 then y = nil end
+ if w == 0 then w = nil end
+ if h == 0 then h = nil end
+ if d == 0 then d = nil end
+ if extra == "" then extra = nil end
+ -- todo: sparse
+ tobesaved[name] = {
+ p = p,
+ x = x,
+ y = y,
+ w = w,
+ h = h,
+ d = d,
+ e = extra,
+ r = region,
+ c = column,
+ }
+end
+
+local function enhance(data)
+ if not data then
+ return nil
+ end
+ if data.r == true then -- or ""
+ data.r = region
+ end
+ if data.x == true then
+ data.x = pdf.h
+ end
+ if data.y == true then
+ data.y = pdf.v
+ end
+ if data.p == true then -- or 0
+ data.p = texcount.realpageno
+ end
+ if data.c == true then -- or 0
+ data.c = column
+ end
+ if data.w == 0 then
+ data.w = nil
+ end
+ if data.h == 0 then
+ data.h = nil
+ end
+ if data.d == 0 then
+ data.d = nil
+ end
+ return data
+end
+
+local function set(name,index,val)
+ local data = enhance(val or index)
+ if val then
+ container = tobesaved[name]
+ if not container then
+ tobesaved[name] = {
+ [index] = data
+ }
+ else
+ container[index] = data
+ end
+ else
+ tobesaved[name] = data
+ end
end
-function jobpositions.setdim(name,wd,ht,dp,plus) -- will be used when we move to sp allover
- if plus then
- tobesaved[name] = { texcount.realpageno, pdf.h, pdf.v, wd, ht, dp, plus }
- elseif wd then
- tobesaved[name] = { texcount.realpageno, pdf.h, pdf.v, wd, ht, dp }
+local function get(id,index)
+ if index then
+ local container = collected[id]
+ return container and container[index]
else
- tobesaved[name] = { texcount.realpageno, pdf.h, pdf.v }
+ return collected[id]
end
end
-function jobpositions.setall(name,p,x,y,wd,ht,dp,plus) -- will be used when we move to sp allover
- if plus then
- tobesaved[name] = { p, x, y, wd, ht, dp, plus }
- elseif wd then
- tobesaved[name] = { p, x, y, wd, ht, dp }
+jobpositions.setdim = setdim
+jobpositions.setall = setall
+jobpositions.set = set
+jobpositions.get = get
+
+-- function jobpositions.pushregion(tag,w,h,d)
+-- if w then
+-- setdim(tag,w,h,d)
+-- end
+-- insert(regions,tag)
+-- region = tag
+-- end
+
+-- function jobpositions.popregion()
+-- remove(regions)
+-- region = regions[#regions]
+-- end
+
+-- function jobpositions.markregionbox(n,tag)
+-- if not tag or tag == "" then
+-- nofregions = nofregions + 1
+-- tag = nofregions
+-- end
+-- local box = texbox[n]
+-- local push = new_latelua(format("_plib_.pushregion(%q,%s,%s,%s)",tag,box.width,box.height,box.depth))
+-- local pop = new_latelua("_plib_.popregion()")
+-- local head = box.list
+-- local tail = find_tail(head)
+-- head.prev = push
+-- push.next = head
+-- pop .prev = tail
+-- tail.next = pop
+-- box.list = push
+-- end
+
+function jobpositions.b_region(tag)
+ local last = tobesaved[tag]
+ last.x = pdf.h
+ last.p = texcount.realpageno
+ insert(regions,tag)
+ region = tag
+end
+
+function jobpositions.e_region()
+ remove(regions)
+ tobesaved[region].y = pdf.v
+ region = regions[#regions]
+end
+
+function jobpositions.markregionbox(n,tag)
+ if not tag or tag == "" then
+ nofregions = nofregions + 1
+ tag = format("region:%s",nofregions)
+ end
+ local box = texbox[n]
+ tobesaved[tag] = {
+ p = true,
+ x = true,
+ y = true,
+ w = box.width,
+ h = box.height,
+ d = box.depth,
+ }
+ local push = new_latelua(format("_plib_.b_region(%q)",tag))
+ local pop = new_latelua("_plib_.e_region()")
+ local head = box.list
+ local tail = find_tail(head)
+ head.prev = push
+ push.next = head
+ pop .prev = tail
+ tail.next = pop
+ box.list = push
+end
+
+-- here the page is part of the column so we can only save when we reassign
+-- the table (column:* => column:*:*)
+
+function jobpositions.b_column(w,h,d) -- there can be multiple column ranges per page
+ local page = texcount.realpageno -- we could have a nice page synchronizer (saves calls)
+ if page ~= nofpages then
+ nofpages = page
+ nofcolumns = 1
else
- tobesaved[name] = { p, x, y }
+ nofcolumns = nofcolumns + 1
+ end
+ column = nofcolumns
+ if w then
+ set(format("column:%s:%s",page,column), {
+ x = true,
+ y = true,
+ w = w,
+ h = h,
+ d = d,
+ })
end
end
--- _praw_ = jobpositions.setraw
--- _pdim_ = jobpositions.setdim
--- _pall_ = jobpositions.setall
+function jobpositions.e_column()
+ column = nil
+end
+
+function jobpositions.markcolumnbox(n,column)
+ local box = texbox[n]
+ local push = new_latelua(format("_plib_.b_column(%s,%s,%s)",box.width,box.height,box.depth))
+ local pop = new_latelua("_plib_.e_column()")
+ local head = box.list
+ if head then
+ local tail = find_tail(head)
+ head.prev = push
+ push.next = head
+ pop .prev = tail
+ tail.next = pop
+ else -- we can have a simple push/pop
+ push.next = pop
+ pop.prev = push
+ end
+ box.list = push
+end
+
+function jobpositions.enhance(name)
+ enhance(tobesaved[name])
+end
+
+function commands.pos(name,t)
+ tobesaved[name] = t
+ context(new_latelua(format("_plib_.enhance(%q)",name)))
+end
+
+local nofparagraphs = 0
+
+function commands.parpos() -- todo: relate to localpar (so this is an intermediate variant)
+ nofparagraphs = nofparagraphs + 1
+ texsetcount("global","parposcounter",nofparagraphs)
+ local strutbox = texbox.strutbox
+ local t = {
+ p = true,
+ -- c = true,
+ x = true,
+ y = true,
+ h = strutbox.height,
+ d = strutbox.depth,
+ hs = tex.hsize,
+ }
+ local leftskip = tex.leftskip.width
+ local rightskip = tex.rightskip.width
+ local hangindent = tex.hangindent
+ local hangafter = tex.hangafter
+ local parindent = tex.parindent
+ if leftskip ~= 0 then
+ t.ls = leftskip
+ end
+ if rightskip ~= 0 then
+ t.rs = rightskip
+ end
+ if hangindent ~= 0 then
+ t.hi = hangindent
+ end
+ if hangafter ~= 1 and hangafter ~= 0 then -- can not be zero .. so it needs to be 1 if zero
+ t.ha = hangafter
+ end
+ if parindent ~= 0 then
+ t.pi = parindent
+ end
+ local tag = format("p:%s",nofparagraphs)
+ tobesaved[tag] = t
+ context(new_latelua(format("_plib_.enhance(%q)",tag)))
+end
+
+function commands.posxy(name) -- can node.write be used here?
+ tobesaved[name] = {
+ p = true,
+ -- c = true,
+ r = true,
+ x = true,
+ y = true,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ }
+ context(new_latelua(format("_plib_.enhance(%q)",name)))
+end
+
+function commands.poswhd(name,w,h,d)
+ tobesaved[name] = {
+ p = true,
+ -- c = true,
+ r = true,
+ x = true,
+ y = true,
+ w = w,
+ h = h,
+ d = d,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ }
+ context(new_latelua(format("_plib_.enhance(%q)",name)))
+end
+
+function commands.posplus(name,w,h,d,extra)
+ tobesaved[name] = {
+ p = true,
+ -- c = true,
+ r = true,
+ x = true,
+ y = true,
+ w = w,
+ h = h,
+ d = d,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ e = extra,
+ }
+ context(new_latelua(format("_plib_.enhance(%q)",name)))
+end
+
+function commands.posstrut(name,w,h,d)
+ local strutbox = texbox.strutbox
+ tobesaved[name] = {
+ p = true,
+ -- c = true,
+ r = true,
+ x = true,
+ y = true,
+ h = strutbox.height,
+ d = strutbox.depth,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ }
+ context(new_latelua(format("_plib_.enhance(%q)",name)))
+end
+
+function jobpositions.getreserved(tag,n)
+ if tag == v_column then
+ local fulltag = format("%s:%s:%s",tag,texcount.realpageno,n or 1)
+ local data = collected[fulltag]
+ if data then
+ return data, fulltag
+ end
+ tag = v_text
+ end
+ if tag == v_text then
+ local fulltag = format("%s:%s",tag,texcount.realpageno)
+ return collected[fulltag] or false, fulltag
+ end
+ return collected[tag] or false, tag
+end
function jobpositions.copy(target,source)
- collected[target] = collected[source] or tobesaved[source]
+ collected[target] = collected[source]
end
-function jobpositions.replace(name,...)
- collected[name] = {...}
+function jobpositions.replace(id,p,x,y,w,h,d)
+-- local t = collected[id]
+-- if t then
+-- t.p = p or t.p
+-- t.x = x or t.x
+-- t.y = y or t.y
+-- t.w = w or t.w
+-- t.h = h or t.h
+-- t.d = d or t.d
+-- else
+ collected[id] = { p = p, x = x, y = y, w = w, h = h, d = d }
+-- end
end
-function jobpositions.v(id,default)
- return collected[id] or tobesaved[id] or default
+function jobpositions.page(id)
+ local jpi = collected[id]
+ return jpi and jpi.p or 0
end
-function jobpositions.page(id)
- local jpi = collected[id] or tobesaved[id]
- return jpi and jpi[1] or 0
+function jobpositions.region(id)
+ local jpi = collected[id]
+ return jpi and jpi.r or false
+end
+
+function jobpositions.column(id)
+ local jpi = collected[id]
+ return jpi and jpi.c or false
end
+function jobpositions.paragraph(id)
+ local jpi = collected[id]
+ return jpi and jpi.n or 0
+end
+
+jobpositions.p = jobpositions.page
+jobpositions.r = jobpositions.region
+jobpositions.c = jobpositions.column
+jobpositions.n = jobpositions.paragraph
+
function jobpositions.x(id)
- local jpi = collected[id] or tobesaved[id]
- return jpi and jpi[2] or 0
+ local jpi = collected[id]
+ return jpi and jpi.x or 0
end
function jobpositions.y(id)
- local jpi = collected[id] or tobesaved[id]
- return jpi and jpi[3] or 0
+ local jpi = collected[id]
+ return jpi and jpi.y or 0
end
function jobpositions.width(id)
- local jpi = collected[id] or tobesaved[id]
- return jpi and jpi[4] or 0
+ local jpi = collected[id]
+ return jpi and jpi.w or 0
end
function jobpositions.height(id)
- local jpi = collected[id] or tobesaved[id]
- return jpi and jpi[5] or 0
+ local jpi = collected[id]
+ return jpi and jpi.h or 0
end
function jobpositions.depth(id)
- local jpi = collected[id] or tobesaved[id]
- return jpi and jpi[6] or 0
+ local jpi = collected[id]
+ return jpi and jpi.d or 0
+end
+
+function jobpositions.leftskip(id)
+ local jpi = collected[id]
+ return jpi and jpi.ls or 0
+end
+
+function jobpositions.rightskip(id)
+ local jpi = collected[id]
+ return jpi and jpi.rs or 0
+end
+
+function jobpositions.hsize(id)
+ local jpi = collected[id]
+ return jpi and jpi.hs or 0
+end
+
+function jobpositions.parindent(id)
+ local jpi = collected[id]
+ return jpi and jpi.pi or 0
+end
+
+function jobpositions.hangindent(id)
+ local jpi = collected[id]
+ return jpi and jpi.hi or 0
+end
+
+function jobpositions.hangafter(id)
+ local jpi = collected[id]
+ return jpi and jpi.ha or 1
end
function jobpositions.xy(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- return jpi[2], jpi[3]
+ local x = jpi.x or 0
+ local y = jpi.y or 0
+ return x, y
else
return 0, 0
end
end
function jobpositions.lowerleft(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- return jpi[2], jpi[3] - jpi[6]
+ local x = jpi.x or 0
+ local y = jpi.y or 0
+ local d = jpi.d or 0
+ return x, y - d
else
return 0, 0
end
end
function jobpositions.lowerright(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- return jpi[2] + jpi[4], jpi[3] - jpi[6]
+ local x = jpi.x or 0
+ local y = jpi.y or 0
+ local w = jpi.w or 0
+ local d = jpi.d or 0
+ return x + w, y - d
else
return 0, 0
end
end
function jobpositions.upperright(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- return jpi[2] + jpi[4], jpi[3] + jpi[5]
+ local x = jpi.x or 0
+ local y = jpi.y or 0
+ local w = jpi.w or 0
+ local h = jpi.h or 0
+ return x + w, y + h
else
return 0, 0
end
end
function jobpositions.upperleft(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- return jpi[2], jpi[3] + jpi[5]
+ local x = jpi.x or 0
+ local y = jpi.y or 0
+ local h = jpi.h or 0
+ return x, y + h
else
return 0, 0
end
end
function jobpositions.position(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- return jpi[1], jpi[2], jpi[3], jpi[4], jpi[5], jpi[6]
+ return jpi.p or 0, jpi.x or 0, jpi.y or 0, jpi.w or 0, jpi.h or 0, jpi.d or 0
else
return 0, 0, 0, 0, 0, 0
end
end
function jobpositions.extra(id,n,default) -- assume numbers
- local jpi = collected[id] or tobesaved[id]
- if not jpi then
- return default
- else
- local split = jpi[0]
- if not split then
- split = lpegmatch(splitter,jpi[7])
- jpi[0] = split
+ local jpi = collected[id]
+ if jpi then
+ local e = jpi.e
+ if e then
+ local split = jpi.split
+ if not split then
+ split = lpegmatch(splitter,jpi.e)
+ jpi.split = split
+ end
+ return texsp(split[n]) or default -- watch the texsp here
end
- return texsp(split[n]) or default -- watch the texsp here
end
+ return default
end
local function overlapping(one,two,overlappingmargin) -- hm, strings so this is wrong .. texsp
- one = collected[one] or tobesaved[one]
- two = collected[two] or tobesaved[two]
- if one and two and one[1] == two[1] then
+ one = collected[one]
+ two = collected[two]
+ if one and two and one.p == two.p then
if not overlappingmargin then
overlappingmargin = 2
end
- local x_one = one[2]
- local x_two = two[2]
- local w_two = two[4]
+ local x_one = one.x or 0
+ local x_two = two.x or 0
+ local w_two = two.w or 0
local llx_one = x_one - overlappingmargin
local urx_two = x_two + w_two + overlappingmargin
if llx_one > urx_two then
return false
end
- local w_one = one[4]
+ local w_one = one.w or 0
local urx_one = x_one + w_one + overlappingmargin
local llx_two = x_two - overlappingmargin
if urx_one < llx_two then
return false
end
- local y_one = one[3]
- local y_two = two[3]
- local d_one = one[6]
- local h_two = two[5]
+ local y_one = one.y or 0
+ local y_two = two.y or 0
+ local d_one = one.d or 0
+ local h_two = two.h or 0
local lly_one = y_one - d_one - overlappingmargin
local ury_two = y_two + h_two + overlappingmargin
if lly_one > ury_two then
return false
end
- local h_one = one[5]
- local d_two = two[6]
+ local h_one = one.h or 0
+ local d_two = two.d or 0
local ury_one = y_one + h_one + overlappingmargin
local lly_two = y_two - d_two - overlappingmargin
if ury_one < lly_two then
@@ -226,10 +636,12 @@ end
local function onsamepage(list,page)
for id in gmatch(list,"(, )") do
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- local p = jpi[1]
- if not page then
+ local p = jpi.p
+ if not p then
+ return false
+ elseif not page then
page = p
elseif page ~= p then
return false
@@ -248,138 +660,284 @@ commands.replacepospxywhd = jobpositions.replace
commands.copyposition = jobpositions.copy
function commands.MPp(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context(jpi[1])
- else
- context('0')
+ local p = jpi.p
+ if p then
+ context(p)
+ return
+ end
end
+ context('0')
end
function commands.MPx(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context("%spt",jpi[2]*pt)
- else
- context('0pt')
+ local x = jpi.x
+ if x then
+ context("%spt",x*pt)
+ return
+ end
end
+ context('0pt')
end
function commands.MPy(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context("%spt",jpi[3]*pt)
- else
- context('0pt')
+ local y = jpi.y
+ if y then
+ context("%spt",y*pt)
+ return
+ end
end
+ context('0pt')
end
function commands.MPw(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context("%spt",jpi[4]*pt)
- else
- context('0pt')
+ local w = jpi.w
+ if w then
+ context("%spt",w*pt)
+ return
+ end
end
+ context('0pt')
end
function commands.MPh(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context("%spt",jpi[5]*pt)
- else
- context('0pt')
+ local h = jpi.h
+ if h then
+ context("%spt",h*pt)
+ return
+ end
end
+ context('0pt')
end
function commands.MPd(id)
- local jpi = collected[id] or tobesaved[id]
if jpi then
- context("%spt",jpi[6]*pt)
- else
- context('0pt')
+ local d = jpi.d
+ if d then
+ context("%spt",d*pt)
+ return
+ end
end
+ context('0pt')
end
function commands.MPxy(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context('(%spt,%spt)',jpi[2]*pt,jpi[3]*pt)
+ context('(%spt,%spt)',
+ (jpi.x or 0)*pt,
+ (jpi.y or 0)*pt
+ )
else
context('(0,0)')
end
end
function commands.MPll(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context('(%spt,%spt)',jpi[2]*pt,(jpi[3]-jpi[6])*pt)
+ context('(%spt,%spt)',
+ (jpi.x or 0) *pt,
+ ((jpi.y or 0)-(jpi.d or 0))*pt
+ )
else
context('(0,0)')
end
end
function commands.MPlr(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context('(%spt,%spt)',(jpi[2]+jpi[4])*pt,(jpi[3]-jpi[6])*pt)
+ context('(%spt,%spt)',
+ ((jpi.x or 0)+(jpi.w or 0))*pt,
+ ((jpi.y or 0)-(jpi.d or 0))*pt
+ )
else
context('(0,0)')
end
end
function commands.MPur(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context('(%spt,%spt)',(jpi[2]+jpi[4])*pt,(jpi[3]+jpi[5])*pt)
+ context('(%spt,%spt)',
+ ((jpi.x or 0)+(jpi.w or 0))*pt,
+ ((jpi.y or 0)+(jpi.h or 0))*pt
+ )
else
context('(0,0)')
end
end
function commands.MPul(id)
- local jpi = collected[id] or tobesaved[id]
+ local jpi = collected[id]
if jpi then
- context('(%spt,%spt)',jpi[2]*pt,(jpi[3]+jpi[5])*pt)
+ context('(%spt,%spt)',
+ (jpi.x or 0) *pt,
+ ((jpi.y or 0)+(jpi.h or 0))*pt
+ )
else
context('(0,0)')
end
end
-function commands.MPpos(id)
- local jpi = collected[id] or tobesaved[id]
+local function MPpos(id)
+ local jpi = collected[id]
+ if jpi then
+ local p = jpi.p
+ if p then
+ context("%s,%spt,%spt,%spt,%spt,%spt",
+ p,
+ (jpi.x or 0)*pt,
+ (jpi.y or 0)*pt,
+ (jpi.w or 0)*pt,
+ (jpi.h or 0)*pt,
+ (jpi.d or 0)*pt
+ )
+ return
+ end
+ end
+ context('0,0,0,0,0,0')
+end
+
+commands.MPpos = MPpos
+
+function commands.MPn(id)
+ local jpi = collected[id]
+ if jpi then
+ local n = jpi.n
+ if n then
+ context(n)
+ return
+ end
+ end
+ context(0)
+end
+
+function commands.MPc(id)
+ local jpi = collected[id]
+ if jpi then
+ local c = jpi.c
+ if c then
+ context(c)
+ return
+ end
+ end
+ context(c) -- number
+end
+
+function commands.MPr(id)
+ local jpi = collected[id]
if jpi then
- context("%s,%spt,%spt,%spt,%spt,%spt",jpi[1],jpi[2]*pt,jpi[3]*pt,jpi[4]*pt,jpi[5]*pt,jpi[6]*pt)
+ local r = jpi.r
+ if r then
+ context(r)
+ return
+ end
+ end
+ -- context("") -- empty so that we can test
+end
+
+local function MPpardata(n)
+ local t = collected[n]
+ if not t then
+ local tag = format("p:%s",n)
+ t = collected[tag]
+ end
+ if t then
+ context("%spt,%spt,%spt,%spt,%s,%spt", -- can be %.5f
+ (t.hs or 0)*pt,
+ (t.ls or 0)*pt,
+ (t.rs or 0)*pt,
+ (t.hi or 0)*pt,
+ (t.ha or 1),
+ (t.pi or 0)*pt
+ )
else
- context('0,0,0,0,0,0')
+ context("0,0,0,0,0,0") -- meant for MP
+ end
+end
+
+commands.MPpardata = MPpardata
+
+-- function commands.MPposset(id) -- special helper, used in backgrounds
+-- local b = format("b:%s",id)
+-- local e = format("e:%s",id)
+-- local w = format("w:%s",id)
+-- local p = format("p:%s",jobpositions.n(b))
+-- MPpos(b) context(",") MPpos(e) context(",") MPpos(w) context(",") MPpos(p) context(",") MPpardata(p)
+-- end
+
+function commands.MPls(id)
+ local t = collected[id]
+ if t then
+ context((t.ls or 0)*pt)
+ else
+ context("0pt")
+ end
+end
+
+function commands.MPrs(id)
+ local t = collected[id]
+ if t then
+ context((t.rs or 0)*pt)
+ else
+ context("0pt")
end
end
local splitter = lpeg.tsplitat(",")
function commands.MPplus(id,n,default)
- local jpi = collected[id] or tobesaved[id]
- if not jpi then
- context(default)
- else
- local split = jpi[0]
- if not split then
- split = lpegmatch(splitter,jpi[7])
- jpi[0] = split
+ local jpi = collected[id]
+ if jpi then
+ local e = jpi.e
+ if e then
+ local split = jpi.split
+ if not split then
+ split = lpegmatch(splitter,jpi.e)
+ jpi.split = split
+ end
+ context(split[n] or default)
+ return
end
- context(split[n] or default)
end
+ context(default)
end
function commands.MPrest(id,default)
- local jpi = collected[id] or tobesaved[id]
- context(jpi and jpi[7] or default)
+ local jpi = collected[id]
+ context(jpi and jpi.e or default)
+end
+
+function commands.MPxywhd(id)
+ local t = collected[id]
+ if t then
+ context("%spt,%spt,%spt,%spt,%spt", -- can be %.5f
+ (t.x or 0)*pt,
+ (t.y or 0)*pt,
+ (t.w or 0)*pt,
+ (t.h or 0)*pt,
+ (t.d or 0)*pt
+ )
+ else
+ context("0,0,0,0,0") -- meant for MP
+ end
end
-- is testcase already defined? if so, then local
function commands.doifpositionelse(name)
- commands.testcase(collected[name] or tobesaved[name])
+ commands.testcase(collected[name])
end
function commands.doifoverlappingelse(one,two,overlappingmargin)
@@ -393,3 +951,6 @@ end
function commands.doifpositionsonthispageelse(list)
commands.testcase(onsamepage(list,tostring(tex.count.realpageno)))
end
+
+commands.markcolumnbox = jobpositions.markcolumnbox
+commands.markregionbox = jobpositions.markregionbox
diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv
index a801a5763..c28747c46 100644
--- a/tex/context/base/anch-pos.mkiv
+++ b/tex/context/base/anch-pos.mkiv
@@ -105,11 +105,15 @@
\def\dosavepositionwhd #1#2#3#4#5#6#7{\normalexpanded{\ctxlua {_plib_.setall("#1",\number#2,\number\dimexpr#3,\number\dimexpr#4,\number\dimexpr#5,\number\dimexpr#6,\number\dimexpr#7)}}}
\def\dosavepositionplus#1#2#3#4#5#6#7#8{\normalexpanded{\ctxlua {_plib_.setall("#1",\number#2,\number\dimexpr#3,\number\dimexpr#4,\number\dimexpr#5,\number\dimexpr#6,\number\dimexpr#7,"#8")}}}
-\def\dosetposition #1{\normalexpanded{\ctxlatelua{_plib_.setdim("#1")}}}
-\def\dosetpositionwhd #1#2#3#4{\normalexpanded{\ctxlatelua{_plib_.setdim("#1",\number\dimexpr#2,\number\dimexpr#3,\number\dimexpr#4)}}}
-\def\dosetpositionplus #1#2#3#4#5{\normalexpanded{\ctxlatelua{_plib_.setdim("#1",\number\dimexpr#2,\number\dimexpr#3,\number\dimexpr#4,"#5")}}}
+% \def\dosetposition #1{\normalexpanded{\ctxlatelua{_plib_.setdim("#1")}}}
+% \def\dosetpositionwhd #1#2#3#4{\normalexpanded{\ctxlatelua{_plib_.setdim("#1",\number\dimexpr#2,\number\dimexpr#3,\number\dimexpr#4)}}}
+% \def\dosetpositionplus #1#2#3#4#5{\normalexpanded{\ctxlatelua{_plib_.setdim("#1",\number\dimexpr#2,\number\dimexpr#3,\number\dimexpr#4,"#5")}}}
-% % %
+\def\dosetposition #1{\ctxcommand{posxy("#1")}}
+\def\dosetpositionwhd #1#2#3#4{\ctxcommand{poswhd("#1",\number\dimexpr#2,\number\dimexpr#3,\number\dimexpr#4)}}
+\def\dosetpositionplus#1#2#3#4#5{\ctxcommand{posplus("#1",\number\dimexpr#2,\number\dimexpr#3,\number\dimexpr#4,"#5")}}
+\def\dosetpositionbox #1#2{\ctxcommand{poswhd("#1",\number\wd#2,\number\ht#2,\number\dp#2)}}
+\def\dosetpositionstrut #1{\ctxcommand{posstrut("#1")}}
\let\dosetpositionpapersize\gobbletwoarguments
@@ -140,7 +144,8 @@
%D not applicable when the content floats indeed. In such
%D situations one can treat positions and graphics local.
-\newif\iflocalpositioning % todo: conditional
+\newif\iflocalpositioning % todo: conditional
+\newif\ifregionpositioning % todo: conditional
%D Watch out: sometimes a pagebreak occurs inside a float
%D placement, so there we need to disable local mode.
@@ -150,21 +155,25 @@
\to \everyinsidefloat
\appendtoks
+ \regionpositioningfalse
\localpositioningfalse
\to \everybeforepagebody
%D \macros
%D {MPp, MPx, MPy, MPw, MPh, MPd,
-%D MPxy, MPll, MPlr, MPur, MPul, MPpos}
+%D MPxy, MPll, MPlr, MPur, MPul, MPpos,MPanchor}
%D
%D Access to the positional information is provided by macros
%D with short names that are clearly meant for \METAPOST\ but
%D nowadays also used for other purposes.
-\def\MPp #1{\ctxcommand{MPp("#1")}}
+\def\MPp #1{\ctxcommand{MPp("#1")}} \let\MPpage \MPp
+\def\MPr #1{\ctxcommand{MPr("#1")}} \let\MPregion \MPr
+\def\MPc #1{\ctxcommand{MPc("#1")}} \let\MPcolumn \MPc
+\def\MPn #1{\ctxcommand{MPn("#1")}} \let\MPparagraph\MPn
\def\MPx #1{\ctxcommand{MPx("#1")}}
\def\MPy #1{\ctxcommand{MPy("#1")}}
-\def\MPw #1{\ctxcommand{MPw("#1")}}
+\def\MPw #1{\ctxcommand{MPw("#1")}} % first we need to replace \MPwidth etc
\def\MPh #1{\ctxcommand{MPh("#1")}}
\def\MPd #1{\ctxcommand{MPd("#1")}}
\def\MPxy #1{\ctxcommand{MPxy("#1")}}
@@ -172,7 +181,14 @@
\def\MPlr #1{\ctxcommand{MPlr("#1")}}
\def\MPur #1{\ctxcommand{MPur("#1")}}
\def\MPul #1{\ctxcommand{MPul("#1")}}
-\def\MPpos#1{\ctxcommand{MPpos("#1")}}
+\def\MPpos#1{\ctxcommand{MPpos("#1")}} \def\MPanchor{\MPpos}
+\def\MPe #1{\ctxcommand{MPe("#1")}}
+
+\def\MPls #1{\ctxcommand{MPls("#1")}} \let\MPleftskip\MPls % compatible feature
+\def\MPrs #1{\ctxcommand{MPrs("#1")}} \let\MPrightkip\MPrs % compatible feature
+
+\def\MPpardata#1{\ctxcommand{MPpardata("#1")}}
+\def\MPxywhd #1{\ctxcommand{MPxywhd("#1")}}
%D \macros
%D {MPplus, MPrest, MPv, MPvv}
@@ -197,13 +213,6 @@
\def\MPplus#1#2#3{\ctxcommand{MPplus("#1",#2,"#3")}} \let\MPv \MPplus
\def\MPrest #1#2{\ctxcommand{MPrest("#1","#2")}} \let\MPvv\MPrest
-%D \macros
-%D {MPanchor}
-%D
-%D For readability we define a few synonyms:
-
-\def\MPanchor{\MPpos}
-
%D There are two low level positioning macros. Both store the
%D position as well as execute an action associated with that
%D position.
@@ -275,13 +284,33 @@
{\anch_positions_initialize
\hbox to \wd\nextbox
{\edef\currentposition{#1}%
- \dosetpositionwhd\currentposition{\wd\nextbox}{\ht\nextbox}{\dp\nextbox}% already \the\dimexpr
+ \dosetpositionbox\currentposition\nextbox
\traceposstring\llap\green{\currentposition>}%
\setbox\positionbox\box\nextbox
\dopositionaction\currentposition
\box\positionbox
\hss}}
+\unexpanded\def\setpositionstrut
+ {\iftrialtypesetting
+ \expandafter\anch_positions_set_strut_nop
+ \else
+ \expandafter\anch_positions_set_strut_yes
+ \fi}
+
+\def\anch_positions_set_strut_nop#1%
+ {\strut}
+
+\def\anch_positions_set_strut_yes#1%
+ {\anch_positions_initialize
+ \hbox to \zeropoint
+ {\edef\currentposition{#1}%
+ \dosetpositionstrut\currentposition
+ \traceposstring\llap\green{\currentposition>}%
+ \dopositionaction\currentposition
+ \strut
+ \hss}}
+
\def\setpositiondataplus
{\iftrialtypesetting
\expandafter\gobblefivearguments
@@ -324,6 +353,30 @@
\let\currentposition\s!unknown
+%D A few special ones:
+
+\unexpanded\def\anch_mark_column_box
+ {\ifpositioning
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\anch_mark_column_box_indeed
+ \fi}
+
+\unexpanded\def\anch_mark_column_box#1%
+ {\ctxcommand{markcolumnbox(\number#1)}}
+
+\unexpanded\def\anch_mark_region_box
+ {\iftrialtypesetting
+ \singleexpandafter\gobbleoneargument
+ \else\ifpositioning
+ \doubleexpandafter\gobbleoneargument
+ \else
+ \doubleexpandafter\anch_mark_region_box_indeed
+ \fi\fi}
+
+\unexpanded\def\anch_mark_region_box#1%
+ {\ctxcommand{markregionbox(\number#1)}}
+
%D We can copy a position with:
%D
%D \starttyping
@@ -370,33 +423,26 @@
\let\xypos\setpositiononly
-\unexpanded\def\hpos#1{\dontleavehmode\setpositionbox{#1}\hbox}
-\unexpanded\def\vpos#1{\setpositionbox{#1}\vbox}
-
-\unexpanded\def\bpos#1{\hpos{b:#1}{\strut}\ignorespaces}
-\unexpanded\def\epos#1{\removelastspace\hpos{e:#1}{\strut}}
+\unexpanded\def\hpos #1{\dontleavehmode\setpositionbox{#1}\hbox}
+\unexpanded\def\vpos #1{\setpositionbox{#1}\vbox}
-\unexpanded\def\fpos#1%
- {\setpositionplus{b:#1}{\number\parposcounter}\horizontalstrut
- \ignorespaces}
+\unexpanded\def\bpos #1{\dontleavehmode \setpositionstrut{b:#1}\ignorespaces}
+\unexpanded\def\epos #1{\removeunwantedspaces\setpositionstrut{e:#1}}
+%unexpanded\def\fpos #1{\dontleavehmode \setpositionstrut{b:#1}\ignorespaces}
+%unexpanded\def\tpos #1{\removeunwantedspaces\setpositionstrut{e:#1}}
+\unexpanded\def\ffpos#1{\dontleavehmode \setpositionstrut{b:#1}\wpos{#1}\ignorespaces}
+%unexpanded\def\ttpos#1{\removeunwantedspaces\setpositionstrut{e:#1}}
-\unexpanded\def\tpos#1%
- {\removelastspace
- \setpositionplus{e:#1}{\number\parposcounter}\horizontalstrut}
+\let\fpos \bpos
+\let\tpos \epos
+\let\ttpos\epos
-\unexpanded\def\ffpos#1%
- {\setpositionplus{b:#1}{\number\parposcounter}\horizontalstrut\wpos{#1}%
- \ignorespaces}
+%D Crap:
-\unexpanded\def\ttpos#1%
- {\removelastspace
- \setpositionplus{e:#1}{\number\parposcounter}\horizontalstrut}
-
-\unexpanded\def\wpos#1%
+\unexpanded\def\wpos#1% will be redone
{\dontleavehmode\vadjust % may disappear if buried
{\setbox\scratchbox\hbox{\raise\strutdp\hbox{\rawwpos{#1}}}%
- \rlap
- {\smashedbox\scratchbox}}}
+ \rlap{\smashedbox\scratchbox}}}
\unexpanded\def\wwpos#1% \hsmashed{\llap{\rawwpos{#1}}}
{\rlap
@@ -406,9 +452,6 @@
\unexpanded\def\rawwpos#1%
{\hpos{w:#1}
{\strut
-% \hskip-\leftskip
-% \hskip\hsize
-% \hskip-\rightskip}}
\hskip\dimexpr\hsize-\leftskip-\rightskip\relax}}
% the next macro disables par positions (in inner boxes) and
@@ -454,12 +497,16 @@
\fi \fi \fi
\fi}
+% \def\anch_positions_register_par_options
+% {\global\advance\parposcounter\plusone
+% \setpositiondataplus
+% {p:\number\parposcounter}\zeropoint\strutht\strutdp
+% {\the\hsize,\the\dimexpr\leftskip\relax,\the\dimexpr\rightskip\relax,\the\hangindent,\the\hangafter,\the\parindent}%
+% %\hbox{\registerparsymbol}%
+% \iftracepositions\registerparsymbol\fi}
+
\def\anch_positions_register_par_options
- {\global\advance\parposcounter\plusone
- \setpositiondataplus
- {p:\number\parposcounter}\zeropoint\strutht\strutdp
- {\the\hsize,\the\dimexpr\leftskip\relax,\the\dimexpr\rightskip\relax,\the\hangindent,\the\hangafter,\the\parindent}%
- %\hbox{\registerparsymbol}%
+ {\dontleavehmode\ctxcommand{parpos()}%
\iftracepositions\registerparsymbol\fi}
\unexpanded\def\traceposstring#1#2#3%
@@ -486,7 +533,7 @@
% \appendtoks \registerparoptions \to \everypar
-%D Eperimental code, don't use this yet: (must be sped up anyway)
+%D Eperimental code, don't use this yet: (must be sped up anyway) .. obsolete
\def\@@noden{node:n:}
\def\@@nodeo{node:o:}
@@ -638,12 +685,6 @@
\def\doifpositionsonsamepageelse#1{\ctxcommand{doifpositionsonsamepageelse("#1")}}
\def\doifpositionsonthispageelse#1{\ctxcommand{doifpositionsonthispageelse("#1")}}
-%D Plugins:
-
-\let\MPv \MPplus
-\let\MPvv \MPrest
-\let\MPanchor\MPpos
-
%D \macros
%D {POSp, POSx, POSy, POSh, POSd, POSw}
%D
diff --git a/tex/context/base/anch-snc.mkiv b/tex/context/base/anch-snc.mkiv
index 32222bb50..c7448f3a1 100644
--- a/tex/context/base/anch-snc.mkiv
+++ b/tex/context/base/anch-snc.mkiv
@@ -17,6 +17,7 @@
\unprotect
+\ifx\s!num \undefined \def\s!num {num} \fi
\ifx\s!set \undefined \def\s!set {set} \fi
\ifx\s!reset \undefined \def\s!reset {reset} \fi
\ifx\s!preset \undefined \def\s!preset {preset} \fi
@@ -155,10 +156,14 @@
%
% \appendtoks \flushsyncpositions \to \neverypar
-\protect \endinput
+\protect
+
+\continueifinputfile{anch-snc.mkiv}
\starttext
+\setupbodyfont[dejavu]
+
\definesyncpositions[1]
\startuseMPgraphic{sync}
@@ -185,9 +190,14 @@
\setupbackgrounds[page][background=tempoverlay]
-\syncposition[1][1] \input ward \endgraf
-\syncposition[1][2] \input ward \endgraf
-\syncposition[1][3] \input ward \endgraf
-\syncposition[1][4] \input ward \endgraf
+\dorecurse {100} {
+
+ \startchapter[title={Test #1}]
+ \syncposition[1][1] \dorecurse{10}{\input ward \endgraf}
+ \syncposition[1][2] \dorecurse{4}{\input ward \endgraf}
+ \syncposition[1][3] \dorecurse{7}{\input ward \endgraf}
+ \syncposition[1][4] \dorecurse{3}{\input ward \endgraf}
+ \stopchapter
+}
\stoptext
diff --git a/tex/context/base/buff-imp-mp.lua b/tex/context/base/buff-imp-mp.lua
index 24ca597e7..f219df797 100644
--- a/tex/context/base/buff-imp-mp.lua
+++ b/tex/context/base/buff-imp-mp.lua
@@ -16,12 +16,6 @@ if not modules then modules = { } end modules ['buff-imp-mp'] = {
local P, S, V, patterns = lpeg.P, lpeg.S, lpeg.V, lpeg.patterns
-local mps = dofile(resolvers.findfile("mult-mps.lua","tex"))
-
-local primitives = table.tohash(mps.primitives)
-local plain = table.tohash(mps.plain)
-local metafun = table.tohash(mps.metafun)
-
local context = context
local verbatim = context.verbatim
local makepattern = visualizers.makepattern
@@ -39,7 +33,23 @@ local MetapostSnippetNamePlain = verbatim.MetapostSnippetNamePlain
local MetapostSnippetNameMetafun = verbatim.MetapostSnippetNameMetafun
local MetapostSnippetName = verbatim.MetapostSnippetName
+local primitives, plain, metafun
+
+local function initialize()
+ local mps = dofile(resolvers.findfile("mult-mps.lua","tex")) or {
+ primitives = { },
+ plain = { },
+ metafun = { },
+ }
+ primitives = table.tohash(mps.primitives)
+ plain = table.tohash(mps.plain)
+ metafun = table.tohash(mps.metafun)
+end
+
local function visualizename(s)
+ if not primitives then
+ initialize()
+ end
if primitives[s] then
MetapostSnippetNamePrimitive(s)
elseif plain[s] then
diff --git a/tex/context/base/buff-par.mkiv b/tex/context/base/buff-par.mkiv
index 02e250b81..7d35676bd 100644
--- a/tex/context/base/buff-par.mkiv
+++ b/tex/context/base/buff-par.mkiv
@@ -85,7 +85,7 @@
\def\doflushparalleldefault{\directsetup{\parallelparameter\c!setups}}
\startsetups parallel:place:default
- \hangafter1
+ \hangafter\plusone
\hangindent4em
\dontleavehmode
\hbox to 3em \bgroup
diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua
index 4757735e8..ba844ff9b 100644
--- a/tex/context/base/char-def.lua
+++ b/tex/context/base/char-def.lua
@@ -60627,9 +60627,11 @@ characters.data={
[0x2212]={
adobename="minus",
category="sm",
+--comment="the mathclass is needed for mathsymbol remapping",
description="MINUS SIGN",
direction="es",
linebreak="pr",
+--mathclass="binary",
mathspec={
{
class="binary",
diff --git a/tex/context/base/colo-grp.mkiv b/tex/context/base/colo-grp.mkiv
index 8c6d4df6b..11b759062 100644
--- a/tex/context/base/colo-grp.mkiv
+++ b/tex/context/base/colo-grp.mkiv
@@ -76,7 +76,7 @@
\def\colo_groups_define_entry#1#2#3% name mode specification
{\advance\c_colo_groups_n\plusone
- \csname\??colorgroupsetter\ifcsname\??colorgroupssetter#2\endcsname#2\else\s!rgb\fi\endcsname[#1:\the\c_colo_groups_n][#3:0:0:0:0]}
+ \csname\??colorgroupsetter\ifcsname\??colorgroupsetter#2\endcsname#2\else\s!rgb\fi\endcsname[#1:\the\c_colo_groups_n][#3:0:0:0:0]}
\setvalue{\??colorgroupsetter\s!gray}[#1][#2:#3]{\definecolor[#1][s=#2]}
\setvalue{\??colorgroupsetter\s!rgb }[#1][#2:#3:#4:#5]{\definecolor[#1][r=#2,g=#3,b=#4]}
diff --git a/tex/context/base/cont-fil.mkiv b/tex/context/base/cont-fil.mkiv
index e6d69b939..db7505bcb 100644
--- a/tex/context/base/cont-fil.mkiv
+++ b/tex/context/base/cont-fil.mkiv
@@ -98,5 +98,6 @@
\definefilesynonym [letter] [cor-01]
\definefilesynonym [memo] [cor-02]
+\definefilesynonym [resume] [cor-03]
\endinput
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 6f341ac2f..fb4ee485d 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.01.25 14:16}
+\newcontextversion{2012.02.08 21:04}
%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/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index ee45720fa..ebf6aa3c3 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.01.25 14:16}
+\newcontextversion{2012.02.08 21:04}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
@@ -427,13 +427,6 @@
% \startplaatsen[links] bla \stopplaatsen
-% we don't register the paragraph characteristics, only the
-% width
-
-\appendtoks
- \setinnerparpositions % see "techniek" for application
-\to \everytabulate
-
\def\startcolumnmakeup % don't change
{\bgroup
\getrawnoflines\textheight % teksthoogte kan topskip hebben, dus raw
@@ -450,7 +443,7 @@
\wd\scratchbox\textwidth
\box\scratchbox
\egroup
- \synchronizehsize}
+ \page_otr_command_synchronize_hsize}
\long\def\startexternalfigure
{\dotripleempty\dostartexternalfigure}
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index a4d31a83c..f1efd3a17 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index e0bdc7a46..08b891640 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 3b58fa307..e62b4e583 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.01.25 14:16}
+\edef\contextversion{2012.02.08 21:04}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index ec46764c8..eaa4c3a3c 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -23,7 +23,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.01.25 14:16}
+\edef\contextversion{2012.02.08 21:04}
%D For those who want to use this:
@@ -243,12 +243,19 @@
\loadmarkfile{pack-obj}
\loadmkvifile{strc-itm}
-\loadmarkfile{strc-des}
+
+\loadmkvifile{strc-con}
+\loadmkvifile{strc-des}
+\loadmkvifile{strc-enu}
+
+\loadmarkfile{strc-ind}
+\loadmarkfile{strc-lab}
\loadmarkfile{strc-syn}
\loadmarkfile{core-sys}
\loadmarkfile{page-var}
+\loadmkvifile{page-otr}
\loadmarkfile{page-ini}
\loadmarkfile{page-fac}
\loadmarkfile{page-brk}
@@ -262,7 +269,7 @@
\loadmarkfile{page-lay}
\loadmkvifile{page-box}
\loadmkvifile{page-txt}
-\loadmarkfile{page-sid}
+\loadmarkfile{page-sid} % when
\loadmkvifile{strc-flt}
@@ -412,8 +419,8 @@
\loadmarkfile{node-rul}
\loadmarkfile{node-spl}
-\loadmarkfile{strc-not}
-\loadmarkfile{strc-lnt}
+\loadmkvifile{strc-not}
+\loadmkvifile{strc-lnt}
\loadmarkfile{core-mis}
\loadmarkfile{pack-com}
diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv
index cc30cb8e5..1819d084d 100644
--- a/tex/context/base/core-env.mkiv
+++ b/tex/context/base/core-env.mkiv
@@ -370,13 +370,27 @@
\let\directsetup\syst_setups
\let\texsetup \syst_setups % nicer than \directsetup and more en par with xmlsetup and luasetup
-\def\doifsetupselse#1% to be done: grid
+\unexpanded\def\doifsetupselse#1% to be done: grid
{\ifcsname\??setup:#1\endcsname
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
+\unexpanded\def\doifsetups#1% to be done: grid
+ {\ifcsname\??setup:#1\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\unexpanded\def\doifnotsetups#1% to be done: grid
+ {\ifcsname\??setup:#1\endcsname
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
% \startluasetups oeps
% context("DONE")
% a = 1
diff --git a/tex/context/base/core-ini.mkiv b/tex/context/base/core-ini.mkiv
index 0c369ff3a..75a0ed5d9 100644
--- a/tex/context/base/core-ini.mkiv
+++ b/tex/context/base/core-ini.mkiv
@@ -21,40 +21,59 @@
\everypar \emptytoks
\neverypar \emptytoks
-%appendtoks \flushnotes \to \everypar
-\appendtoks \synchronizesidefloats \to \everypar
-
-\appendtoks \checkindentation \to \everypar
-\appendtoks \showparagraphnumber \to \everypar
-\appendtoks \restoreinterlinepenalty \to \everypar
-%appendtoks \flushmargincontents \to \everypar
-%appendtoks \flushcommentanchors \to \everypar
-\appendtoks \flushnotes \to \everypar
-\appendtoks \synchronizenotes \to \everypar
-\appendtoks \OTRSETshowstatus \to \everypar
-\appendtoks \flushpostponedbookmark \to \everypar
-\appendtoks \registerparoptions \to \everypar
-\appendtoks \flushsyncpositions \to \everypar
-\appendtoks \flushpostponednodedata \to \everypar
-\appendtoks \typo_delimited_repeat \to \everypar
-\appendtoks \insertparagraphintro \to \everypar
-
-\appendtoks \flushpostponedbookmark \to \neverypar
-\appendtoks \flushpostponedbookmark \to \everylistentry
-
-\appendtoks \flushnotes \to \everydisplay
-\appendtoks \adjustsidefloatdisplaylines \to \everydisplay
-
-\appendtoks \flushsyncpositions \to \everyheadstart
-
-\appendtoks \flushsyncresets \to \everyendoftextbody
-
-\appendtoks \ignorespaces \to \everybeginofpar
-
-\appendtoks \removeunwantedspaces \to \everyendofpar
-%appendtoks \strut \to \everyendofpar % option ?
-\appendtoks \flushsyncresets \to \everyendofpar
-%appendtoks \setlastlinewidth \to \everyendofpar % gone, will be done in lua
-\appendtoks \endgraf \to \everyendofpar
+\appendtoks
+ %flushnotes
+ \page_otr_command_synchronize_side_floats % an otr specific command
+ \checkindentation
+ \showparagraphnumber
+ \restoreinterlinepenalty
+ %flushmargincontents
+ %flushcommentanchors
+ \flushnotes
+ \synchronizenotes
+ \OTRSETshowstatus
+ \flushpostponedbookmark
+ \registerparoptions
+ \flushsyncpositions
+ \flushpostponednodedata
+ \typo_delimited_repeat
+ \insertparagraphintro
+\to \everypar
+
+\appendtoks
+ \flushpostponedbookmark
+\to \neverypar
+
+\appendtoks
+ \flushpostponedbookmark
+\to \everylistentry
+
+\appendtoks
+ \flushnotes
+\to \everydisplay
+
+\appendtoks
+ \adjustsidefloatdisplaylines
+\to \everydisplay
+
+\appendtoks
+ \flushsyncpositions
+\to \everyheadstart
+
+\appendtoks
+ \flushsyncresets
+\to \everyendoftextbody
+
+\appendtoks
+ \ignorespaces
+\to \everybeginofpar
+
+\appendtoks
+ \removeunwantedspaces
+ %strut % option ?
+ \flushsyncresets
+ %setlastlinewidth % gone, will be done in lua
+ \endgraf
+\to \everyendofpar
\protect \endinput
diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua
index 7834be963..cfe95a6bb 100644
--- a/tex/context/base/core-uti.lua
+++ b/tex/context/base/core-uti.lua
@@ -34,7 +34,7 @@ local report_jobcontrol = logs.reporter("jobcontrol")
job = job or { }
local job = job
-job.version = 1.17
+job.version = 1.18
-- some day we will implement loading of other jobs and then we need
-- job.jobs
diff --git a/tex/context/base/data-tex.lua b/tex/context/base/data-tex.lua
index c2257296c..6cb361699 100644
--- a/tex/context/base/data-tex.lua
+++ b/tex/context/base/data-tex.lua
@@ -19,16 +19,16 @@ local methodhandler = resolvers.methodhandler
local splitlines = string.splitlines
local utffiletype = unicode.filetype
-local fileprocessor = nil
-local lineprocessor = nil
+-- local fileprocessor = nil
+-- local lineprocessor = nil
-local textfileactions = sequencers.reset {
+local textfileactions = sequencers.new {
arguments = "str,filename,coding",
returnvalues = "str",
results = "str",
}
-local textlineactions = sequencers.reset {
+local textlineactions = sequencers.new {
arguments = "str,filename,linenumber,noflines,coding",
returnvalues = "str",
results = "str",
@@ -78,10 +78,10 @@ function helpers.textopener(tag,filename,filehandle,coding)
elseif coding == "utf-32-le" then
lines = unicode.utf32_to_utf8_le(lines)
else -- utf8 or unknown (could be a mkvi file)
- if textfileactions.dirty then -- maybe use autocompile
- fileprocessor = sequencers.compile(textfileactions) -- no need for dummy test .. always one
+ local runner = textfileactions.runner
+ if runner then
+ lines = runner(lines,filename,coding) or lines
end
- lines = fileprocessor(lines,filename,coding) or lines
lines = splitlines(lines)
end
elseif trace_locating then
@@ -119,11 +119,9 @@ function helpers.textopener(tag,filename,filehandle,coding)
-- elseif content == ctrl_d or ctrl_z then
-- return nil -- we need this as \endinput does not work in prints
else
- if textlineactions.dirty then -- no dummy
- lineprocessor = sequencers.compile(textlineactions,false,true) -- maybe use autocompile
- end
- if lineprocessor then
- return lineprocessor(content,filename,currentline,noflines,coding) or content
+ local runner = textlineactions.runner
+ if runner then
+ return runner(content,filename,currentline,noflines,coding) or content
else
return content
end
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index 9329fbb83..928099688 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -44,7 +44,6 @@ local setmetatableindex = table.setmetatableindex
-- will be directives
constructors.dontembed = allocate()
-constructors.mathactions = { }
constructors.autocleanup = true
constructors.namemode = "fullpath" -- will be a function
@@ -278,6 +277,14 @@ function constructors.assignmathparameters(target,original) -- simple variant, n
end
end
+function constructors.beforecopyingcharacters(target,original)
+ -- can be used for additional tweaking
+end
+
+function constructors.aftercopyingcharacters(target,original)
+ -- can be used for additional tweaking
+end
+
function constructors.enhanceparameters(parameters)
local xheight = parameters.x_height
local quad = parameters.quad
@@ -527,7 +534,7 @@ function constructors.scale(tfmdata,specification)
--
local italickey = "italic"
--
- -- some context specific trickery (we might move this to a plug in into here
+ -- some context specific trickery (this will move to a plugin)
--
if hasmath then
if properties.mathitalics then
@@ -553,6 +560,8 @@ function constructors.scale(tfmdata,specification)
--
-- end of context specific trickery
--
+ constructors.beforecopyingcharacters(target,tfmdata)
+ --
local sharedkerns = { }
--
-- we can have a dumb mode (basemode without math etc) that skips most
@@ -795,6 +804,9 @@ function constructors.scale(tfmdata,specification)
end
targetcharacters[unicode] = chr
end
+ --
+ constructors.aftercopyingcharacters(target,tfmdata)
+ --
return target
end
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 8031299f4..5680ee69e 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -58,6 +58,10 @@ local registerotffeature = otffeatures.register
local baseprocessors = otffeatures.processors.base
local baseinitializers = otffeatures.initializers.base
+local sequencers = utilities.sequencers
+local appendgroup = sequencers.appendgroup
+local appendaction = sequencers.appendaction
+
specifiers.contextsetups = specifiers.contextsetups or { }
specifiers.contextnumbers = specifiers.contextnumbers or { }
specifiers.contextmerged = specifiers.contextmerged or { }
@@ -223,81 +227,6 @@ local privatefeatures = {
anum = true,
}
--- local function modechecker(tfmdata,features,mode) -- we cannot adapt features as they are shared!
--- if trace_features then
--- report_features(serialize(features,"used"))
--- end
--- local rawdata = tfmdata.shared.rawdata
--- local resources = rawdata and rawdata.resources
--- local script = features.script
--- if script == "auto" then
--- local latn = false
--- for g, list in next, resources.features do
--- for f, scripts in next, list do
--- if privatefeatures[f] then
--- -- skip
--- elseif scripts.dflt then
--- script = "dflt"
--- break
--- elseif scripts.latn then
--- latn = true
--- end
--- end
--- end
--- if script == "auto" then
--- script = latn and "latn" or "dflt"
--- end
--- features.script = script
--- if trace_automode then
--- report_defining("auto script mode: using script '%s' in font '%s'",script,file.basename(tfmdata.properties.name))
--- end
--- end
--- if mode == "auto" then
--- local sequences = resources.sequences
--- if sequences and #sequences > 0 then
--- local script = features.script or "dflt"
--- local language = features.language or "dflt"
--- for feature, value in next, features do
--- if value then
--- local found = false
--- for i=1,#sequences do
--- local sequence = sequences[i]
--- local features = sequence.features
--- if features then
--- local scripts = features[feature]
--- if scripts then
--- local languages = scripts[script]
--- if languages and languages[language] then
--- if found then
--- -- more than one lookup
--- if trace_automode then
--- report_defining("forcing node mode in font %s for feature %s, script %s, language %s (multiple lookups)",file.basename(tfmdata.properties.name),feature,script,language)
--- end
--- features.mode = "node"
--- return "node"
--- elseif needsnodemode[sequence.type] then
--- if trace_automode then
--- report_defining("forcing node mode in font %s for feature %s, script %s, language %s (no base support)",file.basename(tfmdata.properties.name),feature,script,language)
--- end
--- features.mode = "node"
--- return "node"
--- else
--- -- at least one lookup
--- found = true
--- end
--- end
--- end
--- end
--- end
--- end
--- end
--- end
--- return "base"
--- else
--- return mode
--- end
--- end
-
local function checkedscript(tfmdata,resources,features)
local latn = false
local script = false
@@ -415,6 +344,38 @@ registerotffeature {
-- },
-- }
+local beforecopyingcharacters = sequencers.new {
+ name = "beforecopyingcharacters",
+ arguments = "target,original",
+}
+
+appendgroup(beforecopyingcharacters,"before") -- user
+appendgroup(beforecopyingcharacters,"system") -- private
+appendgroup(beforecopyingcharacters,"after" ) -- user
+
+function constructors.beforecopyingcharacters(original,target)
+ local runner = beforecopyingcharacters.runner
+ if runner then
+ runner(original,target)
+ end
+end
+
+local aftercopyingcharacters = sequencers.new {
+ name = "aftercopyingcharacters",
+ arguments = "target,original",
+}
+
+appendgroup(aftercopyingcharacters,"before") -- user
+appendgroup(aftercopyingcharacters,"system") -- private
+appendgroup(aftercopyingcharacters,"after" ) -- user
+
+function constructors.aftercopyingcharacters(original,target)
+ local runner = aftercopyingcharacters.runner
+ if runner then
+ runner(original,target)
+ end
+end
+
--[[ldx--
<p>So far we haven't really dealt with features (or whatever we want
to pass along with the font definition. We distinguish the following
@@ -672,8 +633,11 @@ end
-- todo: support a,b,c
+-- we need a copy as we will add (fontclass) goodies to the features and
+-- that is bad for a shared table
+
local function splitcontext(features) -- presetcontext creates dummy here
- return setups[features] or (presetcontext(features,"","") and setups[features])
+ return fastcopy(setups[features] or (presetcontext(features,"","") and setups[features]))
end
--~ local splitter = lpeg.splitat("=")
@@ -843,13 +807,13 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
local lookup, name, sub, method, detail = getspecification(str or "")
-- new (todo: inheritancemode)
local designsize = fontdesignsize ~= "" and fontdesignsize or classdesignsize or ""
- if designsize == "auto" or designsize == "default" then -- or any value
- local okay = designsizefilename(name,size)
- -- we don't catch detail here
+ local designname = designsizefilename(name,designsize,size)
+ if designname and designname ~= "" then
if trace_defining or trace_designsize then
- report_defining("remapping name: %s + size: %s => designsize: %s",name,size,okay)
+ report_defining("remapping name: %s, specification: %s, size: %s => designsize: %s",name,designsize,size,designname)
end
- local o_lookup, o_name, o_sub, o_method, o_detail = getspecification(okay)
+ -- we don't catch detail here
+ local o_lookup, o_name, o_sub, o_method, o_detail = getspecification(designname)
if o_lookup and o_lookup ~= "" then lookup = o_lookup end
if o_method and o_method ~= "" then method = o_method end
if o_detail and o_detail ~= "" then detail = o_detail end
@@ -1067,6 +1031,50 @@ function constructors.calculatescale(tfmdata,scaledpoints,relativeid)
return scaledpoints, delta
end
+-- We overload the (generic) resolver:
+
+local resolvers = definers.resolvers
+local hashfeatures = constructors.hashfeatures
+
+function definers.resolve(specification) -- overload function in font-con.lua
+ if not specification.resolved or specification.resolved == "" then -- resolved itself not per se in mapping hash
+ local r = resolvers[specification.lookup]
+ if r then
+ r(specification)
+ end
+ end
+ if specification.forced == "" then
+ specification.forced = nil
+ else
+ specification.forced = specification.forced
+ end
+ -- goodies are a context specific thing and not always defined
+ -- as feature, so we need to make sure we add them here before
+ -- hashing because otherwise we get funny goodies applied
+ local goodies = specification.goodies
+ if goodies and goodies ~= "" then
+ -- this adapts the features table so it has best be a copy
+ local normal = specification.features.normal
+ if not normal then
+ specification.features.normal = { goodies = goodies }
+ elseif not normal.goodies then
+ local g = normal.goodies
+ if g and g ~= "" then
+ normal.goodies = format("%s,%s",g,goodies)
+ else
+ normal.goodies = goodies
+ end
+ end
+ end
+ -- so far for goodie hacks
+ specification.hash = lower(specification.name .. ' @ ' .. hashfeatures(specification))
+ if specification.sub and specification.sub ~= "" then
+ specification.hash = specification.sub .. ' @ ' .. specification.hash
+ end
+ return specification
+end
+
+
-- soon to be obsolete:
local mappings = fonts.mappings
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index 5f7917063..10958cfbc 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -214,17 +214,6 @@ function definers.resolve(specification)
else
specification.forced = specification.forced
end
- -- for the moment here (goodies set outside features)
- local goodies = specification.goodies
- if goodies and goodies ~= "" then
- local normal = specification.features.normal
- if not normal then
- specification.features.normal = { goodies = goodies }
- elseif not normal.goodies then
- normal.goodies = goodies
- end
- end
- --
specification.hash = lower(specification.name .. ' @ ' .. constructors.hashfeatures(specification))
if specification.sub and specification.sub ~= "" then
specification.hash = specification.sub .. ' @ ' .. specification.hash
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua
index 03eb20705..97e97a640 100644
--- a/tex/context/base/font-gds.lua
+++ b/tex/context/base/font-gds.lua
@@ -104,6 +104,9 @@ local function setgoodies(tfmdata,value)
-- we need to check for duplicates
local ok = loadgoodies(filename)
if ok then
+ if trace_goodies then
+ report_goodies("assigning goodie '%s'",filename)
+ end
goodies[#goodies+1] = ok
end
end
@@ -472,6 +475,7 @@ local function initialize(tfmdata)
-- As we want to set italic_correction (the context one) we need a
-- postprocessor instead of messing with the (unscaled) descriptions.
fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy)
+ -- better make a helper so that we have less code being defined
local properties = tfmdata.properties
local parameters = tfmdata.parameters
local characters = tfmdata.characters
@@ -581,7 +585,7 @@ fontgoodies.designsizes = designsizes
local designdata = allocate()
designsizes.data = designdata
-local function initialize(goodies)
+local function initialize(goodies) -- design sizes are registered global
local gd = goodies.designsizes
if gd then
for name, data in next, gd do
@@ -622,21 +626,26 @@ function fontgoodies.designsizes.register(name,size,specification)
end
end
-function fontgoodies.designsizes.filename(name,size)
- local data = designdata[lower(name)]
- if data then
- local ranges = data.ranges
- if ranges and size ~= "default" then
- for i=1,#ranges do
- local r = ranges[i]
- if r[1] >= size then -- todo: rounding so maybe size - 100
- return r[2]
+function fontgoodies.designsizes.filename(name,spec,size) -- returns nil of no match
+ if spec and spec ~= "" then
+ local data = designdata[lower(name)]
+ if data then
+ if spec == "default" then
+ return data.default
+ elseif spec == "auto" then
+ local ranges = data.ranges
+ if ranges then
+ for i=1,#ranges do
+ local r = ranges[i]
+ if r[1] >= size then -- todo: rounding so maybe size - 100
+ return r[2]
+ end
+ end
end
+ return data.default or (ranges and ranges[#ranges][2])
end
end
- return data.default or (ranges and ranges[#ranges][2]) or name
end
- return name
end
-- The following file (husayni.lfg) is the experimental setup that we used
diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi
index 7351e7134..ea0c0dedc 100644
--- a/tex/context/base/font-ini.mkvi
+++ b/tex/context/base/font-ini.mkvi
@@ -811,7 +811,7 @@
"\m_font_fallbacks",
0\currentmathsize,
\number\d_font_scaled_text_face,
- "\number\relativefontid", % experiment
+ "\number\relativefontid", % experiment
"\m_font_class_goodies", % experiment (not yet used)
"\m_font_goodies",
"\m_font_class_designsize",
diff --git a/tex/context/base/font-set.mkvi b/tex/context/base/font-set.mkvi
index 2d7a5888e..d692c6cc8 100644
--- a/tex/context/base/font-set.mkvi
+++ b/tex/context/base/font-set.mkvi
@@ -37,14 +37,16 @@
%D runtime we have to load the default bodyfont size just before
%D we start typesetting.
+\def\fallbacktypeface{modern-designsize} % at some point we might prefer just modern
+
\def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont
- {%\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as:
+ {\dorecurse\plusseven{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as:
\ctxcommand{resetnullfont()}% in luatex 0.70 this will also do the previous
\globallet\font_preloads_reset_nullfont\relax}
\def\font_preload_default_fonts
{\font_preloads_reset
- \setupbodyfont[modern,\fontstyle,\fontbody]%
+ \setupbodyfont[\fallbacktypeface,\fontstyle,\fontbody]%
\showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}}
\def\font_preload_default_fonts_mm
@@ -97,6 +99,7 @@
{\ifx\fontclass\empty
\writestatus\m!fonts{preloading latin modern fonts (third stage)}%
\font_preload_default_fonts
+ \font_preloads_reset
\else
\font_preloads_reset
\pushmacro\fontstyle
@@ -138,5 +141,4 @@
% \unexpanded\def\checkpreloadedbodyfont % no \let here
% {\font_preloads_at_start_text}
-
\protect \endinput
diff --git a/tex/context/base/java-imp-rhh.mkiv b/tex/context/base/java-imp-rhh.mkiv
new file mode 100644
index 000000000..5f057f550
--- /dev/null
+++ b/tex/context/base/java-imp-rhh.mkiv
@@ -0,0 +1,34 @@
+%D \module
+%D [ file=java-rhh,
+%D version=2010.02.01,
+%D title=\CONTEXT\ JavaScript Macros,
+%D subtitle=Runtime Highlight Hack,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D As hightlighting is rather intrusive it makes sense to turn it off when
+%D using nice appearances.
+
+% app.runtimeHighlightColor = [ "T" ] ;
+%
+% var SavedAlwaysShowFocus = app.alwaysShowFocus ;
+% app.alwaysShowFocus = true ;
+% "app.alwaysShowFocus = SavedAlwaysShowFocus ; "
+
+\startJSpreamble RuntimeHighlightHack used now
+ var SavedHighlightState = app.runtimeHighlight ;
+ var SavedFocusRectState = app.focusRect ;
+ app.runtimeHighlight = false ;
+ app.focusRect = true ;
+ this.setAction("WillClose",
+ "app.runtimeHighlight = SavedHighlightState ; " +
+ "app.focusRect = SavedFocusRectState ; "
+ ) ;
+\stopJSpreamble
+
+\endinput
diff --git a/tex/context/base/java-ini.lua b/tex/context/base/java-ini.lua
index ff9afe239..1e98de717 100644
--- a/tex/context/base/java-ini.lua
+++ b/tex/context/base/java-ini.lua
@@ -174,7 +174,7 @@ end
function javascripts.flushpreambles()
local t = { }
- if used then
+-- if used then -- we want to be able to enforce inclusion
for i=1,#preambles do
local preamble = preambles[i]
if preamble[2] == "now" then
@@ -184,7 +184,7 @@ function javascripts.flushpreambles()
t[#t+1] = { preamble[1], preamble[3] }
end
end
- end
+-- end
return t
end
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 1777f26de..1aebe4e64 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['lpdf-ano'] = {
-- when using rotation: \disabledirectives[refences.sharelinks] (maybe flag links)
+-- todo: /AA << WC << ... >> >> : WillClose actions etc
+
local next, tostring = next, tostring
local rep, format = string.rep, string.format
local texcount = tex.count
@@ -147,7 +149,7 @@ local function link(url,filename,destination,page,actions)
pdf_fit,
}
}
- else
+ elseif trace_references then
report_reference("invalid page reference: %s",tostring(page))
end
end
diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua
index 1ccf41823..30052538d 100644
--- a/tex/context/base/lpdf-fld.lua
+++ b/tex/context/base/lpdf-fld.lua
@@ -18,6 +18,42 @@ if not modules then modules = { } end modules ['lpdf-fld'] = {
-- generated) MK behaviour built in. So ... hard to test. Unfortunately
-- not even the default appearance is generated. This will probably be
-- solved at some point.
+--
+-- Also, for some reason the viewer does not always show custom appearances
+-- when fields are being rolled over or clicked upon, and circles or checks
+-- pop up when you don't expect them. I fear that this kind of instability
+-- eventually will kill pdf forms. After all, the manual says: "individual
+-- annotation handlers may ignore this entry and provide their own appearances"
+-- and one might wonder what 'individual' means here, but effectively this
+-- renders the whole concept of appearances useless.
+--
+-- Okay, here is one observation. A pdf file contains objects and one might
+-- consider each one to be a static entity when read in. However, acrobat
+-- starts rendering and seems to manipulate (appearance streams) of objects
+-- in place (this is visible when the file is saved again). And, combined
+-- with some other caching and hashing, this might give side effects for
+-- shared objects. So, it seems that for some cases one can best be not too
+-- clever and not share but duplicate information. Of course this defeats the
+-- whole purpose of these objects. Of course I can be wrong.
+--
+-- A rarther weird side effect of the viewer is that the highlighting of fields
+-- obscures values, unless you uses one of the BS variants, and this makes
+-- custum appearances rather useless as there is no way to control this apart
+-- from changing the viewer preferences. It could of course be a bug but it would
+-- be nice if the highlighting was at least transparent. I have no clue why the
+-- built in shapes work ok (some xform based appearances are generated) while
+-- equally valid other xforms fail. It looks like acrobat appearances come on
+-- top (being refered to in the MK) while custom ones are behind the highlight
+-- rectangle. One can disable the "Show border hover color for fields" option
+-- in the preferences. If you load java-imp-rhh this side effect gets disabled
+-- and you get what you expect (it took me a while to figure out this hack).
+--
+-- When highlighting is enabled, those default symbols flash up, so it looks
+-- like we have some inteference between this setting and custom appearances.
+--
+-- Anyhow, the NeedAppearances is really needed in order to get a rendering
+-- for printing especially when highlighting (those colorfull foregrounds) is
+-- on.
local gmatch, lower, format = string.gmatch, string.lower, string.format
local lpegmatch = lpeg.match
@@ -71,7 +107,7 @@ local pdf_widget = pdfconstant("Widget")
local pdf_tx = pdfconstant("Tx")
local pdf_ch = pdfconstant("Ch")
local pdf_btn = pdfconstant("Btn")
-local pdf_yes = pdfconstant("Yes")
+----- pdf_yes = pdfconstant("Yes")
local pdf_off = pdfconstant("Off")
local pdf_p = pdfconstant("P") -- None Invert Outline Push
local pdf_n = pdfconstant("N") -- None Invert Outline Push
@@ -88,31 +124,40 @@ function codeinjections.setformsmethod(name)
submitoutputformat = formats[lower(name)] or formats.xml
end
-local flag = {
- MultiLine = 4096, -- 13
- NoToggleToOff = 16384, -- 15
- Radio = 32768, -- 16
- PushButton = 65536, -- 17
- PopUp = 131072, -- 18
- Edit = 262144, -- 19
- RadiosInUnison = 33554432, -- 26
- DoNotSpellCheck = 4194304, -- 23
- DoNotScroll = 8388608, -- 24
- ReadOnly = 1, -- 1
- Required = 2, -- 2
- NoExport = 4, -- 3
- Password = 8192, -- 14
- Sort = 524288, -- 20
- FileSelect = 1048576, -- 21
+local flag = { -- /Ff
+ ReadOnly = 1, -- 1
+ Required = 2, -- 2
+ NoExport = 4, -- 3
+ MultiLine = 4096, -- 13
+ Password = 8192, -- 14
+ NoToggleToOff = 16384, -- 15
+ Radio = 32768, -- 16
+ PushButton = 65536, -- 17
+ PopUp = 131072, -- 18
+ Edit = 262144, -- 19
+ Sort = 524288, -- 20
+ FileSelect = 1048576, -- 21
+ DoNotSpellCheck = 4194304, -- 23
+ DoNotScroll = 8388608, -- 24
+ Comb = 16777216, -- 25
+ RichText = 33554432, -- 26
+ RadiosInUnison = 33554432, -- 26
+ CommitOnSelChange = 67108864, -- 27
}
-local plus = {
- Invisible = 1, -- 1
- Hidden = 2, -- 2
- Printable = 4, -- 3
- NoView = 32, -- 6
- ToggleNoView = 256, -- 9
- AutoView = 256, -- 288 (6+9)
+local plus = { -- /F
+ Invisible = 1, -- 1
+ Hidden = 2, -- 2
+ Printable = 4, -- 3
+ Print = 4, -- 3
+ NoZoom = 8, -- 4
+ NoRotate = 16, -- 5
+ NoView = 32, -- 6
+ ReadOnly = 64, -- 7
+ Locked = 128, -- 8
+ ToggleNoView = 256, -- 9
+ LockedContents = 512, -- 10,
+ AutoView = 256, -- 288 (6+9)
}
-- todo: check what is interfaced
@@ -132,7 +177,7 @@ plus.auto = plus.AutoView
-- some day .. lpeg with function or table
-local function fieldflag(specification)
+local function fieldflag(specification) -- /Ff
local o, n = specification.option, 0
if o and o ~= "" then
for f in gmatch(o,"[^, ]+") do
@@ -142,13 +187,14 @@ local function fieldflag(specification)
return n
end
-local function fieldplus(specification)
+local function fieldplus(specification) -- /F
local o, n = specification.option, 0
if o and o ~= "" then
for p in gmatch(o,"[^, ]+") do
n = n + (plus[p] or 0)
end
end
+-- n = n + 4
return n
end
@@ -310,11 +356,17 @@ local function fieldappearances(specification)
N = registeredsymbol(n), R = registeredsymbol(r), D = registeredsymbol(d),
}
return pdfshareobjectreference(appearance)
+-- return pdfreference(pdfflushobject(appearance))
end
local YesorOn = "Yes" -- somehow On is not always working out well any longer (why o why this change)
-local function fieldstates(specification,forceyes,values,default)
+-- beware ... maybe we should have unique /Yes1 ... we will probably
+-- change this one too.
+--
+-- TODO: the same as radio .. play safe and use different names.
+
+local function fieldstates_check(specification,forceyes,values,default,yesdefault)
-- we don't use Opt here (too messy for radio buttons)
local values, default = values or specification.values, default or specification.default
if not values or values == "" then
@@ -353,13 +405,13 @@ local function fieldstates(specification,forceyes,values,default)
offn, offr, offd = off[1], off[2], off[3]
end
if not yesvalue then
- yesvalue = yesn
+ yesvalue = yesdefault or yesn
end
if not offvalue then
offvalue = offn
end
if forceyes == true then
- forceyes = forceyes and YesorOn -- spec likes Yes more but we've used On for ages now
+ forceyes = YesorOn -- spec likes Yes more but we've used On for ages now
else
-- false or string
end
@@ -383,6 +435,91 @@ local function fieldstates(specification,forceyes,values,default)
}
end
local appearanceref = pdfshareobjectreference(appearance)
+ -- local appearanceref = pdfreference(pdfflushobject(appearance))
+ return appearanceref, default, yesvalue
+end
+
+-- It looks like there is always a (MK related) symbol used and that
+-- the appearances are only used as ornaments behind a symbol. So,
+-- contrary to what we did when widgets showed up, we now limit
+-- ourself to more dumb definitions. Especially when highlighting is
+-- enabled weird interferences happen. So, we play safe (some nice code
+-- has been removed that worked well till recently).
+
+local function fieldstates_radio(specification,name,parent)
+ local values = values or specification.values
+ local default = default or parent.default -- specification.default
+ if not values or values == "" then
+ -- error
+ return
+ end
+ local v = settings_to_array(values)
+ local yes, off, yesn, yesr, yesd, offn, offr, offd
+ if #v == 1 then
+ yes, off = v[1], v[1]
+ else
+ yes, off = v[1], v[2]
+ end
+ -- yes keys might be the same in the three appearances within a field
+ -- but can best be different among fields ... don't ask why
+ local yessymbols, yesvalue = lpegmatch(splitter,yes) -- n,r,d=>x
+ if not (yessymbols and yesvalue) then
+ yessymbols = yes
+ end
+ if not yesvalue then
+ yesvalue = name
+ end
+ yessymbols = settings_to_array(yessymbols)
+ if #yessymbols == 1 then
+ yesn = yessymbols[1]
+ yesr = yesn
+ yesd = yesr
+ elseif #yessymbols == 2 then
+ yesn = yessymbols[1]
+ yesr = yessymbols[2]
+ yesd = yesr
+ else
+ yesn = yessymbols[1]
+ yesr = yessymbols[2]
+ yesd = yessymbols[3]
+ end
+ -- we don't care about names, as all will be /Off
+ local offsymbols = lpegmatch(splitter,off) or off
+ offsymbols = settings_to_array(offsymbols)
+ if #offsymbols == 1 then
+ offn = offsymbols[1]
+ offr = offn
+ offd = offr
+ elseif #offsymbols == 2 then
+ offn = offsymbols[1]
+ offr = offsymbols[2]
+ offd = offr
+ else
+ offn = offsymbols[1]
+ offr = offsymbols[2]
+ offd = offsymbols[3]
+ end
+ if default == name then
+ default = pdfconstant(name)
+ else
+ default = pdf_off
+ end
+ --
+ local appearance
+ if false then -- needs testing
+ appearance = pdfdictionary { -- maybe also cache components
+ N = pdfshareobjectreference(pdfdictionary { [name] = registeredsymbol(yesn), Off = registeredsymbol(offn) }),
+ R = pdfshareobjectreference(pdfdictionary { [name] = registeredsymbol(yesr), Off = registeredsymbol(offr) }),
+ D = pdfshareobjectreference(pdfdictionary { [name] = registeredsymbol(yesd), Off = registeredsymbol(offd) }),
+ }
+ else
+ appearance = pdfdictionary { -- maybe also cache components
+ N = pdfdictionary { [name] = registeredsymbol(yesn), Off = registeredsymbol(offn) },
+ R = pdfdictionary { [name] = registeredsymbol(yesr), Off = registeredsymbol(offr) },
+ D = pdfdictionary { [name] = registeredsymbol(yesd), Off = registeredsymbol(offd) }
+ }
+ end
+ local appearanceref = pdfshareobjectreference(appearance) -- pdfreference(pdfflushobject(appearance))
return appearanceref, default, yesvalue
end
@@ -433,14 +570,17 @@ local function todingbat(n)
end
end
+-- local zero_bc = pdfarray { 0, 0, 0 }
+-- local zero_bg = pdfarray { 1, 1, 1 }
+
local function fieldrendering(specification)
local bvalue = tonumber(specification.backgroundcolorvalue)
local fvalue = tonumber(specification.framecolorvalue)
local svalue = specification.fontsymbol
if bvalue or fvalue or (svalue and svalue ~= "") then
return pdfdictionary {
- BG = bvalue and pdfarray { lpdf.colorvalues(3,bvalue) } or nil,
- BC = fvalue and pdfarray { lpdf.colorvalues(3,fvalue) } or nil,
+ BG = bvalue and pdfarray { lpdf.colorvalues(3,bvalue) } or nil, -- or zero_bg,
+ BC = fvalue and pdfarray { lpdf.colorvalues(3,fvalue) } or nil, -- or zero_bc,
CA = svalue and pdfstring (svalue) or nil,
}
end
@@ -775,7 +915,10 @@ local function save_kid(field,specification,d,optname)
local kn = pdfreserveannotation()
field.kids[#field.kids+1] = pdfreference(kn)
if optname then
- field.opt[#field.opt+1] = optname
+ local opt = field.opt
+ if opt then
+ opt[#opt+1] = optname
+ end
end
local width, height, depth = specification.width or 0, specification.height or 0, specification.depth
local box = hpack_node(pdfannotation_node(width,height,depth,d(),kn))
@@ -959,7 +1102,7 @@ local function makecheckchild(name,specification)
d.MK = fieldrendering(specification)
return save_kid(parent,specification,d)
else
- local appearance, default, value = fieldstates(field,true)
+ local appearance, default, value = fieldstates_check(field,true)
d.AS = default
d.AP = appearance
return save_kid(parent,specification,d,value)
@@ -1034,18 +1177,78 @@ function methods.push(name,specification)
end
local function makeradioparent(field,specification)
- specification = enhance(specification,"Radio,RadiosInUnison")
+-- specification = enhance(specification,"Radio,RadiosInUnison")
+ specification = enhance(specification,"Radio,RadiosInUnison,Print,NoToggleToOff")
+-- specification = enhance(specification,"Radio,Print,NoToggleToOff")
local d = pdfdictionary {
T = field.name,
FT = pdf_btn,
- F = fieldplus(specification),
+-- F = fieldplus(specification),
Ff = fieldflag(specification),
- H = pdf_n,
+-- H = pdf_n,
V = fielddefault(field),
}
save_parent(field,specification,d,true)
end
+-- local function makeradiochild(name,specification)
+-- local field, parent = clones[name], nil
+-- if field then
+-- field = radios[field.parent]
+-- parent = fields[field.parent]
+-- if not parent.pobj then
+-- if trace_fields then
+-- report_fields("forcing parent radio '%s'",parent.name)
+-- end
+-- makeradioparent(parent,parent)
+-- end
+-- else
+-- field = radios[name]
+-- if not field then
+-- report_fields("there is some problem with field '%s'",name)
+-- return nil
+-- end
+-- parent = fields[field.parent]
+-- if not parent.pobj then
+-- if trace_fields then
+-- report_fields("using parent radio '%s'",name)
+-- end
+-- makeradioparent(parent,parent)
+-- end
+-- end
+-- if trace_fields then
+-- report_fields("using child radio '%s' with values '%s' and default '%s'",name,field.values or "?",field.default or "?")
+-- end
+-- local fontsymbol = specification.fontsymbol
+-- fontsymbol="star"
+-- local d = pdfdictionary {
+-- Subtype = pdf_widget,
+-- Parent = pdfreference(parent.pobj),
+-- F = fieldplus(specification),
+-- OC = fieldlayer(specification),
+-- AA = fieldactions(specification),
+-- H = pdf_n,
+-- }
+-- if fontsymbol and fontsymbol ~= "" then
+-- local appearance, default, value = fieldstates_radio(field,true,false,false,name) -- false is also ok
+-- specification.fontsymbol = todingbat(fontsymbol)
+-- specification.fontstyle = "symbol"
+-- specification.fontalternative = "dingbats"
+-- d.DA = fieldsurrounding(specification)
+-- d.MK = fieldrendering(specification)
+-- d.AS = pdfconstant(value) -- default -- mandate when AP but confuses viewers
+-- d.AP = appearance
+-- return save_kid(parent,specification,d,value)
+-- -- return save_kid(parent,specification,d,name)
+-- else
+-- -- local appearance, default, value = fieldstates_radio(field,true) -- false is also ok
+-- local appearance, default, value = fieldstates_radio(field,true,false,false,name) -- false is also ok
+-- d.AS = default -- mandate when AP but confuses viewers
+-- d.AP = appearance
+-- return save_kid(parent,specification,d,value)
+-- end
+-- end
+
local function makeradiochild(name,specification)
local field, parent = clones[name], nil
if field then
@@ -1075,6 +1278,7 @@ local function makeradiochild(name,specification)
report_fields("using child radio '%s' with values '%s' and default '%s'",name,field.values or "?",field.default or "?")
end
local fontsymbol = specification.fontsymbol
+ -- fontsymbol = "circle"
local d = pdfdictionary {
Subtype = pdf_widget,
Parent = pdfreference(parent.pobj),
@@ -1089,13 +1293,11 @@ local function makeradiochild(name,specification)
specification.fontalternative = "dingbats"
d.DA = fieldsurrounding(specification)
d.MK = fieldrendering(specification)
- return save_kid(parent,specification,d)
- else
- local appearance, default, value = fieldstates(field,true) -- false is also ok
- d.AS = default -- needed ?
- d.AP = appearance
- return save_kid(parent,specification,d,value)
end
+ local appearance, default, value = fieldstates_radio(field,name,fields[field.parent])
+ d.AP = appearance
+ d.AS = default -- /Whatever
+ return save_kid(parent,specification,d,value)
end
function methods.sub(name,specification)
diff --git a/tex/context/base/m-visual.tex b/tex/context/base/m-visual.mkii
index 314630e53..ae52f6571 100644
--- a/tex/context/base/m-visual.tex
+++ b/tex/context/base/m-visual.mkii
@@ -226,7 +226,6 @@
%D test \type{\bodyfontgrid}\space test
%D test \type{\emexgrid} \space test
-
\def\smashedgrid
{\dosingleempty\dosmashedgrid}
diff --git a/tex/context/base/m-visual.mkiv b/tex/context/base/m-visual.mkiv
new file mode 100644
index 000000000..5d259f6ab
--- /dev/null
+++ b/tex/context/base/m-visual.mkiv
@@ -0,0 +1,252 @@
+%D \module
+%D [ file=m-visual,
+%D version=2000.01.10,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Visualization and Faking,
+%D author={Hans Hagen \& Ton Otten},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+%D This module collect a few more visual debugger features. I
+%D needed them for manuals and styles. The macros are documented
+%D in a my way document.
+
+\definecolor[fakerulecolor] [black]
+\definecolor[fakebaselinecolor] [green]
+\definecolor[fakeparindentcolor][blue]
+
+\newif\iffakebaseline \fakebaselinetrue
+
+\unexpanded\def\fakerule#1%
+ {\strut
+ \begingroup
+ \directcolored[fakerulecolor]%
+ \iffakebaseline
+ \vrule\!!height1.25ex\!!depth-.05ex\!!width#1%
+ \kern-#1%
+ \vrule\!!height-.05ex\!!depth .25ex\!!width#1%
+ \else
+ \vrule\!!height1.25ex\!!depth .25ex\!!width#1%
+ \fi
+ \endgroup
+ \allowbreak}
+
+\unexpanded\def\dorandomrecurse#1%
+ {\getrandomcount\scratchcounter{1}{#1}%
+ \dorecurse\scratchcounter}
+
+% can be used in hbox, so %'s are really needed
+
+\unexpanded\def\fakelines#1#2% min max / 3 10
+ {\fakeparindent
+ \scratchdimen\hsize
+ \ifindentation
+ \advance\scratchdimen -\parindent
+ \fi
+ \fakerule\scratchdimen\break
+ \getrandomcount\scratchcounter{\ifcase0#1 3\else#1\fi}{\ifcase0#2 10\else#2\fi}%
+ \dorecurse\scratchcounter{\fakerule\hsize}%
+ \getrandomdimen\scratchdimen{.25\hsize}\hsize
+ \fakerule\scratchdimen
+ \par} % indeed
+
+\unexpanded\def\fakewords
+ {\ifvmode\fakeparindent\fi\onlyfakewords}
+
+\definepalet
+ [fakerule]
+ [fr1c=darkred,
+ fr2c=darkgreen,
+ fr3c=darkblue,
+ fr4c=darkyellow,
+ fr5c=darkgray]
+
+\unexpanded\def\onlyfakewords#1#2% min max / 10 40
+ {\getrandomcount\scratchcounter{\ifcase0#1 10\else#1\fi}{\ifcase0#2 40\else#2\fi}%
+ \dofakewords\scratchcounter
+ } % no \par
+
+\unexpanded\def\fakenwords#1#2% words seed
+ {\fakeparindent
+ \getrandomseed\fakedwordseed
+ \setrandomseed{\ifcase0#2 #1\else#2\fi}%
+ \dofakewords{#1}%
+ \setrandomseed\fakedwordseed
+ } % no \par
+
+\def\dofakewords#1%
+ {\bgroup
+ \dorecurse{#1}
+ {\getrandomcount\scratchcounter{1}{5}%
+ \dorecurse\scratchcounter
+ {\getrandomdimen\scratchdimen{.5em}{1.25em}%
+ \fakerule\scratchdimen}%
+ \space}%
+ \removeunwantedspaces
+ \egroup}
+
+\def\doshowfakewords#1%
+ {\bgroup
+ \setuppalet[fakerule]%
+ \definecolor[fakerulecolor]%
+ \dorecurse{#1}
+ {\getrandomcount\scratchcounter{1}{5}%
+ \dorecurse\scratchcounter
+ {\getrandomdimen\scratchdimen{.5em}{1.25em}%
+ \color[fr\recurselevel c]{\fakerule\scratchdimen}}%
+ \space}%
+ \removeunwantedspaces
+ \egroup}
+
+\unexpanded\def\showfakewords
+ {\let\dofakewords\doshowfakewords}
+
+\unexpanded\def\fakeword
+ {\fakewords{1}{1}} % no \plusone
+
+\unexpanded\def\fakeparindent
+ {\noindent
+ \ifindentation
+ \ifx\dofakedroppedcaps\relax
+ {\fakeparindentcolor
+ \vrule
+ \!!height \strutheight % not longer .5ex
+ \!!depth \strutdepth % not longer 0pt
+ \!!width \parindent}%
+ \else
+ \dofakedroppedcaps \let\dofakedroppedcaps\relax
+ \fi
+% \else
+% \dontleavehmode
+ \fi}
+
+\let\dofakedroppedcaps\relax
+
+\unexpanded\def\fakedroppedcaps#1%
+ {\ifnum#1>0
+ \def\dofakedroppedcaps
+ {\setbox\scratchbox\hbox
+ {\setbox\scratchbox\hbox{W}%
+ \scratchdimen#1\lineheight
+ \advance\scratchdimen -\lineheight
+ \advance\scratchdimen \dp\strutbox
+ \vrule
+ \!!width#1\wd\scratchbox
+ \!!height\ht\scratchbox
+ \!!depth\scratchdimen}%
+ \ht\scratchbox\ht\strutbox
+ \dp\scratchbox\dp\strutbox
+ \hangindent\wd\scratchbox
+ \advance\hangindent .5em
+ \wd\scratchbox\hangindent
+ \hangafter-#1\noindent
+ \llap{\fakeparindentcolor\box\scratchbox}}%
+ \fi}
+
+\unexpanded\def\fakefigure
+ {\dodoubleempty\dofakefigure}
+
+\def\dofakefigure[#1][#2]#3#4#5#6% [] [] minwidth maxwidth minheight maxheight
+ {\getvalue{\e!place\v!figure}
+ [#1][#2]%
+ {\freezerandomseed
+ \let\endstrut\relax
+ \let\begstrut\relax
+ \doifinsetelse{#1}{\v!left,\v!right}
+ {\fakewords{2}{4}}
+ {\fakewords{4}{10}}}%
+ {\doifinset{#1}{\v!left,\v!right}
+ {\dimen0=.75\dimen0
+ \ifdim\dimen0>.6\hsize \dimen0=.5\hsize\fi
+ \ifdim\dimen0<.3\hsize \dimen0=.3\hsize\fi}%
+ \framed
+ [\c!width=\dimen0,
+ \c!height=\dimen2,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=fakeparindentcolor]
+ {\bf\white#1}}%
+ \defrostrandomseed}
+
+\unexpanded\def\fakeimage#1#2#3#4%
+ {\getrandomdimen{\dimen0}{#1}{#3}%
+ \getrandomdimen{\dimen2}{#2}{#4}%
+ \framed
+ [\c!width=\dimen0,
+ \c!height=\dimen2,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=fakeparindentcolor]
+ {}}
+
+\unexpanded\def\fakeformula
+ {\dimen0\zeropoint
+ \getrandomcount\scratchcounter{3}{6}%
+ \dorecurse\scratchcounter
+ {\getrandomdimen\scratchdimen{1em}{3em}%
+ \mathinner{\red\fakerule\scratchdimen}%
+ \ifnum\recurselevel<\scratchcounter+\fi
+ \advance\scratchdimen\dimen0}%
+ =\mathinner{\red\fakerule\scratchdimen}}
+
+\unexpanded\def\fakespacingformula
+ {\color[fakebaselinecolor]{\ruledbaseline}\fakeformula}
+
+%D test \type{\bodyfontgrid}\space test
+%D test \type{\emexgrid} \space test
+
+\unexpanded\def\smashedgrid
+ {\dosingleempty\dosmashedgrid}
+
+\def\dosmashedgrid[#1]%
+ {\hsmashed
+ {\setbox\scratchbox=\hbox
+ {\basegrid
+ [\c!nx=10,\c!ny=10,\c!dx=1,\c!dy=1,
+ \c!unit=\bodyfontsize,#1]}%
+ \hbox to \zeropoint
+ {\hss\lower.5\ht\scratchbox\box\scratchbox\hss}%
+ \hbox to \zeropoint
+ {\hss
+ \black\vrule\!!width6\linewidth\!!height3\linewidth\!!depth3\linewidth
+ \hss}}}
+
+\unexpanded\def\bodyfontgrid
+ {\hbox
+ {{\linewidth.1pt\yellow\smashedgrid[\c!nx=30,\c!ny=30,\c!scale=.3333]}%
+ {\linewidth.2pt\green \smashedgrid[\c!nx=20,\c!ny=20,\c!scale=.5]}%
+ {\linewidth.3pt\red \smashedgrid[\c!nx=10,\c!ny=10,\c!scale=1]}}}
+
+\unexpanded\def\emexgrid
+ {\hbox
+ {{\linewidth.15pt\green\smashedgrid[\c!nx=20,\c!ny=20,\c!unit=ex]}%
+ {\linewidth.15pt\red \smashedgrid[\c!nx=10,\c!ny=10,\c!unit=em]}}}
+
+%D For Mojca:
+
+\unexpanded\def\simplethesis
+ {\setupsystem[random=1234]
+ \title{\fakewords{3}{4}}
+ \placelist[chapter,section]
+ \dorecurse{6}
+ {\chapter{\fakewords{5}{10}}
+ \dorecurse{5}
+ {\section{\fakewords{2}{5}}
+ \dorecurse{2}
+ {\dorecurse{3}{\fakewords{100}{200}\endgraf}
+ \placefigure{\fakewords{8}{15}}{\fakeimage{5cm}{3cm}{10cm}{5cm}}
+ \dorecurse{2}{\fakewords{100}{200}\endgraf}}}}}
+
+\continueifinputfile{m-visual.mkiv}
+
+\starttext
+ \simplethesis
+\stoptext
+
+\protect \endinput
diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua
index cc058bf60..278d323c6 100644
--- a/tex/context/base/math-act.lua
+++ b/tex/context/base/math-act.lua
@@ -14,23 +14,23 @@ local mathematics = mathematics
local sequencers = utilities.sequencers
local appendgroup = sequencers.appendgroup
local appendaction = sequencers.appendaction
-local mathprocessor = nil
-local mathactions = sequencers.reset {
+local mathfontparameteractions = sequencers.new {
+ name = "mathparameters",
arguments = "target,original",
}
+appendgroup("mathparameters","before") -- user
+appendgroup("mathparameters","system") -- private
+appendgroup("mathparameters","after" ) -- user
+
function fonts.constructors.assignmathparameters(original,target)
- if mathactions.dirty then -- maybe use autocompile
- mathprocessor = sequencers.compile(mathactions)
+ local runner = mathfontparameteractions.runner
+ if runner then
+ runner(original,target)
end
- mathprocessor(original,target)
end
-appendgroup(mathactions,"before") -- user
-appendgroup(mathactions,"system") -- private
-appendgroup(mathactions,"after" ) -- user
-
function mathematics.initializeparameters(target,original)
local mathparameters = original.mathparameters
if mathparameters and next(mathparameters) then
@@ -38,7 +38,7 @@ function mathematics.initializeparameters(target,original)
end
end
-sequencers.appendaction(mathactions,"system","mathematics.initializeparameters")
+sequencers.appendaction("mathparameters","system","mathematics.initializeparameters")
local how = {
-- RadicalKernBeforeDegree = "horizontal",
@@ -50,9 +50,9 @@ local how = {
function mathematics.scaleparameters(target,original)
if not target.properties.math_is_scaled then
--- print("\n",target.properties.fontname)
--- print(original.mathparameters.DisplayOperatorMinHeight)
--- print(target.mathparameters.DisplayOperatorMinHeight)
+ -- print("\n",target.properties.fontname)
+ -- print(original.mathparameters.DisplayOperatorMinHeight)
+ -- print(target.mathparameters.DisplayOperatorMinHeight)
local mathparameters = target.mathparameters
if mathparameters and next(mathparameters) then
local parameters = target.parameters
@@ -70,18 +70,18 @@ function mathematics.scaleparameters(target,original)
else
value = value * factor
end
--- if name == "DisplayOperatorMinHeight" then
--- report_math("f: %s, p: %s, h: %s, b: %s, a: %s",target.properties.fontname,name,h or "scaled",mathparameters[name],value)
--- end
+ -- if name == "DisplayOperatorMinHeight" then
+ -- report_math("f: %s, p: %s, h: %s, b: %s, a: %s",target.properties.fontname,name,h or "scaled",mathparameters[name],value)
+ -- end
mathparameters[name] = value
end
end
--- print(mathparameters.DisplayOperatorMinHeight)
+ -- print(mathparameters.DisplayOperatorMinHeight)
target.properties.math_is_scaled = true
end
end
-sequencers.appendaction(mathactions,"system","mathematics.scaleparameters")
+sequencers.appendaction("mathparameters","system","mathematics.scaleparameters")
function mathematics.checkaccentbaseheight(target,original)
local mathparameters = target.mathparameters
@@ -90,7 +90,7 @@ function mathematics.checkaccentbaseheight(target,original)
end
end
-sequencers.appendaction(mathactions,"system","mathematics.checkaccentbaseheight")
+sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight")
function mathematics.checkprivateparameters(target,original)
local mathparameters = target.mathparameters
@@ -104,7 +104,7 @@ function mathematics.checkprivateparameters(target,original)
end
end
-sequencers.appendaction(mathactions,"system","mathematics.checkprivateparameters")
+sequencers.appendaction("mathparameters","system","mathematics.checkprivateparameters")
function mathematics.overloadparameters(target,original)
local mathparameters = target.mathparameters
@@ -149,4 +149,56 @@ function mathematics.overloadparameters(target,original)
end
end
-sequencers.appendaction(mathactions,"system","mathematics.overloadparameters")
+sequencers.appendaction("mathparameters","system","mathematics.overloadparameters")
+
+local function applytweaks(when,target,original)
+ local goodies = original.goodies
+ if goodies then
+ for i=1,#goodies do
+ local goodie = goodies[i]
+ local mathematics = goodie.mathematics
+ local tweaks = mathematics and mathematics.tweaks
+ if tweaks then
+ tweaks = tweaks[when]
+ if tweaks then
+ if trace_defining then
+ report_math("tweaking math of '%s' @ %s (%s)",target.properties.fullname,target.parameters.size,when)
+ end
+ for i=1,#tweaks do
+ local tweak= tweaks[i]
+ local tvalue = type(tweak)
+ if tvalue == "function" then
+ tweak(target,original)
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+function mathematics.tweakbeforecopyingfont(target,original)
+ local mathparameters = target.mathparameters -- why not hasmath
+ if mathparameters then
+ applytweaks("beforecopying",target,original)
+ end
+end
+
+function mathematics.tweakaftercopyingfont(target,original)
+ local mathparameters = target.mathparameters -- why not hasmath
+ if mathparameters then
+ applytweaks("aftercopying",target,original)
+ end
+end
+
+sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont")
+sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaftercopyingfont")
+
+-- a couple of predefined tewaks:
+
+local tweaks = { }
+mathematics.tweaks = tweaks
+
+function tweaks.fixbadprime(target,original)
+ target.characters[0xFE325] = target.characters[0x2032]
+end
diff --git a/tex/context/base/math-def.mkiv b/tex/context/base/math-def.mkiv
index 96c122f51..43a511e43 100644
--- a/tex/context/base/math-def.mkiv
+++ b/tex/context/base/math-def.mkiv
@@ -270,7 +270,7 @@
%D Now we define all the colon relations .. needs checking with char-def.lua:
-\definemathcommand [centercolon] [rel] {\mathpalette\vcenter{\hbox{$\mathsurround\zeropoint\colon$}}}
+\definemathcommand [centercolon] [rel] {\mathstylevcenteredhbox\colon}
\definemathcommand [colonminus] [rel] {\centercolon\colonsep\mathrel{-}}
\definemathcommand [minuscolon] [rel] {\mathrel{-}\colonsep\centercolon}
\definemathcommand [colonequals] [rel] {\centercolon\colonsep=}
diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua
index 663f6bb1e..54452282b 100644
--- a/tex/context/base/math-ini.lua
+++ b/tex/context/base/math-ini.lua
@@ -134,16 +134,19 @@ local escapes = characters.filters.utf.private.escapes
local setmathcharacter, setmathsynonym, setmathsymbol -- once updated we will inline them
+-- beware ... we only set the math character once ... which is why we
+-- have the 'done' checking below
+
if setmathcode then
- setmathcharacter = function(class,family,slot,unicode,firsttime)
- if not firsttime and class <= 7 then
+ setmathcharacter = function(class,family,slot,unicode)
+ if class <= 7 then
setmathcode(slot,{class,family,unicode or slot})
end
end
- setmathsynonym = function(class,family,slot,unicode,firsttime)
- if not firsttime and class <= 7 then
+ setmathsynonym = function(class,family,slot,unicode,setcode)
+ if setcode and class <= 7 then
setmathcode(slot,{class,family,unicode})
end
if class == classes.open or class == classes.close then
@@ -180,14 +183,14 @@ if setmathcode then
else
- setmathcharacter = function(class,family,slot,unicode,firsttime)
- if not firsttime and class <= 7 then
+ setmathcharacter = function(class,family,slot,unicode)
+ if class <= 7 then
contextsprint(mathcode(slot,class,family,unicode or slot))
end
end
- setmathsynonym = function(class,family,slot,unicode,firsttime)
- if not firsttime and class <= 7 then
+ setmathsynonym = function(class,family,slot,unicode,setcode)
+ if setcode and class <= 7 then
contextsprint(mathcode(slot,class,family,unicode))
end
if class == classes.open or class == classes.close then
@@ -241,6 +244,7 @@ function mathematics.define(family)
local data = characters.data
for unicode, character in next, data do
local symbol = character.mathsymbol
+ local setcode = true
if symbol then
local other = data[symbol]
local class = other.mathclass
@@ -249,7 +253,8 @@ function mathematics.define(family)
if trace_defining then
report(class,family,unicode,symbol)
end
- setmathsynonym(class,family,unicode,symbol)
+ setmathsynonym(class,family,unicode,symbol,setcode)
+ setcode = false
end
local spec = other.mathspec
if spec then
@@ -257,7 +262,8 @@ function mathematics.define(family)
local class = m.class
if class then
class = classes[class] or class -- no real checks needed
- setmathsynonym(class,family,unicode,symbol,i)
+ setmathsynonym(class,family,unicode,symbol,setcode)
+ setcode = false
end
end
end
@@ -288,7 +294,10 @@ function mathematics.define(family)
end
end
end
- setmathcharacter(class,family,unicode,unicode,i)
+ if setcode then
+ setmathcharacter(class,family,unicode,unicode)
+ setcode = false
+ end
end
end
end
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index 0e65c8d28..fa29e49c2 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -579,6 +579,8 @@
%
% \typebuffer \getbuffer
+% most math fonts have messed up primes, just test this: $\prime^{\prime^{\prime}}$
+
{ \catcode\circumflexasciicode\othercatcode \global\let\othercircumflextoken ^ }
{ \catcode\circumflexasciicode\superscriptcatcode \global\let\superscriptcircumflextoken^ }
@@ -589,8 +591,9 @@
\let\math_prime_indeed_normal\prime
\appendtoks
- \let\math_prime_indeed_normal\prime % gets defined later
- \let\prime\math_prime_indeed % so this is needed
+ \let\math_prime_indeed_normal\prime % gets defined later
+ \let\mathfontprime\prime % for tracing
+ \let\prime\math_prime_indeed % so this is needed
\to \everydump
\unexpanded\def\math_prime_indeed
@@ -984,6 +987,34 @@
{#1\scriptstyle {#2}}%
{#1\scriptscriptstyle{#2}}}
+%D Often we can use:
+%D
+%D \startbuffer
+%D $x^{\mathstylehbox{x^{\mathstylehbox{x}}}}$
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\unexpanded\def\mathstylehbox#1%
+ {\normalexpanded{\hbox\bgroup
+ $\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1$\egroup}
+
+\unexpanded\def\mathstylevbox#1%
+ {\normalexpanded{\vbox\bgroup
+ $\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1$\egroup}
+
+\unexpanded\def\mathstylevcenter#1%
+ {\normalexpanded{\vcenter\bgroup
+ $\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1$\egroup}
+
+\unexpanded\def\mathstylevcenteredhbox#1%
+ {\normalexpanded{\vcenter\bgroup\hbox\bgroup
+ $\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1$\egroup\egroup}
+
+\unexpanded\def\mathstylevcenteredvbox#1%
+ {\normalexpanded{\vcenter\bgroup\vbox\bgroup
+ $\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1$\egroup\egroup}
+
%D Something similar can be used in the (re|)|definition
%D of \type {\text}. This version is a variation on the one
%D in the math module (see \type{m-math} and|/|or \type
diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua
index fe50b4703..8caf21cc2 100644
--- a/tex/context/base/math-noa.lua
+++ b/tex/context/base/math-noa.lua
@@ -38,7 +38,7 @@ local trace_collapsing = false trackers.register("math.collapsing", functio
local trace_goodies = false trackers.register("math.goodies", function(v) trace_goodies = v end)
local trace_variants = false trackers.register("math.variants", function(v) trace_variants = v end)
local trace_italics = false trackers.register("math.italics", function(v) trace_italics = v end)
-local trace_italics = false trackers.register("math.families", function(v) trace_families = v end)
+local trace_families = false trackers.register("math.families", function(v) trace_families = v end)
local check_coverage = true directives.register("math.checkcoverage", function(v) check_coverage = v end)
@@ -57,6 +57,7 @@ local mlist_to_hlist = node.mlist_to_hlist
local font_of_family = node.family_font
local insert_node_after = node.insert_after
local free_node = node.free
+local new_node = node.new -- todo: pool: math_noad math_sub
local new_kern = nodes.pool.kern
@@ -389,7 +390,7 @@ respace[math_char] = function(pointer,what,n,parent) -- not math_noad .. math_ch
local lc = chardata[last_char]
lc = lc and lc.category
if lc == "nd" or lc == "ll" or lc == "lu" then
- local ord = node.new(math_noad) -- todo: pool
+ local ord = new_node(math_noad) -- todo: pool
ord.subtype, ord.nucleus, ord.sub, ord.sup, ord.attr = noad_ord, next_noad.nucleus, next_noad.sub, next_noad.sup, next_noad.attr
-- next_noad.nucleus, next_noad.sub, next_noad.sup, next_noad.attr = nil, nil, nil, nil
next_noad.nucleus, next_noad.sub, next_noad.sup = nil, nil, nil -- else crash with attributes ref count
@@ -545,7 +546,7 @@ local function replace(pointer,what,n,parent)
if start_super == stop_super then
pointer.sup = start_super.nucleus
else
- local list = node.new(math_sub) -- todo attr
+ local list = new_node(math_sub) -- todo attr
list.head = start_super
pointer.sup = list
end
@@ -558,7 +559,7 @@ local function replace(pointer,what,n,parent)
if start_sub == stop_sub then
pointer.sub = start_sub.nucleus
else
- local list = node.new(math_sub) -- todo attr
+ local list = new_node(math_sub) -- todo attr
list.head = start_sub
pointer.sub = list
end
@@ -933,12 +934,13 @@ end
tasks.new {
name = "math",
arguments = 2,
+ processor = utilities.sequencers.nodeprocessor,
sequence = {
"before",
"normalizers",
"builders",
"after",
- }
+ },
}
tasks.freezegroup("math", "normalizers") -- experimental
diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv
index 366d69d97..f117b6b3d 100644
--- a/tex/context/base/meta-pag.mkiv
+++ b/tex/context/base/meta-pag.mkiv
@@ -86,23 +86,17 @@
\def\MPonrightpage{true}
\def\MPonoddpage {true}
-% obsolete (but keep the code)
-%
-% \def\freezeMPpagelayout
-% {\edef\MPonrightpage{\doifbothsides {tru}{tru}{fals}e}%
-% \edef\MPonoddpage {\doifoddpageelse {tru}{fals}e}}
-%
-% \let\freezeMPlayout\relax % obsolete
+\def\freezeMPpagelayout
+ {\edef\MPonrightpage{\doifbothsides {tru}{tru}{fals}e}%
+ \edef\MPonoddpage {\doifoddpageelse {tru}{fals}e}}
%D We need to freeze the pagelayout before the backgrounds
%D are build, because the overlay will temporarily become
%D zero (overlay).
-% obsolete (but keep the code)
-%
-% \appendtoks
-% \freezeMPpagelayout
-% \to \everybeforepagebody
+\appendtoks
+ \freezeMPpagelayout
+\to \everybeforepagebody
%D By freezing these value every graphic, we can use layout
%D variables that change halfways a page, whatever use that
@@ -144,62 +138,17 @@
\newtoks\MPsavedtextareadata
\newtoks\MPtextareadata
\newtoks\MPlocaltextareadata
+\newtoks\MPregionareadata
% optimaliseren voor herhaling
\newif\iftracetextareas
-% \def\registerMPtextarea#1%
-% {\ifpositioning
-% \bgroup
-% \global\advance\currentMPtextareadata\plusone
-% %\hpos{gbd:\the\currentMPtextareadata}{#1}%
-% \hpos{gbd:\the\currentMPtextareadata}%
-% {\iftracetextareas\boxrulewidth1.5pt\ruledhbox\fi{#1}}%
-% \edef\!!stringa{gbd:\the\currentMPtextareadata}%
-% \edef\!!stringa{RegisterTextArea(%
-% \MPx\!!stringa,\MPy\!!stringa,%
-% \MPw\!!stringa,\MPh\!!stringa,\MPd\!!stringa);}%
-% \@EA \doglobal \@EA \appendtoks \!!stringa \to \MPtextareadata
-% \egroup
-% \else
-% \hbox{#1}%
-% \fi}
-
-% \def\registerMPlocaltextarea#1%
-% {\ifpositioning
-% \bgroup
-% \global\advance\currentMPtextareadata\plusone
-% %\hpos{gbd:\the\currentMPtextareadata}{#1}%
-% \hpos{gbd:\the\currentMPtextareadata}%
-% {\iftracetextareas\boxrulewidth3pt\ruledhbox\fi{#1}}%
-% \edef\!!stringa{gbd:\the\currentMPtextareadata}%
-% \edef\!!stringa{RegisterLocalTextArea(%
-% \MPx\!!stringa,\MPy\!!stringa,%
-% \MPw\!!stringa,\MPh\!!stringa,\MPd\!!stringa);}%
-% \global\MPlocaltextareadata\@EA{\!!stringa}%
-% \egroup
-% \else
-% \hbox{#1}%
-% \fi}
-
\unexpanded\def\globalregisterMPtextarea{\normalexpanded{\global\MPtextareadata{\the\MPtextareadata
- RegisterTextArea(%
- \MPx\currentMPtextarea,%
- \MPy\currentMPtextarea,%
- \MPw\currentMPtextarea,%
- \MPh\currentMPtextarea,%
- \MPd\currentMPtextarea%
- );}}}
+ RegisterTextArea(\MPxywhd\currentMPtextarea);}}}
\unexpanded\def\localregisterMPtextarea{\normalexpanded{\global\MPlocaltextareadata{%
- RegisterLocalTextArea(%
- \MPx\currentMPtextarea,%
- \MPy\currentMPtextarea,%
- \MPw\currentMPtextarea,%
- \MPh\currentMPtextarea,%
- \MPd\currentMPtextarea%
- );}}}
+ RegisterLocalTextArea(\MPxywhd\currentMPtextarea);}}}
\unexpanded\def\registerMPtextareaindeed#1#2%
{\ifpositioning
@@ -219,10 +168,6 @@
\unexpanded\def\resetMPlocaltextarea
{\global\MPlocaltextareadata\emptytoks}
-\startMPextensions
- path PlainTextArea;
-\stopMPextensions
-
\startMPinitializations
ResetTextAreas;
\the\MPsavedtextareadata;
@@ -230,8 +175,8 @@
ResetTextAreas;
\the\MPtextareadata;
\the\MPlocaltextareadata;
- PlainTextArea:=boundingbox(\MPxy{text:\realfolio}--\MPxy{text:\realfolio}
- shifted (\MPw{text:\realfolio},\MPh{text:\realfolio}));
+ RegisterPlainTextArea(\MPxywhd\textanchor);
+ RegisterRegionTextArea(\MPxywhd\regionanchor);
\stopMPinitializations
\appendtoks
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index 0827b43c0..deac9d51a 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -274,9 +274,9 @@ function metapost.flush(result,flusher,askedfig)
local figures = result.fig
if figures then
flusher = flusher or metapost.flushers.pdf
- local resetplugins = metapost.resetplugins or ignore
- local processplugins = metapost.processplugins or ignore
- local pluginactions = metapost.pluginactions or ignore
+ local resetplugins = metapost.resetplugins or ignore -- before figure
+ local processplugins = metapost.processplugins or ignore -- each object
+ local pluginactions = metapost.pluginactions or ignore -- before / after
local startfigure = flusher.startfigure
local stopfigure = flusher.stopfigure
local flushfigure = flusher.flushfigure
@@ -447,7 +447,7 @@ function metapost.parse(result,askedfig)
if result then
local figures = result.fig
if figures then
- local analyzeplugins = metapost.analyzeplugins
+ local analyzeplugins = metapost.analyzeplugins -- each object
for f=1, #figures do
local figure = figures[f]
local fignum = figure:charcode() or 0
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 85766a866..e6459df05 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -624,9 +624,9 @@ local resetter = nil
local analyzer = nil
local processor = nil
-local resetteractions = sequencers.reset { arguments = "" }
-local analyzeractions = sequencers.reset { arguments = "object,prescript" }
-local processoractions = sequencers.reset { arguments = "object,prescript,before,after" }
+local resetteractions = sequencers.new { arguments = "" }
+local analyzeractions = sequencers.new { arguments = "object,prescript" }
+local processoractions = sequencers.new { arguments = "object,prescript,before,after" }
appendgroup(resetteractions, "system")
appendgroup(analyzeractions, "system")
@@ -654,12 +654,12 @@ local function splitscript(script)
return hash
end
-function metapost.pluginactions(what,t,flushfigure) -- to be checked: too many 0 g 0 G
+function metapost.pluginactions(what,t,flushfigure) -- before/after object, depending on what
for i=1,#what do
local wi = what[i]
if type(wi) == "function" then
-- assume injection
- flushfigure(t)
+ flushfigure(t) -- to be checked: too many 0 g 0 G
t = { }
wi()
else
@@ -669,18 +669,23 @@ function metapost.pluginactions(what,t,flushfigure) -- to be checked: too many 0
return t
end
-function metapost.resetplugins()
+function metapost.resetplugins() -- intialize plugins, before figure
+ -- plugins can have been added
+ resetter = resetteractions .runner
+ analyzer = analyzeractions .runner
+ processor = processoractions.runner
+ -- let's apply one runner
resetter()
end
-function metapost.analyzeplugins(object)
+function metapost.analyzeplugins(object) -- each object (first pass)
local prescript = object.prescript -- specifications
if prescript and #prescript > 0 then
return analyzer(object,splitscript(prescript))
end
end
-function metapost.processplugins(object) -- maybe environment table
+function metapost.processplugins(object) -- each object (second pass)
local prescript = object.prescript -- specifications
if prescript and #prescript > 0 then
local before = { }
@@ -1048,8 +1053,8 @@ appendaction(processoractions,"system",tr_process) -- last, as color can be rese
appendaction(processoractions,"system",la_process)
--- no auto here
+-- we're nice and set them already
-resetter = sequencers.compile(resetteractions )
-analyzer = sequencers.compile(analyzeractions )
-processor = sequencers.compile(processoractions)
+resetter = resetteractions .runner
+analyzer = analyzeractions .runner
+processor = processoractions.runner
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index af36a1e19..b4c6ad039 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -206,7 +206,7 @@
\unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
{\ifx#2\relax\let#2\empty\fi
\unexpanded\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
- \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
+ \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
\unexpanded\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2
\unexpanded\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1
@@ -264,11 +264,6 @@
\edef#8{##2}%
\mult_interfaces_get_parameters{#1#4:}[\s!parent=#1##2,##3]%
\else\ifsecondargument
-% \doifassignmentelse{##2}
-% {\let#8\empty
-% \mult_interfaces_get_parameters{#1#4:}[\s!parent=#3,##2]}
-% {\edef#8{##2}%
-% \mult_interfaces_get_parameters{#1#4:}[\s!parent=#1##2]}%
\mult_check_for_assignment##2=@@\_end_
\ifassignment
\let#8\empty
@@ -297,11 +292,12 @@
\expandafter\noexpand\csname current#2parent\endcsname
\expandafter\noexpand\csname saved_defined_#2\endcsname}}
-\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7%
+\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
\unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
\newtoks#5%
+ \newtoks#8%
\def#4[##1][##2]% maybe helper
{\let#7#3%
\ifsecondargument
@@ -315,7 +311,8 @@
\mult_interfaces_get_parameters{#1:}[##1]%
\the#5%
\fi
- \let#3#7}}
+ \let#3#7%
+ \the#8}}
\unexpanded\def\installsetuphandler#1#2%
{\normalexpanded
@@ -326,7 +323,8 @@
\expandafter\noexpand\csname setup_#2\endcsname % semi-public
\expandafter\noexpand\csname everysetup#2\endcsname
\expandafter\noexpand\csname setupcurrent#2\endcsname
- \expandafter\noexpand\csname saved_setup_current#2\endcsname}}
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname
+ \expandafter\noexpand\csname everysetup#2root\endcsname}}
\let\doingrootsetupnamed\plusone % \setuplayout[name][key=value]
\let\doingrootsetuproot \plustwo % \setuplayout [key=value]
@@ -338,10 +336,11 @@
\unexpanded\def#2{\dodoubleempty#4}%
\unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}}
-\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8%
+\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
{\newtoks#5%
\newconstant#2%
\newtoks#8%
+ \newtoks#9%
\ifx#6\relax\let#6\empty\fi
\def#4[##1][##2]% maybe helper
{\ifsecondargument % no commalist here
@@ -382,7 +381,8 @@
\the#5%
\the#8% switchsetups
\fi\fi
- #2\zerocount}} % mode is always zero at the end
+ #2\zerocount % mode is always zero at the end
+ \the#9}}
\unexpanded\def\installswitchsetuphandler#1#2%
{\normalexpanded
@@ -400,7 +400,8 @@
\expandafter\noexpand\csname everysetup#2\endcsname
\expandafter\noexpand\csname previous#2\endcsname
\expandafter\noexpand\csname saved_setup_current#2\endcsname
- \expandafter\noexpand\csname everyswitch#2\endcsname}}
+ \expandafter\noexpand\csname everyswitch#2\endcsname
+ \expandafter\noexpand\csname everysetup#2root\endcsname}}
\unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8%
{\ifx#3\relax\let#3\empty\fi
diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii
index 78421a5d2..98c60cb07 100644
--- a/tex/context/base/mult-de.mkii
+++ b/tex/context/base/mult-de.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{titelausrichten}
\setinterfaceconstant{alternative}{alternative}
+\setinterfaceconstant{anchor}{anchor}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{pfeil}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{referenz}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{referieren}
+\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{regionin}
\setinterfaceconstant{regionout}{regionaus}
\setinterfaceconstant{repeat}{wiederholen}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{textfarbe}
\setinterfaceconstant{textcommand}{textbefehl}
\setinterfaceconstant{textdistance}{textdistance}
+\setinterfaceconstant{textheight}{texthoehe}
\setinterfaceconstant{textlayer}{textlayer}
\setinterfaceconstant{textmargin}{textmargin}
\setinterfaceconstant{textmethod}{textmethod}
diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua
index d311452f8..1af1c969c 100644
--- a/tex/context/base/mult-def.lua
+++ b/tex/context/base/mult-def.lua
@@ -6449,6 +6449,10 @@ return {
},
},
["constants"]={
+ ["anchor"]={
+ ["en"]="anchor",
+ ["nl"]="anker",
+ },
["buffer"]={
["en"]="buffer",
},
@@ -7529,7 +7533,7 @@ return {
["en"]="directory",
["fr"]="repertoire",
["it"]="directory",
- ["nl"]="gebied",
+ ["nl"]="directory",
["pe"]="پوشه",
["ro"]="director",
},
@@ -9589,6 +9593,10 @@ return {
["pe"]="مراجعه",
["ro"]="referinta",
},
+ ["region"]={
+ ["en"]="region",
+ ["nl"]="gebied",
+ },
["regionin"]={
["cs"]="oblastuvnitr",
["de"]="regionin",
@@ -10561,6 +10569,16 @@ return {
["pe"]="سبک‌متن",
["ro"]="stiltext",
},
+ ["textheight"]={
+ ["cs"]="vyskatextu",
+ ["de"]="texthoehe",
+ ["en"]="textheight",
+ ["fr"]="hauteurtexte",
+ ["it"]="altezzatesto",
+ ["nl"]="teksthoogte",
+ ["pe"]="ارتفاع‌متن",
+ ["ro"]="inaltimetext",
+ },
["textwidth"]={
["cs"]="sirkatextu",
["de"]="textbreite",
diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii
index 821315097..681fb2a3a 100644
--- a/tex/context/base/mult-en.mkii
+++ b/tex/context/base/mult-en.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{aligntitle}
\setinterfaceconstant{alternative}{alternative}
+\setinterfaceconstant{anchor}{anchor}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{arrow}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{reference}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{referencing}
+\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{regionin}
\setinterfaceconstant{regionout}{regionout}
\setinterfaceconstant{repeat}{repeat}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{textcolor}
\setinterfaceconstant{textcommand}{textcommand}
\setinterfaceconstant{textdistance}{textdistance}
+\setinterfaceconstant{textheight}{textheight}
\setinterfaceconstant{textlayer}{textlayer}
\setinterfaceconstant{textmargin}{textmargin}
\setinterfaceconstant{textmethod}{textmethod}
diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii
index 6a9275c1a..fa545c424 100644
--- a/tex/context/base/mult-fr.mkii
+++ b/tex/context/base/mult-fr.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{alignementtitre}
\setinterfaceconstant{alternative}{alternative}
+\setinterfaceconstant{anchor}{anchor}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{fleche}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{reference}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{referencing}
+\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{entreregion}
\setinterfaceconstant{regionout}{regionexterieure}
\setinterfaceconstant{repeat}{repete}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{couleurtexte}
\setinterfaceconstant{textcommand}{commandetexte}
\setinterfaceconstant{textdistance}{distancetexte}
+\setinterfaceconstant{textheight}{hauteurtexte}
\setinterfaceconstant{textlayer}{calquetexte}
\setinterfaceconstant{textmargin}{margetexte}
\setinterfaceconstant{textmethod}{textmethod}
diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii
index 2431539b9..34fa737e9 100644
--- a/tex/context/base/mult-it.mkii
+++ b/tex/context/base/mult-it.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{allineatitolo}
\setinterfaceconstant{alternative}{alternativa}
+\setinterfaceconstant{anchor}{anchor}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{freccia}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{riferimento}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{referencing}
+\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{entraregione}
\setinterfaceconstant{regionout}{esciregione}
\setinterfaceconstant{repeat}{ripeti}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{coloretesto}
\setinterfaceconstant{textcommand}{comandotesto}
\setinterfaceconstant{textdistance}{distanzatesto}
+\setinterfaceconstant{textheight}{altezzatesto}
\setinterfaceconstant{textlayer}{textlayer}
\setinterfaceconstant{textmargin}{textmargin}
\setinterfaceconstant{textmethod}{textmethod}
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index 2a68e0cc7..c08247afd 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -97,11 +97,17 @@ return {
"starttext", "stoptext", "startdocument", "stopdocument", "documentvariable",
"startmodule", "stopmodule", "usemodule",
--
+ "enablemode", "disablemode", "preventmode", "pushmode", "popmode",
+ --
"typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix",
--
"mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode",
"mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode",
"mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode",
+ --
+ "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument",
+ --
+ "continueifinputfile",
},
["helpers"] = {
--
@@ -114,11 +120,19 @@ return {
"starttexdefinition", "stoptexdefinition",
"starttexcode", "stoptexcode",
--
+ "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup",
+ --
+ "newmode", "setmode", "resetmode",
+ "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode",
+ "booleanmodevalue",
+ --
"newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif",
"newlanguage", "newfamily", "newfam", "newhelp", -- not used
--
"then",
--
+ "donothing", "dontcomplain",
+ --
"donetrue", "donefalse",
--
"htdp",
@@ -182,7 +196,7 @@ return {
--
"singleexpandafter", "doubleexpandafter", "tripleexpandafter",
--
- "dontleavehmode",
+ "dontleavehmode", "removelastspace", "removeunwantedspaces",
--
"wait", "writestatus", "define", "redefine",
--
@@ -228,6 +242,6 @@ return {
--
"startnointerference", "stopnointerference",
--
- "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd",
+ "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut",
}
}
diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii
index f8178762b..5d1d4dc12 100644
--- a/tex/context/base/mult-nl.mkii
+++ b/tex/context/base/mult-nl.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{titeluitlijnen}
\setinterfaceconstant{alternative}{variant}
+\setinterfaceconstant{anchor}{anker}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{pijl}
@@ -636,7 +637,7 @@
\setinterfaceconstant{depth}{diepte}
\setinterfaceconstant{depthcorrection}{dieptecorrectie}
\setinterfaceconstant{direction}{richting}
-\setinterfaceconstant{directory}{gebied}
+\setinterfaceconstant{directory}{directory}
\setinterfaceconstant{display}{scherm}
\setinterfaceconstant{distance}{afstand}
\setinterfaceconstant{dot}{punt}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{verwijzing}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{refereren}
+\setinterfaceconstant{region}{gebied}
\setinterfaceconstant{regionin}{gebiedin}
\setinterfaceconstant{regionout}{gebieduit}
\setinterfaceconstant{repeat}{herhaal}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{tekstkleur}
\setinterfaceconstant{textcommand}{tekstcommando}
\setinterfaceconstant{textdistance}{tekstafstand}
+\setinterfaceconstant{textheight}{teksthoogte}
\setinterfaceconstant{textlayer}{tekstlaag}
\setinterfaceconstant{textmargin}{tekstmarge}
\setinterfaceconstant{textmethod}{tekstmethode}
diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii
index 98bfcb4d1..5c7da3b11 100644
--- a/tex/context/base/mult-pe.mkii
+++ b/tex/context/base/mult-pe.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{عنوان‌تنظیم}
\setinterfaceconstant{alternative}{جایگزین}
+\setinterfaceconstant{anchor}{anchor}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{پیکان}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{مرجع}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{مراجعه}
+\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{ناحیه‌درون}
\setinterfaceconstant{regionout}{ناحیه‌بیرون}
\setinterfaceconstant{repeat}{تکرار}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{رنگ‌متن}
\setinterfaceconstant{textcommand}{فرمان‌متن}
\setinterfaceconstant{textdistance}{فاصله‌متن}
+\setinterfaceconstant{textheight}{ارتفاع‌متن}
\setinterfaceconstant{textlayer}{لایه‌متن}
\setinterfaceconstant{textmargin}{حاشیه‌متن}
\setinterfaceconstant{textmethod}{روش‌متن}
diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii
index d16f1cc7b..2590b5eed 100644
--- a/tex/context/base/mult-ro.mkii
+++ b/tex/context/base/mult-ro.mkii
@@ -537,6 +537,7 @@
\setinterfaceconstant{alignsymbol}{alignsymbol}
\setinterfaceconstant{aligntitle}{alinieretitlu}
\setinterfaceconstant{alternative}{alternativ}
+\setinterfaceconstant{anchor}{anchor}
\setinterfaceconstant{andtext}{andtext}
\setinterfaceconstant{apa}{apa}
\setinterfaceconstant{arrow}{sageata}
@@ -898,6 +899,7 @@
\setinterfaceconstant{reference}{referinta}
\setinterfaceconstant{referenceprefix}{referenceprefix}
\setinterfaceconstant{referencing}{referinta}
+\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{regiuneintrare}
\setinterfaceconstant{regionout}{regiuneiesire}
\setinterfaceconstant{repeat}{repeta}
@@ -1001,6 +1003,7 @@
\setinterfaceconstant{textcolor}{culoaretext}
\setinterfaceconstant{textcommand}{comandatext}
\setinterfaceconstant{textdistance}{textdistance}
+\setinterfaceconstant{textheight}{inaltimetext}
\setinterfaceconstant{textlayer}{textlayer}
\setinterfaceconstant{textmargin}{textmargin}
\setinterfaceconstant{textmethod}{textmethod}
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index b9bb640e8..beb069a23 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -250,6 +250,7 @@
\definesystemconstant {counter}
\definesystemconstant {single}
\definesystemconstant {multi}
+\definesystemconstant {indeed}
\definesystemconstant {hasnumber}
\definesystemconstant {hastitle}
@@ -485,7 +486,6 @@
\definesystemvariable {gi} % Graphic Instance
\definesystemvariable {gv} % Graphic Variable
\definesystemvariable {ha} % HAng
-\definesystemvariable {hf} % Helpers Framed
\definesystemvariable {id} % Index
\definesystemvariable {ih} % InHoudsopgave
\definesystemvariable {il} % stelInvulRegelsin
@@ -566,7 +566,6 @@
\definesystemvariable {xp} % XML Processing (xtag, so still needed)
\definesystemvariable {za} % layout adapt % ZetspiegelAanpassing
\definesystemvariable {zc} % columns
-\definesystemvariable {zo} % otr
% still used but defined locally
diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua
index a7246e9ca..43624adfd 100644
--- a/tex/context/base/node-aux.lua
+++ b/tex/context/base/node-aux.lua
@@ -312,6 +312,8 @@ local function link(head,tail,list,currentfont,currentattr)
tail = n
end
end
+ else
+ -- permitting nil is convenient
end
end
return head, tail
diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua
index b19ef5589..dc1410282 100644
--- a/tex/context/base/node-ref.lua
+++ b/tex/context/base/node-ref.lua
@@ -180,6 +180,7 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
width = - width
end
local result, resolved = make(width,height,depth,reference)
+ -- todo: only when width is ok
if result and resolved then
if trace_backend then
report_area("box: %04i %s %s: w=%s, h=%s, d=%s, c=%s",reference,pardir or "---",txtdir or "----",width,height,depth,resolved)
@@ -296,7 +297,6 @@ end
-- tracing
-
local nodepool = nodes.pool
local new_rule = nodepool.rule
@@ -312,7 +312,7 @@ local u_transparency = nil
local u_colors = { }
local force_gray = true
-local function colorize(width,height,depth,n)
+local function colorize(width,height,depth,n,reference,what)
if force_gray then n = 0 end
u_transparency = u_transparency or transparencies.register(nil,2,.65)
local ucolor = u_colors[n]
@@ -330,11 +330,12 @@ local function colorize(width,height,depth,n)
u_colors[n] = u_color
end
if width == 0 then
- report_area("reference %s has no horizontal dimensions: width=%s, height=%s, depth=%s",reference,width,height,depth)
+ -- probably a strut as placeholder
+ report_area("%s %s has no horizontal dimensions: width=%s, height=%s, depth=%s",what,reference,width,height,depth)
width = 65536
end
if height + depth <= 0 then
- report_area("reference %s has no vertical dimensions: width=%s, height=%s, depth=%s",reference,width,height,depth)
+ report_area("%s %s has no vertical dimensions: width=%s, height=%s, depth=%s",what,reference,n,width,height,depth)
height = 65536/2
depth = height
end
@@ -407,7 +408,7 @@ local function makereference(width,height,depth,reference)
local result, current
if trace_references then
local step = 65536
- result = hpack_list(colorize(width,height-step,depth-step,2,reference)) -- step subtracted so that we can see seperate links
+ result = hpack_list(colorize(width,height-step,depth-step,2,reference,"reference")) -- step subtracted so that we can see seperate links
result.width = 0
current = result
end
@@ -476,7 +477,7 @@ local function makedestination(width,height,depth,reference)
width, height, depth = 5*step, 5*step, 0
end
for n=1,#name do
- local rule = hpack_list(colorize(width,height,depth,3,reference))
+ local rule = hpack_list(colorize(width,height,depth,3,reference,"destination"))
rule.width = 0
if not result then
result, current = rule, rule
diff --git a/tex/context/base/node-tsk.lua b/tex/context/base/node-tsk.lua
index a78393b82..efc51913c 100644
--- a/tex/context/base/node-tsk.lua
+++ b/tex/context/base/node-tsk.lua
@@ -18,16 +18,18 @@ local report_tasks = logs.reporter("tasks")
local allocate = utilities.storage.allocate
-local nodes = nodes
+local nodes = nodes
-nodes.tasks = nodes.tasks or { }
-local tasks = nodes.tasks
+nodes.tasks = nodes.tasks or { }
+local tasks = nodes.tasks
-local tasksdata = { } -- no longer public
+local tasksdata = { } -- no longer public
-local sequencers = utilities.sequencers
+local sequencers = utilities.sequencers
+local compile = sequencers.compile
+local nodeprocessor = sequencers.nodeprocessor
-local frozengroups = "no"
+local frozengroups = "no"
function tasks.freeze(kind)
frozengroups = kind or "tolerant" -- todo: hook into jobname
@@ -38,13 +40,16 @@ function tasks.new(specification) -- was: name,arguments,list
local arguments = specification.arguments or 0
local sequence = specification.sequence
if name and sequence then
- local tasklist = sequencers.reset()
+ local tasklist = sequencers.new {
+ -- we can move more to the sequencer now .. todo
+ }
tasksdata[name] = {
list = tasklist,
runner = false,
arguments = arguments,
-- sequence = sequence,
frozen = { },
+ processor = specification.processor or nodeprocessor
}
for l=1,#sequence do
sequencers.appendgroup(tasklist,sequence[l])
@@ -154,7 +159,7 @@ end
function tasks.showactions(name,group,action,where,kind)
local data = valid(name)
if data then
- report_tasks("task %s, list:\n%s",name,sequencers.nodeprocessor(data.list))
+ report_tasks("task %s, list:\n%s",name,nodeprocessor(data.list))
end
end
@@ -173,8 +178,6 @@ statistics.register("node list callback tasks", function()
end
end)
-local compile, nodeprocessor = sequencers.compile, sequencers.nodeprocessor
-
function tasks.actions(name) -- we optimize for the number or arguments (no ...)
local data = tasksdata[name]
if data then
@@ -188,7 +191,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s'",name)
end
- runner = compile(data.list,nodeprocessor,0)
+ runner = compile(data.list,data.processor,0)
data.runner = runner
end
return runner(head)
@@ -202,7 +205,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s' with 1 extra arguments",name)
end
- runner = compile(data.list,nodeprocessor,1)
+ runner = compile(data.list,data.processor,1)
data.runner = runner
end
return runner(head,one)
@@ -216,7 +219,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s' with 2 extra arguments",name)
end
- runner = compile(data.list,nodeprocessor,2)
+ runner = compile(data.list,data.processor,2)
data.runner = runner
end
return runner(head,one,two)
@@ -230,7 +233,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s' with 3 extra arguments",name)
end
- runner = compile(data.list,nodeprocessor,3)
+ runner = compile(data.list,data.processor,3)
data.runner = runner
end
return runner(head,one,two,three)
@@ -244,7 +247,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s' with 4 extra arguments",name)
end
- runner = compile(data.list,nodeprocessor,4)
+ runner = compile(data.list,data.processor,4)
data.runner = runner
end
return runner(head,one,two,three,four)
@@ -258,7 +261,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s' with 5 extra arguments",name)
end
- runner = compile(data.list,nodeprocessor,5)
+ runner = compile(data.list,data.processor,5)
data.runner = runner
end
return runner(head,one,two,three,four,five)
@@ -272,7 +275,7 @@ function tasks.actions(name) -- we optimize for the number or arguments (no ...)
if trace_tasks then
report_tasks("creating runner '%s' with n extra arguments",name)
end
- runner = compile(data.list,nodeprocessor,"n")
+ runner = compile(data.list,data.processor,"n")
data.runner = runner
end
return runner(head,...)
@@ -315,6 +318,7 @@ end
tasks.new {
name = "processors",
arguments = 4,
+ processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
@@ -329,6 +333,7 @@ tasks.new {
tasks.new {
name = "finalizers",
arguments = 1,
+ processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
@@ -343,6 +348,7 @@ tasks.new {
tasks.new {
name = "shipouts",
arguments = 0,
+ processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
@@ -354,6 +360,7 @@ tasks.new {
tasks.new {
name = "mvlbuilders",
arguments = 1,
+ processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
@@ -364,6 +371,7 @@ tasks.new {
tasks.new {
name = "vboxbuilders",
arguments = 5,
+ processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
@@ -371,22 +379,24 @@ tasks.new {
}
}
---~ tasks.new {
---~ name = "parbuilders",
---~ arguments = 1,
---~ sequence = {
---~ "before", -- for users
---~ "lists",
---~ "after", -- for users
---~ }
---~ }
-
---~ tasks.new {
---~ name = "pagebuilders",
---~ arguments = 5,
---~ sequence = {
---~ "before", -- for users
---~ "lists",
---~ "after", -- for users
---~ }
---~ }
+-- tasks.new {
+-- name = "parbuilders",
+-- arguments = 1,
+-- processor = nodeprocessor,
+-- sequence = {
+-- "before", -- for users
+-- "lists",
+-- "after", -- for users
+-- }
+-- }
+
+-- tasks.new {
+-- name = "pagebuilders",
+-- arguments = 5,
+-- processor = nodeprocessor,
+-- sequence = {
+-- "before", -- for users
+-- "lists",
+-- "after", -- for users
+-- }
+-- }
diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv
index 68201a660..05e0df6ef 100644
--- a/tex/context/base/pack-lyr.mkiv
+++ b/tex/context/base/pack-lyr.mkiv
@@ -232,6 +232,7 @@
\dontcomplain
\edef\p_pack_layers_option{\layerparameter\c!option}%
\ifx\p_pack_layers_option\v!test
+ \settrue\c_pack_layers_trace
\traceboxplacementtrue
\fi
\edef\m_pack_layers_target{#2}%
@@ -541,6 +542,7 @@
\edef\p_pack_layers_method{\layerparameter\c!method}%
\edef\p_pack_layers_option{\layerparameter\c!option}%
\ifx\p_pack_layers_option\v!test
+ \settrue\c_pack_layers_trace
\traceboxplacementtrue
\fi
\ifcase#1\relax
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index 6980f0b9d..43dcef7bf 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -169,6 +169,7 @@
\c!frameradius=\framedparameter\c!radius,
\c!framedepth=\framedparameter\c!depth,
%\c!component=,
+ %\c!region=,
%\c!align=,
\c!bottom=\vss,
%\c!top=,
@@ -191,6 +192,7 @@
\c!depth=\zeropoint,
\c!offset=\v!overlay,
%\c!component=,
+ %\c!region=,
\c!radius=.5\bodyfontsize,
\c!rulethickness=\linewidth,
\c!corner=\v!rectangular,
@@ -234,6 +236,7 @@
\let\p_framed_backgroundscreen\empty
\let\p_framed_framecolor \empty
\let\p_framed_component \empty
+\let\p_framed_region \empty
\let\p_framed_background \empty
\let\p_framed_rulethickness \empty
\let\p_framed_foregroundcolor \empty
@@ -580,6 +583,9 @@
\def\pack_framed_background_box_content% fuzzy but needed hack, this \vss, otherwise
{\vbox to \framedbackgroundheight{\vss\box\b_framed_normal\vss}} % vertical shift \backgroundheight
+\def\pack_framed_add_region % experiment
+ {\anch_mark_region_box\b_framed_normal}
+
\def\pack_framed_add_background
{\setbox\b_framed_normal\hbox % was vbox
{\pack_framed_forgetall % can be relaxed
@@ -777,7 +783,7 @@
\def\defaultframeoffset{.25ex}
-\def\presetlocalframed [#1]{\letvalue{#1\s!parent}\??oi}
+\def\presetlocalframed [#1]{\letvalue {#1\s!parent}\??oi}
\def\inheritlocalframed[#1]#2[#3]{\setevalue{#1\s!parent}{#3}}
\presetlocalframed[\??ol]
@@ -857,6 +863,10 @@
{\bgroup
\pack_framed_initialize{#1}%
\setbox\b_framed_normal\hbox{#4}%
+ \edef\p_framed_region{\framedparameter\c!region}%
+ \ifx\p_framed_region\v!yes % maybe later named
+ \pack_framed_add_region
+ \fi
\getparameters[\currentframed][#3]% no \expanded !
\edef\p_framed_rulethickness{\framedparameter\c!rulethickness}% also used in backgrounds
\d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds
@@ -870,6 +880,7 @@
\fi
\pack_framed_add_outline % real or invisible frame
\fi \fi
+ \fi
\ifx\p_framed_background\empty \else
\edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
\d_framed_backgroundoffset
@@ -892,6 +903,10 @@
{\bgroup
\pack_framed_initialize{#1}%
\setbox\b_framed_normal\box#3%
+ \edef\p_framed_region{\framedparameter\c!region}%
+ \ifx\p_framed_region\v!yes % maybe later named
+ \pack_framed_add_region
+ \fi
\edef\p_framed_rulethickness{\framedparameter\c!rulethickness}% also used in backgrounds
\d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds
\edef\p_framed_frame{\framedparameter\c!frame}%
@@ -1323,7 +1338,12 @@
\ifx\p_framed_empty\v!yes
\pack_framed_fake_box
\fi
- %
+ \iftrialtypesetting \else
+ \edef\p_framed_region{\framedparameter\c!region}%
+ \ifx\p_framed_region\v!yes % maybe later named
+ \pack_framed_add_region
+ \fi
+ \fi
\d_framed_applied_offset
\ifconditional\c_framed_is_overlaid
\zeropoint
@@ -1369,6 +1389,9 @@
\egroup
\egroup}
+\installcorenamespace{framedlocatorbefore}
+\installcorenamespace{framedlocatorafter}
+
\newconstant\frameddimensionstate % global state: 0=unknown 1=width 2=height 3=both
\def\pack_framed_fake_box
@@ -1379,19 +1402,16 @@
\setbox\b_framed_normal\box\scratchbox}
\def\installframedlocator#1#2#3%
- {\setvalue{\??hf:b:#1}{#2}%
- \setvalue{\??hf:a:#1}{#3}}
-
-\def\pack_framed_locator_before#1%
- {\csname\??hf:b:#1\endcsname}
+ {\setvalue{\??framedlocatorbefore#1}{#2}%
+ \setvalue{\??framedlocatorafter #1}{#3}}
-\def\pack_framed_locator_after#1%
- {\csname\??hf:a:#1\endcsname}
+\def\pack_framed_locator_before#1{\csname\??framedlocatorbefore#1\endcsname}
+\def\pack_framed_locator_after #1{\csname\??framedlocatorafter #1\endcsname}
\newdimen\d_framed_locator_ht
\newdimen\d_framed_locator_dp
-\def\doprelocframedbox#1%
+\def\pack_framed_locater_set#1%
{\d_framed_locator_ht\dimexpr
#1+\d_framed_linewidth
\ifconditional\c_framed_has_offset
@@ -1441,7 +1461,7 @@
\installframedlocator \v!high
{}
- {\doprelocframedbox\strutht
+ {\pack_framed_locater_set\strutht
\setbox\b_framed_normal\hbox{\lower\d_framed_locator_dp\box\b_framed_normal}%
\ht\b_framed_normal\strutht
\dp\b_framed_normal\strutdp
@@ -1456,7 +1476,7 @@
\installframedlocator \v!low
{}
- {\doprelocframedbox\strutdp
+ {\pack_framed_locater_set\strutdp
\setbox\b_framed_normal\hbox{\lower\d_framed_locator_ht\box\b_framed_normal}%
\ht\b_framed_normal\strutht
\dp\b_framed_normal\strutdp
@@ -1464,7 +1484,7 @@
\installframedlocator \v!top
{}
- {\doprelocframedbox\strutht
+ {\pack_framed_locater_set\strutht
\setbox\b_framed_normal\hbox{\lower\d_framed_locator_dp\box\b_framed_normal}%
\ht\b_framed_normal\d_framed_locator_ht
\dp\b_framed_normal\d_framed_locator_dp
@@ -1474,8 +1494,8 @@
{}
{\scratchdimen.5\ht\b_framed_normal
\setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
- \ht\b_framed_normal\d_framed_locator_ht
- \dp\b_framed_normal\d_framed_locator_ht
+ \ht\b_framed_normal\scratchdimen
+ \dp\b_framed_normal\scratchdimen
\hbox{\box\b_framed_normal}}
\installframedlocator \v!lohi
@@ -1484,7 +1504,7 @@
\installframedlocator \v!bottom
{}
- {\doprelocframedbox\strutdp
+ {\pack_framed_locater_set\strutdp
\setbox\b_framed_normal\hbox{\lower\d_framed_locator_ht\box\b_framed_normal}%
\ht\b_framed_normal\d_framed_locator_dp
\dp\b_framed_normal\d_framed_locator_ht
@@ -1613,25 +1633,53 @@
\newcount\c_framed_mstyle
-\unexpanded\def\mframed {\dosingleempty\pack_framed_math_display}
-\unexpanded\def\inmframed{\dosingleempty\pack_framed_math_inline }
+\unexpanded\def\pack_framed_math_strut
+ {\Ustartmath
+ \triggermathstyle\c_framed_mstyle
+ \vphantom{(}%
+ \Ustopmath}
-\def\pack_framed_math_inline[#1]#2%
- {\begingroup
- \c_framed_mstyle\mathstyle
- \inframed[#1]{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
- \endgroup}
+% \unexpanded\def\mframed {\dosingleempty\pack_framed_math_display}
+% \unexpanded\def\inmframed{\dosingleempty\pack_framed_math_inline }
+%
+% \def\pack_framed_math_inline[#1]#2%
+% {\begingroup
+% \c_framed_mstyle\mathstyle
+% \inframed[#1]{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
+% \endgroup}
+%
+% \def\pack_framed_math_display[#1]#2%
+% {\begingroup
+% \c_framed_mstyle\mathstyle
+% \let\normalstrut\pack_framed_math_strut
+% \framed[#1]{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
+% \endgroup}
+
+\installcorenamespace{mathframed}
-\unexpanded\def\funnymathstrut
- {\Ustartmath\triggermathstyle\c_framed_mstyle\vphantom{(}\Ustopmath}
+\installframedcommandhandler \??mathframed {mathframed} \??mathframed
-\def\pack_framed_math_display[#1]#2%
+\appendtoks
+ \setuevalue{\currentmathframed}{\pack_framed_mathframed{\currentmathframed}}%
+\to \everydefinemathframed
+
+\unexpanded\def\pack_framed_mathframed#1%
{\begingroup
+ \edef\currentmathframed{#1}%
+ \dosingleempty\pack_framed_mathframed_indeed}
+
+\def\pack_framed_mathframed_indeed[#1]#2% no fancy nesting supported here
+ {\iffirstargument
+ \setupcurrentmathframed[#1]%
+ \fi
\c_framed_mstyle\mathstyle
- \let\normalstrut\funnymathstrut
- \framed[#1]{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
+ \doifnot{\mathframedparameter\c!location}\v!low{\let\normalstrut\pack_framed_math_strut}%
+ \inheritedmathframedframed{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
\endgroup}
+\definemathframed[mframed]
+\definemathframed[inmframed][\c!location=\v!low]
+
%D So instead of the rather versatile \type {\framed}, we ue
%D the \type {\mframed}.
%D
@@ -2727,6 +2775,7 @@
\c!framedepth=\framedparameter\c!depth,
%
%\c!component=,
+ %\c!region=,
%\c!align=,
\c!bottom=\vss,
%\c!top=,
diff --git a/tex/context/base/page-brk.mkiv b/tex/context/base/page-brk.mkiv
index f3bdddaed..01e4beb95 100644
--- a/tex/context/base/page-brk.mkiv
+++ b/tex/context/base/page-brk.mkiv
@@ -122,7 +122,7 @@
\installpagebreakmethod \s!dummy
{\page_otr_flush_all_floats
- \gotonextpage
+ \page_otr_command_next_page
\page_otr_insert_dummy_page}
\installpagebreakmethod \v!frame
@@ -135,11 +135,11 @@
\installpagebreakmethod \s!unknown
{\doifinstringelse{+}\page_breaks_current_option
{\page_otr_flush_all_floats
- \gotonextpage
+ \page_otr_command_next_page
\dorecurse\page_breaks_current_option\page_otr_insert_dummy_page}
{\doifnumberelse\page_breaks_current_option
{\page_otr_flush_all_floats
- \gotonextpage
+ \page_otr_command_next_page
\doloop
{\ifnum\userpageno<\page_breaks_current_option\relax
\page_otr_insert_dummy_page
@@ -161,7 +161,7 @@
\installpagebreakmethod \v!yes
{\ifconditional\c_page_breaks_enabled
\page_otr_flush_all_floats
- \gotonextpage
+ \page_otr_command_next_page
\ifinsidecolumns % this will move to MUL
\page_otr_eject_page % otherwise sometimes no change
\fi
@@ -207,7 +207,7 @@
\installpagebreakmethod \v!right
{\page_otr_flush_all_floats
- \gotonextpageX % will become \gotonextpage
+ \page_otr_command_next_page_and_inserts
\doifbothsidesoverruled{}{}{\resetcurrentstructuremarkswithpage\page_otr_insert_dummy_page}}
\installpagebreakmethod \v!even
@@ -229,7 +229,7 @@
\installpagebreakmethod \v!last
{\page_otr_flush_all_floats
- \gotonextpageX % will become \gotonextpage
+ \page_otr_command_next_page_and_inserts
\relax
\doifbothsidesoverruled
{\page_facings_flush}% hm
@@ -266,16 +266,16 @@
\def\page_breaks_columns_handle_indeed#1%
{\edef\page_breaks_columns_current_option{#1}%
- \ifcsname\??columnbreakmethod\OTRidentifier:\page_breaks_columns_current_option\endcsname
- \csname\??columnbreakmethod\OTRidentifier:\page_breaks_columns_current_option\endcsname
+ \ifcsname\??columnbreakmethod\currentoutputroutine:\page_breaks_columns_current_option\endcsname
+ \csname\??columnbreakmethod\currentoutputroutine:\page_breaks_columns_current_option\endcsname
\else\ifcsname\??columnbreaks\page_breaks_columns_current_option\endcsname
\expandafter\csname\page_breaks_columns_handle\??columnbreaks\page_breaks_columns_current_option\endcsname
\else
- \csname\??columnbreakmethod\OTRidentifier:\s!unknown\endcsname
+ \csname\??columnbreakmethod\currentoutputroutine:\s!unknown\endcsname
\fi\fi}
\def\page_breaks_columns_handle_direct#1%
- {\csname\??columnbreakmethod\OTRidentifier:#1\endcsname}
+ {\csname\??columnbreakmethod\currentoutputroutine:#1\endcsname}
\unexpanded\def\installcolumnbreakmethod#1#2#3% #1=otr-id #2=tag #3=action
{\setvalue{\??columnbreakmethod#1:#2}{#3}}
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
index 4eef6f25c..e4f4b0da4 100644
--- a/tex/context/base/page-flt.mkiv
+++ b/tex/context/base/page-flt.mkiv
@@ -208,10 +208,10 @@
\def\doreversesavefloat
{\dofloatsresave\s!text}
-\def\doflushsavedfloats % simplified \OTRONEdodoflushfloats
+\def\doflushsavedfloats % simplified \OTRONEdodoflushfloats .. nothing special in otr ... in place
{\doloop
{\ifsomefloatwaiting
- \docheckiffloatfits
+ \page_otr_command_check_if_float_fits
\ifroomforfloat
\dogetfloat
\doplacefloatbox
@@ -269,9 +269,6 @@
\box\floatbox
\fi}
-% \ifdefined\doflushfloats\else \let\doflushfloats\relax \fi
-% \ifdefined\flushfloatbox\else \let\flushfloatbox\relax \fi
-
% temp hack, needed to prevent floatbox being forgotten during
% output, this will change to using another box for flushing
%
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index 757302518..aad08ef3e 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -13,276 +13,54 @@
\writestatus{loading}{ConTeXt Page Macros / Initializations}
-% still a dutch/english mess
-
-%D This class of modules implements the output routines and
-%D floating body support. Although the modules are relatively
-%D new, the code herein is rather old. This reordering was
-%D needed when column sets were implemented and sharing code
-%D started to make sense.
+%D The \type {\processpage} command has become obsolete. It's original
+%D purpose was to flush only parts of a document but nowadays we have
+%D project structure and modes. This is just one of those very early
+%D features that no longer makes sense.
-%D The history shows from the code, since both column
-%D mechanism use a different way of looping over columns.
+%D The \type {\couplepage} command has become obsolete. It's original
+%D purpose was to provide hooks for printer directives (like choosing
+%D different paper trays).
\unprotect
-\def\m!otr{otr}
-
-\newbox \pagebox
-\newcount \nofshipouts
-
-\newconstant\c_page_otr_eject_penalty \c_page_otr_eject_penalty -\plustenthousand
-\newconstant\c_page_otr_super_penalty \c_page_otr_super_penalty -\plustwentythousand
+%D Shipout control.
-\let\ejectpenalty\c_page_otr_eject_penalty % for old times sake
+\newcount\nofshipouts
\appendtoks
\global\advance\nofshipouts\plusone
\to \everyaftershipout
-\ifx\mkprocesscolumncontents\undefined\let\mkprocesscolumncontents\gobbleoneargument\fi
-\ifx\mkprocesspagecontents \undefined\let\mkprocesspagecontents \gobbleoneargument\fi
-\ifx\mkprocessboxcontents \undefined\let\mkprocessboxcontents \gobbleoneargument\fi
-
-%D As we have several fundamentally different output routines
-%D available we need commands that adapt themselves to the
-%D current output routine. Such commands are implemented
-%D in the respective modules and prefixed:
-%D
-%D \starttabulate[|T|T|]
-%D \NC OTRONE \NC single column \NC \NR
-%D \NC OTRMUL \NC multi column \NC \NR
-%D \NC OTRSET \NC columns sets \NC \NR
-%D \stoptabulate
-%D
-%D The following macros are not to be changed by users:
-
-\let\OTRidentifier\empty % public
-\let\OTRdefault \empty % public
-\let\OTRunknown \empty
-\def\OTRprefix {OTR}
-
-%D We keep a list of registered commands so that we can
-%D bind them when we switch to a specific routine.
-
-\newtoks\t_page_otr_registered_commands
-
-\def\registerotrcommand#1%
- {\t_page_otr_registered_commands\expandafter
- {\the\t_page_otr_registered_commands
- \page_otr_with_command#1}}
-
-\def\page_otr_preset_command#1%
- {\expandafter\let\expandafter#1\csname\OTRprefix
- \ifcsname\OTRprefix\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
- \OTRidentifier % dedicated
- \else\ifcsname\OTRprefix\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname
- \OTRdefault % fallback
- \else
- \s!unknown % dummy
- \fi\fi
- \expandafter\gobbleoneargument\string#1\endcsname}
-
-\def\page_otr_activate#1#2%
- {\def\OTRidentifier{#1}%
- \def\OTRdefault {#2}%
- \let\page_otr_with_command\page_otr_preset_command
- \the\t_page_otr_registered_commands}
-
-\appendtoks
- \page_otr_activate{ONE}\empty
-\to \everydump
-
-%D The next commands is a direct call to a specific command but is
-%D normally only used if one wants to call a command inside another
-%D one or for the main (not triggered) outputroutines.
-
-\def\OTRcommand#1%
- {\csname\OTRprefix
- \ifcsname\OTRprefix\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
- \OTRidentifier % dedicated
- \else\ifcsname\OTRprefix\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname
- \OTRdefault % fallback
- \else
- \s!unknown % dummy
- \fi\fi
- \expandafter\gobbleoneargument\string#1\endcsname}
-
-%D The initialization of the \type {\hsize} and \type {\vsize}
-%D depends on the OTR used, as do some other commands.
-
-% These definitions will move to where they are introduced.
-
-\registerotrcommand\setvsize
-\registerotrcommand\sethsize
-\registerotrcommand\finalsidefloatoutput
-\registerotrcommand\dopagecontents
-\registerotrcommand\dosettopinserts
-\registerotrcommand\dosetbotinserts
-\registerotrcommand\dotopinsertions
-\registerotrcommand\dobotinsertions
-\registerotrcommand\dosetbothinserts
-\registerotrcommand\doflushfloats
-\registerotrcommand\flushfloatbox
-\registerotrcommand\docheckiffloatfits
-\registerotrcommand\flushsavedfloats
-\registerotrcommand\synchronizehsize
-\registerotrcommand\gotonextpage
-\registerotrcommand\gotonextpageX
-
-\registerotrcommand\setfloathsize
-
-% \registerotrcommand\_specific_final_side_float_output % todo
-
-%registerotrcommand\someherefloat % not ok this way
-%registerotrcommand\somefixdfloat % not ok this way
-%registerotrcommand\somepagefloat % not ok this way
-%registerotrcommand\sometopsfloat % not ok this way
-%registerotrcommand\somebotsfloat % not ok this way
-%registerotrcommand\somesidefloat % not ok this way
-
-% When issuing two \par\penalty-\plustenthousand's, only the first
-% triggers the otr. Is this an obscure feature or an optimization?
-
-\newif \iftraceotr % will change
-\newif \ifinotr % might change
-
-\newcount\c_page_otf_trigger_penalty \c_page_otf_trigger_penalty=-100010 % -10010
-
-\unexpanded\def\page_otr_trigger
- {\iftraceotr
- \expandafter\page_otr_trigger_traced
- \else
- \expandafter\page_otr_trigger_normal
- \fi}
-
-\def\page_otr_message_b#1#2%
- {\writestatus\m!otr{+ #1 \number#1}}
-
-\def\page_otr_message_e#1#2%
- {\writestatus\m!otr{- #1 \number#2}}
-
-\def\page_otr_message_s
- {\writestatus\m!otr{c:\number\mofcolumns,v:\the\vsize,g:\the\pagegoal,t:\the\pagetotal}}
-
-\def\page_otr_trigger_normal#1%
- {\begingroup\par\penalty#1\endgroup}
-
-\def\page_otr_trigger_traced#1%
- {\page_otr_message_b{traced}{#1}%
- \page_otr_message_s
- \page_otr_trigger_normal{#1}%
- \page_otr_message_s
- \page_otr_message_e{traced}{#1}}
-
-\def\installoutputroutine#1#2% \invoke \action
- {\global\advance\c_page_otf_trigger_penalty\minusone
- \edef#1{\page_otr_trigger{\number\c_page_otf_trigger_penalty}}%
- \setvalue{\??zo\number\c_page_otf_trigger_penalty}{#2}}
-
-\def\page_otr_triggered_output_routine_traced
- {\page_otr_message_b{trying}\outputpenalty
- \ifcsname\??zo\the\outputpenalty\endcsname
- \page_otr_message_b{special}\outputpenalty
- \csname\??zo\the\outputpenalty\endcsname
- \page_otr_message_e{special}\outputpenalty
- \else
- \page_otr_message_b{normal}\outputpenalty
- \the\OTRcommand\output % currently a toks but this will become a normal command
- \page_otr_message_e{normal}\outputpenalty
- \fi
- \page_otr_message_e{trying}\outputpenalty}
-
-\def\page_otr_triggered_output_routine_normal
- {\ifcsname\??zo\the\outputpenalty\endcsname
- \csname\??zo\the\outputpenalty\endcsname
- \else
- \the\OTRcommand\output
- \fi}
+\newconditional\c_otr_shipout_enabled \settrue\c_otr_shipout_enabled
-\def\page_otr_triggered_output_routine
- {\iftraceotr
- \expandafter\page_otr_triggered_output_routine_traced
+\unexpanded\def\page_otr_shipout
+ {\ifconditional\c_otr_shipout_enabled
+ \expandafter\page_otr_shipout_yes
\else
- \expandafter\page_otr_triggered_output_routine_normal
- \fi}
-
-%D Some hooks:
-
-\def\page_otf_set_engine_output_routine#1%
- {\global\output
- {\inotrtrue
- \the\everybeforeoutput
- #1\relax
- \the\everyafteroutput}}
-
-\page_otf_set_engine_output_routine{\page_otr_triggered_output_routine}
-
-\installoutputroutine\synchronizeoutput
- {\ifvoid\normalpagebox\else
- \unvbox\normalpagebox
- \pagediscards
+ \expandafter\page_otr_shipout_nop
\fi}
-\installoutputroutine\discardpage
- {\setbox\scratchbox\box\normalpagebox}
+\let\page_otr_shipout_yes\normalshipout
-\def\page_otr_trigger_output_routine
- {\par
- \ifvmode
- \penalty\c_page_otr_eject_penalty
- \fi
- \resetpagebreak}
+\unexpanded\def\page_otr_shipout_nop
+ {\writestatus\m!system{ignoring shipout of real page \the\realpageno}%
+ \global\advance\realpageno\minusone % else no flush of resources
+ \dowithnextbox{\deadcycles\zerocount}}
-\def\page_otr_fill_and_eject_page
- {\par
- \ifvmode
- \vfill
- \penalty\c_page_otr_eject_penalty
- \fi
- \resetpagebreak}
+% We don't support direct user \shipouts (weird: this does not work, bug?)
+%
+% \let\shipout\page_otr_shipout_nop
-\def\page_otr_eject_page
- {\par
- \ifvmode
- \ifdim\pagetotal>\pagegoal \else
- \normalvfil
- \fi
- \penalty\c_page_otr_eject_penalty
- \fi
- \resetpagebreak}
-
-\def\page_otr_eject_page_and_flush_inserts % can be an installed one
- {\par
- \ifvmode
- \ifdim\pagetotal>\pagegoal \else
- \normalvfil
- \fi
- \penalty\c_page_otr_super_penalty
- \fi
- \resetpagebreak}
-
-\def\page_otr_check_for_pending_inserts
- {\ifnum\outputpenalty>\c_page_otr_super_penalty \else
- \ifnum\insertpenalties>\zerocount
- % something is being held over so we force a new page
- \page_otr_force_another_page
- \fi
- \fi}
+%D Building pages.
-\def\page_otr_force_another_page
- {% we should actually remove the dummy line in the otr
- \hbox to \hsize{}%
- \kern-\topskip
- \nobreak
- \vfill
- \penalty\c_page_otr_super_penalty
- \resetpagebreak}
+\newbox\pagebox
-\unexpanded\def\bye
- {\writestatus\m!system{Sorry, you're not done yet, so no goodbye!}}
+\ifx\mkprocesscolumncontents\undefined\let\mkprocesscolumncontents\gobbleoneargument\fi
+\ifx\mkprocesspagecontents \undefined\let\mkprocesspagecontents \gobbleoneargument\fi
+\ifx\mkprocessboxcontents \undefined\let\mkprocessboxcontents \gobbleoneargument\fi
-% floats
+%D Floats.
\def\page_otr_flush_all_floats
{%\flushnotes already done
@@ -296,7 +74,7 @@
% when just flushing; so now we have (maybe optional):
\pagebaselinecorrection % hm, needs checking, not needed when no floats
% alas, this is tricky but needed (first surfaced in prikkels)
- \doflushfloats
+ \page_otr_command_flush_floats
\endgroup
\fi}
@@ -306,23 +84,26 @@
\page_otr_flush_all_floats
\fixedspace
\vfill
- \gotonextpage
+ \page_otr_command_next_page
\fi}
-\def\finaloutput#1#2%
- {\forgetall
- \page_boxes_shipout{\page_boxes_constructed_page#1#2}% \hbox removed
- \vskip\zeropoint\relax
+\def\page_otr_flush_pending_content
+ {\vskip\zeropoint\relax % brrr .. get rid of this
\ifvoid\normalpagebox \else
\unvbox\normalpagebox
\penalty\outputpenalty
- \fi
+ \fi}
+
+\def\page_otr_construct_and_shipout#1#2%
+ {\forgetall
+ \page_boxes_shipout{\page_boxes_constructed_page#1#2}% \hbox removed
+ \page_otr_flush_pending_content
% not really needed, replaced by \flushsavedfloats
\page_otr_check_for_pending_inserts
% but does not hurt either (we're still in the otr!)
- \inpagebodytrue % needed for enabling \blank !
- \flushsavedfloats % was \dosetbothinserts; only otr one !
- \setvsize % this is needed for interacting components, like floats and multicolumns
+ \inpagebodytrue % needed for enabling \blank ! brrr
+ \page_otr_command_flush_saved_floats
+ \page_otr_command_set_vsize % this is needed for interacting components, like floats and multicolumns
\doincrementpageboundcounters % should hook into an every
\page_adapts_synchronize
\page_otr_check_for_pending_inserts
@@ -352,8 +133,6 @@
\let\flushatshipout\page_otr_add_special_content
-% \def\dooutput{\finaloutput\unvbox\normalpagebox}
-
\maxdeadcycles=1000
\newtoks\afterpage \newtoks\aftereverypage
@@ -394,15 +173,15 @@
{\ifconditional\c_page_boxes_save_page_body \global\setbox\b_page_boxes_saved_page_body \fi \vbox \bgroup
\boxmaxdepth\maxdimen % new
\dontcomplain
- \page_marks_synchronize_page{#2}% we could consider doing this for \pagebox (needs testting)
- \page_boxes_construct_content#1#2% % this one fills pagebox
+ \page_marks_synchronize_page {#2}% we could consider doing this for \pagebox (needs testing)
+ \page_boxes_construct_content \pagebox{#1}{#2}%
\page_backgrounds_add_to_main \pagebox
\page_boxes_apply_offsets \pagebox
\page_info_add_to_box \pagebox
\ifcase\pageornamentstate
\page_backgrounds_add_to_paper \pagebox
\fi
- \anch_positions_register_page \pagebox
+ \anch_positions_register_page \pagebox
\ifarrangingpages
\page_boxes_apply_shift_paper \pagebox % \v!paper
\else
@@ -450,64 +229,4 @@
\the\everyafterpagebody
\egroup}
-%D Shipout control.
-
-\newconditional\c_otr_shipout_enabled \settrue\c_otr_shipout_enabled
-
-\def\page_otr_shipout
- {\ifconditional\c_otr_shipout_enabled
- \expandafter\page_otr_shipout_yes
- \else
- \expandafter\page_otr_shipout_nop
- \fi}
-
-\let\page_otr_shipout_yes\normalshipout
-
-\unexpanded\def\page_otr_shipout_nop
- {\writestatus\m!system{ignoring shipout of real page \the\realpageno}%
- \global\advance\realpageno\minusone % else no flush of resources
- \dowithnextbox{\deadcycles\zerocount}}
-
-% \let\shipout\page_otr_shipout_nop % we don't support direct user \shipouts (weird: this does not work, bug?)
-
-%D The \type {\processpage} command has become obsolete. It's original
-%D purpose was to flush only parts of a document but nowadays we have
-%D project structure and modes. This is just one of those very early
-%D features that no longer makes sense.
-%D
-%D The \type {\couplepage} command has become obsolete. It's original
-%D purpose was to provide hooks for printer directives (like choosing
-%D different paper trays).
-
\protect \endinput
-
-% bewaren tvb documentatie
-%
-% \hbox to \hsize
-% {\en
-% \switchnaarkorps[5pt]%
-% \emergencystretch2em
-% \dimen0=\baselineskip
-% \baselineskip=\dimen0 plus 1pt
-% \hsize=.2\hsize
-% \vsize=2\hsize
-% \ruledvbox to \vsize{\input tufte \par}\hss
-% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth}\hss
-% \ruledvbox to \vsize{\input tufte \par\kern0pt}\hss
-% \ruledvbox to \vsize{\input tufte \par\vfill}\hss
-% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth\vfill}}
-%
-% \hbox to \hsize
-% {\en
-% \switchnaarkorps[5pt]%
-% \emergencystretch2em
-% \dimen0=\baselineskip
-% \baselineskip=\dimen0 plus 1pt
-% \hsize=.18\hsize
-% \vsize=2.5\hsize
-% \setbox0=\vbox{\input tufte\relax}%
-% \ruledvbox to \vsize{\unvcopy0}\hss
-% \ruledvbox to \vsize{\unvcopy0\kern-\dp0}\hss
-% \ruledvbox to \vsize{\unvcopy0\kern0pt}\hss
-% \ruledvbox to \vsize{\unvcopy0\vfill}\hss
-% \ruledvbox to \vsize{\unvcopy0\kern-\dp0\vfill}}
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 4e2c254e6..78839ea70 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -475,12 +475,12 @@
\global\c_page_target_paper_reverse \zerocount}
\setvalue{\??layoutpaper\number\leftrotationangle }{\global\c_page_target_paper_orientation\leftrotationangle
\global\c_page_target_paper_reverse \rightrotationangle}
-\setvalue{\??layoutpaper\v!reset }{\global\setfalse\c_page_target_print_landscape
+
+\setvalue{\??layoutprint\v!reset }{\global\setfalse\c_page_target_print_landscape
\global\setfalse\c_page_target_print_mirror
\global\setfalse\c_page_target_print_negate
\global\c_page_target_print_orientation\uprotationangle
\global\c_page_target_print_reverse \uprotationangle}
-
\setvalue{\??layoutprint\v!landscape }{\global\settrue\c_page_target_print_landscape}
\setvalue{\??layoutprint\v!mirrored }{\global\settrue\c_page_target_print_mirror}
\setvalue{\??layoutprint\v!negative }{\global\settrue\c_page_target_print_negate}
@@ -903,20 +903,20 @@
\def\installlayoutalternative#1#2%
{\setgvalue{\??layoutalternative#1}{#2}}
-\def\page_boxes_construct_content_default#1#2% #1 and #2 will become variables
- {\setbox\pagebox\vbox
+\def\page_boxes_construct_content_default#1#2#3% targetbox flusher box
+ {\setbox#1\vbox
{\offinterlineskip
\begingroup % needed ?
\uselayoutstyleandcolor\c!style\c!color
\offinterlineskip
\page_layouts_insert_elements % zero size
\endgroup
- \page_insert_body#1#2}}% including footnotes
+ \page_insert_body#2#3}}% including footnotes
\installlayoutalternative\v!default{\page_boxes_construct_content_default}
\installlayoutalternative\v!normal {\page_boxes_construct_content_default}
-\def\page_boxes_construct_content
+\def\page_boxes_construct_content % targetbox flusher box
{\csname\??layoutalternative\ifcsname\??layoutalternative\layoutparameter\c!alternative\endcsname
\layoutparameter\c!alternative
\else
@@ -965,7 +965,7 @@
\global\advance\footerheight-\d_page_adepts_height
\showmessage\m!layouts1{\the\d_page_adepts_height,\the\realpageno}%
% this will become a better one (do we need insert correction?)
- \setvsize
+ \page_otr_command_set_vsize
\global\pagegoal\vsize
%
\page_backgrounds_recalculate
@@ -1050,14 +1050,14 @@
\doifelselayoutsomeline\v!footer\compensatevsizefooter\donothing
\page_layouts_set_modes
\resetglobal
- \setvsize}
+ \page_otr_command_set_vsize}
\def\calculateglobalvsizes % name will change
{\global\textheight\makeupheight
\doifelselayoutsomeline\v!header\globalcompensatevsizeheader\donothing
\doifelselayoutsomeline\v!footer\globalcompensatevsizefooter\donothing
\page_layouts_set_modes
- \setvsize}
+ \page_otr_command_set_vsize}
\def\calculatereducedvsizes % name will change
{\textheight\makeupheight
@@ -1091,7 +1091,7 @@
\def\calculatehsizes % name will change
{\freezetextwidth
- \sethsize}
+ \page_otr_command_set_hsize}
% The next few are better off in page-ini.mkiv
diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv
index 98fd78b5f..532fdde40 100644
--- a/tex/context/base/page-mis.mkiv
+++ b/tex/context/base/page-mis.mkiv
@@ -73,7 +73,7 @@
\restoreglobalbodyfont % otherwise problems inside split verbatim
\ctxcommand{flushpostponedblocks()}%
\relax
- \doflushfloats % new but potential dangerous, maybe we need a classification
+ \page_otr_command_flush_floats % new but potential dangerous, maybe we need a classification
\egroup} % of blocks: with and without flush
\def\page_postponed_blocks_flush_indeed
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index 0a0ba5be4..4901c1edf 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -11,6 +11,10 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+% SEE PAGE-MUL-NEW.MKIV
+
+% BEWARE: TEMPORARY ISSUES WITH VSIZE AND HSIZE BUT WILL BE REDONE
+
\writestatus{loading}{ConTeXt Page Macros / Simple Multi Column}
%D This module is mostly a copy from the original multi column
@@ -22,149 +26,57 @@
\unprotect
-% TO DO !
-
-\let\OTRMULsetvsize \OTRONEsetvsize
-\let\OTRMULsethsize \OTRONEsethsize
-\let\OTRMULdopagecontents \OTRONEdopagecontents
-\let\OTRMULfinalsidefloatoutput\OTRONEfinalsidefloatoutput % ???
-\let\OTRMULflushfloatbox \OTRONEflushfloatbox
+\unexpanded\def\page_mul_command_side_float_output
+ {\page_otr_construct_and_shipout\unvbox\normalpagebox}
-\let\OTRMULdosettopinserts \relax
-\let\OTRMULdosetbotinserts \relax
-\let\OTRMULdotopinsertions \relax
-\let\OTRMULdobotinsertions \relax
-\let\OTRMULdosetbothinserts \relax
-\let\OTRMULflushsavedfloats \relax
+\unexpanded\def\page_mul_command_flush_side_floats
+ {\page_sides_forget_floats}
-\let\OTRMULflushsidefloats \forgetsidefloats % \relax
-\let\OTRMULsynchronizesidefloats\forgetsidefloats % \relax
+\unexpanded\def\page_mul_command_synchronize_side_floats
+ {\page_sides_forget_floats}
-\newtoks \OTRMULoutput
-
-\def\OTRMULgotonextpage
+\unexpanded\def\page_mul_command_next_page
{\page_otr_eject_page}
-\def\OTRMULgotonextpageX % will become obsolete
+\unexpanded\def\page_mul_command_next_page_and_inserts
{\page_otr_eject_page_and_flush_inserts}
-
+
% check \count<insert> multiplications
-%D The following macro's implement a multi||column output
-%D routine. The original implementation was based on Donald
-%D Knuth's implementation, which was adapted by Craig Platt to
-%D support balancing of the last page. I gradually adapted
-%D Platt's version to our needs but under certain
-%D circumstances things still went wrong. I considered all
-%D calls to Platt's \type{\balancingerror} as undesirable.
-
-%D This completely new implementation can handle enough
-%D situations for everyday documents, but is still far from
-%D perfect. While at the moment the routine doesn't support
-%D all kind of floats, it does support:
+%D The following macro's implement a multi||column output routine. The original
+%D implementation was based on Donald Knuth's implementation, which was adapted by
+%D Craig Platt to support balancing of the last page. I gradually adapted Platt's
+%D version to our needs but under certain circumstances things still went wrong. I
+%D considered all calls to Platt's \type{\balancingerror} as undesirable.
+%D
+%D This completely new implementation can handle enough situations for everyday
+%D documents, but is still far from perfect. While at the moment the routine doesn't
+%D support all kind of floats, it does support:
%D
%D \startitemize[packed]
%D \item an unlimitted number of columns
%D \item ragged or not ragged bottoms
%D \item optional balancing without \type{\balancingerrors}
-%D \item different \type{\baselineskips}, \type{\spacing},
-%D \type{\topskip} and \type{\maxdepth}
+%D \item different \type{\baselineskips}, \type{\spacing}, \type {\topskip} and
+%D \type {\maxdepth}
%D \item left- and right indentation, e.g. within lists
%D \item moving columns floats to the next column or page
%D \item handling of floats that are to wide for a columns
%D \stopitemize
%D
-%D One could wonder why single and multi||columns modes are
-%D still separated. One reason for this is that \TeX\ is not
-%D suited well for handling multi||columns. As a result, the
-%D single columns routines are more robust. Handling one
-%D column as a special case of multi||columns is posible but at
-%D the cost of worse float handling, worse page breaking,
-%D worse etc. Complicated multi||column page handling should
-%D be done in \cap{DTP}||systems anyway.
+%D One could wonder why single and multi||columns modes are still separated. One
+%D reason for this is that \TeX\ is not suited well for handling multi||columns. As
+%D a result, the single columns routines are more robust. Handling one column as a
+%D special case of multi||columns is posible but at the cost of worse float
+%D handling, worse page breaking, worse etc. Complicated multi||column page handling
+%D should be done in \cap{DTP}||systems anyway.
%D
-%D There are three commands provided for entering and leaving
-%D multi||column mode and for going to the next column:
+%D There are three commands provided for entering and leaving multi||column mode and
+%D for going to the next column:
%D
%D \interface \type{\beginmulticolumns} \\ \\
%D \interface \type{\endmulticolumns} \\ \\
%D \interface \type{\ejectcolumn} \\ \\
-%D
-%D This routines are sort of stand||alone. They communicate
-%D with the rest of \CONTEXT\ by means of some interface
-%D macro's, which we only mention.
-%D
-%D \interface \type{\nofcolumns} \\
-%D the number of columns \\
-%D \interface \type{\minbalancetoplines} \\
-%D the minimum number op balanced top lines \\
-%D \interface \type{\betweencolumns} \\
-%D the stuff between columns \\
-%D \interface \type{\finaloutput{action}{box}} \\
-%D some kind of \type{\pagebody} and \type{\shipout} \\
-%D
-%D \interface \type{\ifbalancecolumns} \\
-%D balancing the colums or not \\
-%D \interface \type{\ifstretchcolumns} \\
-%D ragging the bottom or not \\
-%D
-%D \interface \type{\ifheightencolumns} \\
-%D fix the heigh tor not \\
-%D \interface \type{\fixedcolumnheight} \\
-%D the optional fixed height \\
-%D
-%D \interface \type{\ifinheritcolumns} \\
-%D handle ragging or not \\
-%D
-%D \interface \type{\ifreversecolumns} \\
-%D reverse the order in wich columns are flushed \\
-%D
-%D \interface \type{\usercolumnwidth} \\
-%D the calculated width of a column \\
-%D \interface \type{\columntextwidth} \\
-%D the maximum width of a column \\
-%D \interface \type{\columntextheight} \\
-%D the minimum width of a column \\
-%D
-%D \interface \type{\spacingfactor} \\
-%D the spacing factor \\
-%D \interface \type{\bodyfontsize} \\
-%D the (local) bodyfontsize \\
-%D \interface \type{\openlineheight} \\
-%D the lineheight (including \type{\spacing}) \\
-%D
-%D \interface \type{\EveryBodyFont} \\
-%D communication channel to font switching routines \\
-%D
-%D \interface \type{\global\settopskip} \\
-%D set \type{\topskip} \\
-%D \interface \type{\setvsize} \\
-%D set \type{\vsize} and \type{\pagegoal} \\
-%D \interface \type{\sethsize} \\
-%D set \type{\hsize} \\
-%D
-%D \interface \type{\flushcolumnfloats} \\
-%D push saved column floats (next page) \\
-%D \interface \type{\flushcolumnfloat} \\
-%D push saved column floats (next column) \\
-%D \interface \type{\setcolumnfloats} \\
-%D initialize column floats \\
-%D
-%D \interface \type{\finishcolumnbox} \\
-%D do something special (a hook) \\
-%D \interface \type{\postprocesscolumnpagebox} \\
-%D do something with each columnbox (also a hook) \\
-%D \interface \type{\postprocesscolumnbox} \\
-%D do something with each columnbox (also a hook) \\
-%D \interface \type{\postprocesscolumnline} \\
-%D do something with each columnline (also a hook) \\
-%D \interface \type{\currentcolumn} \\
-%D the current column \\
-%D
-%D These interface macro's are called upon or initialized
-%D by the multi||column macro's.
-
-%D A lot of footnote stuff added!
\def\finalcolumntextwidth {\makeupwidth}
\def\finalcolumntextheight {\textheight}
@@ -181,23 +93,11 @@
\let\flushcolumnfloat \relax % in CONTEXT used for floats
\let\finishcolumnbox \relax % in CONTEXT used for backgrounds
-% %D In fact, the column height and width are set by means of
-% %D two macro's. One can change their meaning if needed:
-%
-% \def\setcolumntextheight
-% {\def\columntextheight{\teksthoogte}}
-%
-% \def\setcolumntextwidth
-% {\def\columntextwidth{\zetbreedte}}
-
-%D Both macros are redefined in \CONTEXT\ when backgrounds
-%D are applied to columns. The final values are used when
-%D flushing the columns.
-
-\newtoks\singlecolumnout % remove that one
+%D Both macros are redefined in \CONTEXT\ when backgrounds are applied to
+%D columns. The final values are used when flushing the columns.
-%D It's more convenient to use \type {\columnwidth} instead
-%D of messing around with boxes each time.
+%D It's more convenient to use \type {\columnwidth} instead of messing around
+%D with boxes each time.
\newdimen\columnwidth
\newdimen\gutterwidth
@@ -205,55 +105,31 @@
\def\determinecolumnwidth
{\bgroup
\setbox\scratchbox\hbox
- {\setcolumnhsize
+ {\page_mul_command_set_hsize
\global\columnwidth\usercolumnwidth
\global\gutterwidth\intercolumnwidth}%
\egroup}
-%D Going to a new columns is done by means of a
-%D \type{\ejectcolumn}. The following definition does not
-%D always work.
+%D Going to a new columns is done by means of a \type {\ejectcolumn}. The
+%D following definition does not always work.
\def\ejectcolumn
{\goodbreak
\showmessage\m!columns2\empty}
-%D The next macro should never be called so let's deal with it.
-%D There were several solutions to these kind of errors. First
-%D we check for a good breakpoint before firing up the
-%D multi||column routine (\type{\break} or \type{\allowbreak}).
-%D We do the same at the end of the routine
-%D (\type{\allowbreak}). These allowances are definitely
-%D needed!
-%D
-%D Some on first sight redundant calls to for instance
-%D \type{\setvsize} in the flushing, splitting and balancing
-%D macro's can definitely not be omitted! Some are just there
-%D to handle situations that only few times arise. One of
-%D those can be that the output routine is invoked before
-%D everything is taken care of. This happens when we
-%D flush (part of) the current page with an \type{\unvbox}
-%D with a \type{\pagetotal}~$\approx$ \type{\pagegoal}. One
-%D simply cannot balance columns that are just balanced.
-%D
-%D I hope one never sees the following message. Because it
-%D took me a lot of time to develop the multi||columns
-%D routines, every (although seldom) warning gives me the
-%D creeps!
-
\def\balancingerror
{\showmessage\m!columns3\empty
- \finaloutput\unvbox\normalpagebox}
-
-\def\OTRMULsometopsfloat{\showmessage\m!columns4\empty \someherefloat}
-\def\OTRMULsomebotsfloat{\showmessage\m!columns5\empty \someherefloat}
+ \page_otr_construct_and_shipout\unvbox\normalpagebox}
-\def\OTRMULsomeherefloat{\OTRONEsomeherefloat}
+\def\page_mul_place_float_top {\showmessage\m!columns4\empty\page_one_place_float_here}
+\def\page_mul_place_float_bottom{\showmessage\m!columns5\empty\page_one_place_float_here}
+\def\page_mul_place_float_here {\page_one_place_float_here}
+\def\page_mul_place_float_force {\page_one_place_float_force}
-%D The local column width is available in the dimension
-%D register \type{\localcolumnwidth}, which is calculated as:
+%D The local column width is available in the dimension register \type
+%D {\localcolumnwidth}, which is calculated as:
-\def\setcolumnhsize % beware, this one is available for use in macros
+\unexpanded\def\page_mul_command_set_hsize % beware, this one is available for use in macros
{\setbox\scratchbox\hbox{\parindent\zeropoint\betweencolumns}%
\intercolumnwidth\wd\scratchbox
\localcolumnwidth\columntextwidth
@@ -337,9 +213,8 @@
%D \getbuffer
%D \stop
-%D One should be aware that when font related dimensions are
-%D used in typesetting the in||between material, these
-%D dimensions are influenced by bodyfont switches inside
+%D One should be aware that when font related dimensions are used in typesetting the
+%D in||between material, these dimensions are influenced by bodyfont switches inside
%D multi||column mode.
\newdimen\mcscratchdimen
@@ -368,29 +243,49 @@
\def\multicolumnovershootratio{.5} % {\ifgridsnapping0\else.5\fi}
-\def\setcolumnvsize
- {\getmulticolumnlines
+\unexpanded\def\page_mul_command_set_vsize
+ {\page_one_command_set_vsize % indeed?
+ \getmulticolumnlines
\mcscratchdimen\nofcolumnlines\openlineheight
\advance\mcscratchdimen \multicolumnovershootratio\openlineheight % collect enough data
\global\vsize\nofcolumns\mcscratchdimen
\global\pagegoal\vsize} % let's do it only here
-%D It really starts here. After some checks and initializations
-%D we change the output routine to continous multi||column
-%D mode. This mode handles columns that fill the current and
-%D next full pages. The method used is (more or less)
-%D multiplying \type{\vsize} and dividing \type{\hsize} by
-%D \type{\nofcolumns}. More on this can be found in the
-%D \TeX book. We save the top of the current page in box
+%D It really starts here. After some checks and initializations we change the output
+%D routine to continous multi||column mode. This mode handles columns that fill the
+%D current and next full pages. The method used is (more or less) multiplying \type
+%D {\vsize} and dividing \type {\hsize} by \type {\nofcolumns}. More on this can be
+%D found in the \TeX book. We save the top of the current page in box
%D \type{\precolumnbox}.
%D
-%D We manipulate \type{\topskip} a bit, just to be shure that
-%D is has no flexibility. This has te be done every time a
-%D font switch takles place, because \type{\topskip} can depend
-%D on this.
-%D
-%D Watch the trick with the \type{\vbox}. This way we get the
-%D right interlining and white space.
+%D We manipulate \type {\topskip} a bit, just to be shure that is has no
+%D flexibility. This has te be done every time a font switch takles place, because
+%D \type{\topskip} can depend on this.
+
+\newconstant\c_page_mul_routine
+
+\setnewconstant\c_page_mul_routine_regular \zerocount
+\setnewconstant\c_page_mul_routine_intercept \plusone
+\setnewconstant\c_page_mul_routine_continuous \plustwo
+\setnewconstant\c_page_mul_routine_balanced \plusthree
+\setnewconstant\c_page_mul_routine_error \plusfour
+
+\unexpanded\def\page_mul_command_routine
+ {\ifcase\c_page_mul_routine
+ \page_one_command_routine
+ \or
+ \interceptmulticolumnsout
+ \or
+ \continuousmulticolumnsout
+ \or
+ \balancedmulticolumnsout
+ \or
+ \balancingerror
+ \fi}
+
+\def\interceptmulticolumnsout
+ {\global\setbox\precolumnbox\vbox
+ {\page_otr_command_flush_top_insertions\unvbox\normalpagebox}}
\def\beginmulticolumns
{\par
@@ -428,38 +323,29 @@
\vskip-\struttotal
\fi
\global\savedpagetotal\pagetotal
- \global\singlecolumnout\output % hm
- %\global\output{\global\setbox\precolumnbox\vbox{\unvbox\normalpagebox}}%
- %\global\output{\global\setbox\precolumnbox\vbox{\dotopinsertions\unvbox\normalpagebox}}%
- \page_otf_set_engine_output_routine{\global\setbox\precolumnbox\vbox{\dotopinsertions\unvbox\normalpagebox}}%
+ \setupoutputroutine[\s!multicolumn]%
+ \c_page_mul_routine\c_page_mul_routine_intercept
\page_otr_trigger_output_routine % no \holdinginserts=1, can make footnote disappear !
\global\precolumnboxheight\ht\precolumnbox
- %\global\output{\continuousmulticolumnsout}%
- \page_otf_set_engine_output_routine{\continuousmulticolumnsout}%
+ \c_page_mul_routine\c_page_mul_routine_continuous
\setcolumnfloats
- \dohandleallcolumns
- {\global\setbox\currenttopcolumnbox\emptybox}%
+ \dohandleallcolumns{\global\setbox\currenttopcolumnbox\emptybox}%
\checkbegincolumnfootnotes
- \page_otr_activate{MUL}{ONE}% todo ! ! ! !
- \let\sethsize\setcolumnhsize
- \let\setvsize\setcolumnvsize
- \sethsize
- \setvsize}
-
-%D When we leave the multi||column mode, we have to process the
-%D not yet shipped out part of the columns. When we don't
-%D balance, we simply force a continuous output, but a balanced
-%D output is more tricky.
-
-%D First we try to fill up the page and when all or something
-%D is left we try to balance things. This is another useful
-%D adaption of the ancesters of these macro's. It takes some
-%D reasoning to find out what happens and maybe I'm making
+ \page_otr_command_set_hsize
+ \page_otr_command_set_vsize}
+
+%D When we leave the multi||column mode, we have to process the not yet shipped out
+%D part of the columns. When we don't balance, we simply force a continuous output,
+%D but a balanced output is more tricky.
+%D
+%D First we try to fill up the page and when all or something is left we try to
+%D balance things. This is another useful adaption of the ancesters of these
+%D macro's. It takes some reasoning to find out what happens and maybe I'm making
%D some mistake, but it works.
%D
-%D Voiding box \type{\precolumnbox} is sometimes necessary,
-%D e.g. when there is no text given between \type{\begin..}
-%D and \type{\end..}. The \type{\par} is needed!
+%D Voiding box \type {\precolumnbox} is sometimes necessary, e.g. when there is no
+%D text given between \type {\begin..} and \type {\end..}. The \type {\par} is
+%D needed!
\setnewconstant\multicolumnendsyncmethod\plusone % 1: old sync 2: new sync (cont-loc/project) / may fail ! ! ! !
@@ -478,34 +364,36 @@
\par
\ifbalancecolumns
\ifnum\multicolumnendsyncmethod=\plusone
- %\global\output{\continuousmulticolumnsout}%
- \page_otf_set_engine_output_routine{\continuousmulticolumnsout}%
+ \c_page_mul_routine\c_page_mul_routine_continuous
\goodbreak
\fi
- %\global\output{\balancedmulticolumnsout}%
- \page_otf_set_engine_output_routine{\balancedmulticolumnsout}%
+ \c_page_mul_routine\c_page_mul_routine_balanced
\else
\goodbreak
\fi
+ % still the multi column routine
\page_otr_trigger_output_routine % the prevdepth is important, try e.g. toclist in
\prevdepth\zeropoint % columns before some noncolumned text text
- \page_otf_set_engine_output_routine{\singlecolumnout}%
- \page_otf_set_engine_output_routine{\page_otr_triggered_output_routine}%
+ %
+ \c_page_mul_routine\c_page_mul_routine_regular
+% \page_otf_set_engine_output_routine{\singlecolumnout}%
+% \page_otf_set_engine_output_routine{\page_otr_triggered_output_routine}%
+ %
\ifvoid\precolumnbox\else
\unvbox\precolumnbox
\fi
\global\precolumnboxheight\zeropoint
\endgroup % here
\nofcolumns\plusone
- \setvsize % the outer one!
+ \page_otr_command_set_vsize % the outer vsize (NEEDS CHECKING)
\synchronizeoutput % new may 2004 / we need to: \pagegoal\vsize
\checkendcolumnfootnotes
\dosomebreak\allowbreak
\dopopcolumnfloats}
-
-%D Because some initializations happen three times, we
-%D defined a macro for them. Erasing \type{\everypar} is
-%D needed because we don't want anything to interfere.
+
+%D Because some initializations happen three times, we defined a macro for
+%D them. Erasing \type{\everypar} is needed because we don't want anything
+%D to interfere.
\def\setmulticolumnsout
{\everypar\emptytoks
@@ -518,27 +406,22 @@
\boxmaxdepth\maxdepth % dangerous
\emergencystretch\zeropoint\relax} % sometimes needed !
-%D Flushing the page comes to pasting the columns together and
-%D appending the result to box \type{\precolumnbox}, if not
-%D void. I've seen a lot of implementations in which some skip
-%D was put between normal text and multi||column text. When we
-%D don't want this, the baselines can be messed up. I hope the
-%D seemingly complicated calculation of a correction
-%D \type{\kern} is adequate to overcome this. Although not
-%D watertight, spacing is taken into account and even multiple
-%D mode changes on one page go well. But cross your fingers and
-%D don't blame me.
+%D Flushing the page comes to pasting the columns together and appending the result
+%D to box \type {\precolumnbox}, if not void. I've seen a lot of implementations in
+%D which some skip was put between normal text and multi||column text. When we don't
+%D want this, the baselines can be messed up. I hope the seemingly complicated
+%D calculation of a correction \type {\kern} is adequate to overcome this. Although
+%D not watertight, spacing is taken into account and even multiple mode changes on
+%D one page go well. But cross your fingers and don't blame me.
%D
-%D One of the complications of flushing out the boxes is that
-%D \type{\precolumnbox} needs to be \type{\unvbox}'ed, otherwise
-%D there is too less flexibility in the page when using
-%D \type{\raggedbottom}. It took a lot of time before these
-%D kind of problems were overcome. Using \type{\unvbox} at the
-%D wrong moment can generate \type{\balancingerror}'s.
+%D One of the complications of flushing out the boxes is that \type {\precolumnbox}
+%D needs to be \type {\unvbox}'ed, otherwise there is too less flexibility in the
+%D page when using \type {\raggedbottom}. It took a lot of time before these kind of
+%D problems were overcome. Using \type {\unvbox} at the wrong moment can generate
+%D \type {\balancingerror}'s.
%D
-%D One can use the macros \type {\maxcolumnheight} and \type
-%D {\maxcolumndepth} when generating material between columns
-%D as well as postprocessing column lines.
+%D One can use the macros \type {\maxcolumnheight} and \type {\maxcolumndepth} when
+%D generating material between columns as well as postprocessing column lines.
\let\maxcolumnheight=\zeropoint
\let\maxcolumndepth =\zeropoint
@@ -607,6 +490,7 @@
\fi
{\finishcolumnbox{\hbox
{\ifx\finishcolumnbox\relax\else\strut\fi
+ \anch_mark_column_box\currentcolumnbox
\box\currentcolumnbox}}%
\hfil}%
\unskip
@@ -643,7 +527,7 @@
\fi \fi
\fi
\global\precolumnboxheight\zeropoint
- \setvsize
+ \page_otr_command_set_vsize
\dosomebreak\nobreak % hm, only needed when topstuff
\ifgridsnapping
\else
@@ -709,13 +593,11 @@
\box\columnpagebox
\egroup}
-%D In case one didn't notice, finaly \type{\finishcolumnbox} is
-%D applied to all boxes. One can use these hooks for special
-%D purposes.
+%D In case one didn't notice, finaly \type{\finishcolumnbox} is applied to
+%D all boxes. One can use these hooks for special purposes.
%D
-%D Once upon a time I wanted to manipulate the individual lines
-%D in a column. This feature is demonstrated in the two examples
-%D below.
+%D Once upon a time I wanted to manipulate the individual lines in a column.
+%D This feature is demonstrated in the two examples below.
%D
%D \startbuffer
%D \def\postprocesscolumnline#1% or \postprocesscolumnbox
@@ -794,21 +676,18 @@
%D \macros
%D {reversecolumnstrue}
%D
-%D We can force the macro that takes care of combining
-%D the columns, to flush them in the revere order. Of
-%D course, by default we don't reverse.
+%D We can force the macro that takes care of combining the columns, to
+%D flush them in the revere order. Of course, by default we don't reverse.
\newif\ifreversecolumns
-%D Here comes the simple splitting routine. It's a bit
-%D longer than expected because of ragging bottoms or not.
-%D This part can be a bit shorter but I suppose that I will
-%D forget what happens. The splitting takes some already
-%D present material (think of floats) into account!
+%D Here comes the simple splitting routine. It's a bit longer than expected because
+%D of ragging bottoms or not. This part can be a bit shorter but I suppose that I
+%D will forget what happens. The splitting takes some already present material
+%D (think of floats) into account!
%D
-%D First we present some auxiliary routines. Any material,
-%D like for instance floats, that is already present in the
-%D boxes is preserved.
+%D First we present some auxiliary routines. Any material, like for instance floats,
+%D that is already present in the boxes is preserved.
\def\splitcolumn#1from \box#2to \dimen#3 top \box#4%
{\bgroup
@@ -829,7 +708,7 @@
\fuzzysnappedbox\unvbox0
\fakecolumnfootnotes{#1}}%
\else
- \ifcase\clevernotes
+ \ifcase\c_strc_notes_page_location
\global\setbox#1\vsplit#2 to \dimen#3%
\global\setbox#1\vbox
{\fuzzysnappedbox\unvbox{#1}}% % or \box ?
@@ -859,7 +738,7 @@
\def\fakecolumnfootnotes#1%
{\relax
- \ifcase\clevernotes\else
+ \ifcase\c_strc_notes_page_location\else
\ifnum#1=\lastcolumnbox
\fakenotes
\fi
@@ -867,7 +746,7 @@
\def\columnfootnotecorrection#1#2%
{\relax
- \ifcase\clevernotes
+ \ifcase\c_strc_notes_page_location
% page notes
\or
\ifnum#1=\firstcolumnbox\relax
@@ -883,57 +762,63 @@
\def\overlaycolumnfootnotes
{\relax
- \ifcase\clevernotes
- % page notes
- \else
- \checknotepresence
- \ifnotespresent
- % the note box has the depth of the notefont
- % because a column (i.e. first column has no depth,
- % we need to anchor top down)
- \bgroup
- \ifcase\clevernotes\or
- \getmulticolumnlines
- \advance\nofcolumnlines \minustwo
- \scratchdimen\nofcolumnlines\lineheight
- \advance\scratchdimen \topskip
- \setbox0\hbox
- {\lower\scratchdimen\vbox{\placenoteinserts}}%
- \ht0=\openstrutheight % \strutht
- \dp0=\openstrutdepth % \strutdp
- \wd0=\zeropoint
- \scratchdimen\ht\firstcolumnbox
- \global\setbox\firstcolumnbox\vbox to \scratchdimen
- {\box\firstcolumnbox
- \vskip-\scratchdimen
- \box0}%
- \else
- % maybe here also \getmulticolumnlines
- \scratchdimen\ht\firstcolumnbox
- \advance\scratchdimen -\openstrutdepth % \strutdp
- \getnoflines\scratchdimen
- \advance\noflines \minustwo
- \scratchdimen\noflines\lineheight
- \advance\scratchdimen \topskip
- \setbox0\hbox
- {\lower\scratchdimen\vbox{\placenoteinserts}}%
- \ht0=\openstrutheight % \strutht
- \dp0=\openstrutdepth % \strutdp
- \wd0=\zeropoint
- \scratchdimen\ht\lastcolumnbox
- \global\setbox\lastcolumnbox\vbox to \scratchdimen
- {\box\lastcolumnbox
- \vskip-\scratchdimen
- \box0}%
- \fi
- \egroup
- \fi
+ \ifcase\c_strc_notes_page_location
+ % page
+ \or
+ \checknotepresence \ifnotespresent \page_mul_notes_flush_first_column \fi
+ \or
+ \checknotepresence \ifnotespresent \page_mul_notes_flush_last_column \fi
\fi}
-%D Here comes the routine that splits the long box in columns.
-%D The macro \type{\flushcolumnfloats} can be used to flush
-%D either floats that were present before the multi||column
-%D mode was entered, or floats that migrate to next columns.
+\newbox\b_page_mul_notes
+
+\def\page_mul_notes_flush_first_column
+ {\begingroup
+ \setbox\b_page_mul_notes\vbox{\placenoteinserts}%
+ \ifzeropt\ht\b_page_mul_notes
+ % can't happen as we already checked
+ \else
+ \getmulticolumnlines
+ \advance\nofcolumnlines \minustwo
+ \scratchdimen\dimexpr\nofcolumnlines\lineheight+\topskip\relax
+ \setbox\b_page_mul_notes\hbox{\lower\scratchdimen\box\b_page_mul_notes}%
+ \ht\b_page_mul_notes\openstrutheight
+ \dp\b_page_mul_notes\openstrutdepth
+ \wd\b_page_mul_notes\zeropoint
+ \scratchdimen\ht\firstcolumnbox
+ \global\setbox\firstcolumnbox\vbox to \scratchdimen
+ {\box\firstcolumnbox
+ \vskip-\scratchdimen
+ \box\b_page_mul_notes}%
+ \fi
+ \endgroup}
+
+\def\page_mul_notes_flush_last_column
+ {\begingroup
+ \setbox\b_page_mul_notes\vbox{\placenoteinserts}%
+ \ifzeropt\ht\b_page_mul_notes
+ % can't happen as we already checked
+ \else
+ % maybe here also \getmulticolumnlines
+ \scratchdimen\dimexpr\ht\firstcolumnbox-\openstrutdepth\relax % \strutdp
+ \getnoflines\scratchdimen
+ \advance\noflines \minustwo
+ \scratchdimen\dimexpr\noflines\lineheight+\topskip\relax
+ \setbox\b_page_mul_notes\hbox{\lower\scratchdimen\box\b_page_mul_notes}%
+ \ht\b_page_mul_notes\openstrutheight
+ \dp\b_page_mul_notes\openstrutdepth
+ \wd\b_page_mul_notes\zeropoint
+ \scratchdimen\ht\lastcolumnbox
+ \global\setbox\lastcolumnbox\vbox to \scratchdimen
+ {\box\lastcolumnbox
+ \vskip-\scratchdimen
+ \box\b_page_mul_notes}%
+ \fi
+ \endgroup}
+
+%D Here comes the routine that splits the long box in columns. The macro \type
+%D {\flushcolumnfloats} can be used to flush either floats that were present before
+%D the multi||column mode was entered, or floats that migrate to next columns.
%D Flushing floats is a delicate process.
\def\continuousmulticolumnsout
@@ -964,7 +849,8 @@
\vskip\openstrutdepth % \strutdp
\prevdepth\openstrutdepth % \strutdp
\vfill}}%
- \ifbottomnotes \else
+ \strc_notes_check_if_bottom_present
+ \ifconditional\c_notes_bottom_present \else
\dimen0\ht\firstcolumnbox
\fi
\or
@@ -990,21 +876,19 @@
{\ht\currentcolumnbox\dimen0}% redundant
\fi
\setbox\precolumnbox\vbox{\flushcolumnedpage\zerocount}%
- \finaloutput\box\precolumnbox
- \sethsize
- \setvsize
+ \page_otr_construct_and_shipout\box\precolumnbox
+ \page_otr_command_set_hsize
+ \page_otr_command_set_vsize
\flushcolumnfloats
\unvbox\restofpage
% \penalty\outputpenalty % gaat gruwelijk mis in opsommingen
\egroup}
-%D And this is the balancing stuff. Again, part of the routine
-%D is dedicated to handling ragged bottoms, but here we also
-%D see some handling concerning the stretching of columns.
-%D We set \type{\widowpenalty} at~0, which enables us to
-%D balance columns with few lines. The use of \type{\box2} and
-%D \type{\box4} garantees a more robust check when skips are
-%D used.
+%D And this is the balancing stuff. Again, part of the routine is dedicated to
+%D handling ragged bottoms, but here we also see some handling concerning the
+%D stretching of columns. We set \type {\widowpenalty} at~0, which enables us to
+%D balance columns with few lines. The use of \type {\box2} and \type {\box4}
+%D garantees a more robust check when skips are used.
\def\multicolumnsbalancemax{250} % 100 is too small when floats are involved
@@ -1148,8 +1032,7 @@
\showmessage\m!columns{10}\empty
\global\setbox\firstcolumnbox\vbox{\unvbox0}%
\fi
- %\global\output{\balancingerror}%
- \page_otf_set_engine_output_routine{\balancingerror}%
+ \c_page_mul_routine\c_page_mul_routine_error
\baselinebottom % forces depth in separation rule
\flushcolumnedpage\plusone
\multicolumnseject
@@ -1162,8 +1045,8 @@
\allowbreak
}%\fi}
-%D The multicolumn mechanism is incorporated in a \CONTEXT\
-%D interface, which acts like:
+%D The multicolumn mechanism is incorporated in a \CONTEXT\ interface,
+%D which acts like:
%D
%D \starttyping
%D \startcolumns[n=4,balance=no]
@@ -1171,8 +1054,8 @@
%D \stopcolumns
%D \stoptyping
%D
-%D The setup is optional. The default behaviour of columns
-%D can be set up with:
+%D The setup is optional. The default behaviour of columns can be set
+%D up with:
%D
%D \starttyping
%D \setupcolumns
@@ -1180,31 +1063,24 @@
%D balance=yes]
%D \stoptyping
%D
-%D In this case, stretching is according to the way it's
-%D done outside columns (\type{\inheritcolumnstrue}). Also
-%D we can setup the \type{tolerance} within a column, the
-%D \type{distance} between columns and the fixed
-%D \type{height} of a column.
-
-%D Multi||column output: the float routines
+%D In this case, stretching is according to the way it's done outside columns
+%D (\type{\inheritcolumnstrue}). Also we can setup the \type{tolerance} within a
+%D column, the \type{distance} between columns and the fixed \type{height} of a
+%D column.
%D
-%D Here come the routines that handle the placement of column
-%D floats. Floats that are to big migrate to the next
-%D column. Floats that are too wide, migrate to the top of the
-%D next page, where they span as much columns as needed.
-%D Floats that are left over from outside the multi||column
-%D mode are flushed first. In macro \type{\finaloutput} the
-%D topfloats that are left from previous text should be set.
+%D Here come the routines that handle the placement of column floats. Floats that
+%D are to big migrate to the next column. Floats that are too wide, migrate to the
+%D top of the next page, where they span as much columns as needed. Floats that are
+%D left over from outside the multi||column mode are flushed first. In macro
+%D \type{\page_otr_construct_and_shipout} the topfloats that are left from previous
+%D text should be set.
%D
-%D When there are some floats in the queue, we inhibit the
-%D flushing of floats on top of columns. The number of
-%D waiting floats is preswent in \type{\savednoftopfloats} and
-%D is saved. As long as there are floats waiting, the topfloats
-%D are places as if we are outside multi||column mode. This is
-%D neccessary for e.g. multicolumn lists.
+%D When there are some floats in the queue, we inhibit the flushing of floats on top
+%D of columns. The number of waiting floats is preswent in \type{\savednoftopfloats}
+%D and is saved. As long as there are floats waiting, the topfloats are places as if
+%D we are outside multi||column mode. This is neccessary for e.g. multicolumn lists.
%D
-%D When all those floats are flushed, we switch to the local
-%D flushing routine.
+%D When all those floats are flushed, we switch to the local flushing routine.
\def\dopushcolumnfloats
{\ifsomefloatwaiting
@@ -1235,10 +1111,29 @@
\newconditional\onlylocalcolumnfloats % temp hack as we will redo floats (grid snapping is also messy now)
-\def\OTRMULdocheckiffloatfits{\ifconditional\onlylocalcolumnfloats\docolumnroomfloat \else\relax \fi}
-\def\OTRMULdosetbothinserts {\ifconditional\onlylocalcolumnfloats\relax \else\OTRONEdosetbothinserts\fi}
-\def\OTRMULdotopinsertions {\ifconditional\onlylocalcolumnfloats\relax \else\OTRONEdotopinsertions \fi}
-\def\OTRMULdoflushfloats {\ifconditional\onlylocalcolumnfloats\doflushcolumnfloats\else\OTRONEdoflushfloats \fi}
+\unexpanded\def\page_mul_command_flush_floats
+ {\ifconditional\onlylocalcolumnfloats
+ \doflushcolumnfloats
+ \else
+ \page_one_command_flush_floats
+ \fi}
+
+\unexpanded\def\page_mul_command_check_if_float_fits
+ {\ifconditional\onlylocalcolumnfloats
+ \docolumnroomfloat
+ \fi}
+
+\unexpanded\def\page_mul_command_flush_saved_floats
+ {\ifconditional\onlylocalcolumnfloats\relax
+ \else
+ \page_one_command_flush_saved_floats
+ \fi}
+
+\unexpanded\def\page_mul_command_flush_top_insertions
+ {\ifconditional\onlylocalcolumnfloats\relax
+ \else
+ \page_one_command_flush_top_insertions
+ \fi}
\newtoks\everylocalcolumnfloatspar
@@ -1264,7 +1159,7 @@
{\bgroup
\xdef\localsavednoffloats{\the\savednoffloats}%
\global\savednoffloats\globalsavednoffloats
- \dotopinsertions
+ \page_otr_command_flush_top_insertions
\xdef\globalsavenoffloats{\the\savednoffloats}%
\ifnum\globalsavednoffloats=\zerocount
\setlocalcolumnfloats
@@ -1272,14 +1167,12 @@
\global\savednoffloats\localsavednoffloats
\egroup}
-%D We need to calculate the amount of free space in a columns.
-%D When there is not enough room, we migrate the float to the
-%D next column. These macro's are alternatives (and
-%D look||alikes) of \type{\doroomfloat}. When a float is to
-%D wide, for one column, it is moved to the top of the next
-%D page. Of course such moved floats have to be taken into
-%D account when we calculate the available space. It's a pitty
-%D that such things are no integral part of \TEX.
+%D We need to calculate the amount of free space in a columns. When there is not
+%D enough room, we migrate the float to the next column. These macro's are
+%D alternatives (and look||alikes) of \type {\doroomfloat}. When a float is to wide,
+%D for one column, it is moved to the top of the next page. Of course such moved
+%D floats have to be taken into account when we calculate the available space. It's
+%D a pitty that such things are no integral part of \TEX.
\def\getcolumnstatus\column#1\total#2\goal#3\\%
{\dimen0=\ifdim\pagegoal<\maxdimen \pagetotal \else \zeropoint \fi
@@ -1339,10 +1232,9 @@
\fi
\egroup
\fi\fi}
-
-%D Flushing one float is done as soon as possible, i.e.
-%D \type{\everypar}. This means that (at the moment)
-%D sidefloats are not supported (overulled)!
+
+%D Flushing one float is done as soon as possible, i.e. \type {\everypar}.
+%D This means that (at the moment) sidefloats are not supported (overulled)!
\newif\ifflushingcolumnfloats \flushingcolumnfloatstrue
@@ -1394,26 +1286,25 @@
\nobreak
\fi
\dofloatsflush\s!text{1}%
- \flushfloatbox
+ \page_otr_command_flush_float_box
\blank[\rootfloatparameter\c!spaceafter]
\fi
\fi
\fi
\egroup}
-%D This one looks complicated. Upto \type{\nofcolumns} floats
-%D are placed, taking the width of a float into account. This
-%D routine can be improved on different ways:
+%D This one looks complicated. Upto \type{\nofcolumns} floats are placed,
+%D taking the width of a float into account. This routine can be improved
+%D on different ways:
%D
%D \startitemize[intro,packed]
-%D \item taking into account some imaginary baseline, just to
-%D get the captions in line
-%D \item multipass flushing until as many floats are displaced
-%D as possible
+%D \item taking into account some imaginary baseline, just to get the
+%D captions in line
+%D \item multipass flushing until as many floats are displaced as possible
%D \stopitemize
%D
-%D When handling lots of (small) floats spacing can get worse
-%D because of lining out the columns.
+%D When handling lots of (small) floats spacing can get worse because of
+%D lining out the columns.
\def\doflushcolumnfloats
{\ifpostponecolumnfloats\else
@@ -1479,17 +1370,17 @@
\advance\dimen8 \dimen6
\advance\count2 \minusone
\advance\count0 \minusone }%
- \setvsize
+ \page_otr_command_set_vsize
\global\advance\vsize -\dimen8
\global\pagegoal\vsize
\else
- %\doflushfloats % does not snap!
+ % \page_mul_command_flush_floats % does not snap!
\fi
\egroup
\fi}
-%D The next macro can be used to flush floats in the current
-%D stream. No width checking is (yet) done.
+%D The next macro can be used to flush floats in the current stream. No
+%D width checking is (yet) done.
\def\insertcolumnfloats
{\doloop
@@ -1506,11 +1397,11 @@
\exitloop
\fi}}
-%D This were the multi||column routines. They can and need to
-%D be improved but at the moment their behaviour is acceptable.
+%D This were the multi||column routines. They can and need to be improved
+%D but at the moment their behaviour is acceptable.
%D
-%D One inprovement can be to normalize the height of floats
-%D to $n\times$\type{\lineheight} with a macro like:
+%D One inprovement can be to normalize the height of floats to $ n \times $
+%D \type {\lineheight} with a macro like:
%D
%D \starttyping
%D \normalizevbox{...}
@@ -1519,13 +1410,11 @@
% border case, should fit on one page
%
% \startcolumns
-%
-% 1 \input tufte \par \plaatsfiguur{}{\omlijnd[breedte=\hsize,hoogte=3cm]{1}}
-% 2 \input tufte \par \plaatsfiguur{}{\omlijnd[breedte=\hsize,hoogte=3cm]{2}}
-% 3 \input tufte \par \plaatsfiguur{}{\omlijnd[breedte=\hsize,hoogte=3cm]{3}}
-%
+% 1 \input tufte \par \placefigure{}{\framed[width=\hsize,height=3cm]{1}}
+% 2 \input tufte \par \placefigure{}{\framed[width=\hsize,height=3cm]{2}}
+% 3 \input tufte \par \placefigure{}{\framed[width=\hsize,height=3cm]{3}}
% \stopcolumns
-
+
\unexpanded\def\setupcolumns
{\dosingleempty\dosetupcolumns}
@@ -1632,19 +1521,18 @@
\fi
\fi}
-\installcolumnbreakmethod {MUL} \v!preference
+\installcolumnbreakmethod \s!multicolumn \v!preference
{\goodbreak}
-\installcolumnbreakmethod {MUL} \v!yes
+\installcolumnbreakmethod \s!multicolumn \v!yes
{\par % todo: since
{\testrulewidth\zeropoint\ruledvskip\textheight} % we misuse a
\penalty-200 % side effect
\vskip-\textheight
}% bugged : \prevdepth-\thousandpoint} % signals top of column to \blank
-
-%D New: only at start of columns; may change ! Rather
-%D interwoven and therefore to be integrated when the multi
-%D column modules are merged. (moved from cont-new.tex)
+
+%D New: only at start of columns; may change ! Rather interwoven and therefore
+%D to be integrated when the multi column modules are merged.
\unexpanded\def\setupcolumnspan[#1]%
{\getparameters[\??ks][#1]}
@@ -1684,7 +1572,7 @@
\wd\b_page_columns_span\hsize
\ifinsidecolumns
\ifnum\@@ksn>1
- \setvsize
+ \page_otr_command_set_vsize
\dohandleallcolumns
{\ifnum\currentcolumn>\@@ksn\else
\global\setbox\currenttopcolumnbox=\vbox
@@ -1712,7 +1600,7 @@
\unexpanded\def\stopcolumnspan
{\egroup}
-
+
\setupcolumns
[\c!n=2,
\c!ntop=1,
@@ -1728,7 +1616,7 @@
\c!option=,
\c!rulethickness=\linewidth,
\c!offset=.5\bodyfontsize]
-
+
%D Undocumented and still under development.
\unexpanded\def\startsimplecolumns
@@ -1756,5 +1644,30 @@
\let\rigidcolumnlines\@@kllines
\setrigidcolumnhsize\@@klwidth\@@kldistance\@@kln}
+\let\page_mul_command_package_contents\page_one_command_package_contents
+\let\page_mul_command_flush_float_box \page_one_command_flush_float_box
+
+\defineoutputroutine
+ [\s!multicolumn]
+ [\s!page_otr_command_routine =\page_mul_command_routine,
+ \s!page_otr_command_package_contents =\page_mul_command_package_contents,
+ \s!page_otr_command_set_vsize =\page_mul_command_set_vsize,
+ \s!page_otr_command_set_hsize =\page_mul_command_set_hsize,
+ \s!page_otr_command_next_page =\page_mul_command_next_page,
+ \s!page_otr_command_next_page_and_inserts =\page_mul_command_next_page_and_inserts,
+ % \s!page_otr_command_synchronize_hsize =\page_mul_command_synchronize_hsize,
+ % \s!page_otr_command_set_top_insertions =\page_mul_command_set_top_insertions,
+ % \s!page_otr_command_set_bottom_insertions =\page_mul_command_set_bottom_insertions,
+ \s!page_otr_command_flush_top_insertions =\page_mul_command_flush_top_insertions,
+ % \s!page_otr_command_flush_bottom_insertions =\page_mul_command_flush_bottom_insertions,
+ % \s!page_otr_command_set_float_hsize =\page_mul_command_set_float_hsize,
+ \s!page_otr_command_check_if_float_fits =\page_mul_command_check_if_float_fits,
+ \s!page_otr_command_flush_float_box =\page_mul_command_flush_float_box,
+ \s!page_otr_command_synchronize_side_floats =\page_mul_command_synchronize_side_floats,
+ \s!page_otr_command_side_float_output =\page_mul_command_side_float_output,
+ \s!page_otr_command_flush_floats =\page_mul_command_flush_floats,
+ \s!page_otr_command_flush_side_floats =\page_mul_command_flush_side_floats,
+ \s!page_otr_command_flush_saved_floats =\page_mul_command_flush_saved_floats
+ ]
\protect \endinput
diff --git a/tex/context/base/page-not.mkiv b/tex/context/base/page-not.mkiv
index 8a0298598..06e2f3875 100644
--- a/tex/context/base/page-not.mkiv
+++ b/tex/context/base/page-not.mkiv
@@ -23,7 +23,7 @@
\unprotect
\def\checkbegincolumnfootnotes % should happen inside otr
- {\ifcase\clevernotes
+ {\ifcase\c_strc_notes_page_location
\erasenotebackup
\else
\flushnotes
@@ -33,7 +33,7 @@
\def\checkendcolumnfootnotes
{\restorenotedata
- \ifcase\clevernotes\else
+ \ifcase\c_strc_notes_page_location\else
\restorenotecontent
\fi}
@@ -50,7 +50,7 @@
% hm
\def\checkbegincolumnfootnotes % should happen inside otr
- {\ifcase\clevernotes
+ {\ifcase\c_strc_notes_page_location
\erasenotebackup
\else
\flushnotes
@@ -61,7 +61,7 @@
\def\checkendcolumnfootnotes
{\restorenotedata
\ifinsidecolumns
- \ifcase\clevernotes\else
+ \ifcase\c_strc_notes_page_location\else
\restorenotecontent
\fi
\fi}
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index 98d82f3a7..1a695e157 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -20,22 +20,21 @@
% OTRONE: basic single column
-\page_otr_activate{ONE}\empty % the default otr
+\newdimen\d_page_one_saved_vsize
-\newtoks\OTRONEoutput
-
-\def\OTRONEgotonextpage
+\unexpanded\def\page_one_command_next_page
{\page_otr_eject_page}
-\def\OTRONEgotonextpageX % will become obsolete
+\unexpanded\def\page_one_command_next_page_and_inserts
{\page_otr_eject_page_and_flush_inserts}
-\def\OTRONEsethsize
+\unexpanded\def\page_one_command_set_hsize
{\global\hsize\textwidth}
-\newdimen\oldvsize
+\unexpanded\def\page_one_command_set_float_hsize
+ {\global\hsize\textwidth}
-\def\OTRONEsetvsize
+\unexpanded\def\page_one_command_set_vsize
{\ifgridsnapping
\ifcase\layoutlines
\getrawnoflines\textheight
@@ -47,13 +46,13 @@
\global\vsize\textheight
\fi
\ifdim\pagegoal<\maxdimen
- \ifdim\oldvsize=\vsize
+ \ifdim\d_page_one_saved_vsize=\vsize
% let's assume that the layout didn't change
\else
- \global\oldvsize\vsize
+ \global\d_page_one_saved_vsize\vsize
\global\pagegoal\dimexpr\vsize-\topinserted-\botinserted\relax
% \bgroup
-% \global\oldvsize\vsize
+% \global\d_page_one_saved_vsize\vsize
% \advance\vsize-\topinserted
% \advance\vsize-\botinserted
% \global\pagegoal\vsize
@@ -61,36 +60,25 @@
\fi
\fi}
-% can we avoid the extra vboxing here?
-
-\def\OTRONEregisteredtextarea#1% obsolete
- {\ifconditional\c_page_areas_enabled
- \setbox0\vbox{#1}%
- \wd0\makeupwidth % somehow a space creeps in
- \vbox{\registeredtextarea000}%
- \else
- #1%
- \fi}
-
% 1 = partial page, 2 = whole page, 3 = partial page
\setnewconstant\kindofpagetextareas\plustwo
-\def\OTRONEregisteredtextareaA
+\def\page_one_registered_text_area_a
{\ifconditional\c_page_areas_enabled
- \expandafter\OTRONEregisteredtextareaAindeed
+ \expandafter\page_one_registered_text_area_a_indeed
\else
\expandafter\firstofoneargument
\fi}
-\def\OTRONEregisteredtextareaB
+\def\page_one_registered_text_area_b
{\ifconditional\c_page_areas_enabled
- \expandafter\OTRONEregisteredtextareaBindeed
+ \expandafter\page_one_registered_text_area_b_indeed
\else
\expandafter\firstofoneargument
\fi}
-\def\OTRONEregisteredtextareaAindeed
+\def\page_one_registered_text_area_a_indeed
{\ifcase\kindofpagetextareas
\expandafter\firstofoneargument
\or % partial page (experimental)
@@ -101,7 +89,7 @@
\expandafter\page_areas_register_boxed
\fi}
-\def\OTRONEregisteredtextareaBindeed
+\def\page_one_registered_text_area_b_indeed
{\ifcase\kindofpagetextareas
\expandafter\firstofoneargument
\or % partial page (experimental)
@@ -113,34 +101,51 @@
\fi}
\newdimen\d_page_one_natural_depth
+\newbox \b_page_one_bottom_notes
+\newbox \b_page_one_contents
+
+\let\page_one_command_package_show_state\relax
+
+% \fakepagenotes ... needs checking
+%
+% we can also have bottom notes on top of bottom insertions
-\def\OTRONEdopagecontents#1#2% \box<n> \unvbox<n> % this one will be redone (checked)
+\unexpanded\def\page_one_command_package_contents#1#2% \box<n> \unvbox<n> % this one will be redone (checked)
{\bgroup
\strc_notes_check_if_bottom_present
- \setbox0\vbox \ifconditional\c_notes_bottom_present to \textheight \fi
- {\d_page_one_natural_depth\dp#2\relax
- \dotopinsertions
- \OTRONEregisteredtextareaA{#1#2}%
+ \d_page_one_natural_depth\dp#2\relax
+ % we need to set the height as otherwise the shrink will not kick in so the following
+ % no longer applies:
+ %
+ % \setbox\b_page_one_contents\vbox \ifconditional\c_notes_bottom_present to \textheight \fi
+ %
+ \setbox\b_page_one_contents\vbox to \textheight
+ {\page_otr_command_flush_top_insertions
+ % this is messy ... we will provide a more tight area (no big deal as we can
+ % do that at the lua end)
+ \page_one_registered_text_area_a{#1#2}% \unvbox <box>
+ %
\ifgridsnapping
\vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax
\prevdepth\openstrutdepth
- \dobotinsertions
+ \page_otr_command_flush_bottom_insertions
\vfil
\else\ifcase\bottomraggednessmode
- % ragged
+ % ragged (default)
\vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax
\prevdepth\openstrutdepth
- \dobotinsertions
+ \page_otr_command_flush_bottom_insertions
\vfil
\or
% align (normal)
- \dobotinsertions
+ \page_otr_command_flush_bottom_insertions
\or
% baseline
\kern\dimexpr\maxdepth-\d_page_one_natural_depth\relax
- \dobotinsertions
+ \page_otr_command_flush_bottom_insertions
\fi\fi
\fakepagenotes}%
+ \page_one_command_package_show_state
\ifconditional\c_notes_bottom_present
\ifgridsnapping
\ifcase\layoutlines
@@ -148,47 +153,42 @@
\else
\noflines\layoutlines
\fi
- \advance\noflines\minusone
- \scratchoffset\dimexpr\noflines\lineheight+\topskip\relax
+ \scratchoffset\dimexpr\numexpr\noflines-\plusone\relax\lineheight+\topskip\relax
\else
- \scratchoffset\ht0
+ \scratchoffset\ht\b_page_one_contents
\fi
+ \setbox\b_page_one_bottom_notes\hbox
+ {\checksinglecolumnfootnotes % why this check? ***
+ \lower\scratchoffset\vbox{\placebottomnotes}}%
+ \smashbox\b_page_one_bottom_notes
+ \ht\b_page_one_contents\zeropoint
+ \page_one_registered_text_area_b
+ {\vbox to \textheight
+ {\box\b_page_one_contents
+ \box\b_page_one_bottom_notes}}%
\else
- \scratchoffset\zeropoint
+ \ht\b_page_one_contents\textheight
+ \page_one_registered_text_area_b
+ {\box\b_page_one_contents}%
\fi
- \setbox2\hbox
- {\checksinglecolumnfootnotes % why this check?
- \lower\scratchoffset
- \vbox{\placebottomnotes}}%
- \smashbox2% % needed here
- \OTRONEregisteredtextareaB
- {\vbox to \textheight
- {\ifconditional\c_notes_bottom_present
- \ht0\zeropoint
- \box0
- \box2
- \else
- \box0
- \box2
- \vfill
- \fi}}%
\egroup}
-\def\OTRONEfinalsidefloatoutput
- {\finaloutput\unvbox\normalpagebox}
+\unexpanded\def\page_one_command_side_float_output
+ {\page_otr_construct_and_shipout\unvbox\normalpagebox}
-\OTRONEoutput{\page_sides_output_routine} % this will become a command
+\unexpanded\def\page_one_command_routine
+ {\page_sides_output_routine}
%D Insertions
-\newif\iftopofinsert
+\newconditional\c_page_one_top_of_insert
-\def\OTRONEdosettopinserts
+\unexpanded\def\page_one_command_set_top_insertions
{\bgroup
\ifsomefloatwaiting
\noffloatinserts\zerocount
\let\totaltopinserted\!!zeropoint
- \OTRONEdodosettopinserts
+ \page_one_command_set_top_insertions_indeed
\ifnum\rootfloatparameter\c!nbottom=\zerocount
\ifnum\rootfloatparameter\c!nlines>\zerocount
\ifdim\totaltopinserted>\zeropoint\relax
@@ -202,20 +202,20 @@
\fi
\egroup}
-\def\OTRONEdodosettopinserts
+\def\page_one_command_set_top_insertions_indeed
{\ifnum\noffloatinserts<\noftopfloats
\dogetfloat
\ifdim\topinserted=\zeropoint
- \topofinserttrue
+ \settrue\c_page_one_top_of_insert
\else
- \topofinsertfalse
+ \setfalse\c_page_one_top_of_insert
\fi
\global\advance\topinserted\dimexpr\ht\floatbox+\dp\floatbox+\floatbottomskip\relax
\ifdim\topinserted<\textheight\relax
\xdef\totaltopinserted{\the\topinserted}%
\insert\topins
{\forgetall
- \iftopofinsert
+ \ifconditional\c_page_one_top_of_insert
\topskipcorrection % [xx] new: see icare topbleed
\kern-\lineskip\par
\prevdepth\maxdimen
@@ -223,7 +223,7 @@
%\blank[-\rootfloatparameter\c!spaceafter,\rootfloatparameter\c!spacebefore]% inserts can't look back
\betweenfloatblanko
\fi
- \flushfloatbox
+ \page_otr_command_flush_float_box
\blank[\rootfloatparameter\c!spaceafter]}%
\ifsomefloatwaiting
\advance\noffloatinserts \plusone
@@ -239,19 +239,19 @@
\ifsomefloatwaiting
\showmessage\m!floatblocks6{\the\noftopfloats}%
\fi
- \let\OTRONEdodosettopinserts\relax
+ \let\page_one_command_set_top_insertions_indeed\relax
\fi
- \OTRONEdodosettopinserts}
+ \page_one_command_set_top_insertions_indeed}
-\def\OTRONEdosetbotinserts
+\unexpanded\def\page_one_command_set_bottom_insertions
{\bgroup
\ifsomefloatwaiting
\noffloatinserts\zerocount
- \OTRONEdodosetbotinserts
+ \page_one_command_set_bottom_insertions_indeed
\fi
\egroup}
-\def\OTRONEdodosetbotinserts
+\def\page_one_command_set_bottom_insertions_indeed
{\ifnum\noffloatinserts<\nofbotfloats\relax
\dogetfloat
\global\advance\botinserted \ht\floatbox\relax
@@ -261,7 +261,7 @@
\insert\botins
{\forgetall
\blank[\rootfloatparameter\c!spacebefore]%
- \flushfloatbox}%
+ \page_otr_command_flush_float_box}%
\ifsomefloatwaiting
\advance\noffloatinserts \plusone
\else
@@ -277,24 +277,13 @@
\ifsomefloatwaiting
\showmessage\m!floatblocks7{\the\nofbotfloats}%
\fi
- \let\OTRONEdodosetbotinserts\relax
+ \let\page_one_command_set_bottom_insertions_indeed\relax
\fi
- \OTRONEdodosetbotinserts}
-
-\def\OTRONEdosetbothinserts
- {\global\topinserted\zeropoint
- \global\botinserted\zeropoint
- \ifflushingfloats \else
- \OTRONEdosettopinserts
- \OTRONEdosetbotinserts
- \ifsomefloatwaiting
- \doif{\rootfloatparameter\c!cache}\v!no\doflushfloats
- \fi
- \fi}
+ \page_one_command_set_bottom_insertions_indeed}
\newconstant\topinserttopskipmode % 1 = no topskip
-\def\OTRONEdotopinsertions
+\unexpanded\def\page_one_command_flush_top_insertions
{\ifvoid\topins\else
\ifgridsnapping
\box\topins
@@ -313,7 +302,7 @@
\fi
\global\topinserted\zeropoint}
-\def\OTRONEdobotinsertions
+\unexpanded\def\page_one_command_flush_bottom_insertions
{\ifvoid\botins\else
\ifgridsnapping
% \floatparameter\c!bottombefore
@@ -328,32 +317,32 @@
\global\botinserted\zeropoint
\global\nofloatpermittedfalse}
-\def\OTRONEdoflushfloats
+\unexpanded\def\page_one_command_flush_floats
{\global\flushingfloatstrue
\ifsomefloatwaiting
\par
% if kept, then option and definitely off in gridmode ! ! ! !
% \ifvmode \prevdepth\maxdimen \fi % prevents whitespace; problematic in icare tests
- \OTRONEdodoflushfloats
+ \page_one_command_flush_floats_indeed
\fi
\global\savednoffloats\zerocount
\global\somefloatwaitingfalse
\global\flushingfloatsfalse}
-\def\OTRONEflushfloatbox % nog verder doorvoeren en meer info in marge
+\unexpanded\def\page_one_command_flush_float_box
{\ifcenterfloatbox \ifdim\wd\floatbox<\hsize
\global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
\fi \fi
\snaptogrid\hbox{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}} % was copy
-\def\OTRONEdodoflushfloats % much in common with OTRSET
+\def\page_one_command_flush_floats_indeed % much in common with OTRSET
{\ifsomefloatwaiting
\ifpackflushedfloats
\centerfloatboxfalse % not needed as we do call directly
\dofloatscollect\s!text{\hsize}{1em}%
%% no longer (interferes with footnotes):
%%
- %% \OTRONEsetvsize % test 2011.06.24.001
+ %% \page_one_command_set_vsize % test 2011.06.24.001
%%
\global\setbox\floatbox\hbox to \hsize
{\hfil
@@ -379,10 +368,10 @@
% fits on a page where it was first rejected, in which case
% the prevdepth is -maxdimen and we cannot obey the grid
\doplacefloatbox
- \expandafter\OTRONEdodoflushfloats
+ \expandafter\page_one_command_flush_floats_indeed
\fi}
-\def\OTRONEdocheckiffloatfits % vervangen ivm downward comp
+\unexpanded\def\page_one_command_check_if_float_fits
{\ifnofloatpermitted
\global\roomforfloatfalse
\else
@@ -414,89 +403,184 @@
\fi
\fi}
-\def\OTRONEflushsavedfloats
- {\dosetbothinserts}
-
-% TODO: TEST FIRST, NO CORRECTION NEEDED IN GRID MODE, EVT OPTION
+\unexpanded\def\page_one_command_flush_saved_floats
+ {\global\topinserted\zeropoint
+ \global\botinserted\zeropoint
+ \ifflushingfloats \else
+ \page_one_command_set_top_insertions
+ \page_one_command_set_bottom_insertions
+ \ifsomefloatwaiting
+ \doif{\rootfloatparameter\c!cache}\v!no\page_one_command_flush_floats % could be _otr_
+ \fi
+ \fi}
-\def\OTRONEsomeherefloat[#1]% spacing between two successive must be better
- {\baselinecorrection % not really needed in grid mode:
- %\ifgridsnapping \else \baselinecorrection \fi % ! ! ! test test test ! ! ! !
+\def\page_one_place_float_here_indeed
+ {%\ifgridsnapping \else
+ \baselinecorrection
+ %\fi
\doplacefloatbox
\doinsertfloatinfo
\dohandlenextfloatindent}
-\setnewconstant\fixedfloatmethod\plusthree
-
-\def\OTRONEsomefixdfloat % [#1]
- {% there is (in mkii) no good way to prevent a break
- % so better fail than mess, we can get loose from
- % heads, so be it
- \showmessage\m!floatblocks9\empty
- \OTRONEsomeherefloat} % [#1]
-
-\def\OTRONEsomesidefloat[#1]% links, rechts NOG TESTEN EN AANPASSEN
- {\ifinsidecolumns
- \someelsefloat[\v!here]%
+\def\page_one_place_float_force
+ {\showmessage\m!floatblocks9\empty
+ \page_one_place_float_here_indeed}
+
+\def\page_one_place_float_side_indeed#1%
+ {\setbox\floatbox\vbox{\box\floatbox}% ? can go
+ \wd\floatbox\floatwidth
+ #1{\box\floatbox}%
+ \doifinset\v!tall\floatlocationmethod\page_sides_flush_floats_after_par}
+
+\def\page_one_place_float_left {\page_one_place_float_side_indeed\page_sides_process_float_left\presetindentation}
+\def\page_one_place_float_right {\page_one_place_float_side_indeed\page_sides_process_float_right}
+\def\page_one_place_float_margin {\page_one_place_float_side_indeed\page_sides_process_float_margin\nonoindentation}
+\def\page_one_place_float_leftmargin {\page_one_place_float_side_indeed\page_sides_process_float_leftmargin}
+\def\page_one_place_float_rightmargin{\page_one_place_float_side_indeed\page_sides_process_float_rightmargin}
+\def\page_one_place_float_leftedge {\page_one_place_float_side_indeed\page_sides_process_float_leftedge}
+\def\page_one_place_float_rightedge {\page_one_place_float_side_indeed\page_sides_process_float_rightedge}
+\def\page_one_place_float_inmargin {\page_one_place_float_side_indeed\page_sides_process_float_cutspace}
+\def\page_one_place_float_backspace {\page_one_place_float_side_indeed\page_sides_process_float_backspace}
+\def\page_one_place_float_cutspace {\page_one_place_float_side_indeed\page_sides_process_float_cutspace}
+
+\def\page_one_place_float_page {\dofloatssavepagefloat \s!page \floatlocationmethod}
+\def\page_one_place_float_leftpage {\dofloatssavepagefloat \s!leftpage \floatlocationmethod}
+\def\page_one_place_float_rightpage {\dofloatssavepagefloat \s!rightpage\floatlocationmethod}
+\def\page_one_place_float_somewhere {\dofloatssavesomewherefloat\s!somewhere\floatlocationmethod}
+
+\def\page_one_place_float_here {\page_one_place_float_otherwise_here}
+\def\page_one_place_float_auto {\page_one_place_float_otherwise}
+\def\page_one_place_float_top {\page_one_place_float_otherwise\nonoindentation}
+\def\page_one_place_float_bottom {\page_one_place_float_otherwise}
+
+\def\page_one_place_float_otherwise
+ {\doifinsetelse\v!here\floatlocationmethod
+ \page_one_place_float_otherwise_here
+ \page_one_place_float_otherwise_else}
+
+\def\page_one_place_float_otherwise_here
+ {\doifinsetelse\v!always\floatlocationmethod
+ {\page[\v!preference]%
+ \page_otr_command_check_if_float_fits
+ \ifroomforfloat
+ \page_one_place_float_here_indeed
+ \else
+ \showmessage\m!floatblocks9\empty
+ \doreversesavefloat
+ \fi}
+ {\ifsomefloatwaiting
+ \dosavefloat
+ \else
+ \page[\v!preference]%
+ \page_otr_command_check_if_float_fits
+ \ifroomforfloat
+ \page_one_place_float_here_indeed
+ \else
+ \dosavefloat
+ \fi
+ \fi}}
+
+\def\page_one_place_float_otherwise_else
+ {\doifinsetelse\v!always\floatlocationmethod
+ {\page_otr_command_check_if_float_fits
+ \ifroomforfloat
+ \page_one_place_float_auto_top_bottom
+ \else
+ \showmessage\m!floatblocks9\empty
+ \doreversesavefloat
+ \fi}
+ {\page_otr_command_check_if_float_fits
+ \ifroomforfloat
+ \page_one_place_float_auto_top_bottom
+ \else
+ \dosavefloat
+ \fi}}
+
+\def\floatautofactor{.5}
+
+\def\page_one_place_float_auto_top_bottom
+ {\ifx\floatmethod\v!auto
+ \ifdim\pagetotal<\floatautofactor\pagegoal % when empty page, maxdimen
+ \page_one_place_float_top_indeed
+ \else
+ \page_one_place_float_bottom_indeed
+ \fi
\else
- %\checkwaitingfloats{#1}%
- \setbox\floatbox\vbox{\box\floatbox}% ? can go
- \wd\floatbox\floatwidth
- \processfirstactioninset
- [#1]
- [ \v!left=>\leftfloat {\box\floatbox},
- \v!right=>\rightfloat {\box\floatbox},
- \v!inleft=>\leftmarginfloat {\box\floatbox},
- \v!inright=>\rightmarginfloat{\box\floatbox},
- \v!leftmargin=>\leftmarginfloat {\box\floatbox},
- \v!rightmargin=>\rightmarginfloat{\box\floatbox},
- \v!leftedge=>\leftedgefloat {\box\floatbox},
- \v!rightedge=>\rightedgefloat {\box\floatbox},
- \v!backspace=>\backspacefloat {\box\floatbox},
- \v!cutspace=>\cutspacefloat {\box\floatbox},
- \v!inmargin=>\cutspacefloat {\box\floatbox}]%
- \doifinset\v!tall{#1}\flushsidefloatsafterpar
+ \ifx\floatmethod\v!top
+ \page_one_place_float_top_indeed
+ \else\ifx\floatmethod\v!bottom
+ \page_one_place_float_top_indeed
+ \else
+ \page_one_place_float_here_indeed
+ \fi\fi
\fi}
-\def\OTRONEsomepagefloat [#1]{\dofloatssavepagefloat {\s!page} {#1}}
-\def\OTRONEsomeleftpagefloat [#1]{\dofloatssavepagefloat {\s!leftpage} {#1}}
-\def\OTRONEsomerightpagefloat[#1]{\dofloatssavepagefloat {\s!rightpage}{#1}}
-
-%def\OTRONEsomesoemwherefloat[#1]{\dofloatssavesomewherefloat{\s!somewhere}{#1}}
-
-\def\OTRONEsometopsfloat[#1]%
+\def\page_one_place_float_top_indeed
{\ifdim\topinserted=\zeropoint
- \topofinserttrue
+ \settrue\c_page_one_top_of_insert
\else
- \topofinsertfalse
+ \setfalse\c_page_one_top_of_insert
\fi
\global\advance\topinserted\dimexpr\ht\floatbox+\dp\floatbox+\floatbottomskip\relax
\insert\topins
{\forgetall
- \iftopofinsert
+ \ifconditional\c_page_one_top_of_insert
\topskipcorrection % [xx] new: see icare topbleed
\kern-\lineskip\par\prevdepth\maxdimen
\else
%\blank[-\rootfloatparameter\c!spaceafter,\rootfloatparameter\c!spacebefore]% inserts can't look back
\betweenfloatblanko
\fi
- \flushfloatbox
+ \page_otr_command_flush_float_box
\blank[\rootfloatparameter\c!spaceafter]}%
\doinsertfloatinfo}
-\def\OTRONEsomebotsfloat[#1]%
+\def\page_one_place_float_bottom_indeed
{\global\advance\botinserted\dimexpr\ht\floatbox+\dp\floatbox+\floattopskip\relax
\insert\botins
{\forgetall
\blank[\rootfloatparameter\c!spacebefore]%
- \flushfloatbox}%
+ \page_otr_command_flush_float_box}%
%\global\nofloatpermittedtrue
\doinsertfloatinfo}
-\def\OTRONEsomefacefloat[#1]% untested
- {\startopposite\flushfloatbox\stopopposite}
-
-\def\OTRONEnextcolumn[#1]%
- {}
+\def\page_one_place_float_face % links, rechts, midden, hoog, midden, laag
+ {%\checkwaitingfloats{#1}%
+ \startopposite
+ \page_otr_command_flush_float_box
+ \stopopposite
+ }%\doinsertfloatinfo}
+
+\unexpanded\def\page_one_command_flush_side_floats
+ {\page_sides_flush_floats}
+
+\unexpanded\def\page_one_command_synchronize_side_floats
+ {\page_sides_synchronize_floats}
+
+\defineoutputroutine
+ [\s!singlecolumn]
+ [\s!page_otr_command_routine =\page_one_command_routine,
+ \s!page_otr_command_package_contents =\page_one_command_package_contents,
+ \s!page_otr_command_set_vsize =\page_one_command_set_vsize,
+ \s!page_otr_command_set_hsize =\page_one_command_set_hsize,
+ \s!page_otr_command_next_page =\page_one_command_next_page,
+ \s!page_otr_command_next_page_and_inserts =\page_one_command_next_page_and_inserts,
+ % \s!page_otr_command_synchronize_hsize =\page_one_command_synchronize_hsize,
+ \s!page_otr_command_set_top_insertions =\page_one_command_set_top_insertions,
+ \s!page_otr_command_set_bottom_insertions =\page_one_command_set_bottom_insertions,
+ \s!page_otr_command_flush_top_insertions =\page_one_command_flush_top_insertions,
+ \s!page_otr_command_flush_bottom_insertions =\page_one_command_flush_bottom_insertions,
+ % \s!page_otr_command_set_float_hsize =\page_one_command_set_float_hsize,
+ \s!page_otr_command_check_if_float_fits =\page_one_command_check_if_float_fits,
+ \s!page_otr_command_flush_float_box =\page_one_command_flush_float_box,
+ \s!page_otr_command_synchronize_side_floats =\page_one_command_synchronize_side_floats,
+ \s!page_otr_command_side_float_output =\page_one_command_side_float_output,
+ \s!page_otr_command_flush_floats =\page_one_command_flush_floats,
+ \s!page_otr_command_flush_side_floats =\page_one_command_flush_side_floats,
+ \s!page_otr_command_flush_saved_floats =\page_one_command_flush_saved_floats
+ ]
+
+% \setupoutputroutine
+% [\s!singlecolumn]
\protect \endinput
diff --git a/tex/context/base/page-otr.mkvi b/tex/context/base/page-otr.mkvi
new file mode 100644
index 000000000..fd96054cf
--- /dev/null
+++ b/tex/context/base/page-otr.mkvi
@@ -0,0 +1,288 @@
+%D \module
+%D [ file=page-otr,
+%D version=2012.01.25,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Output Routines,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Page Macros / Output Routines}
+
+%D This module will get some of the code from other modules. At the
+%D same time we provide a bit more control.
+
+% When issuing two \par\penalty-\plustenthousand's, only the first
+% triggers the otr. Is this an obscure feature or an optimization?
+
+\unprotect
+
+\def\m!otr{otr} % todo
+
+\installcorenamespace{outputroutine}
+
+\installswitchcommandhandler \??outputroutine {outputroutine} \??outputroutine
+
+\newtoks\t_page_otr_commands
+\newtoks\t_page_otr_tracers
+
+\unexpanded\def\defineoutputroutinecommand[#name]% doing multiple on one go saves syncing
+ {\processcommalist[#name]\page_otr_commands_define}
+
+\unexpanded\def\page_otr_commands_define#name%
+ {\ifcsname#name\endcsname \else
+ \expandafter\let\csname#name\endcsname\relax
+ \normalexpanded{\t_page_otr_commands{\the\t_page_otr_commands\noexpand\page_otr_commands_process{#name}}}%
+ \fi}
+
+\let\page_otr_commands_process\gobbleoneargument
+
+\appendtoks
+ \let\page_otr_commands_process\page_otr_specifics_preset
+ \the\t_page_otr_commands
+ \let\page_otr_commands_process\gobbleoneargument
+\to \everyswitchoutputroutine
+
+\unexpanded\def\page_otr_specifics_preset#1%
+ {\edef\page_otr_specifics_command{\strictoutputroutineparameter{#1}}% no inheritance of commands
+ \ifx\page_otr_specifics_command\empty
+ \writestatus{\currentoutputroutine}{- \expandafter\strippedcsname\csname#1\endcsname}%
+ \expandafter\let\csname#1\endcsname\relax
+ \else
+ \writestatus{\currentoutputroutine}{+ \expandafter\strippedcsname\csname#1\endcsname}%
+ \expandafter\let\csname#1\expandafter\endcsname\page_otr_specifics_command
+ \fi}
+
+\unexpanded\def\page_otr_specifics_preset_normal#1%
+ {\edef\page_otr_specifics_command{\strictoutputroutineparameter{#1}}% no inheritance of commands
+ \ifx\page_otr_specifics_command\empty
+ \expandafter\let\csname#1\endcsname\relax
+ \else
+ \expandafter\let\csname#1\expandafter\endcsname\page_otr_specifics_command
+ \fi}
+
+\unexpanded\def\page_otr_specifics_preset_traced#1%
+ {\edef\page_otr_specifics_command{\strictoutputroutineparameter{#1}}% no inheritance of commands
+ \ifx\page_otr_specifics_command\empty
+ \writestatus{\currentoutputroutine}{preset: - \expandafter\strippedcsname\csname#1\endcsname}%
+ \expandafter\let\csname#1\endcsname\relax
+ \else
+ \writestatus{\currentoutputroutine}{preset: + \expandafter\strippedcsname\csname#1\endcsname}%
+ \expandafter\let\csname#1\expandafter\endcsname\page_otr_specifics_command
+ \fi}
+
+\let\page_otr_specifics_preset\page_otr_specifics_preset_normal
+
+\unexpanded\def\traceoutputroutines
+ {\the\t_page_otr_tracers}
+
+\appendtoks
+ \let\page_otr_specifics_preset\page_otr_specifics_preset_traced
+\to \t_page_otr_tracers
+
+%D We have a couple of output routines and the default one is
+%D the single column routine. Then there is a multicolumn variant
+%D that can be used mixed, and a columnset variant that is more
+%D exclusive.
+
+\installcorenamespace{otrtriggers}
+
+\newconstant\c_page_otr_eject_penalty \c_page_otr_eject_penalty -\plustenthousand
+\newconstant\c_page_otr_super_penalty \c_page_otr_super_penalty -\plustwentythousand
+\newcount \c_page_otf_trigger_penalty \c_page_otf_trigger_penalty -100010
+
+\newif \ifinotr % we keep this (name) for old times sake
+
+\unexpanded\def\page_otr_message_b{\page_otr_message_s+}
+\unexpanded\def\page_otr_message_e{\page_otr_message_s-}
+
+\unexpanded\def\page_otr_message_s#1#2%
+ {\writestatus
+ \currentoutputroutine
+ {#1\space \space
+ #2\space \space
+ p:\the\outputpenalty,\space
+ r:\the\realpageno ,\space
+ c:\number\mofcolumns,\space
+ v:\the\vsize ,\space
+ g:\the\pagegoal ,\space
+ t:\the\pagetotal ,\space
+ \ifdim\pagetotal>\pagegoal
+ d:\the\dimexpr\pagetotal-\pagegoal\relax
+ \fi}}
+
+\unexpanded\def\page_otr_trigger#1%
+ {\begingroup
+ \par
+ \penalty#1%
+ \endgroup}
+
+\unexpanded\def\installoutputroutine#1#2% \invoke \action
+ {\global\advance\c_page_otf_trigger_penalty\minusone
+ \edef#1{\page_otr_trigger{\number\c_page_otf_trigger_penalty}}%
+ \setvalue{\??otrtriggers\number\c_page_otf_trigger_penalty}{#2}}
+
+\unexpanded\def\page_otr_triggered_output_routine_traced
+ {\ifcsname\??otrtriggers\the\outputpenalty\endcsname
+ \page_otr_message_b{special}%
+ \csname\??otrtriggers\the\outputpenalty\endcsname
+ \page_otr_message_e{special}%
+ \else
+ \page_otr_message_b{normal}%
+ \page_otr_command_routine
+ \page_otr_message_e{normal}%
+ \fi}
+
+\unexpanded\def\page_otr_triggered_output_routine_normal
+ {\ifcsname\??otrtriggers\the\outputpenalty\endcsname
+ \csname\??otrtriggers\the\outputpenalty\endcsname
+ \else
+ \page_otr_command_routine
+ \fi}
+
+\let\page_otr_triggered_output_routine\page_otr_triggered_output_routine_normal
+
+\appendtoks
+ \let\page_otr_triggered_output_routine\page_otr_triggered_output_routine_traced
+\to \t_page_otr_tracers
+
+%D The real routine handler:
+
+\ifdefined\everybeforeoutput \else \newtoks\everybeforeoutput \fi
+\ifdefined\everyafteroutput \else \newtoks\everyafteroutput \fi
+
+\def\page_otf_set_engine_output_routine#1%
+ {\global\output
+ {\inotrtrue
+ \the\everybeforeoutput
+ #1\relax
+ \the\everyafteroutput}}
+
+\page_otf_set_engine_output_routine\page_otr_triggered_output_routine
+
+\installoutputroutine\synchronizeoutput
+ {\ifvoid\normalpagebox\else
+ \unvbox\normalpagebox
+ \pagediscards
+ \fi}
+
+\installoutputroutine\discardpage
+ {\setbox\scratchbox\box\normalpagebox}
+
+% todo: \resetpagebreak -> everyejectpage
+
+\def\page_otr_trigger_output_routine
+ {\par
+ \ifvmode
+ \penalty\c_page_otr_eject_penalty
+ \fi
+ \resetpagebreak}
+
+\def\page_otr_fill_and_eject_page
+ {\par
+ \ifvmode
+ \vfill
+ \penalty\c_page_otr_eject_penalty
+ \fi
+ \resetpagebreak}
+
+\def\page_otr_eject_page
+ {\par
+ \ifvmode
+ \ifdim\pagetotal>\pagegoal \else
+ \normalvfil
+ \fi
+ \penalty\c_page_otr_eject_penalty
+ \fi
+ \resetpagebreak}
+
+\def\page_otr_eject_page_and_flush_inserts % can be an installed one
+ {\par
+ \ifvmode
+ \ifdim\pagetotal>\pagegoal \else
+ \normalvfil
+ \fi
+ \penalty\c_page_otr_super_penalty
+ \fi
+ \resetpagebreak}
+
+\def\page_otr_check_for_pending_inserts
+ {\ifnum\outputpenalty>\c_page_otr_super_penalty \else
+ \ifnum\insertpenalties>\zerocount
+ % something is being held over so we force a new page
+ \page_otr_force_another_page
+ \fi
+ \fi}
+
+\def\page_otr_force_another_page
+ {% we should actually remove the dummy line in the otr
+ \hbox to \hsize{}%
+ \kern-\topskip
+ \nobreak
+ \vfill
+ \penalty\c_page_otr_super_penalty
+ \resetpagebreak}
+
+%D For those who've read the plain \TEX\ book, we provide the next
+%D macro:
+
+\unexpanded\def\bye
+ {\writestatus\m!system{Sorry, you're not done yet, so no goodbye!}}
+
+%D We define a few constants because that (1) provides some checking
+%D and (2) is handier when aligning definitions (checks nicer).
+
+\definesystemconstant{page_otr_command_routine}
+\definesystemconstant{page_otr_command_package_contents}
+\definesystemconstant{page_otr_command_set_vsize}
+\definesystemconstant{page_otr_command_set_hsize}
+\definesystemconstant{page_otr_command_synchronize_hsize}
+\definesystemconstant{page_otr_command_next_page}
+\definesystemconstant{page_otr_command_next_page_and_inserts}
+\definesystemconstant{page_otr_command_set_top_insertions}
+\definesystemconstant{page_otr_command_set_bottom_insertions}
+\definesystemconstant{page_otr_command_flush_top_insertions}
+\definesystemconstant{page_otr_command_flush_bottom_insertions}
+\definesystemconstant{page_otr_command_check_if_float_fits}
+\definesystemconstant{page_otr_command_set_float_hsize}
+\definesystemconstant{page_otr_command_flush_float_box}
+\definesystemconstant{page_otr_command_side_float_output}
+\definesystemconstant{page_otr_command_synchronize_side_floats}
+\definesystemconstant{page_otr_command_flush_floats}
+\definesystemconstant{page_otr_command_flush_side_floats}
+\definesystemconstant{page_otr_command_flush_saved_floats}
+
+\definesystemconstant{singlecolumn}
+\definesystemconstant{multicolumn}
+\definesystemconstant{columnset}
+
+\defineoutputroutinecommand
+ [\s!page_otr_command_routine,
+ \s!page_otr_command_package_contents,
+ \s!page_otr_command_set_vsize,
+ \s!page_otr_command_set_hsize,
+ \s!page_otr_command_synchronize_hsize, % for columns of different width
+ \s!page_otr_command_next_page,
+ \s!page_otr_command_next_page_and_inserts,
+ \s!page_otr_command_set_top_insertions,
+ \s!page_otr_command_set_bottom_insertions,
+ \s!page_otr_command_flush_top_insertions,
+ \s!page_otr_command_flush_bottom_insertions,
+ \s!page_otr_command_check_if_float_fits,
+ \s!page_otr_command_set_float_hsize,
+ \s!page_otr_command_flush_float_box,
+ \s!page_otr_command_side_float_output, % name will change as will hooks
+ \s!page_otr_command_synchronize_side_floats,
+ \s!page_otr_command_flush_floats,
+ \s!page_otr_command_flush_side_floats,
+ \s!page_otr_command_flush_saved_floats]
+
+\appendtoks
+ \setupoutputroutine[\s!singlecolumn]%
+\to \everydump
+
+\protect \endinput
diff --git a/tex/context/base/page-plg.mkiv b/tex/context/base/page-plg.mkiv
index 189228f17..798014f19 100644
--- a/tex/context/base/page-plg.mkiv
+++ b/tex/context/base/page-plg.mkiv
@@ -108,10 +108,12 @@
%D \stoptext
%D \stoptyping
+% will become an outputroutine
+
\unprotect
-\def\page_boxes_construct_content_makeup#1#2%
- {\setbox\pagebox\hbox
+\def\page_boxes_construct_content_makeup#1#2#3% targetbox flusher box
+ {\setbox#1\hbox
{\vbox to \textheight
{\offinterlineskip
% optie
@@ -121,21 +123,16 @@
\hsize\textwidth
\boxmaxdepth\maxdepth
\noindent
- \dopagecontents#1#2}}%
- \wd\pagebox\makeupwidth
- \ht\pagebox\textheight
- \dp\pagebox\zeropoint
+ \page_otr_command_package_contents#2#3}}%
+ \wd#1\makeupwidth
+ \ht#1\textheight
+ \dp#1\zeropoint
\hsize\paperwidth
\vsize\paperheight
- \setbox\pagebox\vbox
-% {\doifbothsidesoverruled
-% {\csname\??layoutmethod\v!page\endcsname}
-% {\csname\??layoutmethod\v!rightpage\endcsname}
-% {\csname\??layoutmethod\v!leftpage\endcsname}}%
- {\csname\??layoutmethod\doifbothsidesoverruled\v!page\v!rightpage\v!leftpage\endcsname}%
- \wd\pagebox\paperwidth
- \ht\pagebox\paperheight
- \dp\pagebox\zeropoint}
+ \setbox#1\vbox{\csname\??layoutmethod\doifbothsidesoverruled\v!page\v!rightpage\v!leftpage\endcsname}%
+ \wd#1\paperwidth
+ \ht#1\paperheight
+ \dp#1\zeropoint}
\installlayoutalternative\v!makeup{\page_boxes_construct_content_makeup}
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index 45f6f7660..674f54831 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -54,8 +54,11 @@
\def\OTRSETmakeupwidth{\innermakeupwidth}
-\let\OTRSETflushsidefloats \forgetsidefloats % \relax
-\let\OTRSETsynchronizesidefloats\forgetsidefloats % \relax
+\unexpanded\def\page_set_command_flush_side_floats
+ {\page_sides_forget_floats}
+
+\unexpanded\def\page_set_command_synchronize_side_floats
+ {\page_sides_forget_floats}
\def\OTRSETgridcell #1#2{\csname \@otr@:\number#1:\number#2\endcsname}
\def\OTRSETgetgridcell#1#2{\box\csname \@otr@:\number#1:\number#2\endcsname}
@@ -500,7 +503,6 @@
\fi
\doglobal\increment\columnsetpage
\OTRSETinitializecolumns
- %\OTRSETdoflushfloats
\OTRSETstartnextpage
\initializecolumntextareas
\fi}
@@ -520,16 +522,16 @@
\def\OTRSETdofinaloutput
{\ifdim\ht\OTRfinalpagebox=\textheight
- \bgroup % \let\OTRSETsetvsize\relax % prevents useless search for gap
+ \bgroup
\ifcase\OTRSETbalancemethod
- \finaloutput\box\OTRfinalpagebox
+ \page_otr_construct_and_shipout\box\OTRfinalpagebox
\else\ifdim\OTRSETbalht>\zeropoint
% catch a bordercase
\scratchdimen\OTRSETbalht
\advance\scratchdimen\lineheight\relax
\ifdim\scratchdimen>\textheight
% full page
- \finaloutput\box\OTRfinalpagebox
+ \page_otr_construct_and_shipout\box\OTRfinalpagebox
\else
% same page
\global\setbox\OTRfinalpagebox \iftracecolumnset\ruledvbox\else\vbox\fi to \OTRSETbalht
@@ -538,7 +540,7 @@
\snaptogrid\vbox{\vskip\OTRSETbalht}% hack
\fi
\else
- \finaloutput\box\OTRfinalpagebox
+ \page_otr_construct_and_shipout\box\OTRfinalpagebox
\fi \fi
\globallet\OTRSETbalht\zeropoint
\egroup
@@ -552,8 +554,6 @@
\newdimen \OTRSETtextsheight
\let \OTRSETidentifier=\empty
-\newtoks \OTRSEToutput
-
\def\OTRSETgetparameter#1#2{\csname\??mc\OTRSETidentifier\number#2#1\endcsname}
\def\OTRSETsetparameter#1#2{\setvalue{\??mc\OTRSETidentifier\number#2#1}}
@@ -568,7 +568,7 @@
\emptybox
\fi}
-\def\OTRSETsetvsize % snap per sectie (gap here?)
+\unexpanded\def\page_set_command_set_vsize % snap per sectie (gap here?)
{\ifcollectingcontent \else % can be assigndimen
\OTRSETsetcolumnmaxcells % layout can be changed
\OTRSETskipstart % not that well tested
@@ -590,7 +590,7 @@
\textwidth\localcolumnwidth
\hsize\localcolumnwidth}
-\def\OTRSETsynchronizehsize
+\unexpanded\def\page_set_command_synchronize_hsize
{\ifcase0\getvalue{\??mc\??mc\c!width}\else % some width set
\bgroup
\scratchdimen\OTRSETlocalwidth\mofcolumns
@@ -603,7 +603,7 @@
\fi}
\def\OTRSETcheckfreelines
- {\OTRSETsetvsize}
+ {\page_set_command_set_vsize}
\def\doOTRSETcolumnseparator
{\hbox to \zeropoint{\hss\red\vl\hss}}
@@ -613,34 +613,6 @@
\def\showbreaks
{\let\OTRSETcolumnseparator\doOTRSETcolumnseparator}
-% \installcolumnbreakmethod {SET} \v!ja
-% {% hmmm:
-% \ifhmode
-% \bgroup
-% \removeunwantedspaces
-% \parfillskip\zeropoint
-% \OTRSETcolumnseparator
-% \par
-% \egroup
-% \fi
-% % brrr:
-% \page_otr_flush_all_floats
-% \page_otr_eject_page
-% \OTRSETsynchronizehsize} % no \OTRSETsethsize, can be mid smaller (like tabulate)
-%
-% \installcolumnbreakmethod {SET} \v!forceer
-% {\OTRSETgotocolumn[\v!forceer]}
-% \installcolumnbreakmethod {SET} \v!eerste
-% {\OTRSETgotocolumn[\v!eerste]}
-% \installcolumnbreakmethod {SET} \v!laatste
-% {\OTRSETgotocolumn[\v!laatste]}
-%
-% \installcolumnbreakmethod {SET} \v!pagina
-% {\simplepagebreak % \flushnotes \executepagebreakhandler\v!ja
-% \ifnum\mofcolumns>\plusone
-% \OTRSETgotocolumn[\v!laatste,\v!forceer]%
-% \fi}
-
\def\OTRSETcolumnhbreak
{\ifhmode
\bgroup
@@ -651,21 +623,21 @@
\egroup
\fi}
-\installcolumnbreakmethod {SET} \v!local
+\installcolumnbreakmethod \s!columnset \v!local
{\OTRSETcolumnhbreak
\page_otr_flush_all_floats
\page_otr_eject_page
% no \OTRSETsethsize, can be mid smaller (like tabulate)
% also, this one should be executed at the outer level
% (setting hsize inside otr does not work)
- \OTRSETsynchronizehsize}
+ \page_set_command_synchronize_hsize}
% We need to make sure that we really leave the column; mid
% column we may end up in an empty gap, and we don't want to
% stay there (basically such a gap is a small empty page
% then).
-\installcolumnbreakmethod {SET} \v!yes
+\installcolumnbreakmethod \s!columnset \v!yes
{\OTRSETcolumnhbreak
\edef\savedmofcolumns{\the\mofcolumns}%
\edef\savedrealpageno{\the\realpageno}%
@@ -681,14 +653,13 @@
\else
\exitloop
\fi}%
- \OTRSETsynchronizehsize}
+ \page_set_command_synchronize_hsize}
-\installcolumnbreakmethod {SET} \s!unknown
+\installcolumnbreakmethod \s!columnset \s!unknown
{\expanded{\OTRSETgotocolumn[\@@columnspecification]}}
-\installcolumnbreakmethod {SET} \v!page
- {\page_otr_fill_and_eject_page
- \OTRSETgotonextpage}
+\installcolumnbreakmethod \s!columnset \v!page
+ {\page_otr_fill_and_eject_page}
\newtoks\OTRSETeverystartofcolumn
@@ -759,7 +730,7 @@
\else
% we should not discard skips after here; tricky
\fi
- \OTRSETsetvsize
+ \page_set_command_set_vsize
\fi}
\def\OTRSETplacebottomnotes
@@ -830,8 +801,8 @@
% we cannot adapt the hsize since it may have changed (like
% inside a tabulate) so we only change it when there is a
% reason to do so
- \OTRSETsynchronizehsize
- \OTRSETsetvsize}
+ \page_set_command_synchronize_hsize
+ \page_set_command_set_vsize}
\def\OTRSETfindnextgap
{\OTRSETsetfreecells\mofcolumns\columnlastcell
@@ -843,7 +814,7 @@
\OTRSETdoflush
\global\columnlastcell\plusone
\global\columnfirstcell\zerocount
- \OTRSETdoflushfloats
+ \page_set_command_flush_floats
\else
\the\OTRSETeverystartofcolumn
\global\columnlastcell\plusone
@@ -936,7 +907,7 @@
\ifenoughcolumncells
\OTRSETsetgridcells\mofcolumns\columnfirstcell\columnhcells\columnvcells
{\hbox{\copy#1}}%
- \OTRSETsetvsize
+ \page_set_command_set_vsize
\else
\OTRSETsavebox{#1}%
\fi}
@@ -953,7 +924,7 @@
\ifenoughcolumncells
\OTRSETsetgridcells\mofcolumns\columnlastcell\columnhcells\columnvcells{\copy#1}%
\OTRSETfillgapsbetweencells\mofcolumns\savedcolumnlastcell % -)
- \OTRSETsetvsize
+ \page_set_command_set_vsize
\else
\columnlastcell\savedcolumnlastcell
\OTRSETsavebox{#1}%
@@ -1168,7 +1139,7 @@
\OTRSETstoreincolumnslotindeed
\mofcolumns\mofcolumns+\currenthcell
\noflines\columnmaxcells+\currentvcell{#2}%
- \OTRSETsetvsize}
+ \page_set_command_set_vsize}
\def\OTRSETcheckprefered
{\ifnum\preferedcolumn<\mofcolumns
@@ -1246,7 +1217,7 @@
\else
%\message{[flt]}% float
\fi
- \OTRSETsetvsize
+ \page_set_command_set_vsize
%\message{[fnt]}% float
\else
%\message{[rej]}% save box
@@ -1291,7 +1262,7 @@
\egroup
\fi}
-\def\OTRSETdocheckiffloatfits % eigenlijk moet else float anders
+\unexpanded\def\page_set_command_check_if_float_fits
{\global\ifnofloatpermitted\roomforfloatfalse\else\roomforfloattrue\fi}
\def\OTRSETunpreparebox#1%
@@ -1313,10 +1284,10 @@
{\OTRSETunpreparebox{#1}%
\dofloatsresave\s!text}
-\def\OTRSETflushfloatbox % nog verder doorvoeren en meer info in marge
+\unexpanded\def\page_set_command_flush_float_box
{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
-\def\OTRSETdoflushfloats
+\unexpanded\def\page_set_command_flush_floats
{\bgroup
\def\OTRSETsavebox##1{\!!doneafalse}%
\doloop
@@ -1487,7 +1458,7 @@
\definecolumnset[\s!default][\c!n=2] % fallback
-\def\OTRSETgotonextpage
+\unexpanded\def\page_set_command_next_page
{\page_otr_fill_and_eject_page
\relax\ifnum\mofcolumns>\plusone
\OTRSETgotocolumn[\v!last]%
@@ -1496,7 +1467,8 @@
\fi
\fi}
-\let\OTRSETgotonextpageX\OTRSETgotonextpage % will become obsolete
+\let\page_set_command_next_page_and_inserts\page_set_command_next_page
+
\def\OTRSETgotocolumn
{\dosingleempty\doOTRSETgotocolumn}
@@ -1535,7 +1507,7 @@
\dorecurse\scratchcounter{\line{\strut}}%
\fi
\fi
- \OTRSETsetvsize}
+ \page_set_command_set_vsize}
\def\doOTRSETgotocolumn[#1]% yes|force|first|last|<number>|<number>*<number>
{\processallactionsinset
@@ -1583,7 +1555,7 @@
% \fi
% \fi
% \fi
-% \OTRSETsetvsize}
+% \page_set_command_set_vsize}
\def\OTRSETgotocell#1#2% obsolete: now \column[#1*#2]
{\endgraf
@@ -1613,7 +1585,7 @@
\globallet\columnsetpage\!!plusone
\def\currentcolumnset{#2}%
\insidecolumnstrue % will be different flag in addition
- \page_otr_activate{SET}{ONE}% andere naam, activate or so
+ \setupoutputroutine[\s!columnset]%
\doifelsenothing{#1}
{\globallet\OTRSETlist\s!default}
{\xdef\OTRSETlist{#1}}%
@@ -1657,8 +1629,8 @@
\dostopcolumnset
\egroup
\global\notelimittrue % brrr, untested and fuzzy
- \setvsize
- \sethsize
+ \page_otr_command_set_vsize
+ \page_otr_command_set_hsize
\ifvoid\OTRfinalpagebox\else
% probably balanced
\ifdim\ht\OTRfinalpagebox<\textheight
@@ -1668,7 +1640,11 @@
\fi
\fi
\global\setfalse\OTRSETfinish
- \ifsomefloatwaiting \setvsize \pagebreak \setvsize \fi
+ \ifsomefloatwaiting
+ \page_otr_command_set_vsize
+ \pagebreak
+ \page_otr_command_set_vsize
+ \fi
\OTRSETflushleftovers
\else
\egroup
@@ -1758,13 +1734,13 @@
\OTRSETinitializecolumns
\OTRSETcheckinsert
\OTRSETcheckgrid
- \OTRSETsetvsize
- \OTRSETsethsize % or local ?
+ \page_set_command_set_vsize
+ \page_set_command_set_hsize % or local ?
\OTRSETsetplaceholders
\OTRSEThandlepreposttext
\initializecolumntextareas % name !
\OTRSETcheckstartcells
- \OTRSETsetvsize}
+ \page_set_command_set_vsize}
\def\OTRSETcheckstartcells
{\dorecurse\nofcolumns
@@ -1777,12 +1753,12 @@
\donothing{\OTRSETsetgridcell\mofcolumns\recurselevel\copy\placeholderboxe}}%
\egroup}}
-\OTRSEToutput
+\unexpanded\def\page_otr_set_routine
{\dontcomplain % new, get rid of overfull message (to be sorted out)
\doloop
{\OTRSETnaturalflush
%\OTRSETstartnextpage % no
- \OTRSETdoflushfloats % actually belongs in \flushsavedfloats (but goes wrong)
+ \page_set_command_flush_floats
\OTRSETcheckfreelines
\ifsomefreecolumncells
\exitloop
@@ -1871,8 +1847,8 @@
\def\OTRSETchecksidefloat
{} % {\sidefloatoutput}
-\def\OTRSETfinalsidefloatoutput
- {}
+\unexpanded\def\page_set_command_side_float_output
+ {} % nothing, reset anyway
\def\OTRSETcheckgrid
{\topskip1\topskip
@@ -1994,21 +1970,22 @@
% page contents
-\def\OTRSETdopagecontents#1#2% takes two args: \box<n> \unvbox<n>
+% \def\OTRSETdopagecontents#1#2% takes two args: \box<n> \unvbox<n>
+\unexpanded\def\page_set_command_package_contents#1#2% \box<n> \unvbox<n> % this one will be redone (checked)
{\vbox to \textheight{\forgetall#1#2}}
-
-\def\OTRSETsomepagefloat {\def\floatmethod{PAGE}\OTRSETsomeslotfloat} % check
-\def\OTRSETsomeherefloat {\def\floatmethod{HERE}\OTRSETsomeslotfloat} % check
-\def\OTRSETsomeelsefloat {\def\floatmethod{HERE}\OTRSETsomeslotfloat} % check
-\def\OTRSETsomefixdfloat {\def\floatmethod{FIXD}\OTRSETsomeslotfloat} % check
-\def\OTRSETsometopfloat {\def\floatmethod{TOPS}\OTRSETsomeslotfloat} % check
-\def\OTRSETsomebottomfloat{\def\floatmethod{BOTS}\OTRSETsomeslotfloat} % check
+
+\def\page_set_place_float_page {\def\floatmethod{PAGE}\page_set_place_float_slot} % check
+\def\page_set_place_float_here {\def\floatmethod{HERE}\page_set_place_float_slot} % check
+\def\page_set_place_float_else {\def\floatmethod{HERE}\page_set_place_float_slot} % check / not used
+\def\page_set_place_float_force {\def\floatmethod{FIXD}\page_set_place_float_slot} % check
+\def\page_set_place_float_top {\def\floatmethod{TOPS}\page_set_place_float_slot} % check
+\def\page_set_place_float_bottom{\def\floatmethod{BOTS}\page_set_place_float_slot} % check
\def\OTRSETflushfloatbox % nog verder doorvoeren en meer info in marge
{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
-\def\OTRSETsomeslotfloat[#1]%
- {\setbox\floatbox\vbox{\flushfloatbox}%
+\def\page_set_place_float_slot
+ {\setbox\floatbox\vbox{\page_otr_command_flush_float_box}%
\dp\floatbox\strutdp
\@EA\uppercasestring\floatmethod\to\floatmethod
\OTRSETstoreincolumnslot\floatmethod\floatbox
@@ -2016,7 +1993,9 @@
% kind of new, looks much like OTRONE, but not entirely
-\def\OTRSETdosettopinserts
+\newconditional\c_page_set_top_of_insert
+
+\unexpanded\def\page_set_command_set_top_insertions
{\bgroup
\ifsomefloatwaiting
\noffloatinserts\zerocount
@@ -2042,20 +2021,20 @@
{\ifnum\noffloatinserts<\noftopfloats
\dogetfloat
\ifdim\topinserted=\zeropoint\relax
- \topofinserttrue
+ \settrue\c_page_set_top_of_insert
\else
- \topofinsertfalse
+ \setfalse\c_page_set_top_of_insert
\fi
\setbox\scratchbox\vbox % kan beter !
{\forgetall
- \iftopofinsert
+ \ifconditional\c_page_set_top_of_insert
%\ifdim\OTRSETtopoffset=\zeropoint
% \moveongrid[\v!top]
%\fi
\else
\betweenfloatblanko % inserts can't look back
\fi
- \flushfloatbox
+ \page_otr_command_flush_float_box
\blank[\rootfloatparameter\c!spaceafter]}%
\global\advance\topinserted \ht\scratchbox\relax
\ifdim\topinserted>\vsize % was \textheight\relax
@@ -2081,7 +2060,7 @@
\fi
\OTRSETdodosettopinserts}
-\def\OTRSETdosetbotinserts
+\unexpanded\def\page_set_command_set_bottom_insertions
{\bgroup
\ifsomefloatwaiting
\noffloatinserts\zerocount
@@ -2099,7 +2078,7 @@
\insert\botins
{\forgetall
\blank[\rootfloatparameter\c!spacebefore]%
- \flushfloatbox}%
+ \page_otr_command_flush_float_box}%
\ifsomefloatwaiting
\advance\noffloatinserts \plusone
\else
@@ -2119,9 +2098,7 @@
\fi
\OTRSETdodosetbotinserts}
-\let\OTRSETdosetbothinserts\relax
-
-\def\OTRSETdotopinsertions
+\unexpanded\def\page_set_command_flush_top_insertions
{\ifvoid\topins\else
\ifvoid\columntopbox\mofcolumns
\columnsettopbox\mofcolumns\box\topins
@@ -2135,7 +2112,7 @@
\fi
\global\topinserted\zeropoint\relax} % goes away
-\def\OTRSETdobotinsertions
+\unexpanded\def\page_set_command_flush_bottom_insertions
{\ifvoid\botins \else
\columnsetbotbox\mofcolumns\box\botins
% \else
@@ -2275,7 +2252,7 @@
\def\flushcolumntextareas
{\initializecolumntextareas
- \setvsize}
+ \page_otr_command_set_vsize} % set ?
\def\columntextlastbackspace{\backspace}
@@ -2407,7 +2384,7 @@
{\!!counta#1\!!countb#2\docalculatecolumnsetspan
\edef\columnsetspanhsize{\the\!!widtha}}
-\def\OTRSETsetfloathsize % new, otherwise wrong spanning floats in columnset
+\unexpanded\def\page_set_command_set_float_hsize
{\hsize % maybe checking optional
\ifdim\tempfloatwidth>\makeupwidth
\makeupwidth
@@ -2557,7 +2534,41 @@
% \startcolumnsetspan[two] \emptylines[5] \stopcolumnsetspan
% \startcolumnsetspan[two] \input tufte \stopcolumnsetspan
% \stopcolumnset
-
+
+\unexpanded\def\page_set_command_flush_saved_floats % rather similar to _one_ ut this might change
+ {\global\topinserted\zeropoint
+ \global\botinserted\zeropoint
+ \ifflushingfloats \else
+ \page_set_command_set_top_insertions
+ \page_set_command_set_bottom_insertions
+ \ifsomefloatwaiting
+ \doif{\rootfloatparameter\c!cache}\v!no\page_set_command_flush_floats % could be _otr_
+ \fi
+ \fi}
+
+\defineoutputroutine
+ [\s!columnset]
+ [\s!page_otr_command_routine =\page_set_command_routine,
+ \s!page_otr_command_package_contents =\page_set_command_package_contents,
+ \s!page_otr_command_set_vsize =\page_set_command_set_vsize,
+ \s!page_otr_command_set_hsize =\page_set_command_set_hsize,
+ \s!page_otr_command_next_page =\page_set_command_next_page,
+ \s!page_otr_command_next_page_and_inserts =\page_set_command_next_page_and_inserts,
+ \s!page_otr_command_synchronize_hsize =\page_set_command_synchronize_hsize,
+ \s!page_otr_command_set_top_insertions =\page_set_command_set_top_insertions,
+ \s!page_otr_command_set_bottom_insertions =\page_set_command_set_bottom_insertions,
+ \s!page_otr_command_flush_top_insertions =\page_set_command_flush_top_insertions,
+ \s!page_otr_command_flush_bottom_insertions =\page_set_command_flush_bottom_insertions,
+ \s!page_otr_command_set_float_hsize =\page_set_command_set_float_hsize,
+ \s!page_otr_command_check_if_float_fits =\page_set_command_check_if_float_fits,
+ \s!page_otr_command_flush_float_box =\page_set_command_flush_float_box,
+ \s!page_otr_command_synchronize_side_floats =\page_set_command_synchronize_side_floats,
+ \s!page_otr_command_side_float_output =\page_set_command_side_float_output,
+ \s!page_otr_command_flush_floats =\page_set_command_flush_floats,
+ \s!page_otr_command_flush_side_floats =\page_set_command_flush_side_floats,
+ \s!page_otr_command_flush_saved_floats =\page_set_command_flush_saved_floats
+ ]
+
\protect \endinput
% extreme examples (1)
diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv
index f95cc0bb3..dbf567f5f 100644
--- a/tex/context/base/page-sid.mkiv
+++ b/tex/context/base/page-sid.mkiv
@@ -92,16 +92,16 @@
\let\sidefloatalign \c_page_sides_align
\let\sidefloatmethod \c_page_sides_method
-\def\backspacefloat {\global\c_page_sides_float_type\plusone \page_sides_handle_float}
-\def\leftedgefloat {\global\c_page_sides_float_type\plustwo \page_sides_handle_float}
-\def\leftmarginfloat {\global\c_page_sides_float_type\plusthree\page_sides_handle_float}
-\def\leftfloat {\global\c_page_sides_float_type\plusfour \page_sides_handle_float}
-\def\rightfloat {\global\c_page_sides_float_type\plusfive \page_sides_handle_float}
-\def\rightmarginfloat{\global\c_page_sides_float_type\plussix \page_sides_handle_float}
-\def\rightedgefloat {\global\c_page_sides_float_type\plusseven\page_sides_handle_float}
-\def\cutspacefloat {\global\c_page_sides_float_type\pluseight\page_sides_handle_float}
-
-\let\marginfloat \cutspacefloat
+\def\page_sides_process_float_backspace {\global\c_page_sides_float_type\plusone \page_sides_handle_float}
+\def\page_sides_process_float_leftedge {\global\c_page_sides_float_type\plustwo \page_sides_handle_float}
+\def\page_sides_process_float_leftmargin {\global\c_page_sides_float_type\plusthree\page_sides_handle_float}
+\def\page_sides_process_float_left {\global\c_page_sides_float_type\plusfour \page_sides_handle_float}
+\def\page_sides_process_float_right {\global\c_page_sides_float_type\plusfive \page_sides_handle_float}
+\def\page_sides_process_float_rightmargin{\global\c_page_sides_float_type\plussix \page_sides_handle_float}
+\def\page_sides_process_float_rightedge {\global\c_page_sides_float_type\plusseven\page_sides_handle_float}
+\def\page_sides_process_float_cutspace {\global\c_page_sides_float_type\pluseight\page_sides_handle_float}
+\def\page_sides_process_float_margin {\global\c_page_sides_float_type\pluseight\page_sides_handle_float}
+
\let\logsidefloat \relax
\newif\ifroomforfloat % shared (will change)
@@ -261,11 +261,11 @@
\global\c_page_sides_n_of_lines\zerocount % here !
\fi}
-\def\page_sides_flush_floats_after_par
+\unexpanded\def\page_sides_flush_floats_after_par
{\xdef\oldpagetotal{\the\pagetotal}%
\global\let\page_sides_check_floats\page_sides_check_floats_after_par}
-\def\page_sides_forget_floats
+\unexpanded\def\page_sides_forget_floats
{\global\d_page_sides_vsize\d_page_sides_vsize_reset
\global\c_page_sides_n_of_lines\zerocount
% also here if used at all \global\holdinginserts\zerocount
@@ -312,7 +312,7 @@
\fi}
\def\page_sides_output_routine_nop
- {\finalsidefloatoutput % indirect call
+ {\page_otr_command_side_float_output % otr specific
\global\d_page_sides_vsize\d_page_sides_vsize_reset
\global\c_page_sides_n_of_lines\zerocount
% we can end up in fig lock, so \global\holdinginserts\zerocount here too ?
@@ -656,7 +656,7 @@
\def\iffirstsidefloatparagraph
{\ifcase\c_page_sides_checks_done\or}
-\def\page_sides_check_floats_set
+\unexpanded\def\page_sides_check_floats_set
{\scratchdimen\dimexpr\d_page_sides_progress+\strutht-\roundingeps\relax
\c_page_sides_n_of_hang\scratchdimen
\divide\c_page_sides_n_of_hang \baselineskip\relax
@@ -708,15 +708,15 @@
\llap{\showstruts\strut\kern.25\bodyfontsize}}%
\fi}
-\def\page_sides_check_floats_reset
+\unexpanded\def\page_sides_check_floats_reset
{\global\c_page_sides_checks_done\zerocount}
-\def\page_sides_synchronize_floats
+\unexpanded\def\page_sides_synchronize_floats
{\ifinner \else
\page_sides_check_floats
\fi}
-\def\page_sides_check_previous_float
+\unexpanded\def\page_sides_check_previous_float
{\page_sides_analyse_progress
\ifdim\d_page_sides_progress>\zeropoint \relax
\ifconditional\c_page_sides_short
@@ -785,26 +785,12 @@
% \def as they can be redefined!
+% some will become obsolete
+
\def\checksidefloat {\page_sides_check_floats}
-\def\flushsidefloats {\page_sides_flush_floats}
+%def\flushsidefloats {\page_sides_flush_floats}
\def\flushsidefloatsafterpar{\page_sides_flush_floats_after_par}
-\def\forgetsidefloats {\page_sides_forget_floats}
-\def\synchronizesidefloats {\page_sides_synchronize_floats}
-
-\let\OTRONEflushsidefloats \page_sides_flush_floats
-\let\OTRONEsynchronizesidefloats\page_sides_synchronize_floats
-
-% page-set
-%
-% \let\OTRSETflushsidefloats \forgetsidefloats
-% \let\OTRSETsynchronizesidefloats\forgetsidefloats
-%
-% page-mul
-%
-% \let\OTRMULflushsidefloats \forgetsidefloats
-% \let\OTRMULsynchronizesidefloats\forgetsidefloats
-
-\registerotrcommand\synchronizesidefloats
-\registerotrcommand\flushsidefloats
+%def\forgetsidefloats {\page_sides_forget_floats}
+%def\synchronizesidefloats {\page_sides_synchronize_floats}
\protect \endinput
diff --git a/tex/context/base/page-spr.mkiv b/tex/context/base/page-spr.mkiv
index 33bd6ff16..f4768d4e9 100644
--- a/tex/context/base/page-spr.mkiv
+++ b/tex/context/base/page-spr.mkiv
@@ -33,7 +33,7 @@
\hsize\textwidth % local variant of \sethsize
\boxmaxdepth\maxdepth
\noindent % content can be < \hsize
- \dopagecontents#2#3}}%
+ \page_otr_command_package_contents#2#3}}%
\dp#1\zeropoint
\setbox#1\hbox to \makeupwidth
{\ifinspread
diff --git a/tex/context/base/page-str.mkiv b/tex/context/base/page-str.mkiv
index 1808eed01..f14f2f716 100644
--- a/tex/context/base/page-str.mkiv
+++ b/tex/context/base/page-str.mkiv
@@ -40,7 +40,7 @@
\newtoks \everyenableoutputstream
\appendtoks
- \flushsidefloats
+ \page_otr_command_flush_side_floats
\to \everyenableoutputstream
\def\initializeoutputstreams
diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi
index 10192a028..c63f697e1 100644
--- a/tex/context/base/page-txt.mkvi
+++ b/tex/context/base/page-txt.mkvi
@@ -514,16 +514,19 @@
\page_layouts_left_edge_element\c!lefttext
\fi
\ifdim\leftmarginwidth>\zeropoint
- \page_layouts_left_margin_element\c!lefttext\page_layouts_extra_at_margin_left
+ %\page_layouts_left_margin_element\c!lefttext\page_layouts_extra_at_margin_left
+ \page_layouts_left_margin_element\c!lefttext\page_layouts_extra_at_margin_right
\fi
\ifdim\makeupwidth>\zeropoint
\page_layouts_text_body_element\c!lefttext\c!middletext\c!righttext\page_layouts_extra_at_margin_left
\fi
\ifdim\rightmarginwidth>\zeropoint
- \page_layouts_right_margin_element\c!righttext\page_layouts_extra_at_margin_left
+ %\page_layouts_right_margin_element\c!righttext\page_layouts_extra_at_margin_left
+ \page_layouts_right_margin_element\c!righttext\page_layouts_extra_at_margin_right
\fi
\ifdim\rightedgewidth>\zeropoint
- \page_layouts_right_edge_element\c!lefttext
+ %\page_layouts_right_edge_element\c!lefttext
+ \page_layouts_right_edge_element\c!righttext
\fi}}
\def\page_layouts_place_text_line_left
@@ -532,16 +535,19 @@
\page_layouts_left_edge_element\c!righttext
\fi
\ifdim\leftmarginwidth>\zeropoint
- \page_layouts_left_margin_element\c!righttext\page_layouts_extra_at_margin_right
+ %\page_layouts_left_margin_element\c!righttext\page_layouts_extra_at_margin_right
+ \page_layouts_left_margin_element\c!righttext\page_layouts_extra_at_margin_left
\fi
\ifdim\makeupwidth>\zeropoint
\page_layouts_text_body_element\c!righttext\c!middletext\c!lefttext\page_layouts_extra_at_margin_right
\fi
\ifdim\rightmarginwidth>\zeropoint
- \page_layouts_right_margin_element\c!lefttext\page_layouts_extra_at_margin_right
+ %\page_layouts_right_margin_element\c!lefttext\page_layouts_extra_at_margin_right
+ \page_layouts_right_margin_element\c!lefttext\page_layouts_extra_at_margin_left
\fi
\ifdim\rightedgewidth>\zeropoint
- \page_layouts_right_edge_element\c!righttext
+ %\page_layouts_right_edge_element\c!righttext
+ \page_layouts_right_edge_element\c!lefttext
\fi}}
\def\page_layouts_left_edge_element#parameter%
@@ -661,7 +667,7 @@
\installpagebreakmethod \v!empty
{\page_otr_flush_all_floats
- \gotonextpage
+ \page_otr_command_next_page
\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}%
\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}%
\page_otr_insert_dummy_page}
diff --git a/tex/context/base/scrn-fld.mkvi b/tex/context/base/scrn-fld.mkvi
index 0554f8783..872099099 100644
--- a/tex/context/base/scrn-fld.mkvi
+++ b/tex/context/base/scrn-fld.mkvi
@@ -409,7 +409,7 @@
[\c!alternative=\v!normal,
\c!type=\v!line,
\c!width=5em,
- \c!height=1em,
+ \c!height=\lineheight,
\c!depth=\zeropoint,
\c!align=\v!flushleft,
\c!option=\v!printable,
@@ -431,22 +431,22 @@
\def\scrn_field_setup_field[#tag][#variant][#totalsettings][#labelsettings][#fieldsettings]%
{\iffifthargument
- \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#fieldsettings]
+ \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#fieldsettings]%
\setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant},#totalsettings]%
\setupfieldlabelframed [#tag][\s!parent=\??fieldlabel,#labelsettings]%
\setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#fieldsettings]%
\else\iffourthargument
- \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#labelsettings]
+ \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#labelsettings]%
\setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant},#totalsettings]%
\setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]%
\setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#labelsettings]%
\else\ifthirdargument
- \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#totalsettings]
+ \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#totalsettings]%
\setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant}]%
\setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]%
\setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#totalsettings]%
\else\ifsecondargument
- \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#variant]
+ \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#variant]%
\setupfieldtotalframed [#tag][\s!parent=\??fieldtotal]%
\setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]%
\setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#variant]%
@@ -599,6 +599,8 @@
\def\scrn_field_flush_content
{\box\b_scrn_field_content}
+%D todo: replace \processallactionsinset
+
\def\scrn_field_analyze_setups
{\setfalse\fieldlabelshown
\setfalse\fieldframeshown
diff --git a/tex/context/base/scrn-ini.mkvi b/tex/context/base/scrn-ini.mkvi
index 842d83812..daf0a1b91 100644
--- a/tex/context/base/scrn-ini.mkvi
+++ b/tex/context/base/scrn-ini.mkvi
@@ -120,8 +120,8 @@
%D When we're dealing with pure page references, contrast
%D colors are used when we are already at the page mentioned.
-\def\setlocationcolor % not grouped !
- {\ifnum\referencepagestate=\plusone
+\unexpanded\def\setlocationcolorspecified#1% not grouped !
+ {\ifnum#1=\plusone
\edef\askedcontrastcolor{\interactionparameter\c!contrastcolor}%
\ifx\askedcontrastcolor\empty
\useinteractioncolorparameter\c!color
@@ -132,11 +132,8 @@
\useinteractioncolorparameter\c!color
\fi}
-\def\setlocationfont % not grouped !
- {\useinteractionstyleparameter\c!style}
-
-\def\setlocationattributes % not grouped !
- {\ifnum\referencepagestate=\plusone
+\unexpanded\def\setlocationattributesspecified#1% not grouped !
+ {\ifnum#1=\plusone
\edef\askedcontrastcolor{\interactionparameter\c!contrastcolor}%
\ifx\askedcontrastcolor\empty
\useinteractionstyleandcolor\c!style\c!color
@@ -147,18 +144,25 @@
\useinteractionstyleandcolor\c!style\c!color
\fi}
-\def\setlocationcolorspec#1% \resolver
- {\ifnum\referencepagestate=\plusone
- \edef\askedcontrastcolor{#1\c!contrastcolor}%
+\unexpanded\def\setlocationcolorspec#1#2% \resolver
+ {\ifnum#1=\plusone
+ \edef\askedcontrastcolor{#2\c!contrastcolor}%
\ifx\askedcontrastcolor\empty
- \doactivatecolor{#1\c!color}%
+ \doactivatecolor{#2\c!color}%
\else
\doactivatecolor\askedcontrastcolor
\fi
\else
- \doactivatecolor{#1\c!color}%
+ \doactivatecolor{#2\c!color}%
\fi}
+\unexpanded\def\setlocationcolor {\setlocationcolorspecified \referencepagestate}
+\unexpanded\def\setlocationattributes{\setlocationattributesspecified\referencepagestate}
+\unexpanded\def\setlocationcolorspec {\setlocationcolorspecspecified \referencepagestate}
+
+\unexpanded\def\setlocationfont % not grouped !
+ {\useinteractionstyleparameter\c!style}
+
\setupinteraction
[\c!style=\v!bold,
\c!color=interactioncolor,
diff --git a/tex/context/base/scrn-wid.lua b/tex/context/base/scrn-wid.lua
index 90e353306..6fdc4fca0 100644
--- a/tex/context/base/scrn-wid.lua
+++ b/tex/context/base/scrn-wid.lua
@@ -103,7 +103,7 @@ end
commands.registerattachment = attachments.register
function commands.insertattachment(specification)
- tex.box["scrn_attachment_box_link"] = attachments.insert(specification)
+ tex.box["b_scrn_attachment_link"] = attachments.insert(specification)
end
-- Comment
@@ -117,7 +117,7 @@ function comments.insert(specification)
end
function commands.insertcomment(specification)
- tex.box["scrn_comment_box_link"] = comments.insert(specification)
+ tex.box["b_scrn_comment_link"] = comments.insert(specification)
end
-- Soundclips
diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi
index 7a595cf2d..97fd1eb59 100644
--- a/tex/context/base/scrn-wid.mkvi
+++ b/tex/context/base/scrn-wid.mkvi
@@ -408,10 +408,10 @@
\unexpanded\def\scrn_comment_start#category%
{\def\currentcomment{#category}%
\doifelselocation
- {\dodoubleempty\scrn_comment_start_indeed}
+ {\dodoubleempty\scrn_comment_start_status}
{\dodoubleempty\scrn_comment_start_ignore}}
-\def\scrn_comment_start_indeed
+\def\scrn_comment_start_status
{\doifelse{\commentparameter\c!state}\v!start
{\scrn_comment_start_indeed}
{\scrn_comment_start_ignore}}
@@ -419,8 +419,8 @@
\def\scrn_comment_start_indeed[#title][#settings]%
{\bgroup
\doifassignmentelse{#title}
- {\setupcurrentcomment[\currentcomment][#title]}
- {\setupcurrentcomment[\currentcomment][\c!title=#title,#settings]}%
+ {\setupcurrentcomment[#title]}
+ {\setupcurrentcomment[\c!title=#title,#settings]}%
\def\scrn_comment_stop{\scrn_comment_inject\egroup}%
\grabbufferdatadirect\v!comment{\e!start\currentcomment}{\e!stop\currentcomment}}
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua
index e22cb3e84..593f60e77 100644
--- a/tex/context/base/spac-ver.lua
+++ b/tex/context/base/spac-ver.lua
@@ -678,7 +678,7 @@ local function nodes_to_string(head)
if id == penalty_code then
t[#t+1] = format("%s:%s",ty,current.penalty)
elseif id == glue_code then
- t[#t+1] = format("%s:%s",ty,stripzeros(topoints(current.spec.width)))
+ t[#t+1] = format("%s:%s",ty,glue_to_string(current)) -- stripzeros(topoints(current.spec.width)))
elseif id == kern_code then
t[#t+1] = format("%s:%s",ty,stripzeros(topoints(current.kern)))
else
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index cbe971ca9..8df213520 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -17,6 +17,10 @@
\registerctxluafile{spac-ver}{1.001}
+% todo: itemize : intro ... only when there is one or two lines preceding and then
+% keep these together i.e. \blank[intro]
+
+
% Isn't it about time to get rid of topskip i.e. make it equivalent to
% \openstrutheight so that we can remove delta code.
%
@@ -404,7 +408,6 @@
\s_spac_whitespace_parskip#1\fi
\relax}
-
\unexpanded\def\forgetparskip
{\s_spac_whitespace_parskip\zeropoint
\parskip\zeropoint
@@ -1277,6 +1280,25 @@
\synchronizelocallinespecs
\to \everysetuplocalinterlinespace
+%D We still have to synchronize these:
+
+\unexpanded\def\synchronizeskipamounts
+ {\bigskipamount
+ \skipfactor\baselineskip
+ plus\skipgluefactor\baselineskip
+ minus\skipgluefactor\baselineskip
+ \relax
+ \medskipamount \bigskipamount \divide\medskipamount \plustwo
+ \smallskipamount\bigskipamount \divide\smallskipamount\plusfour}
+
+\appendtoks
+ \synchronizeskipamounts
+\to \everysetupglobalinterlinespace
+
+\appendtoks
+ \synchronizeskipamounts
+\to \everysetuplocalinterlinespace
+
%D Snapping.
\newif\ifgridsnapping
@@ -1482,11 +1504,6 @@
\attribute\skipcategoryattribute\plusone
\attribute\skippenaltyattribute \attributeunsetvalue
\attribute\skiporderattribute \attributeunsetvalue
-% \ifgridsnapping % \ifblankflexible
-% \setfalse\blankisfixed
-% \else
-% \settrue\blankisfixed
-% \fi
\ifgridsnapping
\settrue\blankisfixed
\else
@@ -1519,7 +1536,7 @@
{\settrue\someblankdone
\advance\s_spac_vspacing_temp#1\dimexpr\ifgridsnapping#3\else#2\fi\relax\relax}
-\def\setblankpenalty #1%
+\def\setblankpenalty#1%
{\flushblankhandling
\settrue\someblankdone
\attribute\skipcategoryattribute \plusthree
@@ -1600,13 +1617,17 @@
\def\spac_vspacing_nop_ignore
{\ifmmode\else\par\fi}
+% these depend on bigskipamount cum suis so we'd better sync them
+
\unexpanded\def\setupvspacing
{\doifnextoptionalelse\setupvspacing_yes\setupvspacing_nop}
\let\currentvspacing\s!default % hm, default, standard ...
\def\setupvspacing_yes[#1]%
- {\edef\currentvspacing{#1}}
+ {\edef\currentvspacing{#1}%
+ \spac_whitespace_setup_nop % yes or no, was forgotten
+ }
\def\setupvspacing_nop
{\ifx\empty\currentvspacing\else
@@ -1634,11 +1655,11 @@
\definevspacingamount[\v!none] [\zeropoint] [\zeropoint]
\definevspacingamount[\v!big] [\bigskipamount] [\bodyfontlineheight]
-\definevspacingamount[\v!medium] [\medskipamount] [0.50\bodyfontlineheight]
-\definevspacingamount[\v!small] [\smallskipamount] [0.25\bodyfontlineheight]
+\definevspacingamount[\v!medium] [\medskipamount] [.5\bodyfontlineheight]
+\definevspacingamount[\v!small] [\smallskipamount] [.25\bodyfontlineheight]
\definevspacingamount[\v!line] [\openlineheight] [\bodyfontlineheight]
-\definevspacingamount[\v!halfline][0.50\openlineheight][0.50\bodyfontlineheight]
-\definevspacingamount[\v!formula] [\medskipamount] [0.50\bodyfontlineheight]
+\definevspacingamount[\v!halfline][.5\openlineheight] [.5\bodyfontlineheight]
+\definevspacingamount[\v!formula] [\medskipamount] [.5\bodyfontlineheight]
\definevspacingamount[\v!white] [\parskip] [\bodyfontwhitespace]
\definevspacingamount[\v!height] [\strutheight] [\bodyfontstrutheight]
\definevspacingamount[\v!depth] [\strutdepth] [\bodyfontstrutdepth]
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 5ca1a9c33..44799888e 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 7699fb29b..b46e426d3 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index 9c20b18d4..df7b57d5a 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -640,7 +640,22 @@ return {
status = "unknown",
},
{
- filename = "strc-syn",
+ filename = "strc-des",
+ marktype = "mkiv",
+ status = "unknown",
+ },
+ {
+ filename = "strc-enu",
+ marktype = "mkiv",
+ status = "unknown",
+ },
+ {
+ filename = "strc-ind",
+ marktype = "mkiv",
+ status = "unknown",
+ },
+ {
+ filename = "strc-lab",
marktype = "mkiv",
status = "unknown",
},
@@ -656,9 +671,15 @@ return {
status = "unknown",
},
{
+ filename = "page-otr",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
filename = "page-ini",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "code might end up elsewhere",
},
{
filename = "page-fac",
@@ -704,7 +725,8 @@ return {
{
filename = "page-one",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "can probably be improved",
},
{
filename = "page-lay",
diff --git a/tex/context/base/strc-des.lua b/tex/context/base/strc-con.lua
index ee5fe702b..29a1c0cb3 100644
--- a/tex/context/base/strc-des.lua
+++ b/tex/context/base/strc-con.lua
@@ -1,6 +1,6 @@
-if not modules then modules = { } end modules ['strc-des'] = {
+if not modules then modules = { } end modules ['strc-con'] = {
version = 1.001,
- comment = "companion to strc-des.mkiv",
+ comment = "companion to strc-con.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi
new file mode 100644
index 000000000..0ef2d8b4a
--- /dev/null
+++ b/tex/context/base/strc-con.mkvi
@@ -0,0 +1,886 @@
+%D \module
+%D [ file=strc-con,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Constructions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Constructions}
+
+\registerctxluafile{strc-con}{1.001}
+
+% todo: check if commands similar to lists
+% todo: \strc_constructions_setup_counter\strc_constructions_setup_counter{#1} in setup ... synchronization
+%
+% ? : \def\showdnlisttext{\constructionparameter\c!listtext} % space in default
+%
+% maybe: pickup text and store in buffer ...
+%
+% \@@notemakeconstruction[##1]{}{##2}%
+% \expandafter\endgroup\noteparameter\c!next}}
+%
+% todo: \currentconstructionattribute : can be a counter instead
+
+
+%D Constructions are just descriptions but a bit more abstract so that
+%D we can conveniently build upon them. They are not really meant for
+%D users but module writers might find them useful. We mention a
+%D couple of parameters but these are only mentioned because in the
+%D shared code we map all resolvers to constructions.
+
+\unprotect
+
+\ifdefined\v!construction \else \def\v!construction{construction} \fi
+
+%D Todo:
+
+\installcorenamespace{construction}
+
+\installcommandhandler \??construction {construction} \??construction
+
+\let\setupconstructions\setupconstruction
+
+\setupconstructions[%
+ %c!title=,
+ %c!text=,
+ %
+ %c!style=,
+ %c!color=,
+ %c!command=,
+ %c!align=,
+ %
+ %c!headstyle=,
+ %c!headcolor=,
+ %c!headalign=,
+ %
+ %c!titlestyle=,
+ %c!titlecolor=,
+ %c!titlecommand=,
+ %c!titleleft=,
+ %c!titleright=,
+ %
+ %c!closesymbol=,
+ %c!closecommand=,
+ %
+ \c!alternative=\v!left,
+ \c!display=\v!yes,
+ \c!width=7em,
+ \c!distance=1em,
+ \c!titledistance=0.5em,
+ %c!hang=,
+ %c!sample=,
+ \c!margin=\v!no,
+ \c!before=\blank,
+ \c!inbetween=\blank,
+ \c!after=\blank,
+ %c!indentnext=,
+ %c!indenting=,
+ %
+ \c!expansion=\v!no,
+ %c!xmlsetup=,
+ %s!catcodes=,
+]
+
+%D Constructions and alike uses similar structures. In order to prevent issues
+%D we freeze some states. There is some overhead in the intermediate define
+%D step (as we could set them directly) but this is more flexible (and looks
+%D nicer). Keep in mind that descriptions, enumeration and notations are all
+%D independent and that we just remap the resolvers.
+
+% \defineconstruction[test][handler=description,level=1]
+% \defineconstruction[test][parent][handler=description,level=3]
+
+\installcorenamespace{constructionmain} % frozen after definition
+\installcorenamespace{constructionlevel} % frozen after definition
+\installcorenamespace{constructionclass} % frozen after definition
+
+\let\currentconstructionmain \empty
+\let\currentconstructionlevel \empty
+\let\currentconstructionhandler\empty
+
+\appendtoks
+ \ifx\currentconstructionparent\empty
+ \letvalue{\??constructionmain \currentconstruction}\currentconstruction
+ \definelist[\currentconstruction]% goodie
+ \else
+ \letvalue{\??constructionmain \currentconstruction}\currentconstructionparent
+ \definelist[\currentconstruction][\currentconstructionparent]% goodie
+ \fi
+ \setevalue{\??constructionlevel\currentconstruction}{\number\constructionparameter\c!level}%
+ \setevalue{\??constructionclass\currentconstruction}{\constructionparameter\s!handler}%
+\to \everydefineconstruction
+
+\appendtoks
+ \setuevalue{\e!start\currentconstruction}{\strc_constructions_start{\currentconstruction}}%
+ \setuevalue{\e!stop \currentconstruction}{\strc_constructions_stop}%
+\to \everydefineconstruction
+
+%D Just a basic environment (mostly for testing). We will provide a 'setup' based
+%D plugin once the rest is sorted out.
+
+\unexpanded\def\strc_constructions_start#1%
+ {\begingroup
+ \strc_constructions_initialize{#1}%
+ \dodoubleempty\strc_constructions_start_regular}
+
+\unexpanded\def\strc_constructions_start_regular[#1][#2]%
+ {\strc_constructions_register[\c!label={\constructionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,#1][#2]%
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_constructions_stop
+ {\csname\??constructionstophandler\currentconstructionhandler\endcsname
+ \endgroup}
+
+%D As we will build on top of the generic construction mechanism we
+%D have handlers as a sort of plug in mechanism. In order to have
+%D some consistency we share some namespaces.
+
+\installcorenamespace{constructioninitializer}
+\installcorenamespace{constructionfinalizer}
+
+\installcorenamespace{constructionmainhandler}
+\installcorenamespace{constructioncommandhandler}
+\installcorenamespace{constructionstarthandler}
+\installcorenamespace{constructionstophandler}
+
+\installcorenamespace{constructiontexthandler}
+\installcorenamespace{constructionnotehandler}
+
+\unexpanded\def\strc_constructions_initialize#1% class instance
+ {\edef\currentconstruction{#1}%
+ \expandafter\let\expandafter\currentconstructionmain \csname\??constructionmain \currentconstruction\endcsname
+ \expandafter\let\expandafter\currentconstructionlevel \csname\??constructionlevel\currentconstruction\endcsname
+ \expandafter\let\expandafter\currentconstructionhandler\csname\??constructionclass\currentconstruction\endcsname
+ \csname\??constructioninitializer\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_constructions_finalize
+ {\csname\??constructionfinalizer\currentconstructionhandler\endcsname
+ \strc_constructions_discard}
+
+\newconditional\c_strc_constructions_number_state
+\newconditional\c_strc_constructions_title_state
+
+\setvalue{\??constructioninitializer\v!construction}%
+ {\setfalse\c_strc_constructions_number_state
+ \setfalse\c_strc_constructions_title_state}
+
+\setvalue{\??constructionfinalizer\v!construction}%
+ {}
+
+% We keep the command variant around but rather would move to the
+% start-stop one. Also, passing the title as argument has some
+% history so we need to keep that as well.
+
+\ifdefined\dotagsetconstruction \else \let\dotagsetconstruction\relax \fi
+
+\newtoks\everyconstruction
+
+\unexpanded\def\currentconstructiontext
+ {\begstrut
+ \csname\??constructiontexthandler\currentconstructionhandler\endcsname
+ \endstrut}
+
+\unexpanded\def\currentconstructionsample
+ {\begstrut
+ \constructionparameter\c!text
+ \constructionparameter\c!sample
+ \endstrut}
+
+\setvalue{\??constructionmainhandler\v!construction}#1%
+ {\iftrialtypesetting \else
+ \begingroup
+ \currentconstructionsynchronize
+ \attribute\destinationattribute\currentconstructionattribute\relax % todo, whole text
+ \signalcharacter
+ \endgroup
+ \fi#1}
+
+\setvalue{\??constructiontexthandler\v!construction}%
+ {\begingroup
+ \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext
+ \the\everyconstruction
+ \constructionparameter\c!headcommand
+ {\strut
+ \constructionparameter\c!text
+ \ctxcommand{savedlisttitle("\currentconstructionmain",\currentconstructionlistentry)}}%
+ \endgroup}
+
+\unexpanded\def\strc_constructions_stored_start
+ {\begingroup
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname
+ }
+
+\unexpanded\def\strc_constructions_stored_stop
+ {\csname\??constructionstophandler\currentconstructionhandler\endcsname
+ %\endgroup % brrr
+ }
+
+\newconstant\c_strc_constructions_nested_state % to be redone
+
+\def\resetconstructions % to be used in e.g. footnotes
+ {\c_strc_constructions_nested_state\zerocount}
+
+\setvalue{\??constructioncommandhandler\v!construction}%
+ {\endgroup}
+
+\setvalue{\??constructionstarthandler\v!construction}% this will be redone (reorganized) .. too much boxing
+ {\dostarttagged\t!construction\currentconstruction
+ \dotagsetconstruction
+ \constructionparameter\c!before
+ \begingroup
+ \doadaptleftskip{\constructionparameter\c!margin}%
+ \setlocalhsize % so we can use \localhsize in width assignments
+ \constructionsheaddistance\constructionalternativeparameter\c!distance\relax
+ \ifdim\constructionsheaddistance=\zeropoint
+ \doif{\constructionalternativeparameter\c!width}\v!broad{\constructionsheaddistance\emwidth}%
+ \fi
+ % inefficient and not always needed, for instance not with margins so we will make checkers
+ % per alternative
+ \setbox\constructionheadbox\hbox
+ {\forgetall
+ \dontcomplain
+ \settrialtypesetting
+ \doifelsenothing{\constructionparameter\c!sample}
+ {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext}%
+ {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructionsample}}%
+ \assignwidth
+ {\constructionalternativeparameter\c!width}
+ \constructionsheadwidth
+ {\unhcopy\constructionheadbox}
+ \constructionsheaddistance
+ \dostarttagged\t!constructiontag\empty % todo
+ \setbox\constructionheadbox\hbox
+ {\forgetall
+ \dontcomplain
+ \doifelse{\constructionparameter\c!alternative}\v!serried % brrr, hack, will change
+ {\csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext}
+ {\csname\??constructionmainhandler\currentconstructionhandler\endcsname{\boxedconstructionhead\currentconstructiontext}}}%
+ \doifelse{\constructionparameter\c!aligntitle}\v!no
+ {\leftconstructionskip \leftskip
+ \rightconstructionskip\rightskip}
+ {\ifcase\c_strc_constructions_nested_state
+ \leftconstructionskip \leftskip
+ \rightconstructionskip\rightskip
+ \fi}%
+ \doifsomething{\constructionparameter\c!align}{\setupalign[\constructionparameter\c!align]}% \use...
+ \indenting[\constructionparameter\c!indenting]% \use...
+ \ifcase\c_strc_constructions_nested_state
+ \c_strc_constructions_nested_state\plusone
+ \or
+ \c_strc_constructions_nested_state\plustwo
+ \fi
+ \strc_constructions_close_symbol_reset
+ %
+ \edef\currentconstructionalternative{\constructionparameter\c!alternative}%
+ \doifnotsetups {\constructionalternativeparameter\c!renderingsetup}
+ {\let\currentconstructionalternative\v!left}%
+ \directsetup{\constructionalternativeparameter\c!renderingsetup}\relax
+ %
+ \dostoptagged % tag
+ \dostarttagged\t!constructioncontent\empty
+ \ignorespaces} % args not needed
+
+\setvalue{\??constructionstophandler\v!construction}%
+ {\strc_constructions_close_symbol_place
+ \doifnot{\constructionparameter\c!display}\v!no\par
+ \dostoptagged % content
+ \dostoptagged % construction
+ \endgroup
+ \constructionparameter\c!after
+ \useindentnextparameter\constructionparameter
+ \strc_constructions_finalize
+% \endgroup
+ \dorechecknextindentation}
+
+\def\boxedconstructionhead#1%
+ {\vtop
+ {\hsize\constructionsheadwidth
+ \doifsomething{\constructionparameter\c!headalign}{\setupalign[\constructionparameter\c!headalign]}%
+ #1}}
+
+\installcorenamespace{constructionalternative}
+\installcorenamespace{constructionrenderings}
+
+% see lists: alternativemethods ... todo
+
+\installcommandhandler \??constructionalternative {constructionalternative} \??constructionalternative
+
+\setupconstructionalternative
+ [\c!width=\constructionparameter\c!width,
+ \c!distance=\constructionparameter\c!distance]
+
+\defineconstructionalternative
+ [\v!left]
+ [%\c!width=7em,
+ %\c!distance=1em,
+ \c!renderingsetup=\??constructionrenderings:\v!left]
+
+\defineconstructionalternative
+ [\v!right]
+ [%\c!width=7em,
+ %\c!distance=1em,
+ \c!renderingsetup=\??constructionrenderings:\v!right]
+
+\defineconstructionalternative
+ [\v!inmargin]
+ [\c!renderingsetup=\??constructionrenderings:\v!inmargin]
+
+\defineconstructionalternative
+ [\v!inleft]
+ [\c!renderingsetup=\??constructionrenderings:\v!inleft]
+
+\defineconstructionalternative
+ [\v!inright]
+ [\c!renderingsetup=\??constructionrenderings:\v!inright]
+
+\defineconstructionalternative
+ [\v!margin]
+ [\c!renderingsetup=\??constructionrenderings:\v!margin]
+
+\defineconstructionalternative
+ [\v!leftmargin]
+ [\c!renderingsetup=\??constructionrenderings:\v!leftmargin]
+
+\defineconstructionalternative
+ [\v!rightmargin]
+ [\c!renderingsetup=\??constructionrenderings:\v!rightmargin]
+
+\defineconstructionalternative
+ [\v!innermargin]
+ [\c!renderingsetup=\??constructionrenderings:\v!innermargin]
+
+\defineconstructionalternative
+ [\v!outermargin]
+ [\c!renderingsetup=\??constructionrenderings:\v!outermargin]
+
+\defineconstructionalternative
+ [\v!serried]
+ [\c!renderingsetup=\??constructionrenderings:\v!serried]
+
+\defineconstructionalternative
+ [\v!hanging]
+ [%\c!width=\v!fit,
+ \c!renderingsetup=\??constructionrenderings:\v!hanging]
+
+\defineconstructionalternative
+ [\v!top]
+ [\c!renderingsetup=\??constructionrenderings:\v!top,
+ \c!width=\localhize]
+
+\defineconstructionalternative
+ [\v!command]
+ [\c!renderingsetup=\??constructionrenderings:\v!command]
+
+\newbox \constructionheadbox
+\newskip \leftconstructionskip
+\newskip \rightconstructionskip
+\newdimen \constructionsheadwidth % replaces \!!widtha % TODO: proper namespace dimens
+\newdimen \constructionsheaddistance % replaces \!!widthb % TODO: proper namespace dimens
+
+\def\strc_constructions_set_hang_box#1% messy left/rightskip
+ {\setbox\constructionheadbox\vtop % \vbox gaat fout in hang
+ {\forgetall
+ \dontcomplain
+ \hsize\constructionsheadwidth
+ \edef\p_headalign{\constructionparameter\c!headalign}%
+ \ifx\p_headalign\empty
+ \setupalign[#1]% use fast one
+ \else
+ \setupalign[\p_headalign]% use fast one
+ \fi
+ \advance\ifx#1\v!flushleft\rightskip\else\leftskip\fi\constructionsheaddistance % only difference and wrong anyway
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \ht\constructionheadbox\strutht
+ \dp\constructionheadbox\strutdp}
+
+\def\strc_constructions_set_pure_box#1% default ... better set up differently
+ {\setbox\constructionheadbox\vtop
+ {\forgetall
+ \dontcomplain
+ \hsize\constructionsheadwidth
+ \edef\p_headalign{\constructionparameter\c!headalign}%
+ \ifx\p_headalign\empty
+ \setupalign[#1]% use fast one
+ \else
+ \setupalign[\p_headalign]% use fast one
+ \fi
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \ht\constructionheadbox\strutht
+ \dp\constructionheadbox\strutdp}
+
+\def\strc_constructions_set_hang#1%
+ {\edef\p_hang{\constructionparameter\c!hang}%
+ \ifx\p_hang\empty
+ \else\ifx\p_hang\v!fit
+ \scratchdimen\htdp\constructionheadbox
+ \getnoflines\scratchdimen
+ \hangafter-\noflines
+ \else\ifx\p_hang\v!broad
+ \scratchdimen\dimexpr\htdp\constructionheadbox+.5\strutht\relax
+ \getnoflines\scratchdimen
+ \hangafter-\noflines
+ \else
+ \hangafter-\p_hang
+ \fi
+ \relax
+ \hangindent\ifx#1\v!right-\fi\constructionsheadwidth}
+
+% The setups. These only deal with placement of the descriptor and initializing the
+% environment. The wrapping happens elsewhere.
+
+\startsetups[\??constructionrenderings:\v!left]
+ \edef\p_hang{\constructionparameter\c!hang}
+ \doifsetupselse{\??constructionrenderings:\v!left:\p_hang} {
+ \directsetup{\??constructionrenderings:\v!left:\p_hang}
+ } {
+ \directsetup{\??constructionrenderings:\v!left:\v!hanging}
+ }
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!right]
+ \edef\p_hang{\constructionparameter\c!hang}
+ \doifsetupselse{\??constructionrenderings:\v!right:\p_hang} {
+ \directsetup{\??constructionrenderings:\v!right:\p_hang}
+ } {
+ \directsetup{\??constructionrenderings:\v!right:\v!hanging}
+ }
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!left:\v!none]
+ \let\\=\crlf
+ \noindent
+ \strc_constructions_set_pure_box\v!flushleft
+ \leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth\relax
+ \rightskip\rightconstructionskip
+ \advance\leftskip\constructionsheaddistance
+ \llap {
+ \hbox to \leftskip {
+ \hskip\leftconstructionskip
+ \copy\constructionheadbox\hss
+ }
+ }
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!left:0]
+ \directsetup{\??constructionrenderings:\v!left:\v!none}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!left:]
+ \directsetup{\??constructionrenderings:\v!left:\v!none}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!right:\v!none]
+ \let\\=\crlf
+ \noindent
+ \leftskip\leftconstructionskip
+ \rightskip\dimexpr\rightconstructionskip+\constructionsheadwidth\relax
+ \strc_constructions_pure_hang_box\raggedleft
+ \rlap {
+ \hskip\dimexpr\hsize-\leftskip-\rightskip\relax
+ \copy\constructionheadbox
+ \hskip\rightconstructionskip
+ }
+ \advance\rightskip \constructionsheaddistance
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!right:0]
+ \directsetup{\??constructionrenderings:\v!right:\v!none}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!right:]
+ \directsetup{\??constructionrenderings:\v!right:\v!none}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!left:\v!margin]%
+ \let\\=\crlf
+ \noindent
+ \strc_constructions_set_pure_box\v!flushleft
+ \llap {
+ \hbox to \constructionsheadwidth {
+ \copy\constructionheadbox
+ \hss
+ }
+ \hskip\constructionsheaddistance
+ }
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!right:\v!margin]%
+ \let\\=\crlf
+ \noindent
+ \strc_constructions_set_pure_box\v!flushright
+ \rlap {
+ \hskip\constructionsheaddistance
+ \hbox to \constructionsheadwidth {
+ \copy\constructionheadbox\hss
+ }
+ }
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!left:\v!hanging]%
+ \let\\=\crlf
+ \dontcomplain
+ \advance\constructionsheadwidth \constructionsheaddistance
+ \strc_constructions_set_hang_box\v!flushleft
+ \strc_constructions_set_hang\v!left
+ \noindent
+ \llap {
+ \vtop to \zeropoint {
+ \box\constructionheadbox
+ }
+ }
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!right:\v!hanging]%
+ \let\\=\crlf
+ \dontcomplain
+ \advance\constructionsheadwidth \constructionsheaddistance
+ \strc_constructions_set_hang_box\v!flushright
+ \strc_constructions_set_hang\v!right
+ \noindent
+ \rlap {
+ \hbox to \dimexpr\hsize-\leftskip-\rightskip\relax {
+ \hss
+ \vtop to \zeropoint {
+ \box\constructionheadbox
+ }
+ }
+ }
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!top]
+ \dohandlepagebreakX\plusone
+ \let\\=\space
+ \noindent
+ \copy\constructionheadbox\par % copy ?
+ \nobreak
+ \doifelsenothing{\constructionparameter\c!inbetween}{\blank}{\constructionparameter\c!inbetween}%
+ \nobreak
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!margin]
+ \let\\=\crlf
+ \noindent
+ \inmargin[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!leftmargin]
+ \let\\=\crlf
+ \noindent
+ \inleft[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!rightmargin]
+ \let\\=\crlf
+ \noindent
+ \inright[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!innermargin]
+ \let\\=\crlf
+ \noindent
+ \ininner[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!outermargin]
+ \let\\=\crlf
+ \noindent
+ \inouter[\c!scope=\v!local]{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}%
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!inmargin]
+ \directsetup{\??constructionrenderings:\v!margin}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!inleft]
+ \directsetup{\??constructionrenderings:\v!leftmargin}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!inright]
+ \directsetup{\??constructionrenderings:\v!rightmargin}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!serried]
+ \edef\p_width{\constructionlocationparameter\c!width}% CHECK ! ! ! wrong parameter namespace
+ \doifsetupselse{\??constructionrenderings:\v!serried:\p_width} {
+ \directsetup{\??constructionrenderings:\v!serried:\p_width}
+ } {
+ \directsetup{\??constructionrenderings:\v!serried:\v!wide}
+ }
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!serried:\v!fit]
+ \let\\=\crlf
+ \noindent
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
+ \hskip\constructionsheaddistance\relax
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!serried:\v!broad]
+ \let\\=\crlf
+ \noindent
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
+ \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!serried:]
+ \directsetup{\??constructionrenderings:\v!serried:\v!broad}
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!serried:\v!wide]
+ \let\\=\crlf
+ \noindent
+ \hbox to \constructionsheadwidth {
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
+ \hss
+ }
+ \hskip\constructionsheaddistance\relax
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+\startsetups[\??constructionrenderings:\v!hanging]
+ \let\\=\crlf
+ \noindent
+ \advance\leftskip-\leftskipadaption\relax
+ \ifdim\leftskipadaption=\zeropoint
+ \leftskipadaption1.5em\relax % just some default
+ \ifnum\c_strc_constructions_nested_state=\plusone
+ \ifdim\leftskip>\zeropoint \relax
+ \leftskipadaption\leftskip
+ \fi
+ \fi
+ \fi
+ \ifnum\c_strc_constructions_nested_state>\zerocount % was \ifnum\c_strc_constructions_nested_state=\plusone
+ \advance\leftskip\leftskipadaption % but we're already further on
+ \fi
+ \hskip-\leftskipadaption\relax
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
+ \kern\ifdim\constructionsheaddistance=\zeropoint .75em\else\constructionsheaddistance\fi
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+%D \starttyping
+%D \setupfootnotation[location=command,headcommand=\llap]
+%D \stoptyping
+
+\startsetups[\??constructionrenderings:\v!command]
+ \noindent
+ \constructionparameter\c!headcommand{\ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+% you can use \placeclosesymbol or \qed to place a symbol at the end of a
+% construction
+
+\installcorenamespace{constructionclosesymbol}
+
+\let\placeclosesymbol\donothing
+\let\qed \donothing
+
+\def\strc_constructions_close_symbol_reset % no need for global
+ {\global\expandafter\settrue\csname\??constructionclosesymbol\currentconstruction\endcsname
+ \let\placeclosesymbol\strc_constructions_close_symbol_place
+ \let\qed \strc_constructions_close_symbol_place}
+
+\def\strc_constructions_close_symbol_place
+ {\ifconditional\csname\??constructionclosesymbol\currentconstruction\endcsname
+ \global\expandafter\setfalse\csname\??constructionclosesymbol\currentconstruction\endcsname
+ \edef\p_closesymbol{\constructionparameter\c!closesymbol}%
+ \ifx\p_closesymbol\empty \else
+ \constructionparameter\c!closecommand\p_closesymbol
+ \fi
+ \fi}
+
+\newif\ifnoconstructioncaption
+
+%D The storage macros:
+
+\let\currentconstructionlistentry\!!zerocount
+
+\def\strc_constructions_register
+ {\ctxcommand{doiflisthasentry(\currentconstructionlistentry)}%
+ \strc_constructions_register_nop
+ \strc_constructions_register_yes}
+
+% \def\strc_constructions_register{\strc_constructions_register_yes}
+
+\def\strc_constructions_register_nop[#1][#2]% #1=interfaced-settings, #2=optional user data
+ %{\writestatus{constructions}{reusing \currentconstruction: \number\currentconstructionlistentry}}
+ {}
+
+\def\strc_constructions_discard
+ {\iftrialtypesetting
+ % \writestatus{constructions}{discarding \currentconstruction: \number\currentconstructionlistentry}%
+ \ctxcommand{discardfromlist(\currentconstructionlistentry)}%
+ \fi}
+
+\def\strc_constructions_register_yes[#1][#2]% #1=interfaced-settings, #2=optional user data
+ {\begingroup % similar to structure so we might generalize this
+ \setupcurrentconstruction[#1]% % xdef's will become edef's
+ \xdef\currentconstructionexpansion {\constructionparameter\c!expansion}%
+ \xdef\currentconstructionxmlsetup {\constructionparameter\c!xmlsetup}%
+ \xdef\currentconstructioncatcodes {\constructionparameter\s!catcodes}%
+ \xdef\currentconstructionlabel {\constructionparameter\c!label}%
+ \xdef\currentconstructionreference {\constructionparameter\c!reference}%
+ \xdef\currentconstructionreferenceprefix{\constructionparameter\c!referenceprefix}%
+ %xdef\currentconstructionshownumber {\constructionparameter\c!number}%
+ \xdef\currentconstructionincrementnumber{\constructionparameter\c!incrementnumber}%
+ %
+ \ifx\currentconstructionexpansion\empty
+ \global\let\currentconstructionexpansion\v!no
+ \fi
+ %
+ \ifx\currentconstructionexpansion\s!xml
+ \xmlstartraw
+ \xdef\currentconstructiontitle {\constructionparameter\c!title}%
+ \xdef\currentconstructionbookmark{\constructionparameter\c!bookmark}%
+ \xdef\currentconstructionmarking {\constructionparameter\c!marking}%
+ \xdef\currentconstructionlist {\constructionparameter\c!list}%
+ \xmlstopraw
+ \ifx\currentconstructionlist\empty
+ \global\let\currentconstructionlist\currentconstructiontitle
+ \fi
+ \global\let\currentconstructioncoding\s!xml
+ \else
+ \ifx\currentconstructionexpansion\v!yes
+ \xdef\currentconstructiontitle {\constructionparameter\c!title}%
+ \xdef\currentconstructionbookmark{\constructionparameter\c!bookmark}%
+ \xdef\currentconstructionmarking {\constructionparameter\c!marking}%
+ \xdef\currentconstructionlist {\constructionparameter\c!list}%
+ \else
+ \xdef\currentconstructiontitle {\detokenizedconstructionparameter\c!title}%
+ \xdef\currentconstructionbookmark{\detokenizedconstructionparameter\c!bookmark}%
+ \xdef\currentconstructionmarking {\detokenizedconstructionparameter\c!marking}%
+ \xdef\currentconstructionlist {\detokenizedconstructionparameter\c!list}%
+ \iflocation \ifx\currentconstructionbookmark\empty
+ \begingroup
+ \simplifycommands
+ \xdef\currentconstructionbookmark{\detokenize\expandafter{\normalexpanded{\constructionparameter\c!title}}}%
+ \endgroup
+ \fi \fi
+ \fi
+ \ifx\currentconstructionlist\empty
+ \globallet\currentconstructionlist\currentconstructiontitle
+ \fi
+ \globallet\currentconstructioncoding\s!tex
+ \fi
+ %
+ \ifx\currentconstructiontitle\v!none % will become obsolete
+ \global\noconstructioncaptiontrue\global\noconstructionnumbertrue
+ \fi
+ %
+ \ifnoconstructioncaption % then why analyze anyway?
+ \endgroup
+ \let\currentconstructionlistnumber \relax
+ \let\currentconstructionsynchronize\relax
+ \let\currentconstructionattribute \relax
+ \else
+ \setnextinternalreferences{construction}\currentconstructionmain % plural
+ \relax
+ \scratchcounter\ctxcommand{addtolist{ % we can set a counter at the lua end
+ metadata = {
+ kind = "construction",
+ name = "\currentconstructionmain",
+ level = structures.sections.currentlevel(),
+ catcodes = \the\catcodetable,
+ % \currentdirectionparameters
+ },
+ references = {
+ internal = \nextinternalreference,
+ order = \nextinternalorderreference,
+ reference = "\currentconstructionreference",
+ referenceprefix = "\referenceprefix",
+ block = "\currentsectionblock",
+ section = structures.sections.currentid(),
+ },
+ titledata = {
+ label = \!!bs\detokenize\expandafter{\currentconstructionlabel }\!!es,
+ title = \!!bs\detokenize\expandafter{\currentconstructiontitle }\!!es,
+ \ifx\currentconstructionbookmark\currentconstructiontitle \else
+ bookmark = \!!bs\detokenize\expandafter{\currentconstructionbookmark}\!!es,
+ \fi
+ \ifx\currentconstructionlist\currentconstructiontitle \else
+ list = \!!bs\detokenize\expandafter{\currentconstructionlist }\!!es,
+ \fi
+ },
+ \ifconditional\c_strc_constructions_number_state
+ prefixdata = {
+ prefix = "\constructionparameter\c!prefix",
+ separatorset = "\constructionparameter\c!prefixseparatorset",
+ conversion = \!!bs\constructionparameter\c!prefixconversion\!!es,
+ conversionset = "\constructionparameter\c!prefixconversionset",
+ set = "\constructionparameter\c!prefixset",
+ segments = "\constructionparameter\c!prefixsegments",
+ connector = \!!bs\constructionparameter\c!prefixconnector\!!es,
+ },
+ numberdata = {
+ numbers = structures.counters.compact("\currentconstructionnumber",nil,true), % ! number can be cloned
+ separatorset = "\constructionparameter\c!numberseparatorset",
+ conversion = "\constructionparameter\c!numberconversion",
+ conversionset = "\constructionparameter\c!numberconversionset",
+ starter = \!!bs\constructionparameter\c!numberstarter\!!es,
+ stopper = \!!bs\constructionparameter\c!numberstopper\!!es,
+ segments = "\constructionparameter\c!numbersegments",
+ },
+ \or
+ % symbol
+ \fi
+ userdata = \!!bs\detokenize{#2}\!!es % will be converted to table at the lua end
+ }
+ }\relax
+ % \writestatus{constructions}{registering \currentconstruction: \number\scratchcounter}%
+ \normalexpanded{%
+ \endgroup
+ \edef\noexpand\currentconstructionlistentry {\the\scratchcounter}%
+ \edef\noexpand\currentconstructionattribute {\ctxcommand {setinternalreference("\referenceprefix","\currentconstructionreference",\nextinternalreference,"\interactionparameter\c!focus")}}%
+ \edef\noexpand\currentconstructionsynchronize{\ctxlatecommand{enhancelist(\the\scratchcounter)}}%
+ }%
+ \fi}
+
+% This is not so nice, some day I'll just store the number with the entry
+% and deal with all at the Lua end, but first we need to be able to set
+% macros.
+
+\def\reinstateconstructionnumberentry#1% was xdef
+ {\edef\currentconstructionattribute {\ctxcommand {getinternalreference(#1)}}%
+ \edef\currentconstructionsynchronize{\ctxlatecommand{enhancelist(#1)}}}
+
+\installstructurelistprocessor{construction}{\usestructurelistprocessor{number+title}}
+
+\protect \endinput
diff --git a/tex/context/base/strc-des.mkiv b/tex/context/base/strc-des.mkiv
deleted file mode 100644
index e2e6664eb..000000000
--- a/tex/context/base/strc-des.mkiv
+++ /dev/null
@@ -1,1175 +0,0 @@
-%D \module
-%D [ file=strc-des,
-%D version=2008.10.20,
-%D title=\CONTEXT\ Structure Macros,
-%D subtitle=Descriptions,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Structure Macros / Descriptions}
-
-\registerctxluafile{strc-des}{1.001}
-
-%D TODO: commandhandler
-%D TODO: \startxxx[reference=...]
-
-%D In order to be more flexible with theorems Aditya Mahajan added
-%D support for titles and endsymbols. At the same time we added more
-%D flexible support for inheriting numbers.
-%D
-%D \startbuffer
-%D \defineenumeration[one]
-%D \defineenumeration[two] [one] % clone one
-%D \defineenumeration[three] [counter=one,style=slanted] % only use counter of one
-%D \defineenumeration[four] [three] % clone three
-%D \defineenumeration[five] [three] [counter=five] % clone three and use own counter
-%D \defineenumeration[six] [three] [counter=four] % clone tree and use counter four (undefined)
-%D
-%D \startone test test 6 \stopone
-%D \starttwo test test 7 \stoptwo
-%D \startthree test test 8 \stopthree
-%D \startfour test test 9 \stopfour
-%D \startfive test test 2 \stopfive
-%D \startsix test test 10 \stopsix
-%D \stopbuffer
-%D
-%D \typebuffer \start \getbuffer \stop
-%D
-%D \starttyping
-%D \setupenumerations[one] [prefix=yes,prefixsegments=section]
-%D \setupenumerations[two] [prefix=yes,prefixsegments=section]
-%D \setupenumerations[three][prefix=yes,prefixsegments=section]
-%D \setupenumerations[four] [prefix=yes,prefixsegments=chapter:section]
-%D \setupenumerations[five] [prefix=yes,prefixsegments=chapter:section]
-%D \setupenumerations[six] [prefix=yes,prefixsegments=chapter:section]
-%D \stoptyping
-
-% list and titles are experimental
-%
-% \definedescription[test] [location=left,hang=4,headalign={right},distance=1em,list=test]
-% \defineenumeration[lemma][title=yes,right=:,textdistance=1em, location=top, titlestyle=\bs,list=lemma]
-% \defineenumeration[ammel][title=yes,right=:,textdistance=.5em,location=left,titlestyle=\it,width=9em]
-%
-% \placelist[enumeration:lemma]
-% \placelist[description:test][width=0pt]
-%
-% \starttest {something something something} \input zapf \stoptest
-% \startlemma {with a title of a certain length} \input tufte \stoplemma
-% \startammel {with a title} \input zapf \stopammel
-%
-% \defineenumeration[lemma][...]
-% \defineenumeration[titledlemma][lemma][title=yes,right=:,text=lemma,list=lemma]
-
-\unprotect
-
-% description parameters
-
-\def\descriptionparameter #1{\csname\dodescriptionparameter{\??dd\currentdescription }#1\endcsname}
-\def\descriptionmainparameter #1{\csname\dodescriptionparameter{\??dd\currentdescriptionmain }#1\endcsname}
-\def\descriptionnumberparameter#1{\csname\dodescriptionparameter{\??dd\currentdescriptionnumber}#1\endcsname}
-
-\def\nameddescriptionparameter #1#2{\csname\dodescriptionparameter{\??dd#1}#2\endcsname}
-
-\def\detokenizeddescriptionparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??dd\currentdescription#1\endcsname}}
-
-\def\dodescriptionparameter#1#2%
- {\ifcsname#1#2\endcsname#1#2\else\expandafter\dodescriptionparentparameter\csname#1\s!parent\endcsname#2\fi}
-
-\def\dodescriptionparentparameter#1#2%
- {\ifx#1\relax\s!empty\else\dodescriptionparameter#1#2\fi}
-
-\def\descriptionlocationparameter#1{\csname\dodescriptionlocationparameter{\??dd\currentdescription}#1\endcsname}
-
-\def\dodescriptionlocationparameter#1#2%
- {\ifcsname#1#2:\descriptionparameter\c!location\endcsname
- #1#2:\descriptionparameter\c!location
- \else\ifcsname#1\s!parent\endcsname
- \expandafter\dodescriptionlocationparameter\csname#1\s!parent\endcsname#2%
- \else
- \dodescriptionparameter{\??dd\currentdescription}#2%
- \fi\fi}
-
-% description hashes (needed for style/color)
-
-\def\descriptionparameterhash #1{\dodescriptionparameterhash{\??dd\currentdescription }#1}
-\def\descriptionmainparameterhash#1{\dodescriptionparameterhash{\??dd\currentdescriptionmain}#1}
-
-\def\dodescriptionparameterhash#1#2%
- {\ifcsname#1#2\endcsname#1\else\expandafter\dodescriptionparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-
-\def\dodescriptionparentparameterhash#1#2%
- {\ifx#1\relax\else\dodescriptionparameterhash#1#2\fi}
-
-\def\usedescriptionstyleandcolor#1#2% style color
- {\edef\currentstyleparameter{\descriptionparameter#1}%
- \edef\currentcolorparameter{\descriptionparameter#2}%
- \ifx\currentstyleparameter\empty\else\dousestyleparameter\currentstyleparameter\fi
- \ifx\currentcolorparameter\empty\else\dousecolorparameter\currentcolorparameter\fi}
-
-% typesetting code
-
-\newbox \descriptionheadbox
-\newskip \leftdescriptionskip
-\newskip \rightdescriptionskip
-\newdimen \descriptionsheadwidth % replaces \!!widtha % TODO: proper namespace dimens
-\newdimen \descriptionsheaddistance % replaces \!!widthb % TODO: proper namespace dimens
-
-\setvalue{@@description\v!left }{\@@descriptionhang\@@descriptionleftpure \@@descriptionlefthang \@@descriptionleftmargin }
-\setvalue{@@description\v!right}{\@@descriptionhang\@@descriptionrightpure\@@descriptionrighthang\@@descriptionrightmargin}
-
-\def\@@descriptionhang#1#2#3% \next still needed?
- {\processaction
- [\descriptionparameter\c!hang]
- [ \v!none=>\let\next#1,%
- 0=>\let\next#1,%
- \v!margin=>\let\next#3,%
- \s!unknown=>\let\next#2,%
- \s!default=>\let\next#1]%
- \next}
-
-\def\@@descriptionleftpure
- {\def\\{\crlf}%
- \noindent
- \leftskip\dimexpr\leftdescriptionskip+\descriptionsheadwidth\relax
- \rightskip\rightdescriptionskip
- \@@makedescriptionpurebox\raggedright
- \advance\leftskip\descriptionsheaddistance
- \llap
- {\hbox to \leftskip
- {\hskip\leftdescriptionskip
- \copy\descriptionheadbox\hss}}%
- \@@dodescription}
-
-\def\@@descriptionrightpure
- {\def\\{\crlf}%
- \noindent
- \leftskip\leftdescriptionskip
- \rightskip\dimexpr\rightdescriptionskip+\descriptionsheadwidth\relax
- \@@makedescriptionpurebox\raggedleft
- \rlap
- {\hskip\dimexpr\hsize-\leftskip-\rightskip\relax
- \copy\descriptionheadbox
- \hskip\rightdescriptionskip}%
- \advance\rightskip \descriptionsheaddistance
- \@@dodescription}
-
-\def\@@descriptionleftmargin
- {\def\\{\crlf}%
- \noindent
- \llap
- {\@@makedescriptionpurebox\raggedright
- \hbox to \descriptionsheadwidth{\copy\descriptionheadbox\hss}%
- \hskip\descriptionsheaddistance}%
- \@@dodescription}
-
-\def\@@descriptionrightmargin % whatever this means
- {\def\\{\crlf}%
- \noindent
- \rlap
- {\hskip\descriptionsheaddistance
- \@@makedescriptionpurebox\raggedright
- \hbox to \descriptionsheadwidth{\copy\descriptionheadbox\hss}}%
- \@@dodescription}
-
-\def\@@makedescriptionpurebox#1%
- {\setbox\descriptionheadbox\vtop
- {\dontcomplain
- \hsize\descriptionsheadwidth
- \leftskip\zeropoint
- \rightskip\zeropoint
- #1\setupalign[\descriptionparameter\c!headalign]%
- \ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox}%
- \ht\descriptionheadbox\strutht
- \dp\descriptionheadbox\strutdp}
-
-\def\@@descriptionlefthang
- {\def\\{\crlf}%
- \dontcomplain
- \advance\descriptionsheadwidth \descriptionsheaddistance
- \hangindent\descriptionsheadwidth
- \@@makedescriptionhangbox\raggedright{\advance\rightskip \descriptionsheaddistance}%
- \noindent
- \llap
- {\vtop to \zeropoint{\box\descriptionheadbox}}%
- \@@dodescription}
-
-\def\@@descriptionrighthang
- {\def\\{\crlf}%
- \dontcomplain
- \advance\descriptionsheadwidth \descriptionsheaddistance
- \hangindent-\descriptionsheadwidth
- \@@makedescriptionhangbox\raggedleft{\advance\leftskip \descriptionsheaddistance}%
- \noindent
- \rlap
- {\dontcomplain
- \hbox to \dimexpr\hsize-\leftskip-\rightskip\relax % can be a macro
- {\hss\vtop to \zeropoint{\box\descriptionheadbox}}}%
- \@@dodescription}
-
-\def\@@makedescriptionhangbox#1#2%
- {\setbox\descriptionheadbox\vtop % \vbox gaat fout in hang
- {\forgetall
- \dontcomplain
- \hsize\descriptionsheadwidth
- #1\setupalign[\descriptionparameter\c!headalign]#2%
- \ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox}%
- \ht\descriptionheadbox\strutht
- \dp\descriptionheadbox\strutdp
- \doifsomething{\descriptionparameter\c!hang}
- {\doifinsetelse{\descriptionparameter\c!hang}{\v!fit,\v!broad}
- {\scratchdimen\htdp\descriptionheadbox
- \doif{\descriptionparameter\c!hang}\v!broad
- {\advance\scratchdimen .5\strutht}%
- \getnoflines\scratchdimen
- \hangafter-\noflines}
- {\hangafter-\descriptionparameter\c!hang}}}
-
-\setvalue{@@description\v!top}%
- {%\page[\v!preference]% % Weg ermee!
- %\dosomebreak{\goodbreak}% % Dit is beter en nodig!
- \dohandlepagebreakX\plusone % En dit moet het maar worden.
- \let\\=\space
- \noindent
- \copy\descriptionheadbox\par
- \nobreak
- %\descriptionparameter\c!inbetween % .. brrrr ... :
- \doifelsenothing{\descriptionparameter\c!inbetween}{\blank}{\descriptionparameter\c!inbetween}%
- \nobreak
- \@@dodescription}
-
-\def\do@@description#1% temp hack, the scope
- {\def\\{\crlf}%
- \noindent
- #1[\c!scope=\v!local]{\ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox}%
- \@@dodescription}
-
-\setvalue{@@description\v!inmargin }{\do@@description\inmargin}
-\setvalue{@@description\v!inleft }{\do@@description\inleft }
-\setvalue{@@description\v!inright }{\do@@description\inright }
-\setvalue{@@description\v!margin }{\do@@description\inmargin}
-\setvalue{@@description\v!leftmargin }{\do@@description\inleft }
-\setvalue{@@description\v!rightmargin }{\do@@description\inright }
-\setvalue{@@description\v!innermargin }{\do@@description\ininner }
-\setvalue{@@description\v!outermargin }{\do@@description\inouter }
-
-\setvalue{@@description\v!serried\v!fit}%
- {\def\\{\crlf}%
- \noindent
- \ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox
- \hskip\descriptionsheaddistance % toegevoegd
- \@@dodescription}
-
-\setvalue{@@description\v!serried\v!broad}%
- {\def\\{\crlf}%
- \noindent
- \ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox
- \hskip\descriptionsheaddistance \!!plus .5\descriptionsheaddistance \!!minus .25\descriptionsheaddistance
- \@@dodescription}
-
-\setvalue{@@description\v!serried\v!wide}%
- {\def\\{\crlf}%
- \noindent
- \hbox to \descriptionsheadwidth
- {\ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox\hss}%
- \hskip\descriptionsheaddistance
- \@@dodescription}
-
-\setvalue{@@description\v!serried}%
- {\processaction
- [\descriptionlocationparameter\c!width]
- [ \v!fit=>\let\next\v!fit,
- \v!broad=>\let\next\v!broad,
- \s!unknown=>\let\next\v!wide,
- \s!default=>\let\next\v!broad]%
- \getvalue{@@description\v!serried\next}}
-
-\setvalue{@@description\v!hanging}%
- {\def\\{\crlf}%
- \noindent
- \advance\leftskip -\leftskipadaption \relax
- \ifdim\leftskipadaption=\zeropoint
- \leftskipadaption1.5em\relax % just some default
- \ifnum\nesteddescriptionstate=\plusone
- \ifdim\leftskip>\zeropoint \relax
- \leftskipadaption\leftskip
- \fi
- \fi
- \fi
- \ifnum\nesteddescriptionstate>\zerocount % was \ifnum\nesteddescriptionstate=\plusone
- \advance\leftskip \leftskipadaption % but we're already further on
- \fi
- \hskip-\leftskipadaption
- \ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox
- \kern\ifdim\descriptionsheaddistance=\zeropoint .75em\else\descriptionsheaddistance\fi
- \@@dodescription}
-
-%D A bonus definition
-%D
-%D \starttyping
-%D \setupfootnotedefinition[location=command,headcommand=\llap]
-%D \stoptyping
-
-% \setvalue{@@description\v!command}%
-% {\do@@description{\executeifdefined{\descriptionparameterhash\c!headcommand}\framed}}
-
-\setvalue{@@description\v!command}%
- {\noindent
- \descriptionparameter\c!headcommand{\ifhbox\descriptionheadbox\unhcopy\else\copy\fi\descriptionheadbox}%
- \@@dodescription}
-
-%D A new key 'headalign' in definitions.
-
-\newconstant\nesteddescriptionstate
-
-\def\resetdescriptions % to be used in e.g. footnotes
- {\nesteddescriptionstate\zerocount}
-
-\resetdescriptions
-
-\def\@@dostartdescription
- {\descriptionparameter\c!before
- \begingroup
- \doadaptleftskip{\descriptionparameter\c!margin}%
- \setlocalhsize % so we can use \localhsize in width assignments
- \descriptionsheaddistance\descriptionlocationparameter\c!distance\relax
- \ifdim\descriptionsheaddistance=\zeropoint\relax
- \doif{\descriptionlocationparameter\c!width}\v!broad{\descriptionsheaddistance=1em}%
- \fi
- \setbox\descriptionheadbox\hbox
- {\forgetall\dontcomplain
- \settrialtypesetting
- \doifelsenothing{\descriptionparameter\c!sample}
- {\dodescriptionhandler\currentdescriptiontext}%
- {\dodescriptionhandler\currentdescriptionsample}}%
- \assignwidth
- {\descriptionlocationparameter\c!width}
- \descriptionsheadwidth
- {\unhcopy\descriptionheadbox}
- \descriptionsheaddistance
- \setbox\descriptionheadbox\hbox
- {\forgetall\dontcomplain
- \doifelse{\descriptionparameter\c!location}\v!serried % brrr, hack
- {\dodescriptionhandler\currentdescriptiontext}
- {\dodescriptionhandler{\boxeddescriptionhead\currentdescriptiontext}}}%
- \doifelse{\descriptionparameter\c!aligntitle}\v!no
- {\leftdescriptionskip\leftskip\rightdescriptionskip\rightskip}
- {\ifcase\nesteddescriptionstate\leftdescriptionskip\leftskip\rightdescriptionskip\rightskip\fi}%
- \doifsomething{\descriptionparameter\c!align}{\setupalign[\descriptionparameter\c!align]}%
- \normalexpanded{\noexpand\indenting[\descriptionparameter\c!indenting]}%
- % better a system mode
- \ifcase\nesteddescriptionstate
- \nesteddescriptionstate\plusone
- \or
- \nesteddescriptionstate\plustwo
- \fi % now happens elsewhere : \noindent\ignorespaces
- \@@resetdescriptionclosesymbol}
-
-\def\boxeddescriptionhead#1%
- {\vtop
- %{\hsize\dimexpr\descriptionsheadwidth-\descriptionsheaddistance\relax
- {\hsize\descriptionsheadwidth
- \doifsomething{\descriptionparameter\c!headalign}{\setupalign[\descriptionparameter\c!headalign]}%
- #1}}
-
-\def\@@stopdescription
- {\@@placedescriptionclosesymbol
- \doifnot{\descriptionparameter\c!display}\v!no\par
- \dostoptagged
- \dostoptagged
- \endgroup
- \descriptionparameter\c!after % which currentdescription is taken here?
- \useindentnextparameter\descriptionparameter
- \egroup
- \dorechecknextindentation}
-
-\def\@@dodescription
- {\usedescriptionstyleandcolor\c!style\c!color
- \ignorespaces}
-
-% starters:
-
-\def\@@startdescription[#1]%
- {\doifelse{\descriptionparameter\c!title}\v!yes
- {\permitspacesbetweengroups
- \dodoublegroupempty{\dohandledescriptionstart[#1]}}
- {\dohandledescriptionstart[#1]{}}}
-
-\def\@@description[#1]%
- {\doifelse{\descriptionparameter\c!title}\v!yes
- {\permitspacesbetweengroups
- \dodoublegroupempty{\dohandledescriptiondo[#1]}}
- {\dohandledescriptiondo[#1]{}}}
-
-% these call:
-
-\long\def\@@somedescription[#1]#2%
- {\dowithpar
- {\bgroup % temporary hack
- \@@makedescription[#1]{#2}}%
- {\@@stopdescription}}
-
-\long\def\@@startsomedescription[#1]#2%
- {\bgroup % temporary hack
- \BeforePar{\@@makedescription[#1]{#2}}%
- \GotoPar}
-
-\ifdefined\dotagsetdescription \else \let\dotagsetdescription\relax \fi
-
-\def\@@dostartdescriptionindeed
- {\edef\currentdescriptionlocation{\descriptionparameter\c!location}%
- \ifx\currentdescriptionlocation\empty
- \let\currentdescriptionlocation\v!left
- \fi
- \ifcsname @@description\currentdescriptionlocation\endcsname \else
- \let\currentdescriptionlocation\v!left
- \fi
- \dostarttagged\t!description\currentdescription
- \dotagsetdescription
- \dostarttagged\t!descriptiontag\empty
- \@@dostartdescription
- \csname @@description\currentdescriptionlocation\endcsname
- \dostoptagged
- \dostarttagged\t!descriptioncontent\empty} % args not needed
-
-\def\@@makedescription[#1]#2%
- {\postponenotes % new, assumes grouping
- \edef\currentdescriptionreference{#1}%
- \doenumerationcheckconditions
- \dodescriptioncomponent[\c!reference=#1,\c!label={\descriptionparameter\c!text},\c!title={#2},\c!bookmark=,\c!list=][]%
- \@@dostartdescriptionindeed}
-
-\def\dostartstoreddescription
- {\@@dostartdescriptionindeed}
-
-\def\dostopstoreddescription
- {\@@stopdescription}
-
-% % % % % % % % % % % %
-
-% setup descriptions
-
-\unexpanded\def\setupdescriptions
- {\dodoubleempty\dosetupdescriptions}
-
-\def\dosetupdescriptions[#1][#2]% % beter: \iffirstargument
- {\ifsecondargument
- \dodoubleargumentwithset\dodosetupdescriptions[#1][#2]%
- \else
- \dodosetupdescriptions[][#1]%
- \fi}
-
-\def\dodosetupdescriptions[#1]% [#2]%
- {\getparameters[\??dd#1]} % [#2]}
-
-\setupdescriptions
- [\c!location=\v!left,
- \c!headstyle=\v!bold,
- \c!titlestyle=\v!bold,
- \c!style=\v!normal,
- \c!color=,
- \c!headcolor=,
- \c!titlecolor=,
- %\c!width=8em,
- %\c!distance=0pt,
- \c!titledistance=0.5em,
- \c!hang=,
- \c!sample=,
- \c!align=,
- \c!headalign=,
- \c!margin=\v!no,
- \c!before=\blank,
- \c!inbetween=\blank,
- \c!after=\blank,
- \c!indentnext=\v!yes,
- \c!indenting=\v!never,
- \c!titleleft=(,
- \c!titleright=),
- \c!closesymbol=,
- \c!closecommand=\wordright,
- \c!display=\v!yes,
- \c!command=,
- \c!titlecommand=]
-
-\setupdescriptions
- [\c!expansion=\v!no,
- \c!xmlsetup=,
- \s!catcodes=,
- \c!saveinlist=\v!yes]
-
-\setupdescriptions
- [\c!width=7em,
- \c!distance=1em]
-
-\setupdescriptions[\c!width:\c!top=\localhsize] % undocumented, only width and distance
-% \setupdescriptions[\c!width:\c!left=7em,\c!distance=1em]
-% \setupdescriptions[\c!width:\c!right=7em,\c!distance=1em]
-% \setupdescriptions[\c!width:\v!hanging=\v!fit] % yes or no
-
-% define descriptions
-
-\unexpanded\def\definedescription
- {\dotripleemptywithset\dodefinedescription}
-
-\def\dodefinedescription[#1][#2][#3]% to be simplified cf enumeration
- {\dodescriptioninit{#1}%
- \getparameters[\??dd#1][\c!text=,\s!handler=\v!description,\c!title=\v!yes]%
- \ifsecondargument\doifassignmentelse{#2}\donetrue\donefalse\else\donetrue\fi
- \ifdone
- \getparameters[\??dd#1][\s!parent=\??dd,\c!text=,\s!handler=\v!description,#2]%
- \dodefinedescriptioncommands{#1}{\??dd}%
- \else % clone
- \getparameters[\??dd#1][\s!parent=\??dd#2,\c!text=,\s!handler=\v!description,#3]% clone
- \dodefinedescriptioncommands{#1}{\??dd#2}%
- \fi}
-
-\def\dodefinedescriptioncommands#1#2%
- {\setuevalue {#1}{\noexpand\dodescriptioncommand{#1}}%
- \setuevalue{\e!start#1}{\noexpand\dodescriptionstart {#1}}%
- \setuevalue{\e!stop #1}{\noexpand\dodescriptionstop {#1}}}
-
-% handle descriptions
-
-\def\dodescriptioninit#1%
- {\let\currentdescriptionmain \empty
- \let\currentdescriptionlevel \empty
- \edef\currentdescriptionname {#1}%
- \edef\currentdescription {#1}}
-
-\def\dodescriptioncommand#1{\dodescriptioninit{#1}\dosingleempty\@@description}
-\def\dodescriptionstart #1{\dodescriptioninit{#1}\dosingleempty\@@startdescription}
-\def\dodescriptionstop #1{\dodescriptioninit{#1}\@@stopdescription}
-
-\def\dodescriptiontext {\csname\??dd:\descriptionparameter\s!handler:\s!handler:\s!text \endcsname}
-\def\dodescriptionnumber {\csname\??dd:\descriptionparameter\s!handler:\s!handler:\s!number\endcsname}
-\def\dodescriptionsymbol {\csname\??dd:\descriptionparameter\s!handler:\s!handler:\s!symbol\endcsname}
-\def\dodescriptionhandler {\csname\??dd:\descriptionparameter\s!handler:\s!handler \endcsname}
-\def\dohandledescriptiondo {\csname\??dd:\descriptionparameter\s!handler:\s!handler:\s!do \endcsname}
-\def\dohandledescriptionstart{\csname\??dd:\descriptionparameter\s!handler:\s!handler:\s!start \endcsname}
-
-\def\currentdescriptiontext {\begstrut\dodescriptiontext\endstrut}
-\def\currentdescriptionsample{\begstrut\descriptionparameter\c!text\descriptionparameter\c!sample\endstrut}
-
-% implementation
-
-% beware: with footnotes #2 can be something messy but then #1 is
-% empty anyway, so we have an extra safeguard
-
-\newtoks \everydescription
-
-\setvalue{\??dd:\v!description:\s!handler:\s!text }{\@@dodescriptiontext}
-\setvalue{\??dd:\v!description:\s!handler }{\@@dodescriptionhandler}
-\setvalue{\??dd:\v!description:\s!handler:\s!do }{\@@somedescription}
-\setvalue{\??dd:\v!description:\s!handler:\s!start}{\@@startsomedescription}
-
-\def\@@dodescriptionhandler#1%
- {\iftrialtypesetting \else
- \begingroup
- \currentdescriptionsynchronize
- \attribute\destinationattribute\currentdescriptionattribute\relax % todo, whole text
- \signalcharacter
- \endgroup
- \fi#1}
-
-\def\@@dododescriptiontext
- {\ctxlua{structures.lists.savedtitle("\currentdescriptionmain",\currentdescriptionnumberentry)}}
-
-\def\@@dodescriptiontext
- {\begingroup
- \usedescriptionstyleandcolor\c!headstyle\c!headcolor
- \the\everydescription
- \descriptionparameter\c!command{\strut\descriptionparameter\c!text\ignorespaces\@@dododescriptiontext}% probably incomplete
- \endgroup}
-
-% setup enumerations
-
-\unexpanded\def\setupenumerations
- {\dodoubleempty\dosetupenumerations}
-
-\def\dodosetupenumerations[#1][#2]%
- {\doenumerationinit{#1}{1}\empty
- \getparameters[\??dd#1][#2]%
- \dosetupenumerationcounter{#1}}
-
-\def\dosetupenumerations[#1][#2]%
- {\ifsecondargument
- \dodoubleargumentwithset\dodosetupenumerations[#1][#2]%
- \else
- \getparameters[\??dn][#1]%
- \fi}
-
-\setupenumerations
- [\c!location=\v!top,
- \c!text=,
- \c!way=\v!by\v!text,
- \c!prefix=\v!no,
- \c!prefixconnector=.,
- \c!starter=,
- \c!stopper=,
- \c!number=\v!yes, % else description
- \c!start=0,
- \s!parent=\??dd]
-
-\setupenumerations
- [\c!expansion=\v!no,
- \c!xmlsetup=,
- \s!catcodes=,
- \c!saveinlist=\v!yes]
-
-% define enumerations
-
-\unexpanded\def\defineenumeration
- {\dotripleemptywithset\dodefineenumeration}
-
-\def\dodefineenumeration[#1][#2][#3]% #2 or #3 assignment
- {\doenumerationinit{#1}{1}\empty
- \getparameters[\??dd#1][\c!text=#1,\c!state=\v!start,\s!handler=\v!enumeration,\c!levels=4]%
- \ifsecondargument\doifassignmentelse{#2}\donetrue\donefalse\else\donetrue\fi
- \ifdone % independent
- \getparameters[\??dd#1][\s!counter=#1,#2]%
- \dodefineenumerationcommands{#1}{1}{}{\??dn}%
- \let\@@subslevel\empty
- \dostepwiserecurse{2}{\descriptionparameter\c!levels}{1}
- {\normalexpanded{\noexpand\dodefineenumerationcommands{#1}{\recurselevel}{\@@subslevel\v!sub}{\??dd\@@subslevel#1}}%
- \edef\@@subslevel{\@@subslevel\v!sub}}%
- \else % clone
- \getparameters[\??dd#1][\s!parent=\??dd#2,#3]%
- \let\@@subslevel\empty
- \dorecurse{\descriptionparameter\c!levels}
- {\normalexpanded{\noexpand\dodefineenumerationcommands{#1}{\recurselevel}{\@@subslevel}{\??dd\@@subslevel#2}}%
- \edef\@@subslevel{\@@subslevel\v!sub}}%
- \fi
- \edef\currentdescriptioncounter{\descriptionparameter\s!counter}%
- \ifx\currentdescriptioncounter\empty
- \ifdone\dodefineenumerationcounter{#1}\fi
- \else\ifx\currentdescriptioncounter\v!yes
- \ifdone\dodefineenumerationcounter{#1}\fi
- \else\ifx\currentdescriptioncounter\v!no
- \ifdone\dodefineenumerationcounter{#1}\fi
- \else
- \letvalue{\??dd#1\s!counter}\currentdescriptioncounter % ?
- %[[#1:\currentdescriptioncounter]]
- \doifstructurecounterelse{\currentdescriptioncounter}{}{\dodefineenumerationcounter\currentdescriptioncounter}%
- \fi\fi\fi
- \dosetupenumerationcounter{#1}} % new
-
-\newtoks\everysetupenumerationcounter
-\let\currentenumerationcountername\empty
-
-\def\dosetupenumerationcounter#1%
- {\edef\currentenumerationcountername{#1}% only used in the token list
- \edef\currentdescription{#1}%
- \the\everysetupenumerationcounter}
-
-\appendtoks
- \dostructurecountersetup\currentenumerationcountername\descriptionparameter
-\to \everysetupenumerationcounter
-
-\def\dodefineenumerationcounter#1% todo: fast inheritance (was mainparameter
- {\definestructurecounter[#1]%
- \dosetupenumerationcounter{#1}}
-
-\def\dodefineenumerationcommands#1#2#3#4% since we use \currentdescription, we need an edef
- {\setevalue{\??dd#3#1\s!parent}{#4}%
- \setuevalue {#3#1}{\noexpand\doenumerationcommand {#1}{#2}{#3}}%
- \setuevalue{\c!reset#3#1}{\noexpand\doresetenumerationnumber{#1}{#2}{#3}}%
- %setuevalue{\c!set #3#1}{\noexpand\dosetenumerationnumber {#1}{#2}{#3}}%
- \setuevalue{\e!next #3#1}{\noexpand\donextenumerationnumber {#1}{#2}{#3}}%
- \setuevalue{\e!start#3#1}{\noexpand\doenumerationstart {#1}{#2}{#3}}%
- \setuevalue{\e!stop #3#1}{\noexpand\doenumerationstop {#1}{#2}{#3}}}
-
-% handle enumeration
-
-\def\currentdescriptionnumber {\csname\??dd\currentdescriptionmain\s!counter\endcsname}% no edef (yet)
-\def\specificdescriptionnumber#1{\csname\??dd#1\s!counter\endcsname}% no edef (yet)
-
-\def\doenumerationinit#1#2#3%
- {\edef\currentdescriptionmain {#1}%
- \edef\currentdescriptionlevel{#2}%
- \edef\currentdescriptionname {#1}%
- \edef\currentdescription {#3#1}}
-
-\def\doenumerationcommand#1#2#3{\doenumerationinit{#1}{#2}{#3}\dosingleempty\@@description}
-\def\doenumerationstart #1#2#3{\doenumerationinit{#1}{#2}{#3}\dosingleempty\@@startdescription}
-\def\doenumerationstop #1#2#3{\doenumerationinit{#1}{#2}{#3}\@@stopdescription}
-
-\def\doresetenumerationnumber#1#2#3{\strc_counters_reset_sub {\specificdescriptionnumber{#1}}{#2}}
-\def\dosetenumerationnumber#1#2#3#4{\strc_counters_set_sub {\specificdescriptionnumber{#1}}{#2}{#4}}
-\def\donextenumerationnumber #1#2#3{\strc_counters_increment_sub{\specificdescriptionnumber{#1}}{#2}}
-
-% implementation
-
-\newtoks \everyenumeration
-\newconstant\enumerationnumberstate % 1 == enabled
-\def \enumerationsignalskip {-} % 0 == disabled
-\def \enumerationsignalsymbol{+} % 2 == disabled but symbol
-
-\appendtoks \disablepseudocaps \to \everyenumeration % sorry, uppercase causes troubles
-
-\setvalue{\??dd:\v!enumeration:\s!handler:\s!number}{\@@doenumerationnumber}
-\setvalue{\??dd:\v!enumeration:\s!handler:\s!symbol}{\@@doenumerationsymbol}
-\setvalue{\??dd:\v!enumeration:\s!handler:\s!text }{\@@doenumerationtext}
-\setvalue{\??dd:\v!enumeration:\s!handler }{\@@doenumerationhandler}
-\setvalue{\??dd:\v!enumeration:\s!handler:\s!do }{\@@somedescription}
-\setvalue{\??dd:\v!enumeration:\s!handler:\s!start }{\@@startsomedescription}
-
-\let\@@doenumerationhandler\@@dodescriptionhandler
-
-% \def\currentenumerationfullnumber
-% {\ctxlua{structures.lists.savedprefixednumber("\currentdescriptionmain",\currentdescriptionnumberentry)}}
-
-\def\@@doenumerationnumber
- {\ctxlua{structures.lists.savedprefixednumber("\currentdescriptionmain",\currentdescriptionnumberentry)}}
-
-\def\@@doenumerationsymbol
- {\descriptionparameter\c!symbol}
-
-\def\@@dodoenumerationtext
- {\ctxlua{structures.lists.savedtitle("\currentdescriptionmain",\currentdescriptionnumberentry)}}
-
-\def\doenumerationnumber
- {\descriptionparameter\c!left
- \descriptionparameter\c!starter
- \dodescriptionnumber
- \descriptionparameter\c!stopper
- \descriptionparameter\c!right}
-
-\def\doenumerationsymbol
- {\descriptionparameter\c!left
- \dodescriptionsymbol
- \descriptionparameter\c!right}
-
-\def\@@doenumerationtext
- {\ifcase\enumerationnumberstate
- \doenumerationfullnumbernop
- \or
- \iftrialtypesetting
- \doenumerationfullnumberyes
- \doenumerationcouplingsymbol
- \else
- \doenumerationregistercoupling
- \doenumerationfullnumberyes
- \doenumerationcouplingsymbol
- \fi
- \or
- \doenumerationfullnumbersymbol
- \fi}
-
-\def\doenumerationfullnumberyes {\doenumerationfullnumber{\showdntext \doenumerationnumber\doenumerationextratext}}
-\def\doenumerationfullnumbernop {\doenumerationfullnumber{\showdnpuretext \doenumerationextratext}}
-\def\doenumerationfullnumbersymbol{\doenumerationfullnumber{\showdntext \doenumerationsymbol\doenumerationextratext}}
-
-\def\doenumerationfullnumber#1% text, title (used in notes) .. todo
- {\begingroup
- \usedescriptionstyleandcolor\c!headstyle\c!headcolor
- \the\everyenumeration
- \descriptionparameter\c!command{\strut#1}%
- \endgroup}
-
-\def\doenumerationextratext
- {\doif{\descriptionparameter\c!title}\v!yes
- {\doifsomething\@@dodoenumerationtext
- {\begingroup
- \usedescriptionstyleandcolor\c!titlestyle\c!titlecolor
- \hskip\descriptionparameter\c!titledistance
- \descriptionparameter\c!titlecommand
- {\descriptionparameter\c!titleleft
- \begstrut\@@dodoenumerationtext\endstrut
- \descriptionparameter\c!titleright}%
- \endgroup}}}
-
-\def\doenumerationsavecounter {\strc_counters_save \currentdescriptionnumber} % can be inlined
-\def\doenumerationrestorecounter {\strc_counters_restore \currentdescriptionnumber} % can be inlined
-\def\doenumerationincrementcounter{\strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel} % can be inlined
-
-% to be used in for instance:
-%
-% coupling=questions .... coupling=answers
-%
-% we will provide some more control, like skipping etc or reference relates
-
-\def\doenumerationcheckconditions
- {\doifelse{\descriptionparameter\c!number}\v!yes
- {\ifx\currentdescriptionreference\enumerationsignalsymbol
- \enumerationnumberstate\plustwo % symbol
- \else\ifx\currentdescriptionreference\enumerationsignalskip
- \enumerationnumberstate\zerocount % disabled
- \else
- \enumerationnumberstate\plusone % enabled
- \fi\fi}%
- {\enumerationnumberstate\zerocount}% % disabled
- \edef\currentenumerationcoupling{\descriptionparameter\c!coupling}}
-
-\def\doenumerationregistercoupling
- {\iflocation
- % no area yet, we will provide variants some day
- \fi}
-
-\def\doenumerationcouplingsymbol
- {\iflocation \ifx\currentenumerationcoupling\empty\else
- \symbolreference[order(description:\currentenumerationcoupling:\nextinternalorderreference)]%
- \fi \fi}
-
-\def\skipenumerationcoupling[#1]% e.g. for questions with no answer
- {\ctxlua{structures.references.setnextorder("description","#1")}}
-
-\def\showdnpuretext{\strut\descriptionparameter\c!text} % geen spatie
-\def\showdnlisttext{\descriptionparameter\c!listtext} % space in default
-\def\showdntext {\doifsomething{\descriptionparameter\c!text}{\descriptionparameter\c!text\removeunwantedspaces\fixedspace}}
-
-\unexpanded\def\structurecounterreference#1%
- {[enumref: #1]}
-
-% you can use \placeclosesymbol or \qed to place a symbol at the end of a
-% description
-
-\def\@@resetdescriptionclosesymbol
- {\global\@EA\settrue\csname\??dd\currentdescription:mrk\endcsname
- \let\placeclosesymbol\@@placedescriptionclosesymbol
- \let\qed \@@placedescriptionclosesymbol}
-
-\def\@@placedescriptionclosesymbol
- {\ifconditional\csname\??dd\currentdescription:mrk\endcsname
- \global\@EA\setfalse\csname\??dd\currentdescription:mrk\endcsname
- \doifsomething{\descriptionparameter\c!closesymbol}{\descriptionparameter\c!closecommand{\descriptionparameter\c!closesymbol}}%
- \fi}
-
-\newif\ifnodescriptioncaption
-
-\def\doifelsedescriptioncomponent
- {\ctxlua{structures.lists.doifstoredelse(currentdescriptionnumberentry)}}
-
-\def\dodescriptioncomponent
- {\doifelsedescriptioncomponent\nododescriptioncomponent\dododescriptioncomponent}
-
-\def\nododescriptioncomponent[#1][#2]% #1=interfaced-settings, #2=optional user data
- {}
-
-\def\dododescriptioncomponent[#1][#2]% #1=interfaced-settings, #2=optional user data
- {\begingroup % similar to structure so we might generalize this
- \getparameters[\??dd\currentdescription][#1]%
- %
- \xdef\currentdescriptionexpansion {\descriptionparameter\c!expansion}%
- \xdef\currentdescriptionxmlsetup {\descriptionparameter\c!xmlsetup}%
- \xdef\currentdescriptioncatcodes {\descriptionparameter\s!catcodes}%
- \xdef\currentdescriptionlabel {\descriptionparameter\c!label}%
- \xdef\currentdescriptionreference {\descriptionparameter\c!reference}%
- \xdef\currentdescriptionreferenceprefix{\descriptionparameter\c!referenceprefix}%
- %xdef\currentdescriptionshownumber {\descriptionparameter\c!number}%
- \xdef\currentdescriptionsaveinlist {\descriptionparameter\c!saveinlist}%
- \xdef\currentdescriptionincrementnumber{\descriptionparameter\c!incrementnumber}%
- %
- \ifx\currentdescriptionexpansion\empty
- \glet\currentdescriptionexpansion\v!no
- \fi
- %
- \ifx\currentdescriptionexpansion\s!xml
- \xmlstartraw
- \xdef\currentdescriptiontitle {\descriptionparameter\c!title}%
- \xdef\currentdescriptionbookmark{\descriptionparameter\c!bookmark}%
- \xdef\currentdescriptionmarking {\descriptionparameter\c!marking}%
- \xdef\currentdescriptionlist {\descriptionparameter\c!list}%
- \xmlstopraw
- \ifx\currentdescriptionlist\empty
- \globallet\currentdescriptionlist\currentdescriptiontitle
- \fi
- \globallet\currentdescriptioncoding\s!xml
- \else
- \ifx\currentdescriptionexpansion\v!yes
- \xdef\currentdescriptiontitle {\descriptionparameter\c!title}%
- \xdef\currentdescriptionbookmark{\descriptionparameter\c!bookmark}%
- \xdef\currentdescriptionmarking {\descriptionparameter\c!marking}%
- \xdef\currentdescriptionlist {\descriptionparameter\c!list}%
- \else
- \xdef\currentdescriptiontitle {\detokenizeddescriptionparameter\c!title}%
- \xdef\currentdescriptionbookmark{\detokenizeddescriptionparameter\c!bookmark}%
- \xdef\currentdescriptionmarking {\detokenizeddescriptionparameter\c!marking}%
- \xdef\currentdescriptionlist {\detokenizeddescriptionparameter\c!list}%
- \iflocation \ifx\currentdescriptionbookmark\empty
- \begingroup
- \simplifycommands
- \xdef\currentdescriptionbookmark{\detokenize\expandafter{\normalexpanded{\descriptionparameter\c!title}}}%
- \endgroup
- \fi \fi
- \fi
- \ifx\currentdescriptionlist\empty
- \globallet\currentdescriptionlist\currentdescriptiontitle
- \fi
- \globallet\currentdescriptioncoding\s!tex
- \fi
- %
- \ifx\currentdescriptiontitle\v!none % will become obsolete
- \global\nodescriptioncaptiontrue\global\nodescriptionnumbertrue
- \fi
- %
- \ifcase\enumerationnumberstate
- % disabled
- \or
- \doifelsedescriptioncomponent\donothing\doenumerationincrementcounter
- \or
- % symbol
- \fi
- %
- \ifnodescriptioncaption
- \glet\currentdescriptionlistnumber \relax
- \glet\currentdescriptionsynchronize\relax
- \glet\currentdescriptionattribute \relax
- \else
- %\setnextinternalreference
- \setnextinternalreferences{description}\currentdescriptionname % plural
- \xdef\currentdescriptionnumberentry{\ctxcommand{addtolist{
- metadata = {
- kind = "description",
- name = "\currentdescriptionname",
- level = structures.sections.currentlevel(),
- catcodes = \the\catcodetable,
- % \currentdirectionparameters
- },
- references = {
- internal = \nextinternalreference,
- order = \nextinternalorderreference,
- reference = "\currentdescriptionreference",
- referenceprefix = "\referenceprefix",
- block = "\currentsectionblock",
- section = structures.sections.currentid(),
- },
- titledata = {
- label = \!!bs\detokenize\expandafter{\currentdescriptionlabel }\!!es,
- title = \!!bs\detokenize\expandafter{\currentdescriptiontitle }\!!es,
- \ifx\currentdescriptionbookmark\currentdescriptiontitle \else
- bookmark = \!!bs\detokenize\expandafter{\currentdescriptionbookmark}\!!es,
- \fi
- \ifx\currentdescriptionlist\currentdescriptiontitle \else % \ifx\currentdescriptionsaveinlist\v!no
- list = \!!bs\detokenize\expandafter{\currentdescriptionlist }\!!es,
- \fi % \fi
- },
- \ifcase\enumerationnumberstate
- % disabled
- \or
- prefixdata = {
- prefix = "\descriptionparameter\c!prefix",
- separatorset = "\descriptionparameter\c!prefixseparatorset",
- conversion = \!!bs\descriptionparameter\c!prefixconversion\!!es,
- conversionset = "\descriptionparameter\c!prefixconversionset",
- set = "\descriptionparameter\c!prefixset",
- segments = "\descriptionparameter\c!prefixsegments",
- connector = \!!bs\descriptionparameter\c!prefixconnector\!!es,
- },
- numberdata = {
- numbers = structures.counters.compact("\currentdescriptionnumber",nil,true), % ! number can be cloned
- separatorset = "\descriptionparameter\c!numberseparatorset",
- conversion = "\descriptionparameter\c!numberconversion",
- conversionset = "\descriptionparameter\c!numberconversionset",
- starter = \!!bs\descriptionparameter\c!numberstarter\!!es,
- stopper = \!!bs\descriptionparameter\c!numberstopper\!!es,
- segments = "\descriptionparameter\c!numbersegments",
- },
- \or
- % symbol
- \fi
- userdata = \!!bs\detokenize{#2}\!!es % will be converted to table at the lua end
- }
- }}%
- \xdef\currentdescriptionattribute {\ctxlua {tex.write(structures.references.setinternalreference("\referenceprefix","\currentdescriptionreference",\nextinternalreference,"\interactionparameter\c!focus"))}}%
- \xdef\currentdescriptionsynchronize{\ctxlatecommand{enhancelist(\currentdescriptionnumberentry)}}%
- \fi
- \endgroup}
-
-% This is not so nice, some day i'll just store the number with the entry
-% and deal with all at the Lua end, but first we need to be able to set
-% macros.
-
-\def\reinstatedescriptionnumberentry#1%
- {\xdef\currentdescriptionattribute {\ctxlua {structures.references.getinternalreference(#1)}}%
- \xdef\currentdescriptionsynchronize{\ctxlatecommand{enhancelist(#1)}}}
-
-\installstructurelistprocessor{description}{\usestructurelistprocessor{number+title}}
-
-% labels, we could share with enumerations and forget about the text; anyhow, figure
-% labels etc can use enumerations; we keep labels for compatibility reasons; we need
-% the slightly different namespace; we can still define structure counters directly
-% (multiple levels) and use an enumeration without following text
-
-% unfinished
-
-\unexpanded\def\setuplabels
- {\getparameters[\??db]}
-
-\unexpanded\def\definelabel
- {\dotripleargumentwithset\dodefinelabel}
-
-\def\dodefinelabel[#1][#2][#3]% #2 or #3 assignment
- {\doenumerationinit{#1}{1}\empty
- \getparameters[\??dd#1][\c!command=,\c!state=\v!start,\c!location=,\c!text=#1]%
- \ifsecondargument\doifassignmentelse{#2}\donetrue\donefalse\else\donetrue\fi
- \ifdone
- % an independent one
- \getparameters[\??dd#1][\s!counter=#1,\s!parent=\??db,#2]%
- \dodefinelabelcommands{#1}{\??db}%
- \dodefineenumerationcounter{#1}%
- \else
- \getparameters[\??dd#1][\s!counter=#1,\s!parent=\??dd#2,#3]%
- \dodefinelabelcommands{#1}{\??dd#2}%
- \fi}
-
-\def\dodefinelabelcommands#1#2%
- {\setuevalue {#1}{\noexpand\dolabelnumbercommand {#1}}%
- \setuevalue{\c!reset #1}{\noexpand\doresetlabelnumber {#1}}%
- %\setuevalue{\c!set #1}{\noexpand\dosetlabelnumber {#1}}% [#2] or {#2} ?
- \setuevalue{\e!next #1}{\noexpand\donextlabelnumber {#1}}%
- \setuevalue{\e!increment#1}{\noexpand\doincrementlabelnumber{#1}}%
- \setuevalue{\c!current #1}{\noexpand\docurrentlabelnumber {#1}}}
-
-% this is just for downward compatibility, we might drop it
-
-\setvalue{\??db:\c!location:\v!inmargin}{\inmargin}
-\setvalue{\??db:\c!location:\v!inleft }{\inleft}
-\setvalue{\??db:\c!location:\v!inright }{\inright}
-\setvalue{\??db:\c!location:\v!margin }{\inmargin}
-
-\def\dolabelinit#1%
- {\def\currentdescriptionmain{#1}%
- \def\currentdescription {#1}%
- \def\currentdescriptionlevel{1}}
-
-\def\docurrentlabelnumber #1{\dolabelinit{#1}\dosingleempty\dodocurrentlabelnumber}
-\def\donextlabelnumber #1{\dolabelinit{#1}\dosingleempty\dodonextlabelnumber}
-\def\dolabelnumbercommand #1{\dolabelinit{#1}\dosingleempty\dodolabelnumbercommand}
-
-\def\doresetlabelnumber #1{\dolabelinit{#1}\strc_counters_reset_sub \currentdescriptionnumber\currentdescriptionlevel}
-\def\dosetlabelnumber #1#2{\dolabelinit{#1}\strc_counters_set_sub \currentdescriptionnumber\currentdescriptionlevel{#2}}
-\def\doincrementlabelnumber #1{\dolabelinit{#1}\strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel}
-
-\def\dodocurrentlabelnumber[#1]%
- {\dontleavehmode
- \writestatus{!!!}{todo: reference of label}%
- \dotextprefix{\descriptionparameter\c!text}%
- \convertedsubstructurecounter[\currentdescriptionnumber][\currentdescriptionlevel]}
-
-\def\dodonextlabelnumber[#1]% todo: ref
- {\strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel
- \dodocurrentlabelnumber[\currentdescriptionnumber]}
-
-\def\dodolabelnumbercommand[#1]% todo: ref
- {\dontleavehmode
- \descriptionparameter\c!before
- \begingroup
- \strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel
- \usedescriptionstyleandcolor\c!headstyle\c!headcolor
- \executeifdefined{\??db:\c!location:\descriptionparameter\c!location}{\descriptionparameter\c!command}{\dodocurrentlabelnumber[#1]}%
- \endgroup
- \descriptionparameter\c!after}
-
-\setuplabels
- [\s!parent=\??dn]
-
-%D \macros
-%D {defineindentedtext,
-%D setupindentedtext}
-%D
-%D Ok, we keep it but with a different command as it all looks too
-%D much like indentation and indenting. We also assume start/stop
-%D usage or some explicit par.
-
-\installcorenamespace{indentedtext}
-
-\installcommandhandler \??indentedtext {indentedtext} \??indentedtext
-
-%D \startbuffer
-%D \defineindentedtext[one][text=one]
-%D \defineindentedtext[two][text=two]
-%D
-%D \one test test \par
-%D \subone test test \par
-%D \subtwo test test \par
-%D \subsubone test test \par
-%D
-%D \startone
-%D test test
-%D \startone
-%D test test
-%D \startone
-%D test test
-%D \stopone
-%D \starttwo
-%D test test
-%D \startone
-%D test test
-%D \stopone
-%D \stoptwo
-%D \stopone
-%D \stopone
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\newcount\c_strc_indentedtexts_nesting
-\newdimen\d_strc_indentedtexts_width
-
-\appendtoks
- \setuevalue {\e!start\currentindentedtext}{\strc_indentedtexts_start{\currentindentedtext}\c_strc_indentedtexts_nesting}%
- \setuevalue {\e!stop \currentindentedtext}{\strc_indentedtexts_stop}%
- % to be avoided ... might go away
- \setuevalue {\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{0}}%
- \setuevalue {\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{1}}%
- \setuevalue{\v!sub\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{2}}%
-\to \everydefineindentedtext
-
-\unexpanded\def\strc_indentedtexts_start#1#2%
- {\par
- \begingroup
- \c_strc_indentedtexts_nesting#2\relax
- \edef\currentindentedtext{#1}%
- \indentedtextparameter\c!before
- \doifnothing{\indentedtextparameter\c!sample}
- {\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}%
- \assignwidth
- {\indentedtextparameter\c!width}
- {\d_strc_indentedtexts_width}
- {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
- \indentedtextparameter\c!sample
- \spr{\indentedtextparameter\c!separator}}
- {\indentedtextparameter\c!distance}%
- \advance\d_strc_indentedtexts_width \indentedtextparameter\c!distance
- \setbox\scratchbox\hbox to \d_strc_indentedtexts_width
- {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
- \strut
- \indentedtextparameter\c!text
- \hss
- \spr{\indentedtextparameter\c!separator}%
- \hskip\indentedtextparameter\c!distance}%
- \parindent\zeropoint
- \hskip\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
- \advance\c_strc_indentedtexts_nesting\plusone
- \dontleavehmode\box\scratchbox
- \hangindent\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
- \useindentedtextstyleandcolor\c!style\c!color}
-
-\unexpanded\def\strc_indentedtexts_stop
- {\indentedtextparameter\c!after
- \par
- \endgroup}
-
-\let\stopindentedtext\strc_indentedtexts_stop
-
-\unexpanded\def\strc_indentedtexts_direct#1#2#3\par % no longer clever grabpar trickery
- {\strc_indentedtexts_start{#1}{#2}#3\strc_indentedtexts_stop}
-
-\setupindentedtext
- [\c!style=\v!normal,
- \c!headstyle=\v!normal,
- %\c!color=,
- %\c!headcolor=,
- \c!width=\v!fit,
- \c!text=\unknown,
- %\c!sample=,
- \c!before=\blank,
- \c!after=\blank,
- \c!distance=1em,
- \c!separator={ :}]
-
-\protect \endinput
diff --git a/tex/context/base/strc-des.mkvi b/tex/context/base/strc-des.mkvi
new file mode 100644
index 000000000..ec74a3359
--- /dev/null
+++ b/tex/context/base/strc-des.mkvi
@@ -0,0 +1,196 @@
+%D \module
+%D [ file=strc-des,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Descriptions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Descriptions}
+
+\unprotect
+
+\installcorenamespace{description}
+
+\installcommandhandler \??description {description} \??description
+
+\let\setupdescriptions\setupdescription
+
+\setupdescriptions % check with old
+ [\c!alternative=\v!left,
+ \c!headstyle=\v!bold,
+ \c!titlestyle=\v!bold,
+ %\c!style=,
+ %\c!color=,
+ %\c!headcolor=,
+ %\c!titlecolor=,
+ \c!width=7em,
+ \c!distance=1em,
+ \c!titledistance=0.5em,
+ %\c!hang=,
+ %\c!sample=,
+ %\c!align=,
+ %\c!headalign=,
+ \c!margin=\v!no,
+ \c!before=\blank,
+ \c!inbetween=\blank,
+ \c!after=\blank,
+ \c!indentnext=\v!yes,
+ \c!indenting=\v!never,
+ \c!titleleft=(,
+ \c!titleright=),
+ %\c!closesymbol=,
+ \c!closecommand=\wordright,
+ \c!display=\v!yes,
+ %\c!command=,
+ \c!titlecommand=,
+ \c!expansion=\v!no,
+ %\c!xmlsetup=,
+ %\s!catcodes=,
+ \c!title=\v!yes,
+ %\c!text=,
+ ]
+
+\appendtoks
+ \ifx\currentdescriptionparent\empty
+ \defineconstruction[\currentdescription][\currentdescriptionparent][\s!handler=\v!description,\c!level=1]%
+ \else
+ \defineconstruction[\currentdescription][\s!handler=\v!description,\c!level=1]%
+ \fi
+ \setuevalue {\currentdescription}{\strc_descriptions_command{\currentdescription}}%
+ \setuevalue{\e!start\currentdescription}{\strc_descriptions_start {\currentdescription}}%
+ \setuevalue{\e!stop \currentdescription}{\strc_descriptions_stop}%
+\to \everydefinedescription
+
+\setvalue{\??constructioninitializer\v!description}%
+ {\let\currentdescription \currentconstruction
+ \let\constructionparameter \descriptionparameter
+ \let\detokenizedconstructionparameter\detokenizeddescriptionparameter
+ \let\letconstructionparameter \letdescriptionparameter
+ \let\useconstructionstyleandcolor \usedescriptionstyleandcolor
+ \let\setupcurrentconstruction \setupcurrentdescription
+ \edef\p_title{\constructionparameter\c!title}%
+ \ifx\p_title\v!yes
+ \settrue\c_strc_constructions_title_state
+ \else
+ \setfalse\c_strc_constructions_title_state
+ \fi}
+
+% We keep the command variant around but rather would move to the
+% start-stop one. Also, passing the title as argument has some
+% history so we need to keep that as well.
+
+\ifdefined\dotagsetdescription \else \let\dotagsetdescription\relax \fi
+
+% \startdescription [reference] text \stopdescription
+% \startdescription [reference]{title} text \stopdescription
+% \startdescription [title=,title=,reference=] text \stopdescription
+
+\unexpanded\def\strc_descriptions_start#1%
+ {\begingroup
+ \strc_constructions_initialize{#1}%
+ \doifnextoptionalelse\strc_descriptions_start_yes\strc_descriptions_start_nop}
+
+\unexpanded\def\strc_descriptions_start_yes[#1]%
+ {\doifassignmentelse{#1}\strc_descriptions_start_yes_assignment\strc_descriptions_start_yes_reference[#1]}
+
+\unexpanded\def\strc_descriptions_start_yes_assignment[#1]% todo userdata
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,#1][]%
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_start_yes_reference
+ {\ifconditional\c_strc_descriptions_title_state
+ \expandafter\strc_descriptions_start_yes_titled
+ \else
+ \expandafter\strc_descriptions_start_yes_normal
+ \fi}
+
+\unexpanded\def\strc_descriptions_start_yes_titled[#1]#2% todo userdata
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=][]%
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_start_yes_normal[#1]% todo userdata
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title=,\c!bookmark=,\c!list=][]%
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_start_nop
+ {\ifconditional\c_strc_constructions_title_state
+ \expandafter\strc_descriptions_start_nop_titled
+ \else
+ \expandafter\strc_descriptions_start_nop_normal
+ \fi}
+
+\unexpanded\def\strc_descriptions_start_nop_titled#1%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title={#1},\c!bookmark=,\c!list=][]%
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_start_nop_normal
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=][]%
+ \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_stop
+ {\csname\??constructionstophandler\currentconstructionhandler\endcsname}
+
+% \description [reference] text \par
+% \description [reference] {title} text \par
+
+\unexpanded\def\strc_descriptions_command#1%
+ {\begingroup
+ \strc_constructions_initialize{#1}%
+ \doifnextoptionalelse\strc_descriptions_yes\strc_descriptions_nop}
+
+\unexpanded\def\strc_descriptions_yes
+ {\ifconditional\c_strc_constructions_title_state
+ \expandafter\strc_descriptions_yes_titled
+ \else
+ \expandafter\strc_descriptions_yes_normal
+ \fi}
+
+\unexpanded\def\strc_descriptions_yes_titled[#1]#2%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=][]%
+ \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_yes_normal[#1]%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title=,\c!bookmark=,\c!list=][]%
+ \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_nop
+ {\ifconditional\c_strc_constructions_title_state
+ \expandafter\strc_descriptions_nop_titled
+ \else
+ \expandafter\strc_descriptions_nop_normal
+ \fi}
+
+\unexpanded\def\strc_descriptions_nop_titled#1%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title={#1},\c!bookmark=,\c!list=][]%
+ \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
+
+\unexpanded\def\strc_descriptions_nop_normal
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=][]%
+ \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
+
+%D Handlers:
+
+\expandafter\let\csname\??constructionmainhandler \v!description\expandafter\endcsname\csname\??constructionmainhandler \v!construction\endcsname
+\expandafter\let\csname\??constructioncommandhandler\v!description\expandafter\endcsname\csname\??constructioncommandhandler\v!construction\endcsname
+\expandafter\let\csname\??constructiontexthandler \v!description\expandafter\endcsname\csname\??constructiontexthandler \v!construction\endcsname
+
+\setvalue{\??constructioncommandhandler\v!description}%
+ {\dowithpar
+ {\csname\??constructionstarthandler\v!construction\endcsname}%
+ {\csname\??constructionstophandler \v!construction\endcsname\endgroup}}
+
+\setvalue{\??constructionstarthandler\v!description}%
+ {\BeforePar{\csname\??constructionstarthandler\v!construction\endcsname}%
+ \GotoPar}
+
+\setvalue{\??constructionstophandler\v!description}%
+ {\csname\??constructionstophandler\v!construction\endcsname
+ \endgroup}
+
+\protect \endinput
diff --git a/tex/context/base/strc-enu.mkvi b/tex/context/base/strc-enu.mkvi
new file mode 100644
index 000000000..9cacbd556
--- /dev/null
+++ b/tex/context/base/strc-enu.mkvi
@@ -0,0 +1,371 @@
+%D \module
+%D [ file=strc-enu, % moved from strc-des
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Enumerations,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Enumerations}
+
+\unprotect
+
+% command -> headcommand
+
+%D Enumerations are just super descriptions. Therefore we implement
+%D them as an extension. After all, the keys don't clash. In order
+%D to be able to differentiate between specific settings we use
+%D some flags. Unfortunately we have some historic differences
+%D in default values. Therefore we push an extra step in the
+%D parent chain (we might do the same for regular descriptions).
+
+%D In order to be more flexible with theorems Aditya Mahajan added
+%D support for titles and endsymbols. At the same time we added more
+%D flexible support for inheriting numbers.
+%D
+%D \startbuffer
+%D \defineenumeration[one]
+%D \defineenumeration[two] [one] % clone one
+%D \defineenumeration[three] [counter=one,style=slanted] % only use counter of one
+%D \defineenumeration[four] [three] % clone three
+%D \defineenumeration[five] [three] [counter=five] % clone three and use own counter
+%D \defineenumeration[six] [three] [counter=four] % clone tree and use counter four (undefined)
+%D
+%D \startone test test 6 \stopone
+%D \starttwo test test 7 \stoptwo
+%D \startthree test test 8 \stopthree
+%D \startfour test test 9 \stopfour
+%D \startfive test test 2 \stopfive
+%D \startsix test test 10 \stopsix
+%D \stopbuffer
+%D
+%D \typebuffer \start \getbuffer \stop
+%D
+%D \starttyping
+%D \setupenumerations[one] [prefix=yes,prefixsegments=section]
+%D \setupenumerations[two] [prefix=yes,prefixsegments=section]
+%D \setupenumerations[three][prefix=yes,prefixsegments=section]
+%D \setupenumerations[four] [prefix=yes,prefixsegments=chapter:section]
+%D \setupenumerations[five] [prefix=yes,prefixsegments=chapter:section]
+%D \setupenumerations[six] [prefix=yes,prefixsegments=chapter:section]
+%D \stoptyping
+
+% list and titles are experimental
+%
+% \definedescription[test] [location=left,hang=4,headalign={right},distance=1em,list=test]
+% \defineenumeration[lemma][title=yes,right=:,textdistance=1em, location=top, titlestyle=\bs,list=lemma]
+% \defineenumeration[ammel][title=yes,right=:,textdistance=.5em,location=left,titlestyle=\it,width=9em]
+%
+% \placelist[enumeration:lemma]
+% \placelist[description:test][width=0pt]
+%
+% \starttest {something something something} \input zapf \stoptest
+% \startlemma {with a title of a certain length} \input tufte \stoplemma
+% \startammel {with a title} \input zapf \stopammel
+%
+% \defineenumeration[lemma][...]
+% \defineenumeration[titledlemma][lemma][title=yes,right=:,text=lemma,list=lemma]
+
+\installcorenamespace{enumeration}
+
+\installcommandhandler \??enumeration {enumeration} \??enumeration
+
+\let\setupenumerations\setupenumeration
+
+\setupenumerations % check with old
+ [\c!alternative=\v!top,
+ \c!headstyle=\v!bold,
+ \c!titlestyle=\v!bold,
+ %\c!style=,
+ %\c!color=,
+ %\c!headcolor=,
+ %\c!titlecolor=,
+ \c!width=8em,
+ \c!distance=0pt,
+\c!distance=1em,
+ \c!titledistance=0.5em,
+ %\c!hang=,
+ %\c!sample=,
+ %\c!align=,
+ %\c!headalign=,
+ \c!margin=\v!no,
+ \c!before=\blank,
+ \c!inbetween=\blank,
+ \c!after=\blank,
+ \c!indentnext=\v!yes,
+ \c!indenting=\v!never,
+ \c!titleleft=(,
+ \c!titleright=),
+ %\c!closesymbol=,
+ \c!closecommand=\wordright,
+ \c!display=\v!yes,
+ %\c!command=,
+ \c!titlecommand=,
+ \c!expansion=\v!no,
+ %\c!xmlsetup=,
+ %\s!catcodes=,
+ %
+ \c!way=\v!by\v!text,
+ \c!prefix=\v!no,
+ \c!prefixconnector=.,
+ %\c!starter=,
+ %\c!stopper=,
+ \c!text=\currentenumeration,
+ \c!number=\v!yes, % else description
+ \c!start=0,
+ \c!state=\v!start,
+ \c!levels=4]
+
+\unexpanded\def\strc_define_commands_enumeration#1#2#3% current level parent
+ {\doifelsenothing{#3}
+ {\defineconstruction[#1][\s!handler=\v!enumeration,\c!level=#2]}%
+ {\defineconstruction[#1][#3][\s!handler=\v!enumeration,\c!level=#2]}%
+ \setuevalue{\e!next #1}{\strc_enumerations_next }%
+ \setuevalue{\c!reset#1}{\strc_enumerations_reset }%
+ %setuevalue{\c!set #1}{\strc_enumerations_set }%
+ \setuevalue {#1}{\strc_enumerations_command{\currentenumeration}}%
+ \setuevalue{\e!start#1}{\strc_enumerations_start {\currentenumeration}}%
+ \setuevalue{\e!stop #1}{\strc_enumerations_stop }}
+
+\appendtoks
+ \ifx\currentenumerationparent\empty
+ % clone => parent | subclone => clone | subsubclone => subclone
+ \let\currentenumerationsub\empty
+ \strc_define_commands_enumeration
+ {\currentenumerationsub\currentenumeration}%
+ \plusone
+ \empty
+ \edef\p_levels{\enumerationparameter\c!levels}%
+ \dostepwiserecurse\plustwo\p_levels\plusone
+ {\strc_define_commands_enumeration
+ {\v!sub\currentenumerationsub\currentenumeration}%
+ \recurselevel
+ {\currentenumerationsub\currentenumeration}%
+ \edef\currentenumerationsub{\v!sub\currentenumerationsub}}%
+ \else
+ % clone => parent | subclone => subparent | subsubclone => subsubparent
+ \let\currentenumerationsub\empty
+ \edef\p_levels{\enumerationparameter\c!levels}%
+ \dorecurse\p_levels
+ {\strc_define_commands_enumeration
+ {\currentenumerationsub\currentenumeration}%
+ \recurselevel
+ {\currentenumerationsub\currentenumerationparent}%
+ \edef\currentenumerationsub{\v!sub\currentenumerationsub}}%
+ \fi
+ \edef\p_counter{\enumerationparameter\s!counter}% can inherit from parent
+ \ifx\p_counter\empty %
+ \let\p_counter\currentenumeration
+ \fi
+ \doifstructurecounterelse\p_counter\donothing{\strc_enumerations_define_counter\p_counter}%
+ \letenumerationparameter\s!counter\p_counter
+ \strc_enumerations_setup_counter\currentenumeration
+\to \everydefineenumeration
+
+\setvalue{\??constructioninitializer\v!enumeration}%
+ {\let\currentenumeration \currentconstruction
+ \let\constructionparameter \enumerationparameter
+ \let\detokenizedconstructionparameter\detokenizedenumerationparameter
+ \let\letconstructionparameter \letenumerationparameter
+ \let\useconstructionstyleandcolor \useenumerationstyleandcolor
+ \let\setupcurrentconstruction \setupcurrentenumeration
+ \edef\p_number{\constructionparameter\c!number}%
+ \ifx\p_number\v!yes
+ \settrue\c_strc_constructions_number_state
+ \iftrialtypesetting
+ \strc_counters_save\currentconstructionnumber
+ \fi
+ \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel
+ \else
+ \setfalse\c_strc_constructions_number_state
+ \fi
+ \edef\p_title{\constructionparameter\c!title}%
+ \ifx\p_title\v!yes
+ \settrue\c_strc_constructions_title_state
+ \else
+ \setfalse\c_strc_constructions_title_state
+ \fi}
+
+\setvalue{\??constructionfinalizer\v!enumeration}%
+ {\ifconditional\c_strc_constructions_number_state
+ \iftrialtypesetting
+ \strc_counters_restore\currentconstructionnumber
+ \fi
+ \fi}
+
+%D Interfaces:
+
+\let\strc_enumerations_command\strc_descriptions_command
+\let\strc_enumerations_start \strc_descriptions_start
+\let\strc_enumerations_stop \strc_descriptions_stop
+
+\unexpanded\def\strc_enumerations_next {\strc_counters_increment_sub{\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}}
+\unexpanded\def\strc_enumerations_reset {\strc_counters_reset_sub {\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}}
+%unexpanded\def\strc_enumerations_set #3{\strc_counters_set_sub {\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}{#2}}
+
+%D Counters
+
+%D WILL MOVE:
+
+\newtoks\everysetupenumerationcounter
+\let\v_strc_enumerations_counter_name\empty
+
+\def\strc_enumerations_setup_counter#1%
+ {\edef\v_strc_enumerations_counter_name{#1}% only used in the token list
+ \edef\currentconstruction{#1}%
+ \the\everysetupenumerationcounter}
+
+\def\strc_enumerations_define_counter#1% todo: fast inheritance (was mainparameter
+ {\definestructurecounter[#1]%
+ \strc_enumerations_setup_counter{#1}}
+
+\appendtoks
+ \dostructurecountersetup\v_strc_enumerations_counter_name\constructionparameter
+\to \everysetupenumerationcounter
+
+\def\currentconstructionnumber {\constructionparameter\s!counter}
+\def\specificconstructionnumber#1{\namedconstructionparameter{#1}\s!counter}
+
+%D Initializer:
+
+%D The handlers.
+
+\newtoks\everyenumeration
+
+\appendtoks
+ \disablepseudocaps % sorry, uppercase causes troubles
+\to \everyenumeration
+
+\expandafter\let\csname\??constructionmainhandler \v!enumeration\expandafter\endcsname\csname\??constructionmainhandler \v!description\endcsname
+\expandafter\let\csname\??constructioncommandhandler\v!enumeration\expandafter\endcsname\csname\??constructioncommandhandler\v!description\endcsname
+\expandafter\let\csname\??constructionstarthandler \v!enumeration\expandafter\endcsname\csname\??constructionstarthandler \v!description\endcsname
+\expandafter\let\csname\??constructionstophandler \v!enumeration\expandafter\endcsname\csname\??constructionstophandler \v!description\endcsname
+
+\setvalue{\??constructiontexthandler\v!enumeration}%
+ {\begingroup
+ \useconstructionstyleandcolor\c!headstyle\c!headcolor
+ \strc_enumerations_text
+ \endgroup}
+
+\unexpanded\def\strc_enumerations_text
+ {\the\everyenumeration % will become obsolete
+ \ifconditional\c_strc_constructions_number_state
+ \ifx\currentconstructionreference\!!plustoken
+ \strc_enumerations_full_number_symbol
+ \else\ifx\currentconstructionreference\!!minustoken
+ \strc_enumerations_full_number_nop
+ \else
+ \strc_enumerations_full_number_coupling
+ \fi\fi
+ \else
+ \strc_enumerations_full_number_nop
+ \fi}
+
+\unexpanded\def\strc_enumerations_inject_text_with_space
+ {\edef\p_text{\constructionparameter\c!text}%
+ \ifx\p_text\empty \else
+ \p_text
+ \removeunwantedspaces
+ \nobreakspace
+ \fi}
+
+\unexpanded\def\strc_enumerations_inject_extra_text
+ {\ifconditional\c_strc_constructions_title_state
+ \ctxcommand{doiflisthastitleelse("\currentconstructionmain",\currentconstructionlistentry)}
+ \strc_enumerations_inject_extra_text_indeed
+ \donothing
+ \fi}
+
+\unexpanded\def\strc_enumerations_inject_text
+ {\constructionparameter\c!numbercommand
+ {\constructionparameter\c!text}}
+
+% head ( number title )
+
+\unexpanded\def\strc_enumerations_inject_extra_text_indeed
+ {\begingroup
+ \hskip\constructionparameter\c!titledistance % we listen to the headstyle
+ \useconstructionstyleandcolor\c!titlestyle\c!titlecolor
+ \constructionparameter\c!titlecommand
+ {\constructionparameter\c!titleleft
+ \ctxcommand{savedlisttitle("\currentconstructionmain",\currentconstructionlistentry)}%
+ \constructionparameter\c!titleright}%
+ \endgroup}
+
+\unexpanded\def\strc_enumerations_inject_symbol % todo check
+ {\constructionparameter\c!left
+ \constructionparameter\c!symbol
+ \constructionparameter\c!right}
+
+\unexpanded\def\strc_enumerations_inject_number
+ {\constructionparameter\c!left
+ \constructionparameter\c!starter
+ \ctxcommand{savedlistprefixednumber("\currentconstructionmain",\currentconstructionlistentry)}%
+ \constructionparameter\c!stopper
+ \constructionparameter\c!right}
+
+\unexpanded\def\strc_enumerations_inject_text_and_number
+ {\constructionparameter\c!numbercommand
+ {\strc_enumerations_inject_text_with_space
+ \strc_enumerations_inject_number}}
+
+\unexpanded\def\strc_enumerations_inject_text_and_symbol
+ {\constructionparameter\c!numbercommand
+ {\strc_enumerations_inject_text_with_space
+ \strc_enumerations_inject_symbol}}
+
+\unexpanded\def\strc_enumerations_full_number_yes
+ {\constructionparameter\c!headcommand
+ {\begstrut
+ \strc_enumerations_inject_text_and_number
+ \strc_enumerations_inject_extra_text
+ \endstrut}}
+
+\unexpanded\def\strc_enumerations_full_number_nop
+ {\constructionparameter\c!headcommand
+ {\begstrut
+ \strc_enumerations_inject_text
+ \strc_enumerations_inject_extra_text
+ \endstrut}}
+
+\unexpanded\def\strc_enumerations_full_number_symbol
+ {\constructionparameter\c!headcommand
+ {\begstrut
+ \strc_enumerations_inject_text_and_symbol
+ \strc_enumerations_inject_extra_text
+ \endstrut}}
+
+% to be used in for instance:
+%
+% coupling=questions .... coupling=answers
+%
+% we will provide some more control, like skipping etc or reference relates
+
+% todo
+
+ \unexpanded\def\strc_enumerations_full_number_coupling
+ {\iflocation
+ \strc_enumerations_full_number_yes
+ \else
+ \iftrialtypesetting \else
+ % \doenumerationregistercoupling
+ \fi
+ \strc_enumerations_full_number_yes
+ \edef\p_coupling{\constructionparameter\c!coupling}%
+ \ifx\p_coupling\empty \else
+ \symbolreference[order(construction:\p_coupling:\nextinternalorderreference)]%
+ \fi
+ \fi}
+
+ \def\skipenumerationcoupling[#1]% e.g. for questions with no answer
+ {\ctxlua{structures.references.setnextorder("construction","#1")}}
+
+ \unexpanded\def\structurecounterreference#1%
+ {[enumref: #1]}
+
+\protect \endinput
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index b9a7d7990..099c6fe5f 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -219,7 +219,7 @@
\namedtaggedlabeltexts
\t!floatlabel \currentfloat
\t!floatnumber\currentfloat
- {\ctxlua{structures.lists.savedprefixednumber("\currentfloat",\currentfloatnumber)}%
+ {\ctxcommand{savedlistprefixednumber("\currentfloat",\currentfloatnumber)}%
\thecurrentfloatnumbersuffix}%
\fi
\fi \fi}
@@ -228,7 +228,7 @@
{\ifnofloatcaption \else
\ifx\currentfloatnumber\relax\else
\dostarttagged\t!floattext\empty
- \ctxlua{structures.lists.savedtitle("\currentfloat",\currentfloatnumber)}%
+ \ctxcommand{savedlisttitle("\currentfloat",\currentfloatnumber)}%
\dostoptagged
\fi
\fi}
@@ -410,7 +410,7 @@
\unexpanded\def\strc_floats_place#tag%
{\flushnotes
- \flushsidefloats % here !
+ \page_otr_command_flush_side_floats % here !
\strc_floats_begin_group
\strc_floats_set_current_tag{#tag}%
\dodoubleempty\strc_floats_place_indeed}
@@ -426,7 +426,7 @@
\unexpanded\def\placefloat
{\flushnotes
- \flushsidefloats % here !
+ \page_otr_command_flush_side_floats % here !
\strc_floats_begin_group
\dotripleempty\strc_floats_place_float}
@@ -438,7 +438,7 @@
\unexpanded\def\strc_floats_start_place#tag%
{\flushnotes
- \flushsidefloats % here !
+ \page_otr_command_flush_side_floats % here !
\strc_floats_begin_group
\strc_floats_set_current_tag{#tag}%
\dosingleempty\strc_floats_start_place_indeed}
@@ -462,7 +462,7 @@
\unexpanded\def\startplacefloat
{\flushnotes
- \flushsidefloats % here !
+ \page_otr_command_flush_side_floats % here !
\strc_floats_begin_group
\dodoubleempty\strc_floats_start_place_float}
@@ -476,7 +476,7 @@
\unexpanded\def\strc_floats_reserve#tag%
{\flushnotes
- \flushsidefloats % here !
+ \page_otr_command_flush_side_floats % here !
\strc_floats_begin_group
\strc_floats_set_current_tag{#tag}%
\dotripleempty\strc_floats_reserve_indeed}
@@ -494,7 +494,7 @@
\unexpanded\def\strc_floats_start_text#tag%
{\flushnotes % Here indeed?
- \flushsidefloats % Here indeed?
+ \page_otr_command_flush_side_floats % Here indeed?
\strc_floats_begin_text_group
\strc_floats_set_current_tag{#tag}%
\dodoubleempty\strc_floats_start_text_indeed}
@@ -509,7 +509,7 @@
\unexpanded\def\strc_floats_start_reserve_text#tag%
{\flushnotes
- \flushsidefloats
+ \page_otr_command_flush_side_floats
\strc_floats_begin_text_group
\strc_floats_set_current_tag{#tag}%
\dotripleempty\strc_floats_start_reserve_text_indeed}
@@ -552,7 +552,7 @@
% this was \checkwaitingfloats spread all over
\doifinsetelse\v!always\floatlocation
{\showmessage\m!floatblocks5\empty}
- {\doifcommonelse\floatlocation\flushfloatslist\doflushfloats\donothing}%
+ {\doifcommonelse\floatlocation\flushfloatslist\page_otr_command_flush_floats\donothing}%
% but which should be done before using box \floatbox
\fi
\page_margin_strc_floats_before % todo: each float handler gets a before
@@ -584,7 +584,7 @@
\global\sidefloatdownshift \zeropoint
\global\sidefloatextrashift\zeropoint
\ifparfloat
- \doifinset\v!reset\floatlocation\forgetsidefloats
+ \doifinset\v!reset\floatlocation\page_sides_forget_floats
\doinhibitblank
\fi
\strc_floats_end_group}
@@ -592,6 +592,8 @@
\setnewconstant\textfloatmethod\zerocount % 0=raw 1=safe (.99) 2=tight (-1pt)
\setnewconstant\floatrotation \zerocount % 0 90 180 270
+% nicer is a bunch of states and one loop that sets those states
+
\def\strc_floats_analyze_variables_two
{\doifcommonelse
{\floatlocation}
@@ -826,15 +828,29 @@
\endgroup}
{\movedownsidefloat[#settings]}}
+% \def\strc_floats_move_down#setting%
+% {\processaction
+% [#setting]%
+% [ \v!line=>\strc_floats_move_down_line+,%
+% +\v!line=>\strc_floats_move_down_line+,%
+% -\v!line=>\strc_floats_move_down_line-,%
+% \v!hang=>\strc_floats_move_down_hang\plusone,%
+% +\v!hang=>\strc_floats_move_down_hang\plusone,%
+% -\v!hang=>\strc_floats_move_down_hang\minusone]}
+
+\installcorenamespace{floatmovement}
+
+\setvalue{\??floatmovement \v!line}{\strc_floats_move_down_line+}
+\setvalue{\??floatmovement+\v!line}{\strc_floats_move_down_line+}
+\setvalue{\??floatmovement-\v!line}{\strc_floats_move_down_line-}
+\setvalue{\??floatmovement \v!hang}{\strc_floats_move_down_hang\plusone}
+\setvalue{\??floatmovement+\v!hang}{\strc_floats_move_down_hang\plusone}
+\setvalue{\??floatmovement-\v!hang}{\strc_floats_move_down_hang\minusone}
+
\def\strc_floats_move_down#setting%
- {\processaction
- [#setting]%
- [ \v!line=>\strc_floats_move_down_line+,%
- +\v!line=>\strc_floats_move_down_line+,%
- -\v!line=>\strc_floats_move_down_line-,%
- \v!hang=>\strc_floats_move_down_hang\plusone,%
- +\v!hang=>\strc_floats_move_down_hang\plusone,%
- -\v!hang=>\strc_floats_move_down_hang\minusone]}
+ {\csname\??floatmovement
+ \ifcsname\??floatmovement#setting\endcsname#setting\fi
+ \endcsname}
\def\strc_floats_move_down_line#sign%
{\if!!donea \else
@@ -866,69 +882,151 @@
{\let\extrafloatlocation#rightpagelocation}%
{\let\extrafloatlocation#leftpagelocation}}
-\def\strc_floats_check_extra_actions
+% \def\strc_floats_check_extra_actions
+% {\doifnotinset\v!text\floatlocation % fuzzy, text overloads left, since then it's a directive
+% {\let\extrafloatlocation\empty
+% % \sidefloatdownshift will be reset afterwards, and can
+% % already be set at this point
+% \processallactionsinset
+% [\floatlocation] % ininner/inouter : for old times sake
+% [ \v!inner=>\strc_floats_set_extra_action\v!left \v!right,
+% \v!outer=>\strc_floats_set_extra_action\v!right \v!left,
+% \v!innermargin=>\strc_floats_set_extra_action\v!leftmargin \v!rightmargin,
+% \v!outermargin=>\strc_floats_set_extra_action\v!rightmargin\v!leftmargin,
+% \v!inneredge=>\strc_floats_set_extra_action\v!leftedge \v!rightedge,
+% \v!outeredge=>\strc_floats_set_extra_action\v!rightedge \v!leftedge,
+% \v!backspace=>\strc_floats_set_extra_action\v!backspace \v!cutspace,
+% \v!cutspace=>\strc_floats_set_extra_action\v!cutspace \v!backspace,
+% % \v!margin=>\strc_floats_set_extra_action\v!cutspace \v!backspace,
+% \v!left=>\strc_floats_set_extra_action\v!left \v!left,
+% \v!right=>\strc_floats_set_extra_action\v!right \v!right,
+% \v!line=>, % only -n*line is handled (see ***)
+% \s!unknown=>{\movedownsidefloat[\commalistelement]}]%
+% \ifx\extrafloatlocation\empty \else
+% \edef\floatlocation{\extrafloatlocation,\floatlocation}%
+% \fi}}
+
+\installcorenamespace{extrafloataction}
+
+\setvalue{\??extrafloataction \v!inner}{\strc_floats_set_extra_action\v!left \v!right}
+\setvalue{\??extrafloataction \v!outer}{\strc_floats_set_extra_action\v!right \v!left}
+\setvalue{\??extrafloataction\v!innermargin}{\strc_floats_set_extra_action\v!leftmargin \v!rightmargin}
+\setvalue{\??extrafloataction\v!outermargin}{\strc_floats_set_extra_action\v!rightmargin\v!leftmargin}
+\setvalue{\??extrafloataction \v!inneredge}{\strc_floats_set_extra_action\v!leftedge \v!rightedge}
+\setvalue{\??extrafloataction \v!outeredge}{\strc_floats_set_extra_action\v!rightedge \v!leftedge}
+\setvalue{\??extrafloataction \v!backspace}{\strc_floats_set_extra_action\v!backspace \v!cutspace}
+\setvalue{\??extrafloataction \v!cutspace}{\strc_floats_set_extra_action\v!cutspace \v!backspace}
+%setvalue{\??extrafloataction \v!margin}{\strc_floats_set_extra_action\v!cutspace \v!backspace}
+\setvalue{\??extrafloataction \v!left}{\strc_floats_set_extra_action\v!left \v!left}
+\setvalue{\??extrafloataction \v!right}{\strc_floats_set_extra_action\v!right \v!right}
+\setvalue{\??extrafloataction \v!line}{} % only -n*line is handled (see ***)
+\setvalue{\??extrafloataction \s!unknown}{\movedownsidefloat[\commalistelement]}
+
+\def\strc_floats_check_extra_actions % less tracingthis way ...
{\doifnotinset\v!text\floatlocation % fuzzy, text overloads left, since then it's a directive
{\let\extrafloatlocation\empty
% \sidefloatdownshift will be reset afterwards, and can
% already be set at this point
- \processallactionsinset
- [\floatlocation] % ininner/inouter : for old times sake
- [ \v!inner=>\strc_floats_set_extra_action\v!left \v!right,
- \v!outer=>\strc_floats_set_extra_action\v!right \v!left,
- \v!innermargin=>\strc_floats_set_extra_action\v!leftmargin \v!rightmargin,
- \v!outermargin=>\strc_floats_set_extra_action\v!rightmargin\v!leftmargin,
- \v!inneredge=>\strc_floats_set_extra_action\v!leftedge \v!rightedge,
- \v!outeredge=>\strc_floats_set_extra_action\v!rightedge \v!leftedge,
- \v!backspace=>\strc_floats_set_extra_action\v!backspace \v!cutspace,
- \v!cutspace=>\strc_floats_set_extra_action\v!cutspace \v!backspace,
- % \v!margin=>\strc_floats_set_extra_action\v!cutspace \v!backspace,
- \v!left=>\strc_floats_set_extra_action\v!left \v!left,
- \v!right=>\strc_floats_set_extra_action\v!right \v!right,
- \v!line=>, % only -n*line is handled (see ***)
- \s!unknown=>{\movedownsidefloat[\commalistelement]}]%
+ \processcommacommand[\floatlocation]\strc_floats_check_extra_actions_step
\ifx\extrafloatlocation\empty \else
\edef\floatlocation{\extrafloatlocation,\floatlocation}%
\fi}}
+\def\strc_floats_check_extra_actions_step#step%
+ {\csname\??extrafloataction
+ \ifcsname\??extrafloataction#1\endcsname#step\else\s!unknown\fi
+ \endcsname}
+
% pas op, maxbreedte niet instellen als plaats=links/rechts
+% \def\strc_floats_set_local_dimensions
+% {\global\sidefloatshift \zeropoint % duplicate
+% \global\sidefloatmaximum\zeropoint\relax % duplicate
+% \ifdim\sidefloatdownshift=\zeropoint\else
+% \global\setbox\floatbox\vbox
+% {\vskip\sidefloatdownshift\nointerlineskip\box\floatbox}%
+% \fi
+% \doifsomething{\floatparameter\c!minwidth}
+% {\scratchdimen\floatparameter\c!minwidth\relax
+% \ifdim\wd\floatbox<\scratchdimen
+% \global\setbox\floatbox\hbox to \scratchdimen
+% {\doifnot{\floatparameter\c!location}\v!left \hss
+% \box\floatbox
+% \doifnot{\floatparameter\c!location}\v!right\hss}%
+% \fi}%
+% \doifinset\v!hanging\floatlocation
+% {\doifcommonelse{\v!inleft,\v!leftmargin}\floatlocation
+% {\letfloatparameter\c!maxwidth\leftmarginwidth}%
+% {\doifcommon{\v!inright,\v!rightmargin}\floatlocation
+% {\letfloatparameter\c!maxwidth\rightmarginwidth}}}%
+% \doifsomething{\floatparameter\c!maxwidth}
+% {\scratchdimen\floatparameter\c!maxwidth\relax
+% \ifdim\wd\floatbox>\scratchdimen
+% \doifcommonelse{\v!inright,\v!rightmargin,\v!rightedge,\v!inleft,\v!leftmargin,\v!leftedge}\floatlocation
+% {\global\sidefloatmaximum\scratchdimen}
+% {\global\setbox\floatbox\hbox to \scratchdimen
+% {\doifcommonelse{\v!right,\v!left}\floatlocation
+% {\doifnotinset\v!right\floatlocation\hss
+% \box\floatbox
+% \doifnotinset\v!left\floatlocation\hss}%
+% {\doifnot{\floatparameter\c!location}\v!left\hss
+% \box\floatbox
+% \doifnot{\floatparameter\c!location}\v!right\hss}}}%
+% \fi}}
+
\def\strc_floats_set_local_dimensions
{\global\sidefloatshift \zeropoint % duplicate
\global\sidefloatmaximum\zeropoint\relax % duplicate
\ifdim\sidefloatdownshift=\zeropoint\else
\global\setbox\floatbox\vbox
- {\vskip\sidefloatdownshift\nointerlineskip\box\floatbox}%
+ {\vskip\sidefloatdownshift
+ \nointerlineskip
+ \box\floatbox}%
\fi
- \doifsomething{\floatparameter\c!minwidth}
- {\scratchdimen\floatparameter\c!minwidth\relax
- \ifdim\wd\floatbox<\scratchdimen
- \global\setbox\floatbox\hbox to \scratchdimen
- {\doifnot{\floatparameter\c!location}\v!left \hss
- \box\floatbox
- \doifnot{\floatparameter\c!location}\v!right\hss}%
- \fi}%
- \doifinset\v!hanging\floatlocation
+ \edef\p_minwidth{\floatparameter\c!minwidth}%
+ \ifx\p_minwidth\empty
+ % nothing
+ \else
+ \scratchwidth\p_minwidth\relax
+ \ifdim\wd\floatbox<\scratchwidth
+ \strc_floats_realign_floatbox_horizontal_two
+ \fi
+ \fi
+ % we can also support edges .. in that case no common but a fast loop
+ \doifinsetelse\v!hanging\floatlocation
{\doifcommonelse{\v!inleft,\v!leftmargin}\floatlocation
- {\letfloatparameter\c!maxwidth\leftmarginwidth}%
- {\doifcommon{\v!inright,\v!rightmargin}\floatlocation
- {\letfloatparameter\c!maxwidth\rightmarginwidth}}}%
- \doifsomething{\floatparameter\c!maxwidth}
- {\scratchdimen\floatparameter\c!maxwidth\relax
- \ifdim\wd\floatbox>\scratchdimen
- \doifcommonelse{\v!inright,\v!rightmargin,\v!rightedge,\v!inleft,\v!leftmargin,\v!leftedge}\floatlocation
- {\global\sidefloatmaximum\scratchdimen}
- {\global\setbox\floatbox\hbox to \scratchdimen
- {\doifcommonelse{\v!right,\v!left}\floatlocation
- {\doifnotinset\v!right\floatlocation\hss
- \box\floatbox
- \doifnotinset\v!left\floatlocation\hss}%
- {\doifnot{\floatparameter\c!location}\v!left\hss
- \box\floatbox
- \doifnot{\floatparameter\c!location}\v!right\hss}}}%
- \fi}}
+ {\let\p_maxwidth\leftmarginwidth}%
+ {\doifcommonelse{\v!inright,\v!rightmargin}\floatlocation
+ {\let\p_maxwidth\rightmarginwidth}%
+ {\edef\p_maxwidth{\floatparameter\c!maxwidth}}}}%
+ {\edef\p_maxwidth{\floatparameter\c!maxwidth}}%
+ \ifx\p_maxwidth\empty
+ % nothing
+ \else
+ \scratchwidth\p_maxwidth\relax
+ \ifdim\wd\floatbox>\scratchwidth
+ \doifcommonelse{\v!inright,\v!rightmargin,\v!rightedge,\v!inleft,\v!leftmargin,\v!leftedge}\floatlocation
+ {\global\sidefloatmaximum\scratchwidth}
+ {\doifcommonelse{\v!right,\v!left}\floatlocation
+ \strc_floats_realign_floatbox_horizontal_one
+ \strc_floats_realign_floatbox_horizontal_two}%
+ \fi
+ \fi}
+
+\def\strc_floats_realign_floatbox_horizontal_one
+ {\global\setbox\floatbox\hbox to \scratchwidth
+ {\doifnotinset\v!right\floatlocation\hss
+ \box\floatbox
+ \doifnotinset\v!left \floatlocation\hss}}
+
+\def\strc_floats_realign_floatbox_horizontal_two
+ {\global\setbox\floatbox\hbox to \scratchwidth
+ {\doifnot{\floatparameter\c!location}\v!left \hss
+ \box\floatbox
+ \doifnot{\floatparameter\c!location}\v!right\hss}}
\unexpanded\def\placefloats
- {\doflushfloats}
+ {\page_otr_command_flush_floats}
\installinsertion\topins
\installinsertion\botins
@@ -936,7 +1034,6 @@
\newdimen\botinserted
\newdimen\topinserted
-\newif\iftopofinsert
\newif\iftestfloatbox
\newdimen\floatsideskip \floatsideskip 12pt
@@ -989,18 +1086,9 @@
{%\forgetall % NO
\whitespace
\blank[\rootfloatparameter\c!spacebefore]
- \flushfloatbox
+ \page_otr_command_flush_float_box
\blank[\rootfloatparameter\c!spaceafter]}
-%
-
-\ifdefined\someherefloat\else \let\someherefloat\doplacefloatbox \fi
-\ifdefined\someslotfloat\else \let\someslotfloat\doplacefloatbox \fi
-\ifdefined\somefixdfloat\else \let\somefixdfloat\doplacefloatbox \fi
-\ifdefined\sometopsfloat\else \let\sometopsfloat\doplacefloatbox \fi
-\ifdefined\somebotsfloat\else \let\somebotsfloat\doplacefloatbox \fi
-\ifdefined\somesidefloat\else \let\somesidefloat\doplacefloatbox \fi
-
% test case:
%
% \placefigure[page,none]{}{\blackrule[width=\textwidth,height=0.9\textheight,color=green]}
@@ -1009,16 +1097,16 @@
% the [#1] will go away
-\def\sometextfloat[#1]%
- {%\checkwaitingfloats{#1}%
+\def\page_one_place_float_text % this macro should be defined elsewhere
+ {%\checkwaitingfloats\floatlocationmethod
% todo: check if #1 is indeed \floatlocation or maybe more
\global\floattextwidth\hsize
\global\floatwidth\wd\floatbox
\global\floatheight\ht\floatbox % forget about the depth
\global\advance\floattextwidth -\floatwidth
\global\advance\floattextwidth -\rootfloatparameter\c!margin\relax
- \edef\floatlocation{#1}% to be sure
- \doifinsetelse\v!tall{#1}
+ \edef\floatlocation{\floatlocationmethod}% to be sure .. why
+ \doifinsetelse\v!tall\floatlocationmethod
{\floattextheight\pagegoal
\advance\floattextheight -\pagetotal
\advance\floattextheight -\bigskipamount % lelijk
@@ -1088,63 +1176,6 @@
\blank[\rootfloatparameter\c!spaceafter]%
\strc_floats_end_text_group
\doinsertfloatinfo}
-
-\def\somefacefloat[#1]% links, rechts, midden, hoog, midden, laag
- {%\checkwaitingfloats{#1}%
- \startopposite\box\floatbox\stopopposite
- \doinsertfloatinfo}
-
-\def\someelsefloat[#1]%
- {\doifinsetelse\v!here{#1}
- {\doifinsetelse\v!always{#1}
- {\page[\v!preference]%
- \docheckiffloatfits
- \ifroomforfloat
- \placesomeherefloat[#1]%
- \else
- \showmessage\m!floatblocks9\empty
- \doreversesavefloat
- \fi}
- {\ifsomefloatwaiting
- \dosavefloat
- \else
- \page[\v!preference]%
- \docheckiffloatfits
- \ifroomforfloat
- \placesomeherefloat[#1]%
- \else
- \dosavefloat
- \fi
- \fi}}
- {\doifinsetelse\v!always{#1}
- {\docheckiffloatfits
- \ifroomforfloat
- \sometopbottomfloat[#1]
- \else
- \showmessage\m!floatblocks9\empty
- \doreversesavefloat
- \fi}
- {\docheckiffloatfits
- \ifroomforfloat
- \sometopbottomfloat[#1]
- \else
- \dosavefloat
- \fi}}}
-
-\def\floatautofactor{.5}
-
-\def\sometopbottomfloat[#1]%
- {\doifelse\floatmethod\v!auto
- {\ifdim\pagetotal<\floatautofactor\pagegoal % when empty page, maxdimen
- \placesometopsfloat[#1]%
- \else
- \placesomebotsfloat[#1]%
- \fi}
- {\doifelse\floatmethod\v!top
- {\placesometopsfloat[#1]}
- {\doifelse\floatmethod\v!bottom
- {\placesomebotsfloat[#1]}
- {\placesomeherefloat[#1]}}}}
\def\borderedfloatbox
{\begingroup
@@ -1239,8 +1270,64 @@
{\dopreparesidewidthcaption}}%
\dostoptagged}
+% makes sense if we preexpand more variables
+
+% \def\strc_floats_prepare_page_caption
+% {\edef\p_caption_location{\floatcaptionparameter\c!location}%
+% \edef\p_caption_width {\floatcaptionparameter\c!width}%
+% \edef\p_caption_minwidth{\floatcaptionparameter\c!minwidth}%
+% \edef\p_caption_align {\floatcaptionparameter\c!align}%
+% \dostarttagged\t!floatcaption\empty
+% \ifx\p_caption_location\v!top
+% \strc_floats_prepare_page_caption_top_bottom
+% \else\ifx\p_caption_location\v!bottom
+% \strc_floats_prepare_page_caption_top_bottom
+% \else\ifx\p_caption_width\v!fit
+% \dopreparesideautocaption
+% \else\ifx\p_caption_width\v!max
+% \dopreparesideautocaption
+% \else
+% \dopreparesidewidthcaption
+% \fi\fi\fi\fi
+% \dostoptagged}
+
+% \def\strc_floats_prepare_page_caption_top_bottom
+% {\ifx\p_caption_width\v!fit
+% \strc_floats_prepare_page_caption_top_bottom_fit_max
+% \else\ifx\p_caption_width\v!max
+% \strc_floats_prepare_page_caption_top_bottom_fit_max
+% \else
+% \dopreparesidewidthcaption % new, special effects (see icare)
+% \fi\fi}
+
+% \def\strc_floats_prepare_page_caption_top_bottom_fit_max
+% {\ifx\p_caption_minwidth\v!fit
+% \ifx\p_caption_width\v!max
+% \dopreparestackcaptionmax
+% \else\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content % wider caption
+% \ifx\p_caption_width\v!fit
+% \dopreparestackcaptionaut
+% \else
+% \dopreparestackcaptionwid
+% \fi
+% \else
+% \dopreparestackcaptionmin
+% \fi\fi
+% \else
+% \dopreparestackcaptionfix
+% \fi}
+
+% \def\dopreparestackcaptionmin
+% {\setbox\b_strc_floats_caption\vbox
+% {\strc_floats_caption_set_align
+% \hsize\wd\b_strc_floats_content
+% \ifx\p_caption_align\empty
+% \raggedcenter % on purpose overloads align !
+% \fi
+% \strc_floats_make_complete_caption}}
+
\def\strc_floats_caption_set_align
- {\normalexpanded{\noexpand\setupalign[\v!reset,\floatcaptionparameter\c!align]}}
+ {\normalexpanded{\setupalign[\v!reset,\floatcaptionparameter\c!align]}}
\def\dopreparesideautocaption
{\scratchdimen\dimexpr\hsize-\wd\b_strc_floats_content-\floatparameter\c!margin\relax
@@ -1518,7 +1605,7 @@
\dofloatboxbetweenstack
\hbox{\hbox{\box\b_strc_floats_content}}%
\else
- \setfloathsize
+ \page_otr_command_set_float_hsize
\hbox{\strc_floats_locate_text_float{\box\b_strc_floats_caption}}
\dofloatboxbetweenstack
\hbox{\strc_floats_align_content{\box\b_strc_floats_content}}%
@@ -1532,7 +1619,7 @@
\dofloatboxbetweenstack
\hbox{\strc_floats_locate_side_float{\box\b_strc_floats_caption}}%
\else
- \setfloathsize
+ \page_otr_command_set_float_hsize
\hbox{\strc_floats_align_content{\box\b_strc_floats_content}}%
\dofloatboxbetweenstack
\hbox{\strc_floats_locate_text_float{\box\b_strc_floats_caption}}%
@@ -1547,7 +1634,7 @@
\vss\dofloatboxbetweenstack
\hbox{\box\b_strc_floats_content}%
\else
- \setfloathsize
+ \page_otr_command_set_float_hsize
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
\vss\dofloatboxbetweenstack
\strc_floats_align_content{\box\b_strc_floats_content}%
@@ -1564,7 +1651,7 @@
\vss\dofloatboxbetweenstack
\strc_floats_locate_side_float{\box\b_strc_floats_caption}%
\else
- \setfloathsize
+ \page_otr_command_set_float_hsize
\strc_floats_align_content{\box\b_strc_floats_content}%
\vss\dofloatboxbetweenstack
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
@@ -1585,7 +1672,7 @@
\vss\dofloatboxbetweenstack\vss
\hbox{\box\b_strc_floats_content}%
\else
- \setfloathsize
+ \page_otr_command_set_float_hsize
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
\vss\dofloatboxbetweenstack\vss
\strc_floats_align_content{\box\b_strc_floats_content}%
@@ -1604,7 +1691,7 @@
\vss\dofloatboxbetweenstack\vss
\strc_floats_locate_side_float{\box\b_strc_floats_caption}
\else
- \setfloathsize
+ \page_otr_command_set_float_hsize
\strc_floats_align_content{\box\b_strc_floats_content}%
\vss\dofloatboxbetweenstack\vss
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
@@ -1822,6 +1909,9 @@
\def\setfloatmethodvariables#1% \floatmethod \floatlabel \floatrow \floatcolumn
{\ctxcommand{analysefloatmethod("#1")}}
+\def\somesomewherefloat[#1]%
+ {\dofloatssavesomewherefloat\s!somewhere{#1}}
+
\def\strc_floats_get_box
{\ifvisible
\let\floatlabel \empty
@@ -1832,97 +1922,136 @@
\ifdefined\OTRSETsetpreferedcolumnslot
\OTRSETsetpreferedcolumnslot\floatcolumn\floatrow
\fi
- \ifcsname\??floatmethods\floatmethod\endcsname \else
+ \ifcsname\??floatmethods\currentoutputroutine:\floatmethod\endcsname \else
\let\floatmethod\v!here
\fi
\ifx\forcedfloatmethod\empty \else
\let\floatmethod\forcedfloatmethod
\fi
- \getvalue{\??floatmethods\floatmethod}[\floatmethod,\floatlocation]%
+ % [] will go
+ \edef\floatlocationmethod{\floatmethod,\floatlocation}%
+ \csname\??floatmethods\currentoutputroutine:\floatmethod\endcsname
\fi}
-\unexpanded\def\installfloatmethod#1#2% #1=keyword #2=handler
- {\setvalue{\??floatmethods#1}{#2}}
-
-\let\installfloathandler\installfloatmethod % will go
-
-\def\somesomewherefloat[#1]%
- {\dofloatssavesomewherefloat\s!somewhere{#1}}
-
-\installfloatmethod \v!here \someherefloat
-\installfloatmethod \v!force \somefixdfloat
-\installfloatmethod \v!left \someleftsidefloat
-\installfloatmethod \v!right \somerightsidefloat
-\installfloatmethod \v!text \sometextfloat
-\installfloatmethod \v!top \sometopfloat
-\installfloatmethod \v!bottom \somebottomfloat
-\installfloatmethod \v!auto \someautofloat
-\installfloatmethod \v!margin \somemarginfloat
-\installfloatmethod \v!opposite \somefacefloat
-\installfloatmethod \v!page \somepagefloat
-\installfloatmethod \v!leftpage \someleftpagefloat
-\installfloatmethod \v!rightpage \somerightpagefloat
-\installfloatmethod \v!inmargin \someinmarginfloat
-\installfloatmethod \v!inleft \someinleftmarginfloat
-\installfloatmethod \v!inright \someinrightmarginfloat
-\installfloatmethod \v!leftmargin \someinleftmarginfloat
-\installfloatmethod \v!rightmargin \someinrightmarginfloat
-\installfloatmethod \v!leftedge \someinleftedgefloat
-\installfloatmethod \v!rightedge \someinrightedgefloat
-
-\installfloatmethod \v!somewhere \somesomewherefloat
-
-\installfloatmethod \v!backspace \somebackspacefloat
-\installfloatmethod \v!cutspace \somecutspacefloat
-
-\installfloatmethod {tblr} \someslotfloat
-\installfloatmethod {lrtb} \someslotfloat
-\installfloatmethod {tbrl} \someslotfloat
-\installfloatmethod {rltb} \someslotfloat
-\installfloatmethod {btlr} \someslotfloat
-\installfloatmethod {lrbt} \someslotfloat
-\installfloatmethod {btrl} \someslotfloat
-\installfloatmethod {rlbt} \someslotfloat
-\installfloatmethod {fxtb} \someslotfloat
-\installfloatmethod {fxbt} \someslotfloat
-
-% no \registerotrcommand\placesome* here!, this has to be cleaned up:
-
-\def\somesidefloat{\OTRcommand\somesidefloat}
-
-\def\someleftsidefloat [#1]{\somesidefloat[#1]\presetindentation}
-\def\somerightsidefloat [#1]{\somesidefloat[#1]}
-\def\sometopfloat [#1]{\someelsefloat[#1]\nonoindentation}
-\def\somebottomfloat [#1]{\someelsefloat[#1]}
-\def\someautofloat [#1]{\someelsefloat[#1]}
-\def\somemarginfloat [#1]{\page_margin_process_float{#1}\nonoindentation}
-\def\someinleftmarginfloat [#1]{\somesidefloat[#1]}
-\def\someinrightmarginfloat[#1]{\somesidefloat[#1]}
-\def\someinleftedgefloat [#1]{\somesidefloat[#1]}
-\def\someinrightedgefloat [#1]{\somesidefloat[#1]}
-\def\someinmarginfloat [#1]{\somesidefloat[#1]}
-\def\someherefloat [#1]{\someelsefloat[\v!here,#1]}
-\def\somebackspacefloat [#1]{\somesidefloat[#1]}
-\def\somecutspacefloat [#1]{\somesidefloat[#1]}
-
-\unexpanded\def\placesomeslotfloat {\OTRcommand\someslotfloat}
-\unexpanded\def\placesomeherefloat {\OTRcommand\someherefloat}
-\unexpanded\def\placesomefixdfloat {\OTRcommand\somefixdfloat}
-\unexpanded\def\placesomepagefloat {\OTRcommand\somepagefloat}
-\unexpanded\def\placesomeleftpagefloat {\OTRcommand\someleftpagefloat}
-\unexpanded\def\placesomerightpagefloat{\OTRcommand\somerightpagefloat}
-\unexpanded\def\placesometopsfloat {\OTRcommand\sometopsfloat}
-\unexpanded\def\placesomebotsfloat {\OTRcommand\somebotsfloat}
-\unexpanded\def\placesomesidefloat {\OTRcommand\somesidefloat}
-\unexpanded\def\placesomefacefloat {\OTRcommand\somefacefloat}
-%unexpanded\def\placesomesomewherefloat{\OTRcommand\somesomewherefloat}
-
-\def\somefixdfloat {\placesomefixdfloat}
-\def\somepagefloat {\placesomepagefloat}
-\def\someleftpagefloat {\placesomeleftpagefloat}
-\def\somerightpagefloat{\placesomerightpagefloat}
-\def\somefacefloat {\placesomefacefloat}
-\def\someslotfloat {\placesomeslotfloat}
+\unexpanded\def\installfloatmethod#1#2#3% routine keyword handler
+ {\setvalue{\??floatmethods#1:#2}{#3}}
+
+\definesystemconstant{tblr}
+\definesystemconstant{lrtb}
+\definesystemconstant{tbrl}
+\definesystemconstant{rltb}
+\definesystemconstant{btlr}
+\definesystemconstant{lrbt}
+\definesystemconstant{btrl}
+\definesystemconstant{rlbt}
+\definesystemconstant{fxtb}
+\definesystemconstant{fxbt}
+\definesystemconstant{fixd}
+
+\installfloatmethod \s!singlecolumn \v!here \page_one_place_float_here
+\installfloatmethod \s!singlecolumn \v!force \page_one_place_float_force
+\installfloatmethod \s!singlecolumn \v!left \page_one_place_float_left
+\installfloatmethod \s!singlecolumn \v!right \page_one_place_float_right
+\installfloatmethod \s!singlecolumn \v!text \page_one_place_float_text
+\installfloatmethod \s!singlecolumn \v!top \page_one_place_float_top
+\installfloatmethod \s!singlecolumn \v!bottom \page_one_place_float_bottom
+\installfloatmethod \s!singlecolumn \v!auto \page_one_place_float_auto
+\installfloatmethod \s!singlecolumn \v!margin \page_one_place_float_margin
+\installfloatmethod \s!singlecolumn \v!opposite \page_one_place_float_face
+\installfloatmethod \s!singlecolumn \v!page \page_one_place_float_page
+\installfloatmethod \s!singlecolumn \v!leftpage \page_one_place_float_leftpage
+\installfloatmethod \s!singlecolumn \v!rightpage \page_one_place_float_rightpage
+\installfloatmethod \s!singlecolumn \v!inmargin \page_one_place_float_inmargin
+\installfloatmethod \s!singlecolumn \v!inleft \page_one_place_float_leftmargin
+\installfloatmethod \s!singlecolumn \v!inright \page_one_place_float_rightmargin
+\installfloatmethod \s!singlecolumn \v!leftmargin \page_one_place_float_leftmargin
+\installfloatmethod \s!singlecolumn \v!rightmargin \page_one_place_float_rightmargin
+\installfloatmethod \s!singlecolumn \v!leftedge \page_one_place_float_leftedge
+\installfloatmethod \s!singlecolumn \v!rightedge \page_one_place_float_rightedge
+\installfloatmethod \s!singlecolumn \v!somewhere \page_one_place_float_somewhere
+\installfloatmethod \s!singlecolumn \v!backspace \page_one_place_float_backspace
+\installfloatmethod \s!singlecolumn \v!cutspace \page_one_place_float_cutspace
+\installfloatmethod \s!singlecolumn \s!tblr \page_one_place_float_top
+\installfloatmethod \s!singlecolumn \s!lrtb \page_one_place_float_top
+\installfloatmethod \s!singlecolumn \s!tbrl \page_one_place_float_top
+\installfloatmethod \s!singlecolumn \s!fxtb \page_one_place_float_top
+\installfloatmethod \s!singlecolumn \s!rltb \page_one_place_float_top
+\installfloatmethod \s!singlecolumn \s!btlr \page_one_place_float_bottom
+\installfloatmethod \s!singlecolumn \s!lrbt \page_one_place_float_bottom
+\installfloatmethod \s!singlecolumn \s!btrl \page_one_place_float_bottom
+\installfloatmethod \s!singlecolumn \s!rlbt \page_one_place_float_bottom
+\installfloatmethod \s!singlecolumn \s!fxbt \page_one_place_float_bottom
+\installfloatmethod \s!singlecolumn \s!fixd \page_one_place_float_force
+
+\installfloatmethod \s!multicolumn \v!here \page_mul_place_float_here
+\installfloatmethod \s!multicolumn \v!force \page_mul_place_float_force
+%installfloatmethod \s!multicolumn \v!left
+%installfloatmethod \s!multicolumn \v!right
+%installfloatmethod \s!multicolumn \v!text
+\installfloatmethod \s!multicolumn \v!top \page_mul_place_float_top
+\installfloatmethod \s!multicolumn \v!bottom \page_mul_place_float_bottom
+%installfloatmethod \s!multicolumn \v!auto
+%installfloatmethod \s!multicolumn \v!margin
+%installfloatmethod \s!multicolumn \v!opposite
+%installfloatmethod \s!multicolumn \v!page
+%installfloatmethod \s!multicolumn \v!leftpage
+%installfloatmethod \s!multicolumn \v!rightpage
+%installfloatmethod \s!multicolumn \v!inmargin
+%installfloatmethod \s!multicolumn \v!inleft
+%installfloatmethod \s!multicolumn \v!inright
+%installfloatmethod \s!multicolumn \v!leftmargin
+%installfloatmethod \s!multicolumn \v!rightmargin
+%installfloatmethod \s!multicolumn \v!leftedge
+%installfloatmethod \s!multicolumn \v!rightedge
+%installfloatmethod \s!multicolumn \v!somewhere
+%installfloatmethod \s!multicolumn \v!backspace
+%installfloatmethod \s!multicolumn \v!cutspace
+%installfloatmethod \s!multicolumn \s!tblr
+%installfloatmethod \s!multicolumn \s!lrtb
+%installfloatmethod \s!multicolumn \s!tbrl
+%installfloatmethod \s!multicolumn \s!rltb
+%installfloatmethod \s!multicolumn \s!fxtb
+%installfloatmethod \s!multicolumn \s!btlr
+%installfloatmethod \s!multicolumn \s!lrbt
+%installfloatmethod \s!multicolumn \s!btrl
+%installfloatmethod \s!multicolumn \s!rlbt
+%installfloatmethod \s!multicolumn \s!fxbt
+%installfloatmethod \s!multicolumn \s!fixd
+
+\installfloatmethod \s!columnset \v!here \page_set_place_float_here
+\installfloatmethod \s!columnset \v!force \page_set_place_float_force
+%installfloatmethod \s!columnset \v!left
+%installfloatmethod \s!columnset \v!right
+%installfloatmethod \s!columnset \v!text
+\installfloatmethod \s!columnset \v!top \page_set_place_float_top
+\installfloatmethod \s!columnset \v!bottom \page_set_place_float_bottom
+%installfloatmethod \s!columnset \v!auto
+%installfloatmethod \s!columnset \v!margin
+%installfloatmethod \s!columnset \v!opposite
+\installfloatmethod \s!columnset \v!page \page_set_place_float_page
+%installfloatmethod \s!columnset \v!leftpage
+%installfloatmethod \s!columnset \v!rightpage
+%installfloatmethod \s!columnset \v!inmargin
+%installfloatmethod \s!columnset \v!inleft
+%installfloatmethod \s!columnset \v!inright
+%installfloatmethod \s!columnset \v!leftmargin
+%installfloatmethod \s!columnset \v!rightmargin
+%installfloatmethod \s!columnset \v!leftedge
+%installfloatmethod \s!columnset \v!rightedge
+%installfloatmethod \s!columnset \v!somewhere
+%installfloatmethod \s!columnset \v!backspace
+%installfloatmethod \s!columnset \v!cutspace
+\installfloatmethod \s!columnset \s!tblr \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!lrtb \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!tbrl \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!rltb \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!fxtb \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!btlr \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!lrbt \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!btrl \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!rlbt \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!fxbt \page_set_place_float_slot
+\installfloatmethod \s!columnset \s!fixd \page_set_place_float_force
%D Local floats:
@@ -1934,8 +2063,6 @@
%\c!after=\blank,
\c!inbetween=\blank]
-\installfloatmethod \v!local \somelocalfloat
-
\initializeboxstack{localfloats}
\newcounter\noflocalfloats
@@ -1968,4 +2095,8 @@
\def\forcelocalfloats{\let\forcedfloatmethod\v!local}
+\installfloatmethod \s!singlecolumn \v!local \somelocalfloat
+\installfloatmethod \s!multicolumn \v!local \somelocalfloat
+\installfloatmethod \s!columnset \v!local \somelocalfloat
+
\protect \endinput
diff --git a/tex/context/base/strc-ind.mkiv b/tex/context/base/strc-ind.mkiv
new file mode 100644
index 000000000..4b65c7407
--- /dev/null
+++ b/tex/context/base/strc-ind.mkiv
@@ -0,0 +1,123 @@
+%D \module
+%D [ file=strc-ind, % was part of strc-des,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Indented Text,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Indented Text}
+
+\unprotect
+
+%D \macros
+%D {defineindentedtext,
+%D setupindentedtext}
+%D
+%D Ok, we keep it but with a different command as it all looks too
+%D much like indentation and indenting. We also assume start/stop
+%D usage or some explicit par.
+
+\installcorenamespace{indentedtext}
+
+\installcommandhandler \??indentedtext {indentedtext} \??indentedtext
+
+%D \startbuffer
+%D \defineindentedtext[one][text=one]
+%D \defineindentedtext[two][text=two]
+%D
+%D \one test test \par
+%D \subone test test \par
+%D \subtwo test test \par
+%D \subsubone test test \par
+%D
+%D \startone
+%D test test
+%D \startone
+%D test test
+%D \startone
+%D test test
+%D \stopone
+%D \starttwo
+%D test test
+%D \startone
+%D test test
+%D \stopone
+%D \stoptwo
+%D \stopone
+%D \stopone
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\newcount\c_strc_indentedtexts_nesting
+\newdimen\d_strc_indentedtexts_width
+
+\appendtoks
+ \setuevalue {\e!start\currentindentedtext}{\strc_indentedtexts_start{\currentindentedtext}\c_strc_indentedtexts_nesting}%
+ \setuevalue {\e!stop \currentindentedtext}{\strc_indentedtexts_stop}%
+ % to be avoided ... might go away
+ \setuevalue {\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{0}}%
+ \setuevalue {\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{1}}%
+ \setuevalue{\v!sub\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{2}}%
+\to \everydefineindentedtext
+
+\unexpanded\def\strc_indentedtexts_start#1#2%
+ {\par
+ \begingroup
+ \c_strc_indentedtexts_nesting#2\relax
+ \edef\currentindentedtext{#1}%
+ \indentedtextparameter\c!before
+ \doifnothing{\indentedtextparameter\c!sample}
+ {\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}%
+ \assignwidth
+ {\indentedtextparameter\c!width}
+ {\d_strc_indentedtexts_width}
+ {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
+ \indentedtextparameter\c!sample
+ \spr{\indentedtextparameter\c!separator}}
+ {\indentedtextparameter\c!distance}%
+ \advance\d_strc_indentedtexts_width \indentedtextparameter\c!distance
+ \setbox\scratchbox\hbox to \d_strc_indentedtexts_width
+ {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
+ \strut
+ \indentedtextparameter\c!text
+ \hss
+ \spr{\indentedtextparameter\c!separator}%
+ \hskip\indentedtextparameter\c!distance}%
+ \parindent\zeropoint
+ \hskip\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
+ \advance\c_strc_indentedtexts_nesting\plusone
+ \dontleavehmode\box\scratchbox
+ \hangindent\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
+ \useindentedtextstyleandcolor\c!style\c!color}
+
+\unexpanded\def\strc_indentedtexts_stop
+ {\indentedtextparameter\c!after
+ \par
+ \endgroup}
+
+\let\stopindentedtext\strc_indentedtexts_stop
+
+\unexpanded\def\strc_indentedtexts_direct#1#2#3\par % no longer clever grabpar trickery
+ {\strc_indentedtexts_start{#1}{#2}#3\strc_indentedtexts_stop}
+
+\setupindentedtext
+ [\c!style=\v!normal,
+ \c!headstyle=\v!normal,
+ %\c!color=,
+ %\c!headcolor=,
+ \c!width=\v!fit,
+ \c!text=\unknown,
+ %\c!sample=,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!distance=1em,
+ \c!separator={ :}]
+
+\protect \endinput
diff --git a/tex/context/base/strc-lab.mkiv b/tex/context/base/strc-lab.mkiv
new file mode 100644
index 000000000..447184fc0
--- /dev/null
+++ b/tex/context/base/strc-lab.mkiv
@@ -0,0 +1,96 @@
+%D \module
+%D [ file=strc-lab, % was part of strc-des,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Labels,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Labels}
+
+\unprotect
+
+% labels, we could share with enumerations and forget about the text; anyhow, figure
+% labels etc can use enumerations; we keep labels for compatibility reasons; we need
+% the slightly different namespace; we can still define structure counters directly
+% (multiple levels) and use an enumeration without following text
+
+% unfinished ... no longer okay
+
+\unexpanded\def\setuplabels
+ {\getparameters[\??db]}
+
+\unexpanded\def\definelabel
+ {\dotripleargumentwithset\dodefinelabel}
+
+\def\dodefinelabel[#1][#2][#3]% #2 or #3 assignment
+ {\doenumerationinit{#1}{1}\empty
+ \getparameters[\??dd#1][\c!command=,\c!state=\v!start,\c!location=,\c!text=#1]%
+ \ifsecondargument\doifassignmentelse{#2}\donetrue\donefalse\else\donetrue\fi
+ \ifdone
+ % an independent one
+ \getparameters[\??dd#1][\s!counter=#1,\s!parent=\??db,#2]%
+ \dodefinelabelcommands{#1}{\??db}%
+ \dodefineenumerationcounter{#1}%
+ \else
+ \getparameters[\??dd#1][\s!counter=#1,\s!parent=\??dd#2,#3]%
+ \dodefinelabelcommands{#1}{\??dd#2}%
+ \fi}
+
+\def\dodefinelabelcommands#1#2%
+ {\setuevalue {#1}{\noexpand\dolabelnumbercommand {#1}}%
+ \setuevalue{\c!reset #1}{\noexpand\doresetlabelnumber {#1}}%
+ %\setuevalue{\c!set #1}{\noexpand\dosetlabelnumber {#1}}% [#2] or {#2} ?
+ \setuevalue{\e!next #1}{\noexpand\donextlabelnumber {#1}}%
+ \setuevalue{\e!increment#1}{\noexpand\doincrementlabelnumber{#1}}%
+ \setuevalue{\c!current #1}{\noexpand\docurrentlabelnumber {#1}}}
+
+% this is just for downward compatibility, we might drop it
+
+\setvalue{\??db:\c!location:\v!inmargin}{\inmargin}
+\setvalue{\??db:\c!location:\v!inleft }{\inleft}
+\setvalue{\??db:\c!location:\v!inright }{\inright}
+\setvalue{\??db:\c!location:\v!margin }{\inmargin}
+
+\def\dolabelinit#1%
+ {\def\currentdescriptionmain{#1}%
+ \def\currentdescription {#1}%
+ \def\currentdescriptionlevel{1}}
+
+\def\docurrentlabelnumber #1{\dolabelinit{#1}\dosingleempty\dodocurrentlabelnumber}
+\def\donextlabelnumber #1{\dolabelinit{#1}\dosingleempty\dodonextlabelnumber}
+\def\dolabelnumbercommand #1{\dolabelinit{#1}\dosingleempty\dodolabelnumbercommand}
+
+\def\doresetlabelnumber #1{\dolabelinit{#1}\strc_counters_reset_sub \currentdescriptionnumber\currentdescriptionlevel}
+\def\dosetlabelnumber #1#2{\dolabelinit{#1}\strc_counters_set_sub \currentdescriptionnumber\currentdescriptionlevel{#2}}
+\def\doincrementlabelnumber #1{\dolabelinit{#1}\strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel}
+
+\def\dodocurrentlabelnumber[#1]%
+ {\dontleavehmode
+ \writestatus{!!!}{todo: reference of label}%
+ \dotextprefix{\descriptionparameter\c!text}%
+ \convertedsubstructurecounter[\currentdescriptionnumber][\currentdescriptionlevel]}
+
+\def\dodonextlabelnumber[#1]% todo: ref
+ {\strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel
+ \dodocurrentlabelnumber[\currentdescriptionnumber]}
+
+\def\dodolabelnumbercommand[#1]% todo: ref
+ {\dontleavehmode
+ \descriptionparameter\c!before
+ \begingroup
+ \strc_counters_increment_sub\currentdescriptionnumber\currentdescriptionlevel
+ \usedescriptionstyleandcolor\c!headstyle\c!headcolor
+ \executeifdefined{\??db:\c!location:\descriptionparameter\c!location}{\descriptionparameter\c!command}{\dodocurrentlabelnumber[#1]}%
+ \endgroup
+ \descriptionparameter\c!after}
+
+\setuplabels
+ [\s!parent=\??dn]
+
+\protect \endinput
diff --git a/tex/context/base/strc-lnt.mkiv b/tex/context/base/strc-lnt.mkvi
index c6224106c..dbb1dcc8b 100644
--- a/tex/context/base/strc-lnt.mkiv
+++ b/tex/context/base/strc-lnt.mkvi
@@ -58,7 +58,8 @@
{\dotripleempty\dodefinelinenote}
\def\dodefinelinenote[#1][#2][#3]%
- {\dodefinenote[#1][#2][#3]% do as we need to test for arguments
+% {\dodefinenote[#1][#2][#3]% do as we need to test for arguments
+ {\definenote[#1][#2][#3]%
\expandafter\let\csname\??vn:ln:#1\expandafter\endcsname\csname#1\endcsname % use copy command
\setuvalue {#1}{\dolinenote {#1}}%
\setuvalue{\e!start#1}{\dostartlinenote{#1}}%
@@ -68,7 +69,7 @@
% We predefine one, namely \type {\linenote} cum suis.
-\definelinenote[\v!linenote]
+% \definelinenote[\v!linenote]
% beware: line numbers are added later on so grouping setups is a bad idea
%
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index ba91e56bc..734ca3f7e 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -12,6 +12,8 @@ if not modules then modules = { } end modules ['strc-lst'] = {
-- shared cache [we can use a fast and stupid serializer]
-- todo: tag entry in list is crap
+--
+-- move more to commands
local format, gmatch, gsub = string.format, string.gmatch, string.gsub
local tonumber = tonumber
@@ -136,8 +138,24 @@ function lists.addto(t)
return p
end
-function lists.doifstoredelse(n)
- commands.doifelse(cached[tonumber(n)])
+function lists.discard(n)
+ n = tonumber(n)
+ if not n then
+ -- maybe an error message
+ elseif n == #cached then
+ cached[n] = nil
+ n = n -1
+ while n > 0 and cached[n] == false do
+ cached[n] = nil -- collect garbage
+ n = n - 1
+ end
+ else
+ cached[n] = false
+ end
+end
+
+function lists.iscached(n)
+ return cached[tonumber(n)]
end
-- this is the main pagenumber enhancer
@@ -525,7 +543,7 @@ end
function lists.location(n)
local l = lists.result[n]
- return l.references.internal or n
+ return l and l.references.internal or n
end
function lists.label(n,default)
@@ -553,35 +571,15 @@ function lists.title(name,n,tag) -- tag becomes obsolete
end
end
-function lists.savedtitle(name,n,tag)
+function lists.hastitledata(name,n,tag)
local data = cached[tonumber(n)]
if data then
local titledata = data.titledata
if titledata then
- helpers.title(titledata[tag] or titledata.title or "",data.metadata)
- end
- end
-end
-
-function lists.savednumber(name,n)
- local data = cached[tonumber(n)]
- if data then
- local numberdata = data.numberdata
- if numberdata then
- sections.typesetnumber(numberdata,"number",numberdata or false)
- end
- end
-end
-
-function lists.savedprefixednumber(name,n)
- local data = cached[tonumber(n)]
- if data then
- helpers.prefix(data,data.prefixdata)
- local numberdata = data.numberdata
- if numberdata then
- sections.typesetnumber(numberdata,"number",numberdata or false)
+ return (titledata[tag] or titledata.title or "") == ""
end
end
+ return false
end
function lists.haspagedata(name,n)
@@ -686,7 +684,7 @@ commands.listprefixednumber = lists.prefixednumber
commands.listprefixedpage = lists.prefixedpage
-function commands.addtolist (...) context(lists.addto (...)) end
+function commands.addtolist (...) context(lists.addto (...)) end -- we could use variables instead of print
function commands.listsize (...) context(lists.size (...)) end
function commands.listlocation(...) context(lists.location(...)) end
function commands.listlabel (...) context(lists.label (...)) end
@@ -705,12 +703,43 @@ function commands.listuserdata(...)
end
end
--- we could also set variables
+-- we could also set variables .. names will change (when this module is done)
+-- maybe strc_lists_savedtitle etc
-function commands.doiflisthaspageelse(...)
- commands.doifelse(lists.haspagedata(...))
+function commands.doiflisthastitleelse (...) commands.doifelse(lists.hastitledata (...)) end
+function commands.doiflisthaspageelse (...) commands.doifelse(lists.haspagedata (...)) end
+function commands.doiflisthasnumberelse(...) commands.doifelse(lists.hasnumberdata(...)) end
+function commands.doiflisthasentry (n) commands.doifelse(lists.iscached (n )) end
+
+function commands.savedlistnumber(name,n)
+ local data = cached[tonumber(n)]
+ if data then
+ local numberdata = data.numberdata
+ if numberdata then
+ sections.typesetnumber(numberdata,"number",numberdata or false)
+ end
+ end
+end
+
+function commands.savedlisttitle(name,n,tag)
+ local data = cached[tonumber(n)]
+ if data then
+ local titledata = data.titledata
+ if titledata then
+ helpers.title(titledata[tag] or titledata.title or "",data.metadata)
+ end
+ end
end
-function commands.doiflisthasnumberelse(...)
- commands.doifelse(lists.hasnumberdata(...))
+function commands.savedlistprefixednumber(name,n)
+ local data = cached[tonumber(n)]
+ if data then
+ helpers.prefix(data,data.prefixdata)
+ local numberdata = data.numberdata
+ if numberdata then
+ sections.typesetnumber(numberdata,"number",numberdata or false)
+ end
+ end
end
+
+commands.discardfromlist = lists.discard
diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi
index b0c2aa8c8..aa3da63e8 100644
--- a/tex/context/base/strc-lst.mkvi
+++ b/tex/context/base/strc-lst.mkvi
@@ -166,17 +166,40 @@
{\doif{\namedlistparameter{#tag}\c!state}\v!start
{\strc_lists_inject_yes[#tag][#settings,\c!type=\s!command][\s!command={#command}]}}
-\def\strc_lists_write_data_to[#tag][#settings][#userdata]% we can overload location
- {\doif{\namedlistparameter{#tag}\c!state}\v!start
- {\ifthirdargument
- \strc_lists_inject_yes[#tag][#settings,\c!type=\s!userdata][#userdata]%
- \else
- \strc_lists_inject_yes[#tag][\c!type=\s!userdata][#settings]%
- \fi}}
+% \def\strc_lists_write_data_to[#tag][#settings][#userdata]% we can overload location
+% {\doif{\namedlistparameter{#tag}\c!state}\v!start
+% {\ifthirdargument
+% \strc_lists_inject[#tag][#settings,\c!type=\s!userdata][#userdata]%
+% \else
+% \strc_lists_inject[#tag][\c!type=\s!userdata][#settings]%
+% \fi}}
+
+\def\strc_lists_write_data_to[#tag]% we can overload location
+ {\begingroup
+ \edef\currentlist{#tag}%
+ \doifelse{\namedlistparameter{#tag}\c!state}\v!start\strc_lists_write_data_to_yes\gobbletwooptionals}
-\def\strc_lists_write_to[#tag][#settings]#first#second% we can overload location
- {\doif{\namedlistparameter{#tag}\c!state}\v!start
- {\strc_lists_inject_yes[#tag][\c!location=\v!here,#settings,\c!type=\s!simple][\s!first={#first},\s!second={#second}]}}
+\def\strc_lists_write_data_to_yes[#settings][#userdata]% we can overload location
+ {\ifthirdargument % no need to have an extra step ... used seldom
+ \strc_lists_inject_yes[#settings,\c!type=\s!userdata][#userdata]%
+ \else
+ \strc_lists_inject_yes[\c!type=\s!userdata][#settings]%
+ \fi}
+
+% \def\strc_lists_write_to[#tag][#settings]#first#second% we can overload location
+% {\doif{\namedlistparameter{#tag}\c!state}\v!start
+% {\strc_lists_inject[#tag][\c!location=\v!here,#settings,\c!type=\s!simple][\s!first={#first},\s!second={#second}]}}
+
+\def\strc_lists_write_to[#tag]%
+ {\begingroup
+ \edef\currentlist{#tag}%
+ \doifelse{\namedlistparameter{#tag}\c!state}\v!start\strc_lists_write_to_yes\strc_lists_write_to_nop}
+
+\def\strc_lists_write_to_nop[#settings]#first#second%
+ {}
+
+\def\strc_lists_write_to_yes[#settings]#first#second%
+ {\strc_lists_inject[\c!location=\v!here,#settings,\c!type=\s!simple][\s!first={#first},\s!second={#second}]}
%D When placing a list either one or a set can be giving. This makes
%D it possible to flush for instance an nested (or merged) table of
@@ -568,6 +591,7 @@
% g : interaction
\installcorenamespace{listalternative} % specific ways of rendering a list
+\installcorenamespace{listrenderings} % a namespace for setups (rather local)
\installcommandhandler \??listalternative {listalternative} \??listalternative
@@ -713,7 +737,7 @@
% because we want to avoid redundant lua calls we expand the
% location beforehand
\ifx\currentlistentrylocation\empty
- \edef\currentlistentrylocation{\structurelistlocation}%
+ \edef\currentlistentrylocation{\structurelistlocation}% needs attention
\fi
% because these tests happen often and because we're dealing with
% rather complex composed data we have special conditionals; keep
@@ -741,18 +765,17 @@
{\the\t_lists_every_renderingsetup
\edef\currentlistalternative{\listparameter\c!alternative}%
\directsetup{\listalternativeparameter\c!renderingsetup}\relax
- \the\t_lists_every_renderingsetup}
+ \the\t_lists_every_renderingcleanup}
% todo: provide packager via attributes
\installcorenamespace{listalternativemethods} % the general wrapper of a rendering
-\installcorenamespace{listrenderings} % a namespace for setups (rather local)
-\startsetups[\??listrenderings:\v!none]
+\startsetups[\??listrenderings:none]
% nothing, nb we use the [] syntax here because we end with a \cs
\stopsetups
-\startsetups[\??listrenderings:\v!command]
+\startsetups[\??listrenderings:command]
\edef\p_command{\listalternativeparameter\c!command}%
\ifx\p_command\empty
[\currentlist: \currentlistentrynumber\space -- \currentlistentrytitle\space -- \currentlistentrypagenumber]%
diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua
index 65d806a64..66ec04739 100644
--- a/tex/context/base/strc-mar.lua
+++ b/tex/context/base/strc-mar.lua
@@ -655,12 +655,12 @@ function marks.fetchonemark (name,range,method) fetchonemark (name,range,method)
function marks.fetchtwomarks(name,range) fetchtwomarks(name,range ) end
function marks.fetchallmarks(name,range) fetchallmarks(name,range ) end
--- here we have a few helpers
+-- here we have a few helpers .. will become commands.*
function marks.title(tag,n)
local listindex = match(n,"^li::(.-)$")
if listindex then
- lists.savedtitle(tag,listindex,"marking")
+ commands.savedlisttitle(tag,listindex,"marking")
else
context(n)
end
@@ -669,7 +669,7 @@ end
function marks.number(tag,n) -- no spec
local listindex = match(n,"^li::(.-)$")
if listindex then
- lists.savednumber(tag,listindex)
+ commands.savedlistnumber(tag,listindex)
else
-- no prefix (as it is the prefix)
context(n)
diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua
index 07cd32496..6a3f3bfad 100644
--- a/tex/context/base/strc-not.lua
+++ b/tex/context/base/strc-not.lua
@@ -10,7 +10,8 @@ local format = string.format
local next = next
local texcount = tex.count
-local trace_notes = false trackers.register("structures.notes", function(v) trace_notes = v end)
+local trace_notes = false trackers.register("structures.notes", function(v) trace_notes = v end)
+local trace_references = false trackers.register("structures.notes.references", function(v) trace_references = v end)
local report_notes = logs.reporter("structure","notes")
@@ -44,7 +45,9 @@ function notes.store(tag,n)
local nnd = #nd + 1
nd[nnd] = n
local state = notestates[tag]
- if state.kind ~= "insert" then
+ if not state then
+ report_notes("unknown state for %s",tag)
+ elseif state.kind ~= "insert" then
if trace_notes then
report_notes("storing %s with state %s as %s",tag,state.kind,nnd)
end
@@ -53,17 +56,19 @@ function notes.store(tag,n)
context(#nd)
end
-local function get(tag,n)
+local function get(tag,n) -- tricky ... only works when defined
local nd = notedata[tag]
if nd then
n = n or #nd
nd = nd[n]
if nd then
if trace_notes then
- report_notes("getting note %s of '%s'",n,tag)
+ report_notes("getting note %s of '%s' with listindex '%s'",n,tag,nd)
end
-- is this right?
- local newdata = lists.collected[nd]
+-- local newdata = lists.collected[nd]
+ local newdata = lists.cached[nd]
+-- local newdata = lists.tobesaved[nd]
return newdata
end
end
@@ -161,10 +166,11 @@ end
local function internal(tag,n)
local nd = get(tag,n)
if nd then
+-- inspect(nd)
local r = nd.references
if r then
local i = r.internal
---~ return i and lists.internals[i]
+-- return i and lists.internals[i]
return i and references.internals[i] -- dependency on references
end
end
@@ -210,33 +216,6 @@ function notes.checkpagechange(tag) -- called before increment !
end
end
-function notes.deltapage(tag,n)
- -- 0:unknown 1:textbefore, 2:textafter, 3:samepage
- local what = 0
- local li = internal(tag,n)
- if li then
- local metadata, pagenumber = li.metadata, li.pagenumber
- if metadata and pagenumber then
- local symbolpage = references.symbolpage or 0
- local notepage = pagenumber.number or 0
- if notepage > 0 and symbolpage > 0 then
- if notepage < symbolpage then
- what = 1
- elseif notepage > symbolpage then
- what = 2
- else
- what = 3
- end
- end
- else
- -- might be a note that is not flushed due to to deep
- -- nesting in a vbox
- what = 3
- end
- end
- context(what)
-end
-
function notes.postpone()
if trace_notes then
report_notes("postponing all insert notes")
@@ -252,34 +231,79 @@ function notes.setsymbolpage(tag,n,l)
local l = l or notes.listindex(tag,n)
if l then
local p = texcount.realpageno
- if trace_notes then
- report_notes("note %s of '%s' with list index %s gets page %s",n,tag,l,p)
+ if trace_notes or trace_references then
+ report_notes("note %s of '%s' with list index %s gets symbol page %s",n,tag,l,p)
+ end
+ local entry = lists.cached[l]
+ if entry then
+ entry.references.symbolpage = p
+ else
+ report_notes("internal error: note %s of '%s' is not flushed",n,tag)
end
- lists.cached[l].references.symbolpage = p
else
report_notes("internal error: note %s of '%s' is not initialized",n,tag)
end
end
+-- function notes.getsymbolpage(tag,n)
+-- local nd = get(tag,n)
+-- local p = nd and nd.references.symbolpage or 0
+-- if trace_notes or trace_references then
+-- report_notes("page number of note symbol %s of '%s' is %s",n,tag,p)
+-- end
+-- context(p)
+-- end
+
function notes.getsymbolpage(tag,n)
- local nd = get(tag,n)
- local p = nd and nd.references.symbolpage or 0
- if trace_notes then
- report_notes("page number of note symbol %s of '%s' is %s",n,tag,p)
+ local li = internal(tag,n)
+ li = li and li.references
+ li = li and (li.symbolpage or li.realpage) or 0
+ if trace_notes or trace_references then
+ report_notes("page number of note symbol %s of '%s' is %s",n,tag,li)
end
- context(p)
+ context(li)
end
function notes.getnumberpage(tag,n)
local li = internal(tag,n)
li = li and li.references
li = li and li.realpage or 0
- if trace_notes then
+ if trace_notes or trace_references then
report_notes("page number of note number %s of '%s' is %s",n,tag,li)
end
context(li)
end
+function notes.deltapage(tag,n)
+ -- 0:unknown 1:textbefore, 2:textafter, 3:samepage
+ local what = 0
+
+-- references.internals[lists.tobesaved[nd].internal]
+
+ local li = internal(tag,n)
+ if li then
+ local references = li.references
+ if references then
+ local symbolpage = references.symbolpage or 0
+ local notepage = references.realpage or 0
+ if trace_references then
+ report_notes("note number %s of '%s' points from page %s to page %s ",n,tag,symbolpage,notepage)
+ end
+ if notepage < symbolpage then
+ what = 3 -- after
+ elseif notepage > symbolpage then
+ what = 2 -- before
+ elseif notepage > 0 then
+ what = 1 -- same
+ end
+ else
+ -- might be a note that is not flushed due to to deep
+ -- nesting in a vbox
+ end
+ end
+ context(what)
+end
+
function notes.flush(tag,whatkind,how) -- store and postpone
local state = notestates[tag]
local kind = state.kind
@@ -357,12 +381,12 @@ function notes.resetpostponed()
end
end
-function notes.title(tag,n)
- lists.savedtitle(tag,notedata[tag][n])
+function commands.notetitle(tag,n)
+ command.savedlisttitle(tag,notedata[tag][n])
end
-function notes.number(tag,n,spec)
- lists.savedprefixednumber(tag,notedata[tag][n])
+function commands.noteprefixednumber(tag,n,spec)
+ commands.savedlistprefixednumber(tag,notedata[tag][n])
end
function notes.internalid(tag,n)
diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv
deleted file mode 100644
index 77404ccd6..000000000
--- a/tex/context/base/strc-not.mkiv
+++ /dev/null
@@ -1,1423 +0,0 @@
-%D \module
-%D [ file=strc-not,
-%D version=2008.10.20,
-%D title=\CONTEXT\ Structure Macros,
-%D subtitle=Note Handling,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Structure Macros / Note Handling}
-
-\registerctxluafile{strc-not}{1.001}
-
-\unprotect
-
-% this needs a further cleanup ...
-%
-% -- set breakpoint in descriptions
-% -- reset after trialtypesetting
-% -- that way we can trick the symbol space
-
-% removed:
-%
-% \pushsomestates
-%
-% core-ins -> obsolete
-%
-% saveinsertiondata
-% restoreinsertiondata
-% saveinsertionbox
-% eraseinsertionbackup
-% restoreinsertionbackup
-
-\def\savenotedata {} % \writestatus{todo}{save note data}}
-\def\restorenotedata {} % \writestatus{todo}{restore note data}}
-\def\savenotecontent {} % \writestatus{todo}{save note content}}
-\def\restorenotecontent{} % \writestatus{todo}{restore note content}}
-\def\erasenotebackup {} % \writestatus{todo}{erase note backup}}
-
-% page-set:
-
-\def\enablenotes {\writestatus{todo}{enable notes}}
-\def\disablenotes {\writestatus{todo}{disable notes}}
-\def\savenotes {\writestatus{todo}{save notes}}
-\def\flushsavednotes{\writestatus{todo}{flush notes}}
-
-% experiment: (compare scope=text and scope=page)
-%
-% \definenote[mynote][way=bytext,location=text,width=\leftmarginwidth,scope=page,rule=,before=,after=,factor=0]
-% \setuptexttexts[margin][\vbox to \textheight{\placenotes[mynote]\vfill}][]
-
-%D Footnotes are can be characterized by three components:
-%D
-%D \startitemize[packed]
-%D \item a small number \footnote {a footnote number} or
-%D symbol {\setupfootnotes [conversion=set 2]\footnote
-%D {a footnote}}
-%D \item and a similar mark at the bottom of the page
-%D \item followed by some additional text
-%D \stopitemize
-%D
-%D Because footnotes are declared at the location of their
-%D reference they can be seen as a special kind of
-%D floating bodies. Their placement is postponed but has to be
-%D taken into account in the pagebreak calculations. This kind
-%D of calculations are forced by using \type{\insert}s and dealing
-%D with all cases is not trivial.
-
-%D \macros
-%D {notesenabled}
-%D
-%D We need a couple of states because at some moments we don't want
-%D to mess around with inserts at all. Take for instance a table
-%D of contents. And so we can temporary disable footnotes by saying
-%D
-%D \starttyping
-%D \notesenabledfalse
-%D \stoptyping
-
-\newif\ifnotesenabled \notesenabledtrue
-
-% better mark a note .. once flushed no more flushing
-
-%appendtoks \notesenabledfalse \to \everymarking
-\appendtoks \notesenabledfalse \to \everybeforepagebody
-\appendtoks \notesenabledfalse \to \everystructurelist % quick hack
-
-%D Often we need to process the whole set of notes and to make that
-%D fast, we use a token register:
-
-\newtoks\tobeprocessednotes
-
-\unexpanded\def\processnotes#1% #1: \macro that uses \currentnote
- {\def\doprocesssomenote##1{\edef\currentnote{##1}\let\currentdescription\currentnote#1}%
- \the\tobeprocessednotes}
-
-%D Notes have their own parameter handlers. The complication here
-%D is that we use descriptions to typeset the note, so we have several
-%D resolvers.
-
-% will be commandhandler (but we need a finalizer for setup and define (just after \every)
-
-\let\currentnote\v!footnote
-
-\def\noteparameter #1{\csname\donoteparameter{\??vn\currentnote}#1\endcsname}
-\def\noteparameterhash#1{\donoteparameterhash {\??vn\currentnote}#1}
-
-\def\namednoteparameter#1#2{\csname\donoteparameter{\??vn#1}#2\endcsname}
-
-\def\donoteparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\donoteparentparameter \csname#1\s!parent\endcsname#2\fi}
-\def\donoteparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\donoteparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-
-\def\donoteparentparameter #1#2{\ifx#1\relax\s!empty\else\donoteparameter #1#2\fi}
-\def\donoteparentparameterhash#1#2{\ifx#1\relax \else\donoteparameterhash#1#2\fi}
-
-\def\detokenizednoteparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??vn#1\endcsname}}
-
-\def\usenotestyleandcolor#1#2% style color
- {\edef\currentstyleparameter{\noteparameter#1}%
- \edef\currentcolorparameter{\noteparameter#2}%
- \ifx\currentstyleparameter\empty\else\dousestyleparameter\currentstyleparameter\fi
- \ifx\currentcolorparameter\empty\else\dousecolorparameter\currentcolorparameter\fi}
-
-\def\setnoteparameter#1{\dosetvalue{\??vn\currentnote}{#1}}
-
-%D \macros
-%D {setupnote,setupnotedefinition}
-%D
-%D We can influence footnote typesetting with the setup
-%D command:
-%D
-%D \showsetup{setupnotes}
-%D \showsetup{setupnote}
-%D
-%D The definition command indicate that we can frame the footnote
-%D area. The footnotes themselves are treated as descriptions.
-%D
-%D \showsetup{definenote}
-%D
-%D It's sort of a custom to precede footnotes by a horizontal
-%D rule and although fancy rules like
-%D
-%D \starttyping
-%D \hbox to 10em{\hskip-3em\dotfill}
-%D \stoptyping
-%D
-%D Are quite ligitimate, we default to a simple one 20\% of the
-%D text width.
-
-\unexpanded\def\setupnotes
- {\dodoubleargument\getparameters[\??vn]}
-
-\setupnotes
- [\c!location=\v!page,
- \c!way=\v!by\v!part,
- %\c!conversion=,
- \c!rule=\v!on,
- \c!before=\blank,
- \c!bodyfont=\v!small,
- %\c!style=,
- %\c!color=,
- %\c!after=,
- %\c!rulecolor=,
- \c!rulethickness=\linewidth,
- \c!frame=\v!off,
- \c!margindistance=.5em,
- \c!columndistance=1em,
- \c!distance=.125em,
- \c!align=\v!normal,
- \c!tolerance=\v!tolerant,
- \c!split=\v!tolerant,
- %\c!width=\makeupwidth,
- %\c!width=\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi,
- \c!width=\defaultnotewidth,
- \c!height=\textheight,
- \c!numbercommand=\high,
- \c!command=, % \noteparameter\c!numbercommand, % (command in enumeration) too messy, called twice
- \c!separator=,% \@@koseparator,
- \c!textcommand=\high,
- \c!textstyle=\tx,
- %\c!textcolor=,
- \c!interaction=\v!yes,
- %\c!factor=,
- %\c!scope=, % \v!text \v!page
- \c!prefixconnector=.,
- %\c!next=\autoinsertnextspace,
- \c!prefix=\v!no,
- %\c!continue=\v!no,
- \c!paragraph=\v!no,
- \c!inbetween=\hskip1em,
- \c!symbol=\mathematics{*},
- \c!n=1]
-
-\setupnotes
- [\c!expansion=\v!no,
- \c!xmlsetup=,
- \s!catcodes=,
- \c!saveinlist=\v!yes]
-
-\def\@@defaultnotedefloc{\v!inleft}
-\def\@@defaultnotedefdis{\!!zeropoint}
-
-\unexpanded\def\startnotedef{\resetdescriptions\csname\e!start\??vn\??vn\currentnote\endcsname}
-\unexpanded\def\stopnotedef {\csname\e!stop \??vn\??vn\currentnote\endcsname}
-
-\def\currentnoteins{\csname\??vn:\currentnote\endcsname}
-
-\newtoks \everysetupnote
-
-\unexpanded\def\definenote
- {\dotripleempty\dodefinenote}
-
-\def\dodefinenote[#1][#2][#3]% note [parent] [settings]
- {\edef\currentnote{#1}%
- \ifcsname\??vn:\currentnote\endcsname\else
- \@EA\installinsertion\csname\??vn:\currentnote\endcsname\relax
- \appendtoks\doprocesssomenote{#1}\to\tobeprocessednotes
- \fi
- \ifsecondargument
- \doifassignmentelse{#2}{\dodefinenotewithsettings{#2}}{\dodefinenotewithparent{#2}{#3}}%
- \else
- \dodefinenotesimple
- \fi
- \ctxlua{structures.notes.define("\currentnote","insert",\number\csname\??vn:\currentnote\endcsname)}%
- \the\everysetupnote
- \dochecknote}
-
-\def\dodefinenotesimple
- {\defineenumeration
- [\currentnote]
- [\s!handler=\v!note,
- \c!text=,
- \c!location=\@@defaultnotedefloc,
- \c!distance=\@@defaultnotedefdis,
- \c!width=\v!fit,
- \c!headstyle=\noteparameter\c!style,
- \c!headcolor=\noteparameter\c!color,
- \c!before=,
- \c!after=]%
- \doredefinenotecommands
- \presetlocalframed
- [\??vn\currentnote]%
- \setupenumerations
- [\currentnote]
- [\s!parent=\??vn\currentnote,
- \c!number=\v!yes]% no inheritance from decriptions which is okay
- \getparameters
- [\??vn\currentnote]
- [\s!parent=\??vn]}
-
-\def\dodefinenotewithsettings#1%
- {\defineenumeration % description
- [\currentnote]
- [\s!handler=\v!note,
- \c!text=,
- \c!location=\@@defaultnotedefloc,
- \c!distance=\@@defaultnotedefdis,
- \c!width=\v!fit,
- \c!headstyle=\noteparameter\c!style,
- \c!headcolor=\noteparameter\c!color,
- \c!before=,
- \c!after=]%
- \doredefinenotecommands
- \presetlocalframed
- [\??vn\currentnote]%
- \setupenumerations
- [\currentnote]
- [\s!parent=\??vn\currentnote,
- \c!number=\v!yes]%
- \getparameters
- [\??vn\currentnote]
- [\s!parent=\??vn,#1]}
-
-\def\dodefinenotewithparent#1#2%
- {%setevalue{\??vn:#2:kids}{\ifcsname\??vn:#2:kids\endcsname\csname\??vn:#2:kids\endcsname,\fi#1}%
- \defineenumeration
- [\currentnote]
- [\s!handler=\v!note,
- \c!text=]%
- \doredefinenotecommands
- \presetlocalframed
- [\??vn\currentnote]%
- \setupenumerations
- [\currentnote]
- [\s!parent=\??dd#1,
- \c!number=\v!yes]%
- \getparameters
- [\??vn\currentnote]
- [\s!parent=\??vn#1,#2]}
-
-% \starttext
-% text \startfootnote Test.\stopfootnote
-% test \footnote{xxxx} \subfootnote{xxxx}
-% test \footnote{xxxx} \subfootnote{xxxx}
-% \stoptext
-
-\def\dodoredefinenotecommands#1#2#3%
- {\unexpanded\expandafter\def\csname\e!start#3#1\expandafter\endcsname\expandafter
- {\expandafter\dosingleempty\csname\s!do\e!start#3#1\endcsname}%
- \unexpanded\expandafter\def\csname\s!do\e!start#3#1\expandafter\endcsname
- \expandafter[\expandafter##\expandafter1\expandafter]\expandafter##\expandafter2\csname\e!stop#3#1\endcsname
- {\begingroup
- \doenumerationinit{#1}{#2}{#3}%
- \@@notemakedescription[##1]{}{##2}%
- \expandafter\endgroup\noteparameter\c!next}} % WS: added \noteparameter\c!next
-
-\def\doredefinenotecommands
- {\normalexpanded{\noexpand\dodoredefinenotecommands{\currentnote}{1}{}}%
- \let\@@subslevel\empty
- \dostepwiserecurse{2}{\descriptionparameter\c!levels}{1}
- {\normalexpanded{\noexpand\dodoredefinenotecommands{\currentnote}{\recurselevel}{\@@subslevel\v!sub}}%
- \edef\@@subslevel{\@@subslevel\v!sub}}}
-
-\let\setupnotedefinition\setupenumerations
-
-% \def\dodowithcurrentnoteandkids#1#2% action kid
-% {\pushmacro\currentnote
-% \def\currentnote{#2}%
-% \dowithcurrentnoteandkids{#1}% recursive
-% \popmacro\currentnote}%
-
-\appendtoks
- \setupenumerations[\currentnote][]%
-\to \everysetupnote
-
-\unexpanded\def\setupnote
- {\dodoubleempty\dosetupnote}
-
-\def\dosetupnote[#1][#2]%
- {\edef\currentnote{#1}%
- \ifsecondargument
- \getparameters[\??vn\currentnote][#2]%
- \the\everysetupnote
- \fi
- \dochecknote}
-
-\def\currentnoterulecommand{\csname\??vn\c!rule:c:\currentnote\endcsname}
-\def\currentnoterulealign {\csname\??vn\c!rule:a:\currentnote\endcsname}
-
-\def\currentnoterulecommandnormal {\normalnoterule} % no let as it can be changed afterwards
-\def\currentnoterulecommandunknown{\noteparameter\c!rule}
-
-\def\letcurrentnoterulecommand{\expandafter\let\csname\??vn\c!rule:c:\currentnote\endcsname}
-\def\letcurrentnoterulealign {\expandafter\let\csname\??vn\c!rule:a:\currentnote\endcsname}
-
-\appendtoks
- \letvalue{\??vn\c!rule:c:\currentnote}\currentnoterulecommandnormal
- \letvalue{\??vn\c!rule:a:\currentnote}\lefttoright
-\to \everysetupnote
-
-\appendtoks
- \processallactionsinset[\noteparameter\c!rule]
- [ \v!on=>\letcurrentnoterulecommand\currentnoterulecommandnormal,
- \v!normal=>\letcurrentnoterulecommand\currentnoterulecommandnormal,
- \v!left=>\letcurrentnoterulealign \lefttoright,
- \v!right=>\letcurrentnoterulealign \righttoleft,
- \v!off=>\letcurrentnoterulecommand\relax,
- \s!default=>\letcurrentnoterulecommand\relax,
- \s!unknown=>\letcurrentnoterulecommand\currentnoterulecommandunknown]%
-\to \everysetupnote
-
-\def\currentnotepenalty
- {\ifcsname\??vn\c!split:p:\noteparameter\c!split\endcsname
- \csname\??vn\c!split:p:\noteparameter\c!split\endcsname
- \else
- \numexpr\noteparameter\c!split\relax
- \fi}
-
-\setnewconstant\notepenaltytolerant \zerocount
-\setnewconstant\notepenaltystrict 9999
-\setnewconstant\notepenaltyverystrict\maxdimen
-
-\letvalue{\??vn\c!split:p:\v!tolerant }\notepenaltytolerant
-\letvalue{\??vn\c!split:p:\v!strict }\notepenaltystrict
-\letvalue{\??vn\c!split:p:\v!verystrict}\notepenaltyverystrict
-\letvalue{\??vn\c!split:p:\empty }\notepenaltytolerant
-
-\appendtoks
- \edef\currentnotewidth{\noteparameter\c!width}%
- \ifx\currentnotewidth\empty
- \setnoteparameter\c!width{\hsize}%
- \else
- % \doifdimensionelse\currentnotewidth\donothing
- % {\setnoteparameter\c!width{\hsize}}%
- \fi
-\to \everysetupnote
-
-%D The following switch can be used to disable limiting the
-%D height of the footnote area, something that is needed in
-%D multi column balancing. Use this switch with care.
-
-\newif\ifnotelimit \notelimittrue % shared
-
-% bottomnotes endnotes
-% clevernotes
-
-\appendtoks
- \doifsomething{\noteparameter\c!factor}
- {\ifnum\noteparameter\c!factor<\zerocount\else
- \count\currentnoteins\noteparameter\c!factor
- \fi}%
-\to \everysetupnote
-
-% compatibility (will go away)
-
-\newif\ifbottomnotes % still used in page-one.mkiv
-%newif\endnotes % no longer used
-
-% locations:
-
-\def\s!noteloc{nodeloc} % 1=page 2=columns 3=lastcolumn 4=firstcolumn 5=none
-\def\s!notepos{nodepos} % 0=nothing 1=high 2=bottom
-\def\s!notefmt{nodefmt} % 1 text
-\def\s!notecol{nodecol}
-
-\def\clevernotes % compatibility hack, will be redone
- {\numexpr\ifcase\namednoteparameter\v!footnote\s!noteloc\or0\or2\or2\or1\else0\fi\relax}
-
-\def\setnotelocation #1{\expandafter\let\csname\??vn\currentnote\s!noteloc\endcsname#1\relax}
-\def\setnoteposition #1{\expandafter\let\csname\??vn\currentnote\s!notepos\endcsname#1\relax}
-\def\setnoteformatting#1{\expandafter\let\csname\??vn\currentnote\s!notefmt\endcsname#1\relax}
-
-\def\currentnofcolumns{\@@kln}
-
-\setvalue{\??vn @\v!page }{\setnotelocation\plusone}
-\setvalue{\??vn @\v!columns }{\setnotelocation\plustwo}
-\setvalue{\??vn @\v!lastcolumn }{\setnotelocation\plusthree}
-\setvalue{\??vn @\v!firstcolumn}{\setnotelocation\plusfour}
-\setvalue{\??vn @\v!none }{\setnotelocation\plusfive}
-\setvalue{\??vn @\v!text }{\setnotelocation\plusfive \setnoteformatting\plusone} % test
-\setvalue{\??vn @\v!high }{\setnoteposition\plusone}
-\setvalue{\??vn @\v!bottom }{\setnoteposition\plustwo}
-
-\def\dosetcheckednote#1{\csname\??vn @#1\endcsname}
-
-\newtoks\everychecknote
-
-\def\dochecknote
- {% node states
- \setnotelocation\plusone % page
- \setnoteposition\plustwo % bottom
- \normalexpanded{\rawprocesscommalist[\noteparameter\c!location]}\dosetcheckednote
- % compatibility hack
- %ifnum\noteparameter\s!noteloc=\plusfive \endnotestrue \else \endnotesfalse \fi
- \ifnum\noteparameter\s!notepos=\plustwo \bottomnotestrue \else \bottomnotesfalse \fi
- % set column multiplier
- \edef\currentnotenofcolumns{\noteparameter\c!n}%
- \ifx\currentnotenofcolumns\empty
- \let\currentnotenofcolumns\!!plusone
- \fi
- \ifcase\noteparameter\s!noteloc
- % can't happen
- \scratchcounter\plusone
- \or
- % page
- \scratchcounter \currentnotenofcolumns
- \or
- % columns
- \scratchcounter\ifnum\currentnofcolumns=\zerocount \plusone \else \currentnotenofcolumns \fi \relax
- \or
- % firstcolumn
- \scratchcounter\plusone
- \or
- % lastcolumn
- \scratchcounter\plusone
- \or
- % text
- \scratchcounter\currentnotenofcolumns
- \fi
- % column factor
- \ifcase\scratchcounter
- \scratchcounter\plusone
- \fi
- \global\count\currentnoteins\plusthousand
- \global\count\currentnoteins\numexpr\plusthousand/\scratchcounter\relax
- % maximize height
- \ifnotelimit
- \global\dimen\currentnoteins\dimexpr\noteparameter\c!height*\scratchcounter\relax
- \fi
- % distance -> tricky as this might depend on a font switch so we need a fast checker
- \dosetnotedistance
- % play safe
- \ifnum\noteparameter\s!noteloc=\plusfive
- \ctxlua{structures.notes.setstate("\currentnote","store")}%
- % text notes (e.g. end notes) but we don't use inserts anyway
- \global\dimen\currentnoteins\maxdimen
- \global\count\currentnoteins\zerocount
- \global\skip \currentnoteins\zeropoint
- \else
- % nothing ?
- \fi
- \the\everychecknote}
-
-\def\dosetnotedistance
- {\begingroup
- \setbox\scratchbox\vbox
- {\forgetall
-% \setnotebodyfont
- \dontcomplain
- \noteparameter\c!before
- \placenoterule
- \noteparameter\c!after}%
- \global\skip\currentnoteins\ht\scratchbox
- \endgroup}
-
-%D A fast checker for bottom notes being used:
-
-\newconditional\c_notes_bottom_present
-
-\def\strc_notes_check_if_bottom_present_indeed
- {\ifnum\noteparameter\s!notepos=\plustwo
- \settrue\c_notes_bottom_present
- \fi}
-
-\def\strc_notes_check_if_bottom_present
- {\setfalse\c_notes_bottom_present
- \processnotes{\ifconditional\c_notes_bottom_present\else\strc_notes_check_if_bottom_present_indeed\fi}}
-
-% D When \type{n} exceeds~1, footnotes are typeset in
-% D multi||columns, using the algoritm presented on page~397
-% D of \TEX book. Footnotes can be places on a per page basis
-% D or whereever suitable. When we set~\type{n} to~0, we get a
-% D rearanged paragraph, typeset by the algoritms on pages 398
-% D and~389 (at least in \MKII). We definitely did not reinvent
-% D that wheel.
-
-% Example of using factor:
-%
-% \definenote[mynote][way=bypage,location=text,width=\marginwidth,rule=,before=,factor=0]
-% \setuplayout[backspace=5cm,margin=3cm,margindistance=.5cm,width=middle]
-% \setuptexttexts[margin][\vbox to \textheight{\placenotes[mynote]\vfill}][]
-% \starttext
-% \dorecurse{10}{test \mynote{one one one one one one} \input zapf \mynote{one one one one one one} }
-% \stoptext
-
-%D The noterule can be a graphic and therefore calling this
-%D setup macro at every skipswitch is tricky (many many MP
-%D runs). Let's just reserve a few points, that probably match
-%D those of the stretch component.
-
-%D A bit messy:
-
-\unexpanded\def\placenoterule
- {\bgroup
- \currentnoterulealign
- \currentnoterulecommand
- \par
- \egroup}
-
-\unexpanded\def\normalnoterule
- {\ifvmode
- \dontleavehmode \blackrule
- [ \c!color=\noteparameter\c!rulecolor,
- \c!width=.2\hsize,
- \c!height=\noteparameter\c!rulethickness,
- \c!depth=\zeropoint]%
- \endgraf
- \kern\strutdepth
- \fi}
-
-\ifx\setnotehsize\undefined
-
- \unexpanded\def\setnotehsize{\hsize\noteparameter\c!width\relax} % can be overloaded
-
-\fi
-
-%D The formatting depends on the width of the table, so we
-%D have to set \type {n} to zero.
-%D
-%D \starttyping
-%D \startbuffer
-%D \bTABLE
-%D \bTR \bTD one \footnote{\dorecurse{10}{abcd }} \eTD \bTD two \eTD \eTR
-%D \bTR \bTD three fout five six seven eight nine \eTD \bTD ten \eTD \eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \startlocalfootnotes[n=0,location={text,none}]
-%D \placelegend[n=2]{\getbuffer}{\placelocalfootnotes}
-%D \stoplocalfootnotes
-%D \stoptyping
-
-%D \macros
-%D {footnote}
-%D
-%D A footnote can have a reference as optional argument and
-%D therefore its formal specification looks like:
-%D
-%D \showsetup{footnote}
-%D
-%D This command has one optional command: the reference. By
-%D saying \type{[-]} the number is omitted. The footnote
-%D command is not that sensitive to spacing, so it's quite
-%D legal to say:
-%D
-%D \startbuffer
-%D Users of \CONTEXT\ must keep both feet \footnote{Given they
-%D have two.} on the ground and not get confused \footnote{Or
-%D even crazy.} by all those obscure \footnote{But fortunately
-%D readable.} parameters.
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D When setting the \type{conversion} to \type{set 2} we get
-%D something like:
-%D
-%D \bgroup
-%D \startnarrower
-%D \setupfootnotes[conversion=set 1]
-%D \getbuffer
-%D \stopnarrower
-%D \egroup
-%D
-%D Typesetting footnotes is, at least for the moment, disabled
-%D when reshaping boxes.
-%D
-%D The additional macro \type {\footnotetext} and the
-%D associated \type {\note} macro were implemented at
-%D request of users on the mailing list and a suggestion by
-%D taco to split of the symbol placement. I decided to
-%D merge this functionality with the existing \type {\note}
-%D functionality.
-
-%D The next implementation runs on top of enumerations (only in \MKIV).
-%D
-%D \starttyping
-%D \setupenumerations
-%D [footnote]
-%D [ style=\type{(es)},
-%D headstyle=\type{(hs)}]
-%D
-%D \setupnote
-%D [footnote]
-%D [ style=\type{(s)},
-%D command=\type{(c)},
-%D textcommand=\type{(tc)},
-%D textstyle=\type{(ts)},
-%D numberstyle=\type{(ns)},
-%D numbercommand=\type{(nc)}]
-%D
-%D \setuplayout[backspace=6cm,marginwidth=cm,width=middle]
-%D
-%D \starttext
-%D \dorecurse{9}{This\footnote{Hello World #1} is a test.\par }
-%D \stoptext
-%D \stoptyping
-
-% TODO: \ifnotesenabled
-
-\newif\ifnotesymbol \notesymboltrue
-
-\newconditional\skipnoteplacement
-
-\unexpanded\def\setnote [#1]{\getvalue{#1}}
-\unexpanded\def\setnotetext[#1]{\global\settrue\skipnoteplacement\getvalue{#1}}
-
-\def\domovednote#1#2#3#4%
- {\ifcase\ctxlua{structures.notes.deltapage("#1",#2)}\or\symbol[#3]\or\symbol[#4]\fi}
-
-\setvalue{\??dd:\v!note:\s!handler:\s!text }{\@@donotetext}
-\setvalue{\??dd:\v!note:\s!handler:\s!number}{\@@donotenumber}
-\setvalue{\??dd:\v!note:\s!handler:\s!symbol}{\@@donotesymbol}
-\setvalue{\??dd:\v!note:\s!handler }{\@@donotehandler}
-\setvalue{\??dd:\v!note:\s!handler:\s!do }{\@@somenotedescription}
-\setvalue{\??dd:\v!note:\s!handler:\s!start }{\@@startsomenotedescription}
-
-\let\@@donotehandler\@@dodescriptionhandler
-
-\def\@@somenotedescription {\@@notemakedescription}
-\def\@@startsomenotedescription{\@@notemakedescription}
-
-\def\@@notemakedescription[#1]#2#3%
- {\ifnotesenabled
- \edef\currentdescriptionreference{#1}%
- \iftrialtypesetting
- \doenumerationcheckconditions
- \let\currentnote\currentdescriptionmain
- \typesetdummynotesymbol
- \else
- \begingroup
- \doenumerationcheckconditions
- \let\currentnote\currentdescriptionmain
- \dodescriptioncomponent[\c!reference=#1,\c!label={\descriptionparameter\c!text},\c!title={#3},\c!list=,\c!bookmark=,][]%
- \xdef\currentnotenumber{\ctxlua{structures.notes.store("\currentnote",\currentdescriptionnumberentry)}}%
- \settrue\processingnote
- \ifconditional\skipnoteplacement
- \globallet\lastnotesymbol\dolastnotesymbol
- \else
- \iftypesettinglines % otherwise problems with \type <crlf> {xxx}
- \ignorelines % makes footnotes work in \startlines ... \stoplines
- \fi
- \ifnotesymbol
- \dolastnotesymbol
- \else
- \unskip\unskip
- \globallet\lastnotesymbol\dolastnotesymbol
- \fi
- \fi
- \ifconditional\postponingnotes % todo: per note class
- \global\settrue\postponednote
- \else\ifconditional\inlocalnotes % todo: per note class
- \global\settrue\postponednote
- \else
- \handlenoteinsert\currentnote\currentnotenumber
- \fi\fi
- \endgroup
- \fi
- \fi
- \ifconditional\skipnoteplacement
- \global\setfalse\skipnoteplacement
- \else
- \kern\notesignal\relax % \relax is needed to honor spaces
- \fi}
-
-\def\dolastnotesymbol
- {\typesetsomenotesymbol\currentnote\currentnotenumber\currentdescriptionnumberentry}
-
-\ifdefined\dotagsetnotesymbol \else \let\dotagsetnotesymbol\relax \fi
-
-\def\dotypesetsomenotesymbol#1#2#3% running text (messy: #1 and current mixed)
- {\dodonotesymbol
- {\synchronizesomenotesymbol{#1}{#2}{#3}%
-% \ctxlua{structures.notes.number("\currentnote",\currentnotenumber)}% \currentdescriptionnumberentry
- \dostarttagged\t!descriptionsymbol\currentnote
- \dotagsetnotesymbol
- \ctxlua{structures.notes.number("#1",#2)}%
- \dostoptagged
- \domovednote{#1}{#2}\v!previouspage\v!nextpage}}
-
-\unexpanded\def\typesetsomenotesymbol#1#2#3% running text
- {\removeunwantedspaces
- \doifitalicelse\/\donothing % Charles IV \footnote{the fourth}
- \ifdim\lastkern=\notesignal
- \dodonotesymbol{\kern\noteparameter\c!distance}% gets the font right, hack !
- \fi
- \nobreak
- \doifelse{\noteparameter\c!interaction}\v!no
- {\dotypesetsomenotesymbol{#1}{#2}{#3}}
- {\directgotobox{\dotypesetsomenotesymbol{#1}{#2}{#3}}[page(\ctxlua{structures.notes.getnumberpage("#1",\number#2)})]}% f:
- \globallet\lastnotesymbol\relax}
-
-\unexpanded\def\typesetdummynotesymbol % temp hack
- {\removeunwantedspaces
- \doifitalicelse\/\donothing % Charles IV \footnote{the fourth}
- \ifdim\lastkern=\notesignal
- \dodonotesymbol{\kern\noteparameter\c!distance}% gets the font right, hack !
- \fi
- \nobreak
- \hbox to .5em{}%
- \globallet\lastnotesymbol\relax}
-
-\def\currentnotedescriptiontext % todo: can be other number
- {\ctxlua{structures.notes.title("\currentnote",\currentdescriptionnumberentry)}}
-
-% \def\@@donotetext % same as \@@doenumerationtext
-% {\ifcase\enumerationnumberstate
-% \doenumerationfullnumbernop
-% \or
-% \iftrialtypesetting
-% \doenumerationfullnumberyes
-% \doenumerationcouplingsymbol
-% \else
-% \doenumerationregistercoupling
-% \doenumerationfullnumberyes
-% \doenumerationcouplingsymbol
-% \fi
-% \or
-% \doenumerationfullnumbersymbol
-% \fi}
-
-\def\@@donotetext % experiment ... we run into a problem when we migrate a note otherwise in postpone mode
- {\doenumerationcheckconditions
- \let\doenumerationnumber\docurrentnoteenumerationfullnumber
- \let\doenumerationsymbol\docurrentnoteenumerationsymbol
- \@@doenumerationtext}
-
-\def\@@donotenumber
- {\doifelse{\noteparameter\c!interaction}\v!no
- {\docurrentnoteenumerationfullnumber}%
- {\directgotobox
- {\docurrentnoteenumerationfullnumber}%
- [page(\ctxlua{structures.notes.getsymbolpage("\currentnote",\currentdescriptionnumberentry)})]}}
-
-\def\@@donotesymbol
- {\doifelse{\noteparameter\c!interaction}\v!no
- {\docurrentnoteenumerationsymbol}%
- {\directgotobox
- {\docurrentnoteenumerationsymbol}%
- [page(\ctxlua{structures.notes.getsymbolpage("\currentnote",\currentdescriptionnumberentry)})]}}
-
-\def\docurrentnoteenumerationfullnumber
- {\noteparameter\c!numbercommand
- {\usenotestyleandcolor\c!numberstyle\c!numbercolor
- \ctxlua{structures.notes.number("\currentnote",\currentdescriptionnumberentry)}%
- \domovednote\currentdescription\currentdescriptionnumberentry\v!nextpage\v!previouspage}}
-
-\def\docurrentnoteenumerationsymbol
- {\noteparameter\c!numbercommand
- {\usenotestyleandcolor\c!numberstyle\c!numbercolor
- \descriptionparameter\c!symbol
- \domovednote\currentdescription\currentdescriptionnumberentry\v!nextpage\v!previouspage}}
-
-\def\synchronizesomenotesymbol#1#2#3% called more often than needed
- {\iftrialtypesetting\else
- \normalexpanded{\noexpand\ctxlatelua{structures.notes.setsymbolpage("#1",#2,#3)}}%
- \fi}
-
-\def\handlenoteinsert#1#2% tg, id
- {\begingroup
- \edef\currentnote{#1}%
- \the\everybeforenoteinsert
- \insert\currentnoteins\bgroup
- \the\everyinsidenoteinsert
- \doprocesslocalsetups{\noteparameter\c!setups}% experimental
- \doifelse{\noteparameter\c!paragraph}\v!yes
- {\nointerlineskip
- \startvboxtohbox
- \handlenoteitself{#1}{#2}%
- % add some slack
- \stopvboxtohbox}
- {\handlenoteitself{#1}{#2}}%
- \egroup
- \the\everyafternoteinsert
- \endgroup}
-
-\def\betweennoteitself#1% tg
- {\edef\currentnote{#1}%
- \doif{\noteparameter\c!paragraph}\v!yes\dobetweenparagraphnotes}
-
-\def\handlenoteitself#1#2% tg, id
- {\edef\currentdescription{#1}%
- \edef\currentnote{#1}%
- \edef\currentdescriptionnumberentry{#2}%
- \edef\currentdescriptionlistentry{\ctxlua{tex.write(structures.notes.listindex("#1",#2))}}%
- % as we can have collected notes (e.g. in tables) we need to recover
- % \currentdescriptionattribute and \currentdescriptionsynchronize
- \reinstatedescriptionnumberentry\currentdescriptionlistentry % we could store the number in the entry
- %
- \dontcomplain % should be done in startstoreddescription instead
- \dostartstoreddescription\begstrut\currentnotedescriptiontext\endstrut\dostopstoreddescription}
-
-\def\dostartstoreddescription
- {\bgroup\@@dostartdescriptionindeed}
-
-\def\dostopstoreddescription
- {\@@stopdescription}
-
-%D The main typesetting routine is more or less the same as the
-%D \PLAIN\ \TEX\ one, except that we only handle one type while
-%D \PLAIN\ also has something \type{\v...}. In most cases
-%D footnotes can be handled by a straight insert, but we do so
-%D by using an indirect call to the \type{\insert} primitive.
-
-%D Making footnote numbers active is not always that logical,
-%D especially when we keep the reference and text at one page.
-%D On the other hand we need interactivity when we refer to
-%D previous notes or use end notes. Therefore we support
-%D interactive footnote numbers in two ways \footnote{This
-%D feature was implemented years after we were able to do so,
-%D mainly because endnotes had to be supported.} that is,
-%D automatically (vise versa) and by user supplied reference.
-
-\let\startpushnote\relax
-\let\stoppushnote \relax
-
-\newsignal\notesignal
-
-\newconditional\processingnote
-\newconditional\postponednote
-
-\newtoks\everybeforenoteinsert
-\newtoks\everyinsidenoteinsert
-\newtoks\everyafternoteinsert
-
-\appendtoks
- \let\flushnotes\relax
- \let\postponenotes\relax
- \forgetall
- \resetallattributes % new, we don't want color bleed into notes
-\to \everybeforenoteinsert
-
-\appendtoks
- \doif{\noteparameter\c!scope}\v!page{\floatingpenalty\maxdimen}% experiment
- \penalty\currentnotepenalty
- \forgetall
- \setnotebodyfont
- \redoconvertfont % to undo \undo calls in in headings etc
- \splittopskip\strutht % not actually needed here
- \splitmaxdepth\strutdp % not actually needed here
- \leftmargindistance\noteparameter\c!margindistance
- \rightmargindistance\leftmargindistance
-% \ifnum\noteparameter\c!n=\zerocount % no ifcase new 31-07-99 ; always ?
-% \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize % ?
-% \fi
-\to \everyinsidenoteinsert
-
-\appendtoks
- \setsimplecolumnshsize[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%\currentnotewidth]%
-\to \everyinsidenoteinsert
-
-% not: \appendtoks \setnotehsize \to \everyinsidenoteinsert (spoils columns)
-
-\let\lastnotesymbol\relax
-
-%D \macros
-%D {note}
-%D
-%D Refering to a note is accomplished by the rather short
-%D command:
-%D
-%D \showsetup{note}
-%D
-%D This command is implemented rather straightforward as:
-
-\unexpanded\def\notesymbol
- {\dodoubleempty\donotesymbol}
-
-\def\donotesymbol[#1][#2]%
- {\bgroup
- \ifnotesenabled
- \edef\currentnote{#1}%
- \ifsecondargument
- \unskip
- \dodonotesymbol{\in[#2]}%
- \else
- \dodonotesymbol\lastnotesymbol
- \fi
- \fi
- \egroup}
-
-\def\dodonotesymbol#1%
- {\noteparameter\c!textcommand{\usenotestyleandcolor\c!textstyle\c!textcolor#1}}
-
-%D Normally footnotes are saved as inserts that are called upon
-%D as soon as the pagebody is constructed. The footnote
-%D insertion routine looks just like the \PLAIN\ \TEX\ one,
-%D except that we check for the end note state.
-
-% testcase for split bottom alignment see (a) below
-%
-% \dorecurse{6}{\input tufte\footnote{\input ward \input tufte \relax}}
-
-\unexpanded\def\placenoteinserts
- {\processnotes\doplacenoteinserts}
-
-\unexpanded\def\unvboxed {\ifvmode\unvbox \else\box \fi}
-\unexpanded\def\unvcopied{\ifvmode\unvcopy\else\copy\fi}
-
-% idea: tag with attr and then just flush them again
-
-\def\dobetweenparagraphnotes % should not be too much
- {\noteparameter\c!inbetween}
-
-\def\doflushglobalnotes
- {\doifelse{\noteparameter\c!paragraph}\v!yes
- {\vbox
- {\beginofshapebox
- \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins
- \endofshapebox
- %\doreshapebox{\box\shapebox}{}{}{}% get rid of penalties etc
- \gdef\dodobetweenparagraphnotes{\glet\dodobetweenparagraphnotes\dobetweenparagraphnotes}% shape works reverse
- \doreshapebox{\hbox{\unhbox\shapebox\dodobetweenparagraphnotes}}{}{}{}% get rid of penalties etc
- \innerflushshapebox
- \convertvboxtohbox}}
- {\iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins}}
-
-\def\dodoplacenoteinserts
- {\ifcase\noteparameter\c!n\relax
- % should not happen
- \or
- \doglobalflushnotesnormal
- \else
- \doglobalflushnotescolums
- \fi}
-
-\def\doglobalflushnotesnormal
- {%\iftrialtypesetting\copy\else\box\fi\currentnoteins
- \doflushglobalnotes
- \obeydepth} % (a) added , since split footnotes will not align properly
-
-\def\doglobalflushnotescolums
- {\startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%,\c!width=\currentnotewidth]%
- %\iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins % compare with local
- \doflushglobalnotes
- \stopsimplecolumns}
-
-\def\doplacenoteinserts
- {\relax\ifdim\ht\currentnoteins>\zeropoint\relax
- \ifnum\noteparameter\s!noteloc=\plusfive
- \else
- \endgraf
- \ifvmode
- \whitespace
- \noteparameter\c!before
- \fi
- % \bgroup
- % \setupalign[\noteparameter\c!align]%
- \placenoterule % alleen in ..mode
- % \par
- % \egroup
- \bgroup
- \setnotebodyfont
- \setbox\scratchbox\hbox
- {\dodoplacenoteinserts}%
- \setbox\scratchbox\hbox
- {\localframed
- [\??vn\currentnote]
- [\c!location=,
- \c!width=\v!fit,
- \c!height=\v!fit,
- \c!strut=\v!no,
- \c!offset=\v!overlay]
- {\ifdim\dp\scratchbox=\zeropoint % this hack is needed because \vadjust
- \hbox{\lower\strutdp\box\scratchbox}% % in margin number placement
- \else % hides the (always) present depth
- \box\scratchbox
- \fi}}%
- \setbox\scratchbox\hbox{\lower\strutdepth\box\scratchbox}%
- \dp\scratchbox\strutdepth % so we know that it has the note bodyfont depth
- \box\scratchbox
- \egroup
- \endgraf
- \ifvmode
- \noteparameter\c!after
- \fi
- \fi
- \fi}
-
-%D Supporting end notes is surprisingly easy. Even better, we
-%D can combine this feature with solving the common \TEX\
-%D problem of disappearing inserts when they're called for in
-%D deeply nested boxes. The general case looks like:
-%D
-%D \starttyping
-%D \postponenotes
-%D \.box{whatever we want with footnotes}
-%D \flushnotes
-%D \stoptyping
-%D
-%D This alternative can be used in headings, captions, tables
-%D etc. The latter one sometimes calls for notes local to
-%D the table, which can be realized by saying
-%D
-%D \starttyping
-%D \setlocalfootnotes
-%D some kind of table with local footnotes
-%D \placelocalfootnotes
-%D \stoptyping
-%D
-%D Postponing is accomplished by simply redefining the (local)
-%D insert operation. A not too robust method uses the
-%D \type{\insert} primitive when possible. This method fails in
-%D situations where it's not entirely clear in what mode \TEX\
-%D is. Therefore the auto method can is to be overruled when
-%D needed.
-
-\newconditional\postponingnotes
-
-% we need a proper state: normal, postponing, flushing
-
-\def\postponenotes
- {\ifconditional\postponingnotes\else
- \global\settrue\postponingnotes
- \global\let\flushnotes\doflushnotes
- \ctxlua{structures.notes.postpone()}%
- \fi}
-
-\let\flushnotes\relax
-
-\def\doflushnotes
- {\ifconditional\postponingnotes
- \begingroup
- \let\flushnotes \relax
- \let\postponenotes\relax
- \ctxlua{structures.notes.flushpostponed()}% this also resets the states !
- \global\setfalse\postponednote
- \global\setfalse\postponingnotes
- \global\let\flushnotes\relax
- \endgroup
- \fi}
-
-%D \macros
-%D {startlocalfootnotes,placelocalfootnotes}
-%D
-%D The next two macros can be used in for instance tables, as
-%D we'll demonstrate later on.
-%D
-%D \showsetup{startlocalfootnotes}
-%D \showsetup{placelocalfootnotes}
-
-% todo: compatibility mode: when first arg is assignment or missing, then all
-
-\newtoks\everyplacelocalnotes
-
-\appendtoks
- \let\flushnotes \relax
- \let\postponenotes\relax
-\to \everyplacelocalnotes
-
-\def\defaultnotewidth{\makeupwidth} % {\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}
-
-\newconditional\inlocalnotes
-
-\unexpanded\def\startlocalnotes
- {\dosingleempty\dostartlocalnotes}
-
-\def\dostartlocalnotes[#1]%
- {\def\localnoteslist{#1}%
- \settrue\inlocalnotes
- \processcommacommand[\localnoteslist]\dodostartlocalnotes}
-
-\unexpanded\def\stoplocalnotes
- {\processcommacommand[\localnoteslist]\dodostoplocalnotes
- \setfalse\inlocalnotes}
-
-\def\dodostartlocalnotes#1%
- {\doifnot{\noteparameter\c!continue}\v!yes
- {\strc_counters_save{#1}%
- \strc_counters_reset{#1}}%
- \ctxlua{structures.notes.save("#1","store")}}
-
-\def\dodostoplocalnotes#1%
- {\doifnot{\noteparameter\c!continue}\v!yes
- {\strc_counters_restore{#1}}%
- \ctxlua{structures.notes.restore("#1")}}
-
-\unexpanded\def\placelocalnotes
- {\dodoubleempty\doplacelocalnotes}
-
-\def\doplacelocalnotes[#1][#2]%
- {\doif{\ctxlua{structures.notes.getstate("#1")}}{store}{\dodoplacelocalnotes{#2}{#1}}}
-
-\def\dodoplacelocalnotes#1#2% settings note
- {\begingroup
- \the\everyplacelocalnotes
- % beware, we cannot trust setting \currentnote here
- \getparameters[\??vn#2][\c!width=\v!fit,\c!height=\v!fit,\c!strut=\v!no,\c!offset=\v!overlay,#1]% we only need a selective one
- \dolocalnotealternative{#2}%
- \endgroup
- \dochecknote} % we need to restore the old state
-
-%D These commands can be used like:
-%D
-%D \startbuffer
-%D \startlocalnotes[width=.3\hsize,n=0]
-%D \placetable
-%D {Some Table}
-%D \placeontopofeachother
-%D {\starttable[|l|r|]
-%D \HL
-%D \VL Nota\footnote{Bene} \VL Bene\footnote{Nota} \VL\SR
-%D \VL Bene\footnote{Nota} \VL Nota\footnote{Bene} \VL\SR
-%D \HL
-%D \stoptable}
-%D {\placelocalnotes}
-%D \stoplocalnotes
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D Because this table placement macro expect box content, and
-%D thanks to the grouping of the local footnotes, we don't need
-%D additional braces.
-%D
-%D \getbuffer
-
-%D \macros
-%D {placefootnotes}
-%D
-%D We still have no decent command for placing footnotes
-%D somewhere else than at the bottom of the page (for which no
-%D user action is needed). Footnotes (endnotes) can be
-%D placed by using
-%D
-%D \showsetup{placefootnotes}
-
-\unexpanded\def\placebottomnotes
- {\processnotes\doplacenoteinserts}
-
-\unexpanded\def\placenotes
- {\dodoubleempty\doplacenotes}
-
-\def\doplacenotes[#1][#2]%
- {\processcommalist[#1]{\dodoplacenotes{#2}}}
-
-\def\dodoplacenotes#1#2% settings note
- {\edef\currentnote{#2}%
- \doifelse{\ctxlua{structures.notes.getstate("#2")}}{store}
- \dodoplacelocalnotes
- \dodoplaceglobalnotes
- {#1}{#2}}
-
-\def\dodoplaceglobalnotes#1#2%
- {\begingroup
- \setupnote[#2][#1]%
- \doplacenoteinserts
- \endgroup
- \the\everysetupnote} % to be checkes
-
-%D Placement
-
-\long\def\installnotealternative#1#2%
- {\setvalue{\??vn:\c!alternative:#1}{#2}}
-
-\def\doifnotescollected#1%
- {\ctxlua{structures.notes.doifcontent("#1")}}
-
-\def\dolocalnotealternative#1%
- {\edef\currentnote{#1}%
- \doifnotescollected\currentnote
- {\endgraf
- \ifvmode
- \whitespace
- \noteparameter\c!before
- \fi
- \begingroup
- \setnotebodyfont
- \getvalue{\??vn:\c!alternative:\noteparameter\c!alternative}%
- \endgroup
- \ifvmode
- \noteparameter\c!after
- \fi}}
-
-\setvalue{\??vn:\c!alternative:}{\getvalue{\??vn:\c!alternative:\v!none}}
-
-%D A stupid alternative is also provided:
-%D
-%D \starttyping
-%D \setupfootnotes[location=text,alternative=none]
-%D \stoptyping
-
-% \def\flushlocalnotes#1{\ctxlua{structures.notes.flush("#1","store")}}
-\def\flushlocalnotes#1{\ctxlua{structures.notes.flush("#1","store","\noteparameter\c!criterium")}}
-
-\installnotealternative \v!none
- {\flushlocalnotes\currentnote}
-
-\installnotealternative \v!grid % test if n > 0
- {\snaptogrid\hbox
- {\localframed
- [\??vn\currentnote]
- [\c!location=]
- {\flushlocalnotes\currentnote}}}
-
-\installnotealternative \v!fixed % test if n > 0
- {\localframed
- [\??vn\currentnote]
- [\c!location=]
- {\flushlocalnotes\currentnote}}
-
-\installnotealternative \v!columns % redundant
- {\localframed
- [\??vn\currentnote]
- [\c!location=]
- {\edef\currentnotewidth{\noteparameter\c!width}%
- \doifdimensionelse\currentnotewidth\donothing
- {\edef\currentnotewidth{\the\hsize}}%
-% \setupinmargin[\c!align=\v!left]%
- \startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\currentnotewidth]%
- \flushlocalnotes\currentnote
- \stopsimplecolumns}}
-
-%D \macros
-%D {fakenotes}
-
- % is this ok? endnotes and such
-
- \unexpanded\def\fakenotes
- {\ifhmode\endgraf\fi\ifvmode
- \calculatetotalclevernoteheight
- \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
- \fi}
-
- \unexpanded\def\fakepagenotes
- {\ifhmode\endgraf\fi\ifvmode
- \calculatetotalpagenoteheight
- \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
- \fi}
-
- \newdimen\totalnoteheight
-
- \def\doaddtototalnoteheight#1%
- {\ifdim\ht#1>\zeropoint
- \ifcase\count#1\else
- % todo: divide by count
- \advance\totalnoteheight\ht #1%
- \advance\totalnoteheight\skip#1%
- \fi
- \fi}
-
- \def\docalculatetotalnoteheight
- {\ifcase\clevernotes % tricky here ! ! ! to be sorted out ! ! !
- \doaddtototalnoteheight\currentnoteins
- \else
-% \doaddtototalnoteheight\currentbackupnoteins
- \fi}
-
- \def\docalculatetotalclevernoteheight
- {\ifcase\clevernotes \else % tricky here ! ! ! to be sorted out ! ! !
- \doaddtototalnoteheight\currentnoteins
- \fi}
-
- \def\docalculatetotalpagenoteheight
- {\doaddtototalnoteheight\currentnoteins}
-
- \def\calculatetotalnoteheight {\totalnoteheight\zeropoint\processnotes\docalculatetotalnoteheight}
- \def\calculatetotalclevernoteheight{\totalnoteheight\zeropoint\processnotes\docalculatetotalclevernoteheight}
- \def\calculatetotalpagenoteheight {\totalnoteheight\zeropoint\processnotes\docalculatetotalpagenoteheight}
-
- \newif\ifnotespresent
-
- \def\dochecknotepresence
- {\ifdim\ht\currentnoteins>\zeropoint
- \notespresenttrue
- \fi}
-
- \def\checknotepresence
- {\notespresentfalse
- \processnotes\dochecknotepresence}
-
-%D Now how can this mechanism be hooked into \CONTEXT\ without
-%D explictly postponing footnotes? The solution turned out to
-%D be rather simple:
-%D
-%D \starttyping
-%D \everypar {...\flushnotes...}
-%D \neverypar {...\postponenotes}
-%D \stoptyping
-%D
-%D We can use \type{\neverypar} because in most commands
-%D sensitive to footnote gobbling we disable \type{\everypar}
-%D in favor for \type{\neverypar}. In fact, this footnote
-%D implementation is the first to use this scheme.
-
-%D This is a nasty and new secondary footnote flusher. It
-%D can be hooked into \type {\everypar} like:
-%D
-%D \starttyping
-%D \appendtoks \synchronizenotes \to \everypar
-%D \stoptyping
-
- % \def\dosynchronizenotes
- % {\ifvoid\currentnoteins\else\insert\currentnoteins{\unvbox\currentnoteins}\fi}
- %
- % \def\synchronizenotes
- % {\processnotes\dosynchronizenotes}
-
-\let\synchronizenotes\relax
-
-%D When typesetting footnotes, we have to return to the
-%D footnote specific bodyfont size, which is in most cases derived
-%D from the global document bodyfont size. In the previous macros
-%D we already used a footnote specific font setting macro.
-
-\def\setnotebodyfont
- {\let\setnotebodyfont\relax
- \restoreglobalbodyfont
- \switchtobodyfont[\noteparameter\c!bodyfont]%
- \setuptolerance[\noteparameter\c!tolerance]%
- \setupalign[\noteparameter\c!align]}
-
-%D The footnote mechanism defaults to a traditional one
-%D column way of showing them. By default we precede them by
-%D a small line.
-
-\ifx\v!endnote\undefined \def\v!endnote{endnote} \fi
-
-\definenote [\v!footnote]
-\definenote [\v!endnote ] [\c!location=\v!none] % else no break
-
-%D Compatibility macros:
-
-\unexpanded\def\setupfootnotedefinition{\setupnotedefinition [\v!footnote]}
-\unexpanded\def\setupfootnotes {\setupnote [\v!footnote]}
-%unexpanded\def\footnote {\setnote [\v!footnote]}
-\def\footnotetext {\setnotetext [\v!footnote]}
-%unexpanded\def\note {\dodoubleempty\notesymbol [\v!footnote]} % alleen footnote
-\unexpanded\def\placefootnotes {\dodoubleempty\doplacefootnotes [\v!footnote]}
-\unexpanded\def\placelocalfootnotes {\dodoubleempty\doplacelocalfootnotes[\v!footnote]}
-\unexpanded\def\startlocalfootnotes {\startlocalnotes [\v!footnote]} % alleen footnote
-\unexpanded\def\stoplocalfootnotes {\stoplocalnotes }
-
-\def\doplacefootnotes [#1][#2]{\ifsecondargument\placenotes [#1][#2,\c!height=\textheight]\else\placenotes [#1]\fi}
-\def\doplacelocalfootnotes[#1][#2]{\ifsecondargument\placelocalnotes[#1][#2,\c!height=\textheight]\else\placelocalnotes[#1]\fi}
-
-\unexpanded\def\note{\dodoubleempty\donote}
-
-\def\donote[#1][#2]{\ifsecondargument\donotesymbol[#1][#2]\else\secondargumenttrue\donotesymbol[\v!footnote][#1]\fi}
-
-%D Goodies:
-%D
-%D \starttyping
-%D \dorecurse {100} {
-%D test \footnote{\doifnoteonsamepageelse[footnote]{ibidem}{aaa}}
-%D }
-%D \stoptyping
-
-\def\doifnoteonsamepageelse[#1]{\ctxlua{structures.notes.doifonsamepageasprevious("#1")}}
-
-%D New trickery:
-
-\def\ownnotesymbol#1% #1 gets number passed
- {\executeifdefined{\??vn::\currentnote}\empty}
-
-\unexpanded\def\setnotesymbol[#1]#2#3%
- {\prewordbreak % prevent lookback
- \setgvalue{\??vn::#1}{#3}
- \dolastnotesymbol}
-
-\unexpanded\def\ownnote[#1]#2#3#4%
- {\setnotesymbol[#1]{#2}{#3}%
- \setnotetext [#1]{#4}}
-
-\defineconversion
- [ownnote]
- [\ownnotesymbol]
-
-\protect \endinput
diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi
new file mode 100644
index 000000000..0a1ede550
--- /dev/null
+++ b/tex/context/base/strc-not.mkvi
@@ -0,0 +1,1660 @@
+%D \module
+%D [ file=strc-not,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Note Handling,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Note Handling}
+
+\registerctxluafile{strc-not}{1.001}
+
+\unprotect
+
+% todo: see if we can now use \insertpenalties (>0 == some left)
+
+\ifdefined\v!notation \else \def\v!notation {notation} \fi
+\ifdefined\v!endnote \else \def\v!endnote {endnote} \fi
+\ifdefined\c!symbolcommand \else \def\c!symbolcommand{symbolcommand} \fi
+
+\ifdefined\dotagsetnotesymbol \else \let\dotagsetnotesymbol\relax \fi
+
+\unexpanded\def\unvboxed {\ifvmode\unvbox \else\box \fi} % will change or used more often
+\unexpanded\def\unvcopied{\ifvmode\unvcopy\else\copy\fi} % will change or used more often
+
+%D Notes have two handlers: notations and notes. Although notations can
+%D be defined independently it makes not much sense. In principle we can
+%D treat notes as lists but they are currently done as a variant on
+%D enumerations. I will provide a list variant as well. One complication is
+%D that for page related notes inserts are used and therefore notes are
+%D typeset immediately and descriptions are better suited for that. For
+%D instance endnotes can as well be typeset using lists.
+
+% textcommand/textstyle/textcolor : set by note commandhandler and used for inline number
+
+%D \macros
+%D {setupnote,setupnotedefinition}
+%D
+%D We can influence footnote typesetting with the setup
+%D command:
+%D
+%D \showsetup{setupnotes}
+%D \showsetup{setupnote}
+%D
+%D The definition command indicate that we can frame the footnote
+%D area. The footnotes themselves are treated as descriptions.
+%D
+%D \showsetup{definenote}
+%D
+%D It's sort of a custom to precede footnotes by a horizontal
+%D rule and although fancy rules like
+%D
+%D \starttyping
+%D \hbox to 10em{\hskip-3em\dotfill}
+%D \stoptyping
+%D
+%D Are quite ligitimate, we default to a simple one 20\% of the
+%D text width.
+
+% \c!headstyle=\noteparameter\c!style,
+% \c!headcolor=\noteparameter\c!color,
+
+\installcorenamespace{notation}
+
+\installcommandhandler \??notation {notation} \??notation
+
+\let\setupnotations\setupnotation
+
+% \unexpanded\def\lowllap#1{\low{\llap{#1}}}
+
+\definesymbol[\v!note:\v!previouspage][\llap{\low{\symbol[\v!previouspage]}}]
+\definesymbol[\v!note:\v!nextpage ][\llap{\low{\symbol[\v!nextpage ]}}]
+
+\setupnotations % check with old
+ [\c!alternative=\v!inleft,
+ %\c!headstyle=,
+ %\c!titlestyle=,
+ %\c!style=,
+ %\c!color=,
+ %\c!headcolor=,
+ %\c!titlecolor=,
+ \c!numbercommand=\high,
+ %\c!symbolcommand=\lowllap, % experiment
+ \c!width=\v!fit,
+ \c!titledistance=0.5em,
+ \c!distance=0pt,
+ %\c!hang=,
+ %\c!sample=,
+ %\c!align=,
+ %\c!headalign=,
+ \c!margin=\v!no,
+ \c!before=,
+ \c!inbetween=,
+ \c!after=,
+ \c!indentnext=\v!yes,
+ \c!indenting=\v!never,
+ \c!titleleft=(,
+ \c!titleright=),
+ %\c!closesymbol=,
+ \c!closecommand=\wordright,
+ \c!display=\v!yes,
+ %\c!command=,
+ \c!titlecommand=,
+ \c!expansion=\v!no,
+ %\c!xmlsetup=,
+ %\s!catcodes=,
+ \c!way=\v!by\v!text,
+ \c!prefix=\v!no,
+ \c!prefixconnector=.,
+ %\c!starter=,
+ %\c!stopper=,
+ \c!number=\v!yes,
+ \c!text=,
+ \c!start=0,
+ \c!state=\v!start,
+ \c!levels=3]
+
+% mostly the same as enumersations but we want to keep them
+% isolated and at some point we might differentiate
+
+\unexpanded\def\strc_define_commands_notation#1#2#3% current level parent
+ {\doifelsenothing{#3}
+ {\defineconstruction[#1][\s!handler=\v!notation,\c!level=#2]}%
+ {\defineconstruction[#1][#3][\s!handler=\v!notation,\c!level=#2]}%
+ \setuevalue{\e!next #1}{\strc_notations_next }%
+ \setuevalue{\c!reset#1}{\strc_notations_reset }%
+ %setuevalue{\c!set #1}{\strc_notations_set }%
+ \setuevalue {#1}{\strc_notations_command{\currentnotation}}%
+ \setuevalue{\e!start#1}{\strc_notations_start {\currentnotation}{#1}}%
+ \setuevalue{\e!stop #1}{\strc_notations_stop }}
+
+\appendtoks
+ \ifx\currentnotationparent\empty
+ % clone => parent | subclone => clone | subsubclone => subclone
+ \let\currentnotationsub\empty
+ \strc_define_commands_notation
+ {\currentnotationsub\currentnotation}%
+ \plusone
+ \empty
+ \edef\p_levels{\notationparameter\c!levels}%
+ \dostepwiserecurse\plustwo\p_levels\plusone
+ {\strc_define_commands_notation
+ {\v!sub\currentnotationsub\currentnotation}%
+ \recurselevel
+ {\currentnotationsub\currentnotation}%
+ \edef\currentnotationsub{\v!sub\currentnotationsub}}%
+ \definelist[\currentnotation]% goodie
+ \else
+ % clone => parent | subclone => subparent | subsubclone => subsubparent
+ \let\currentnotationsub\empty
+ \edef\p_levels{\notationparameter\c!levels}%
+ \dorecurse\p_levels
+ {\strc_define_commands_notation
+ {\currentnotationsub\currentnotation}%
+ \recurselevel
+ {\currentnotationsub\currentnotationparent}%
+ \edef\currentnotationsub{\v!sub\currentnotationsub}}%
+ \definelist[\currentnotation][\currentnotationparent]% goodie
+ \fi
+ \edef\p_counter{\notationparameter\s!counter}% can inherit from parent
+ \ifx\p_counter\empty %
+ \let\p_counter\currentnotation
+ \fi
+ \doifstructurecounterelse\p_counter\donothing{\strc_enumerations_define_counter\p_counter}%
+ \letnotationparameter\s!counter\p_counter
+ \strc_enumerations_setup_counter\currentnotation
+\to \everydefinenotation
+
+\setvalue{\??constructioninitializer\v!notation}%
+ {\let\currentnotation \currentconstruction
+ \let\constructionparameter \notationparameter
+ \let\detokenizedconstructionparameter\detokenizednotationparameter
+ \let\letconstructionparameter \letnotationparameter
+ \let\useconstructionstyleandcolor \usenotationstyleandcolor
+ \let\setupcurrentconstruction \setupcurrentnotation
+ \edef\p_number{\constructionparameter\c!number}%
+ \ifx\p_number\v!yes
+ \settrue\c_strc_constructions_number_state
+ \iftrialtypesetting
+ \strc_counters_save\currentconstructionnumber
+ \fi
+ \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel
+ \else
+ \setfalse\c_strc_constructions_number_state
+ \fi
+ \edef\p_title{\constructionparameter\c!title}%
+ \ifx\p_title\v!yes
+ \settrue\c_strc_constructions_title_state
+ \else
+ \setfalse\c_strc_constructions_title_state
+ \fi}
+
+\setvalue{\??constructionfinalizer\v!notation}%
+ {\ifconditional\c_strc_constructions_number_state
+ \iftrialtypesetting
+ \strc_counters_restore\currentconstructionnumber
+ \fi
+ \fi}
+
+%D Notations (we simply needed a word that relates to notes and is
+%D and sounds like description and enumeration) are a special case
+%D in the sense that they are stored, rendered elsewhere and referered
+%D to from where they are specified. For that reason they have a different
+%D set op main commands.
+
+% \notation[ref]{title}
+% \notation[reference=,title=]
+% \startnotation[ref] title \stopnotation
+
+\let\strc_notations_next \strc_enumerations_next
+\let\strc_notations_reset\strc_enumerations_reset
+%let\strc_notations_set \strc_enumerations_set
+
+\unexpanded\def\strc_notations_command#1%
+ {\begingroup
+ \strc_constructions_initialize{#1}%
+ \doifnextoptionalelse\strc_notations_command_yes\strc_notations_command_nop}
+
+\unexpanded\def\strc_notations_command_nop#1%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title={#1},\c!bookmark=,\c!list=][]%
+ \csname\??constructionnotehandler\currentconstructionhandler\endcsname
+ \endgroup}
+
+\unexpanded\def\strc_notations_command_yes[#1]%
+ {\doifassignmentelse{#1}\strc_notations_command_assignment\strc_notations_command_argument[#1]}
+
+\unexpanded\def\strc_notations_command_assignment[#1]%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,#1][]%
+ \csname\??constructionnotehandler\currentconstructionhandler\endcsname
+ \endgroup}
+
+\unexpanded\def\strc_notations_command_argument[#1]#2%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=][]%
+ \csname\??constructionnotehandler\currentconstructionhandler\endcsname
+ \endgroup}
+
+\unexpanded\def\strc_notations_start#1#2%
+ {\begingroup
+ \strc_constructions_initialize{#1}%
+ \normalexpanded % not that efficient but also not that frequently used
+ {\def\noexpand\strc_pickup_yes[##1]##2\csname\e!stop#2\endcsname{\strc_notations_command_yes[##1]{##2}}%
+ \def\noexpand\strc_pickup_nop ##1\csname\e!stop#2\endcsname{\strc_notations_command_nop {##1}}}%
+ \doifnextoptionalelse\strc_pickup_yes\strc_pickup_nop}
+
+\unexpanded\def\strc_notations_start_yes[#1]#2%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=][]%
+ \csname\??constructionnotehandler\currentconstructionhandler\endcsname
+ \endgroup}
+
+\unexpanded\def\strc_notations_start_nop#1%
+ {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title={#1},\c!bookmark=,\c!list=][]%
+ \csname\??constructionnotehandler\currentconstructionhandler\endcsname
+ \endgroup}
+
+\unexpanded\def\strc_notations_stop
+ {}
+
+%D A complication is that we need to set up rather specific properties
+%D of e.g. footnotes. It is for this reason that we introduce an extra
+%D level of indirectness. This way notations don't bark on undefined
+%D macros when used in combination.
+
+\setvalue{\??constructionnotehandler\v!notation}%
+ {\csname\??constructionnotehandler\currentconstructionhandler:\constructionparameter\c!type\endcsname}
+
+\setvalue{\??constructionnotehandler\v!notation:}% empty case
+ {[\currentconstructionhandler:\currentconstruction]}
+
+%D We now implement the note definer.
+
+\installcorenamespace{note}
+
+\installframedcommandhandler \??note {note} \??note
+
+\let\setupnotes\setupnote
+
+% These only concern the inline symbol/number and wrapping of the
+% whole list.
+
+\setupnotes % not all make sense here
+ [\c!location=\v!page,
+ %\c!conversion=,
+ \c!rule=\v!on,
+ \c!before=\blank,
+ \c!bodyfont=\v!small,
+ %\c!style=,
+ %\c!color=,
+ %\c!after=,
+ %\c!rulecolor=,
+ \c!rulethickness=\linewidth,
+ \c!frame=\v!off,
+ \c!distance=.125em, % in the text between symbols
+ \c!columndistance=1em,
+ \c!margindistance=.5em,
+ \c!align=, % also use instead of \c!tolerance
+ \c!split=\v!tolerant,
+ \c!width=\makeupwidth, % \ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi
+ \c!height=\textheight,
+ \c!command=, % \noteparameter\c!numbercommand, % (command in enumeration) too messy, called twice
+ \c!separator=,%
+ \c!textcommand=\high,
+ \c!textstyle=\tx,
+ %\c!textcolor=,
+ \c!interaction=\v!yes,
+ %\c!factor=,
+ %\c!scope=, % \v!text \v!page
+ \c!prefixconnector=.,
+ %\c!next=\autoinsertnextspace,
+ \c!prefix=\v!no,
+ %\c!continue=\v!no,
+ \c!paragraph=\v!no,
+ \c!inbetween=\hskip\emwidth,
+ \c!symbol=\mathematics{*},
+ \c!n=1]
+
+\setupnotes
+ [\c!expansion=\v!no,
+ \c!xmlsetup=,
+ \s!catcodes=]
+
+%D Insertions are part of notes.
+
+\installcorenamespace{noteinsertion}
+
+\def\currentnoteins{\csname\??noteinsertion\currentnote\endcsname}
+
+\appendtoks
+ \ifcsname\??noteinsertion\currentnote\endcsname\else
+ \expandafter\installinsertion\csname\??noteinsertion\currentnote\endcsname\relax
+ \normalexpanded{\t_strc_notes{\the\t_strc_notes\noexpand\strc_notes_process_list{\currentnote}}}%
+ \fi
+ \ctxlua{structures.notes.define("\currentnote","insert",\number\currentnoteins)}%
+ \ifx\currentnoteparent\empty
+ \definenotation[\currentnote][\c!type=\v!note]%
+ \else
+ \definenotation[\currentnote][\currentnoteparent][\c!type=\v!note]%
+ \fi
+\to \everydefinenote
+
+\expandafter\let\csname\??constructionstarthandler \v!notation\expandafter\endcsname\csname\??constructionstarthandler \v!enumeration\endcsname
+\expandafter\let\csname\??constructionstophandler \v!notation\expandafter\endcsname\csname\??constructionstophandler \v!enumeration\endcsname
+\expandafter\let\csname\??constructioncommandhandler\v!notation\expandafter\endcsname\csname\??constructioncommandhandler\v!enumeration\endcsname
+\expandafter\let\csname\??constructiontexthandler \v!notation\expandafter\endcsname\csname\??constructiontexthandler \v!enumeration\endcsname
+
+\setvalue{\??constructionmainhandler\v!notation}#1%
+ {\iftrialtypesetting \else
+ \begingroup
+ \currentconstructionsynchronize
+ \attribute\destinationattribute\currentconstructionattribute\relax % todo, whole text
+ \signalcharacter
+ \endgroup
+ \fi#1}
+
+\setvalue{\??constructionnotehandler\v!notation:\v!note}% in the running text
+ {\ifnotesenabled
+ \let\currentnote\currentconstructionmain % do be done elsewhere
+ \iftrialtypesetting
+ \strc_notes_inject_dummy
+ \else
+ \begingroup
+ \edef\currentnotenumber{\ctxlua{structures.notes.store("\currentnote",\currentconstructionlistentry)}}%
+ \settrue\processingnote
+ \ifconditional\c_strc_notes_skip
+ \globallet\lastnotesymbol\strc_notes_inject_symbol
+ \else
+ \iftypesettinglines % otherwise problems with \type <crlf> {xxx}
+ \ignorelines % makes footnotes work in \startlines ... \stoplines
+ \fi
+ \ifconditional\c_strc_notes_symbol
+ \strc_notes_inject_symbol
+ \else
+ \unskip\unskip
+ \globallet\lastnotesymbol\strc_notes_inject_symbol
+ \fi
+ \fi
+ \ifconditional\postponingnotes % todo: per note class
+ \global\settrue\postponednote
+ \else\ifconditional\inlocalnotes % todo: per note class
+ \global\settrue\postponednote
+ \else
+ \handlenoteinsert\currentnote\currentnotenumber % either an insert or just delayed
+ \fi\fi
+ \endgroup
+ \fi
+ \fi
+ \ifconditional\c_strc_notes_skip
+ \global\setfalse\c_strc_notes_skip
+ \else
+ \kern\notesignal\relax % \relax is needed to honor spaces
+ \fi}
+
+%D Interaction in notes is somewhat complex due to the way notes get
+%D flushed. In principle it is more or less the same as lists but where
+%D in lists we pack whole entries, in notes this doesn't happen. Okay,
+%D in retrospect we could have made descriptions lists but that will be
+%D a backward compatibility mess. At some point a completely new mechanism
+%D might show up, but not now. Also, as notes are inserts there is some
+%D extra mess to be kept in mind and it's easier to maintain two mechanisms
+%D than to combine too much.
+%D
+%D Interaction is also complicated because we want to provide several variants.
+%D For simple reference there is no need for anything special, as page references
+%D will do and we store them in the list anyway. But if we want a destination with
+%D dimensions we will use an additional destination because we can have only
+%D one with the same name and we always have the number as one.
+
+% interaction:
+%
+% all : text and number
+% number|yes: only number
+% text : only text
+%
+% \dogetsimple : injects
+
+\installcorenamespace{noteinteractioninline}
+\installcorenamespace{noteinteractiondisplay}
+
+\newconstant\a_strc_notes_symbol_reference
+\newconstant\a_strc_notes_number_reference
+\newconstant\a_strc_notes_text_reference
+\newconstant\a_strc_notes_text_destination
+
+\def\strc_notes_interaction_check_inline
+ {\edef\p_interaction{\noteparameter\c!interaction}%
+ \csname\??noteinteractioninline
+ \ifcsname\??noteinteractioninline\p_interaction\endcsname\p_interaction\else\v!no\fi
+ \endcsname}
+
+\def\strc_notes_interaction_check_display
+ {\edef\p_interaction{\noteparameter\c!interaction}%
+ \csname\??noteinteractiondisplay
+ \ifcsname\??noteinteractiondisplay\p_interaction\endcsname\p_interaction\else\v!no\fi
+ \endcsname}
+
+\setvalue{\??noteinteractioninline\v!yes}%
+ {\dogetsimplepagereference{page(\ctxlua{structures.notes.getnumberpage("\currentnote",\currentnotenumber)})}%
+ \edef\strc_notes_get_reference_attribute_symbol{attr\referenceattribute\currentreferenceattribute}%
+ \let \strc_notes_set_style_color_inline \strc_notes_set_style_color_inline_yes}
+
+\setvalue{\??noteinteractioninline\v!all}%
+ {%\dogetsimplepagereference{note:\cldcontext{structures.notes.internalid("\currentnote",\currentnotenumber)}}%
+ \dogetsimplepagereference{note:\currentnote:\currentnotenumber}%
+ \edef\strc_notes_get_reference_attribute_symbol{attr\referenceattribute\currentreferenceattribute}%
+ \let \strc_notes_set_style_color_inline \strc_notes_set_style_color_inline_yes}
+
+\setvalue{\??noteinteractioninline\v!no}%
+ {\let\strc_notes_get_reference_attribute_symbol\empty
+ \let\strc_notes_set_style_color_inline \strc_notes_set_style_color_inline_nop}
+
+\expandafter\let\csname\??noteinteractioninline\v!number\expandafter\endcsname\csname\??noteinteractioninline\v!yes\endcsname
+\expandafter\let\csname\??noteinteractioninline\v!text \expandafter\endcsname\csname\??noteinteractioninline\v!yes\endcsname
+
+\setvalue{\??noteinteractiondisplay\v!yes}%
+ {\dogetsimplepagereference{page(\ctxlua{structures.notes.getsymbolpage("\currentnote",\currentnotenumber)})}%
+ \edef\strc_notes_set_reference_attribute_number{\attribute\referenceattribute\currentreferenceattribute}%
+ \let \strc_notes_set_reference_attribute_text \donothing
+ \let \strc_notes_set_destination_attribute_text\donothing
+ \let \strc_notes_set_style_color_display \strc_notes_set_style_color_display_yes}
+
+\setvalue{\??noteinteractiondisplay\v!no}%
+ {\let\strc_notes_set_reference_attribute_number\donothing
+ \let\strc_notes_set_reference_attribute_text \donothing
+ \let\strc_notes_set_destination_attribute_text\donothing
+ \let\strc_notes_set_style_color_display \strc_notes_set_style_color_display_nop}
+
+\setvalue{\??noteinteractiondisplay\v!all}%
+ {\dogetsimplepagereference{page(\ctxlua{structures.notes.getsymbolpage("\currentnote",\currentnotenumber)})}%
+ \edef\strc_notes_set_reference_attribute_text {\attribute\referenceattribute\currentreferenceattribute}%
+ %\dosetsimplepagereference{note:\cldcontext{structures.notes.internalid("\currentnote",\currentnotenumber)}}%
+ \dosetsimplepagereference{note:\currentnote:\currentnotenumber}%
+ \edef\strc_notes_set_destination_attribute_text{\attribute\destinationattribute\currentdestinationattribute}%
+ \let \strc_notes_set_reference_attribute_number\strc_notes_set_reference_attribute_text
+ \let \strc_notes_set_style_color_display \strc_notes_set_style_color_display_yes}
+
+\setvalue{\??noteinteractiondisplay\v!text}%
+ {\dogetsimplepagereference{page(\ctxlua{structures.notes.getsymbolpage("\currentnote",\currentnotenumber)})}%
+ \edef\strc_notes_set_reference_attribute_text {\attribute\referenceattribute\currentreferenceattribute}%
+ %\dosetsimplepagereference{note:\cldcontext{structures.notes.internalid("\currentnote",\currentnotenumber)}}%
+ \dosetsimplepagereference{note:\currentnote:\currentnotenumber}%
+ \edef\strc_notes_set_destination_attribute_text{\attribute\destinationattribute\currentdestinationattribute}%
+ \let \strc_notes_set_reference_attribute_number\donothing
+ \let \strc_notes_set_style_color_display \strc_notes_set_style_color_display_yes}
+
+\expandafter\let\csname\??noteinteractiondisplay\v!number\expandafter\endcsname\csname\??noteinteractiondisplay\v!yes\endcsname
+
+\let\strc_notes_set_style_color_inline_nop \usenotestyleandcolor
+\let\strc_notes_set_style_color_display_nop\usenotationstyleandcolor
+
+\unexpanded\def\strc_notes_set_style_color_inline_yes#1#2%
+ {\usenotestyleandcolor#1#2%
+ \iflocation\strc_notes_set_style_color_special\fi}
+
+\unexpanded\def\strc_notes_set_style_color_display_yes#1#2%
+ {\usenotationstyleandcolor#1#2%
+ \iflocation\strc_notes_set_style_color_special\fi}
+
+\def\strc_notes_set_style_color_special
+ {\iftrialtypesetting
+ % keep
+ \else\ifx\currentcolorparameter\empty
+ \scratchcounter\ctxlua{structures.notes.deltapage("\currentnote",\currentnotenumber)}\relax % todo calculate once
+ \setlocationcolorspecified\scratchcounter
+ \fi\fi}
+
+\setvalue{\??constructiontexthandler\v!notation}%
+ {\begingroup
+ % we need to retrigger the reference as otherwise it gets lost because we don't do nested
+ % references with the same id ... maybe some day if we can figure out a nice heuristic ...
+ % the problem is that normally it's no issue but here we lap into the margin, so maybe that's
+ % a criterium
+ % \strc_notes_interaction_check_display
+ \strc_notes_set_reference_attribute_number
+ \strc_notes_set_style_color_display\c!headstyle\c!headcolor
+ \strc_enumerations_text
+ \endgroup}
+
+\unexpanded\def\strc_notes_inject_pointer % todo calculate once
+ {\ifcase\ctxlua{structures.notes.deltapage("\currentnote",\currentnotenumber)}\relax
+ % unknown
+ \or
+ % same page
+ \or
+ \noteparameter\c!symbolcommand{\symbol[\v!note:\v!nextpage]}%
+ \or
+ \noteparameter\c!symbolcommand{\symbol[\v!note:\v!previouspage]}%
+ \fi}
+
+\unexpanded\def\strc_notes_register_note_page % called more often than needed
+ {\iftrialtypesetting \else
+ \normalexpanded{\noexpand\ctxlatelua{structures.notes.setsymbolpage("\currentnote",\currentnotenumber)}}%
+ \fi}
+
+\unexpanded\def\strc_notes_inject_symbol
+ {\removeunwantedspaces
+ \doifitalicelse\/\donothing % Charles IV \footnote{the fourth}
+ \ifdim\lastkern=\notesignal
+ \kern\noteparameter\c!distance % yes or no note font? or main text
+ \fi
+ \nobreak
+ \begingroup
+ % \currentconstructionsynchronize
+ \strc_notes_register_note_page % thsi registers the symbol page number (late)
+ \strc_notes_interaction_check_inline
+ \strc_notes_set_style_color_inline\c!textstyle\c!textcolor
+ \hbox \strc_notes_get_reference_attribute_symbol \bgroup
+ \dostarttagged\t!descriptionsymbol\currentnote
+ \dotagsetnotesymbol
+ \noteparameter\c!textcommand{\ctxcommand{noteprefixednumber("\currentnote",\currentnotenumber)}}%
+ \strc_notes_inject_pointer % this can cycle so we need to make sure it has no advance width
+ \egroup
+ \endgroup
+ \dostoptagged
+ \globallet\lastnotesymbol\relax}
+
+\unexpanded\def\strc_notes_inject_dummy % temp hack
+ {\removeunwantedspaces
+ \doifitalicelse\/\donothing % Charles IV \footnote{the fourth}
+ \ifdim\lastkern=\notesignal
+ \kern\noteparameter\c!distance % yes or no note font? or main text
+ \fi
+ \nobreak
+ \hbox to .5em{}%
+ \globallet\lastnotesymbol\relax}
+
+% this needs a further cleanup ... soon as it's a slow mechanism
+%
+% -- set breakpoint in descriptions
+% -- reset after trialtypesetting
+% -- that way we can trick the symbol space
+
+% removed:
+%
+% \pushsomestates
+%
+% core-ins -> obsolete
+%
+% saveinsertiondata
+% restoreinsertiondata
+% saveinsertionbox
+% eraseinsertionbackup
+% restoreinsertionbackup
+
+\def\savenotedata {} % \writestatus{todo}{save note data}}
+\def\restorenotedata {} % \writestatus{todo}{restore note data}}
+\def\savenotecontent {} % \writestatus{todo}{save note content}}
+\def\restorenotecontent{} % \writestatus{todo}{restore note content}}
+\def\erasenotebackup {} % \writestatus{todo}{erase note backup}}
+
+% page-set:
+
+\def\enablenotes {\writestatus{todo}{enable notes}}
+\def\disablenotes {\writestatus{todo}{disable notes}}
+\def\savenotes {\writestatus{todo}{save notes}}
+\def\flushsavednotes{\writestatus{todo}{flush notes}}
+
+% experiment: (compare scope=text and scope=page)
+%
+% \definenote[mynote][way=bytext,location=text,width=\leftmarginwidth,scope=page,rule=,before=,after=,factor=0]
+% \setuptexttexts[margin][\vbox to \textheight{\placenotes[mynote]\vfill}][]
+
+%D Footnotes are can be characterized by three components:
+%D
+%D \startitemize[packed]
+%D \item a small number \footnote {a footnote number} or
+%D symbol {\setupfootnotes [conversion=set 2]\footnote
+%D {a footnote}}
+%D \item and a similar mark at the bottom of the page
+%D \item followed by some additional text
+%D \stopitemize
+%D
+%D Because footnotes are declared at the location of their
+%D reference they can be seen as a special kind of
+%D floating bodies. Their placement is postponed but has to be
+%D taken into account in the pagebreak calculations. This kind
+%D of calculations are forced by using \type{\insert}s and dealing
+%D with all cases is not trivial.
+
+%D \macros
+%D {notesenabled}
+%D
+%D We need a couple of states because at some moments we don't want
+%D to mess around with inserts at all. Take for instance a table
+%D of contents. And so we can temporary disable footnotes by saying
+%D
+%D \starttyping
+%D \notesenabledfalse
+%D \stoptyping
+
+\newif\ifnotesenabled \notesenabledtrue
+
+% better mark a note .. once flushed no more flushing
+
+%appendtoks \notesenabledfalse \to \everymarking
+\appendtoks \notesenabledfalse \to \everybeforepagebody
+\appendtoks \notesenabledfalse \to \everystructurelist % quick hack
+
+%D Often we need to process the whole set of notes and to make that
+%D fast, we use a token register:
+
+% we have several synchronizers:
+%
+% - after a definition
+% - after a specific setup
+% - after a general setup (inheritance of dimensions)
+% - just before a note is typeset
+
+\newtoks\t_strc_notes
+
+\let\strc_notes_process_list\gobbleoneargument
+
+\unexpanded\def\strc_notes_process#1% argument is a \macro that uses \currentnote
+ {\def\strc_notes_process_list##1{\edef\currentnote{##1}\let\currentdescription\currentnote#1}%
+ \the\t_strc_notes}
+
+\newtoks\everychecknote % just before a note is typeset
+\newtoks\everysynchronizenote % after a general setup has happened
+
+\appendtoks
+ \ifx\currentnote\empty \else
+ \setupnotations[\currentnote][]% also a synchronize
+ \fi
+\to \everysynchronizenote
+
+\def\strc_notes_synchronize
+ {\the\everysynchronizenote} % we can speed this one up if needed by avoiding the commalist
+
+\appendtoks
+ \strc_notes_process\strc_notes_synchronize
+\to \everysetupnoteroot
+
+\appendtoks
+ \the\everysynchronizenote
+\to \everydefinenote
+
+% \starttext
+% text \startfootnote Test.\stopfootnote
+% test \footnote{xxxx} \subfootnote{xxxx}
+% test \footnote{xxxx} \subfootnote{xxxx}
+% \stoptext
+
+\installcorenamespace{notecommand}
+\installcorenamespace{notealign}
+\installcorenamespace{notepenalty}
+\installcorenamespace{noterule}
+
+\def\currentnoterulecommand{\csname\??notecommand\currentnote\endcsname}
+\def\currentnoterulealign {\csname\??notealign \currentnote\endcsname}
+
+\def\currentnoterulecommandnormal {\normalnoterule} % no let as it can be changed afterwards
+\def\currentnoterulecommandunknown{\noteparameter\c!rule}
+
+\def\letcurrentnoterulecommand{\expandafter\let\csname\??notecommand\currentnote\endcsname}
+\def\letcurrentnoterulealign {\expandafter\let\csname\??notealign \currentnote\endcsname}
+
+\appendtoks
+ \letvalue{\??notecommand\currentnote}\currentnoterulecommandnormal
+ \letvalue{\??notealign \currentnote}\lefttoright
+\to \everysynchronizenote
+
+\def\strc_notes_set_rule
+ {\letcurrentnoterulecommand\relax
+ \processcommacommand[\noteparameter\c!rule]\strc_notes_set_rule_step}
+
+\def\strc_notes_set_rule_step#1%
+ {\csname\??noterule\ifcsname\??noterule#1\endcsname#1\else\s!unknown\fi\endcsname}
+
+\setvalue{\??noterule \v!on}{\letcurrentnoterulecommand\currentnoterulecommandnormal}
+\setvalue{\??noterule \v!normal}{\letcurrentnoterulecommand\currentnoterulecommandnormal}
+\setvalue{\??noterule \v!left}{\letcurrentnoterulealign \lefttoright}
+\setvalue{\??noterule \v!right}{\letcurrentnoterulealign \righttoleft}
+\setvalue{\??noterule \v!off}{\letcurrentnoterulecommand\relax}
+\setvalue{\??noterule\s!unknown}{\letcurrentnoterulecommand\currentnoterulecommandunknown}
+
+\appendtoks
+ \strc_notes_set_rule
+\to \everysynchronizenote
+
+\def\currentnotepenalty
+ {\ifcsname\??notepenalty\noteparameter\c!split\endcsname
+ \csname\??notepenalty\noteparameter\c!split\endcsname
+ \else
+ \numexpr\noteparameter\c!split\relax
+ \fi}
+
+\setnewconstant\notepenaltytolerant \zerocount
+\setnewconstant\notepenaltystrict 9999
+\setnewconstant\notepenaltyverystrict\maxdimen
+
+\letvalue{\??notepenalty\v!tolerant }\notepenaltytolerant
+\letvalue{\??notepenalty\v!strict }\notepenaltystrict
+\letvalue{\??notepenalty\v!verystrict}\notepenaltyverystrict
+\letvalue{\??notepenalty }\notepenaltytolerant
+
+\def\strc_notes_set_width
+ {\edef\p_width{\noteparameter\c!width}%
+ \ifx\p_width\empty
+ \setnoteparameter\c!width{\hsize}%
+ \fi}
+
+\appendtoks
+ \strc_notes_set_width
+\to \everysynchronizenote
+
+%D The following switch can be used to disable limiting the height of the footnote
+%D area, something that is needed in multi column balancing. Use this switch with
+%D care.
+
+\newif\ifnotelimit \notelimittrue % shared
+
+\def\strc_notes_set_factor
+ {\edef\p_factor{\noteparameter\c!factor}%
+ \ifx\p_factor\empty \else
+ \ifnum\p_factor<\zerocount \else
+% \global
+ \count\currentnoteins\p_factor % new: global
+ \fi
+ \fi}
+
+\appendtoks
+ \strc_notes_set_factor
+\to \everysynchronizenote
+
+% locations:
+
+\installcorenamespace{notelocationvariant}
+\installcorenamespace{notepositionvariant}
+\installcorenamespace{notelocation}
+
+% \newconditional\c_strc_notes_delayed
+
+\setvalue{\??notelocation\v!page }{\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_page}
+\setvalue{\??notelocation\v!columns }{\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_columns}
+\setvalue{\??notelocation\v!lastcolumn }{\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_lastcolumn}
+\setvalue{\??notelocation\v!firstcolumn}{\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_firstcolumn}
+\setvalue{\??notelocation\v!none }{\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_none}
+\setvalue{\??notelocation\v!text }{\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_text}
+\setvalue{\??notelocation\v!high }{\letvalue{\??notepositionvariant\currentnote}\strc_notes_set_position_high}
+\setvalue{\??notelocation\v!bottom }{\letvalue{\??notepositionvariant\currentnote}\strc_notes_set_position_bottom}
+
+\def\strc_notes_set_location
+ {\letvalue{\??notelocationvariant\currentnote}\strc_notes_set_position_page
+ \letvalue{\??notepositionvariant\currentnote}\strc_notes_set_position_bottom
+ \normalexpanded{\rawprocesscommalist[\noteparameter\c!location]\strc_notes_set_location_step}}
+
+\unexpanded\def\strc_notes_set_location_step#1%
+ {\ifcsname\??notelocation#1\endcsname
+ \csname\??notelocation#1\endcsname
+ \fi}
+
+\appendtoks
+ \strc_notes_set_location
+\to \everysynchronizenote
+
+\newskip \s_strc_notes_distance % we need to implement stretch
+\newcount\c_strc_notes_columns
+
+\def\strc_notes_set_distance
+ {\begingroup
+ \setbox\scratchbox\vbox % no reuse as it can mirror
+ {\forgetall
+ % \strc_notes_set_bodyfont
+ \dontcomplain
+ \noteparameter\c!before
+ \placenoterule
+ \noteparameter\c!after}%
+ \expandafter\endgroup\expandafter
+ \s_strc_notes_distance\the\ht\scratchbox\relax}
+
+\def\strc_notes_set_columns
+ {\c_strc_notes_columns\noteparameter\c!n\relax
+ \ifcase\c_strc_notes_columns
+ \c_strc_notes_columns\plusone
+ \fi}
+
+\def\strc_notes_set_location_page
+ {%\setfalse\c_strc_notes_delayed
+ \strc_notes_set_distance
+ \strc_notes_set_columns
+ \global\count\currentnoteins\numexpr\plusthousand/\c_strc_notes_columns\relax
+ \global\dimen\currentnoteins\ifnotelimit\dimexpr\noteparameter\c!height*\c_strc_notes_columns\relax\else\maxdimen\fi
+ \global\skip \currentnoteins\s_strc_notes_distance}
+
+\def\strc_notes_set_location_columns
+ {%\setfalse\c_strc_notes_delayed
+ \strc_notes_set_distance
+ \strc_notes_set_columns
+ \ifnum\currentnofcolumns=\zerocount
+ \c_strc_notes_columns\plusone
+ \fi
+ \global\count\currentnoteins\numexpr\plusthousand/\c_strc_notes_columns\relax
+ \global\dimen\currentnoteins\ifnotelimit\dimexpr\noteparameter\c!height*\c_strc_notes_columns\relax\else\maxdimen\fi
+ \global\skip \currentnoteins\s_strc_notes_distance}
+
+\def\strc_notes_set_location_firstcolumn
+ {%\setfalse\c_strc_notes_delayed
+ \strc_notes_set_distance
+ \strc_notes_set_columns
+ \global\count\currentnoteins\plusthousand
+ \global\dimen\currentnoteins\ifnotelimit\noteparameter\c!height\else\maxdimen\fi
+ \global\skip \currentnoteins\s_strc_notes_distance}
+
+\let\strc_notes_set_location_lastcolumn\strc_notes_set_location_firstcolumn
+
+\def\strc_notes_set_location_text % we don't use inserts anyway (e.g. endnotes)
+ {%\settrue\c_strc_notes_delayed
+ \ctxlua{structures.notes.setstate("\currentnote","store")}%
+ \global\dimen\currentnoteins\maxdimen
+ \global\count\currentnoteins\zerocount
+ \global\skip \currentnoteins\zeropoint}
+
+\let\strc_notes_set_location_none\strc_notes_set_location_text
+
+\def\strc_notes_set_properties
+ {\strc_notes_set_columns
+ \strc_notes_set_distance
+ \csname\??notelocationvariant\currentnote\endcsname}
+
+\let\strc_notes_set_position_high\relax
+
+\def\strc_notes_set_position_bottom
+ {\settrue\c_notes_bottom_present}
+
+\appendtoks
+ \strc_notes_set_properties
+\to \everysynchronizenote
+
+%D A fast checker for bottom notes being used:
+
+\newconditional\c_notes_bottom_present
+
+\def\strc_notes_check_if_bottom_present_indeed % in otr !
+ {\ifvoid\currentnoteins\else
+ \csname\??notepositionvariant\currentnote\endcsname
+ \fi}
+
+\def\strc_notes_check_if_bottom_present_step
+ {\ifconditional\c_notes_bottom_present\else\strc_notes_check_if_bottom_present_indeed\fi}
+
+\def\strc_notes_check_if_bottom_present
+ {\setfalse\c_notes_bottom_present
+ \strc_notes_process\strc_notes_check_if_bottom_present_step}
+
+% Example of using factor:
+%
+% \definenote[mynote][way=bypage,location=text,width=\marginwidth,rule=,before=,factor=0]
+% \setuplayout[backspace=5cm,margin=3cm,margindistance=.5cm,width=middle]
+% \setuptexttexts[margin][\vbox to \textheight{\placenotes[mynote]\vfill}][]
+% \starttext
+% \dorecurse{10}{test \mynote{one one one one one one} \input zapf \mynote{one one one one one one} }
+% \stoptext
+
+%D The noterule can be a graphic and therefore calling this
+%D setup macro at every skipswitch is tricky (many many MP
+%D runs). Let's just reserve a few points, that probably match
+%D those of the stretch component.
+
+%D A bit messy:
+
+\unexpanded\def\placenoterule
+ {\begingroup
+ \currentnoterulealign
+ \currentnoterulecommand
+ \par
+ \endgroup}
+
+\unexpanded\def\normalnoterule
+ {\ifvmode
+ \dontleavehmode \blackrule
+ [\c!color=\noteparameter\c!rulecolor,
+ \c!width=.2\hsize,
+ \c!height=\noteparameter\c!rulethickness,
+ \c!depth=\zeropoint]%
+ \endgraf
+ \kern\strutdepth
+ \fi}
+
+\ifdefined\setnotehsize \else
+
+ \unexpanded\def\setnotehsize{\hsize\noteparameter\c!width\relax} % can be overloaded
+
+\fi
+
+%D The formatting depends on the width of the table, so we
+%D have to set \type {n} to zero.
+%D
+%D \starttyping
+%D \startbuffer
+%D \bTABLE
+%D \bTR \bTD one \footnote{\dorecurse{10}{abcd }} \eTD \bTD two \eTD \eTR
+%D \bTR \bTD three fout five six seven eight nine \eTD \bTD ten \eTD \eTR
+%D \eTABLE
+%D \stopbuffer
+%D
+%D \startlocalfootnotes[n=0,location={text,none}]
+%D \placelegend[n=2]{\getbuffer}{\placelocalfootnotes}
+%D \stoplocalfootnotes
+%D \stoptyping
+
+%D \macros
+%D {footnote}
+%D
+%D A footnote can have a reference as optional argument and
+%D therefore its formal specification looks like:
+%D
+%D \showsetup{footnote}
+%D
+%D This command has one optional command: the reference. By
+%D saying \type{[-]} the number is omitted. The footnote
+%D command is not that sensitive to spacing, so it's quite
+%D legal to say:
+%D
+%D \startbuffer
+%D Users of \CONTEXT\ must keep both feet \footnote{Given they
+%D have two.} on the ground and not get confused \footnote{Or
+%D even crazy.} by all those obscure \footnote{But fortunately
+%D readable.} parameters.
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D When setting the \type{conversion} to \type{set 2} we get
+%D something like:
+%D
+%D \bgroup
+%D \startnarrower
+%D \setupfootnotes[conversion=set 1]
+%D \getbuffer
+%D \stopnarrower
+%D \egroup
+%D
+%D Typesetting footnotes is, at least for the moment, disabled
+%D when reshaping boxes.
+%D
+%D The additional macro \type {\footnotetext} and the
+%D associated \type {\note} macro were implemented at
+%D request of users on the mailing list and a suggestion by
+%D taco to split of the symbol placement. I decided to
+%D merge this functionality with the existing \type {\note}
+%D functionality.
+
+%D The next implementation runs on top of enumerations (only in \MKIV).
+%D
+%D \starttyping
+%D \setupenumerations
+%D [footnote]
+%D [ style=\type{(es)},
+%D headstyle=\type{(hs)}]
+%D
+%D \setupnote
+%D [footnote]
+%D [ style=\type{(s)},
+%D command=\type{(c)},
+%D textcommand=\type{(tc)},
+%D textstyle=\type{(ts)},
+%D numberstyle=\type{(ns)},
+%D numbercommand=\type{(nc)}]
+%D
+%D \setuplayout[backspace=6cm,marginwidth=cm,width=middle]
+%D
+%D \starttext
+%D \dorecurse{9}{This\footnote{Hello World #1} is a test.\par }
+%D \stoptext
+%D \stoptyping
+
+% check what is called at the lua end
+
+% ugly ...
+
+\newconditional\c_strc_notes_symbol \settrue\c_strc_notes_symbol % not used
+\newconditional\c_strc_notes_skip
+
+ \unexpanded\def\setnote [#1]{\getvalue{#1}}
+ \unexpanded\def\setnotetext[#1]{\global\settrue\c_strc_notes_skip\getvalue{#1}}
+
+\def\handlenoteinsert#1#2% tg, id
+ {\begingroup
+ \edef\currentnote{#1}%
+ \the\everybeforenoteinsert
+ \insert\currentnoteins\bgroup
+ \the\everyinsidenoteinsert\relax
+ \doprocesslocalsetups{\noteparameter\c!setups}% experimental
+ \doifelse{\noteparameter\c!paragraph}\v!yes
+ {\nointerlineskip
+ \startvboxtohbox
+ \handlenoteitself{#1}{#2}%
+ % add some slack
+ \stopvboxtohbox}
+ {\handlenoteitself{#1}{#2}}%
+ \egroup
+ \the\everyafternoteinsert
+ \endgroup}
+
+\def\betweennoteitself#1% tg
+ {\edef\currentnote{#1}%
+ \doif{\noteparameter\c!paragraph}\v!yes\strc_notes_between_paragraphs}
+
+\def\handlenoteitself#1#2% tg, id
+ {\edef\currentnote{#1}%
+ \edef\currentnotenumber{#2}%
+ \edef\currentconstructionlistentry{\ctxlua{tex.write(structures.notes.listindex("#1",#2))}}% index in list cache
+ % as we can have collected notes (e.g. in tables) we need to recover
+ % \currentdescriptionattribute and \currentdescriptionsynchronize
+ %
+ %\reinstateconstructionnumberentry\currentconstructionlistentry % we could store the number in the entry
+ %
+ \dontcomplain
+% \begingroup
+ \strc_notes_interaction_check_display
+ \strc_notes_set_reference_attribute_text
+ \strc_constructions_stored_start
+ \begstrut
+ \strc_notes_set_destination_attribute_text
+ \strc_notes_inject_text
+ \endstrut
+ \strc_constructions_stored_stop
+% \endgroup
+ }
+
+\unexpanded\def\strc_notes_inject_text
+ {\ctxcommand{savedlisttitle("\currentconstructionmain",\currentconstructionlistentry)}}
+
+\let\startpushnote\relax
+\let\stoppushnote \relax
+
+\newsignal\notesignal
+
+\newconditional\processingnote
+\newconditional\postponednote
+
+\newtoks\everybeforenoteinsert
+\newtoks\everyinsidenoteinsert
+\newtoks\everyafternoteinsert
+
+\appendtoks
+ \let\flushnotes\relax
+ \let\postponenotes\relax
+ \forgetall
+ \resetallattributes % new, we don't want color bleed into notes
+\to \everybeforenoteinsert
+
+\appendtoks
+ \doif{\noteparameter\c!scope}\v!page{\floatingpenalty\maxdimen}% experiment
+ \penalty\currentnotepenalty
+ \forgetall
+ \strc_notes_set_bodyfont
+ \redoconvertfont % to undo \undo calls in in headings etc
+ \splittopskip\strutht % not actually needed here
+ \splitmaxdepth\strutdp % not actually needed here
+ % brrr
+ \leftmargindistance \noteparameter\c!margindistance
+ \rightmargindistance\leftmargindistance
+% \ifnum\noteparameter\c!n=\zerocount % no ifcase new 31-07-99 ; always ?
+% \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize % ?
+% \fi
+\to \everyinsidenoteinsert
+
+\appendtoks % only needed when columns
+ \setsimplecolumnshsize[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%
+\to \everyinsidenoteinsert
+
+% not: \appendtoks \setnotehsize \to \everyinsidenoteinsert (spoils columns)
+
+%D Normally footnotes are saved as inserts that are called upon
+%D as soon as the pagebody is constructed. The footnote
+%D insertion routine looks just like the \PLAIN\ \TEX\ one,
+%D except that we check for the end note state.
+
+% testcase for split bottom alignment see (a) below
+%
+% \dorecurse{6}{\input tufte\footnote{\input ward \input tufte \relax}}
+
+\unexpanded\def\placenoteinserts
+ {\strc_notes_process\strc_notes_place_inserts}
+
+\def\strc_notes_place_inserts
+ {%\ifconditional\c_strc_notes_delayed \else
+ \ifdim\ht\currentnoteins>\zeropoint % or a faster delayed test
+ \strc_notes_place_inserts_indeed
+ \fi}
+
+\def\strc_notes_place_inserts_indeed
+ {\relax
+ \ifdim\ht\currentnoteins>\zeropoint
+ \endgraf
+ \ifvmode
+ \whitespace
+ \noteparameter\c!before
+ \fi
+ % \bgroup
+ % \setupalign[\noteparameter\c!align]%
+ \placenoterule % alleen in ..mode
+ % \par
+ % \egroup
+ \bgroup
+ \strc_notes_set_bodyfont
+ \setbox\scratchbox\hbox
+ {\strc_notes_flush_inserts}%
+ \setbox\scratchbox\hbox
+ {\setupcurrentnote
+ [\c!location=,
+ \c!width=\v!fit,
+ \c!height=\v!fit,
+ \c!strut=\v!no,
+ \c!offset=\v!overlay]%
+ \inheritednoteframed
+ {\ifdim\dp\scratchbox=\zeropoint % this hack is needed because \vadjust
+ \hbox{\lower\strutdp\box\scratchbox}% % in margin number placement
+ \else % hides the (always) present depth
+ \box\scratchbox
+ \fi}}%
+ \setbox\scratchbox\hbox{\lower\strutdepth\box\scratchbox}%
+ \dp\scratchbox\strutdepth % so we know that it has the note bodyfont depth
+ \box\scratchbox
+ \egroup
+ \endgraf
+ \ifvmode
+ \noteparameter\c!after
+ \fi
+ \fi}
+
+\def\strc_notes_flush_inserts
+ {\ifcase\noteparameter\c!n\relax
+ % should not happen
+ \or
+ \strc_notes_flush_inserts_normal
+ \else
+ \strc_notes_flush_inserts_columns
+ \fi}
+
+\def\strc_notes_flush_inserts_normal
+ {%\iftrialtypesetting\copy\else\box\fi\currentnoteins
+ \strc_notes_flush_global
+ \obeydepth} % (a) added , since split footnotes will not align properly
+
+\def\strc_notes_flush_inserts_columns
+ {\startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%
+ %\iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins % compare with local
+ \strc_notes_flush_global
+ \stopsimplecolumns}
+
+% idea: tag with attr and then just flush them again
+
+\def\strc_notes_between_paragraphs % should not be too much
+ {\noteparameter\c!inbetween}
+
+\def\strc_notes_between_paragraphs_first
+ {\glet\strc_notes_between_paragraphs_indeed\strc_notes_between_paragraphs}% shape works reverse
+
+\def\strc_notes_flush_global % will be done in lua instead
+ {\doifelse{\noteparameter\c!paragraph}\v!yes
+ {\vbox
+ {\beginofshapebox
+ \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins
+ \endofshapebox
+ %\doreshapebox{\box\shapebox}{}{}{}% get rid of penalties etc
+ \let\strc_notes_between_paragraphs_indeed\strc_notes_between_paragraphs_first % shape works reverse
+ \doreshapebox
+ {\hbox{\unhbox\shapebox\strc_notes_between_paragraphs_indeed}}
+ {}%
+ {}%
+ {}% get rid of penalties etc
+ \innerflushshapebox
+ \convertvboxtohbox}}
+ {\iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins}}
+
+%D Supporting end notes is surprisingly easy. Even better, we
+%D can combine this feature with solving the common \TEX\
+%D problem of disappearing inserts when they're called for in
+%D deeply nested boxes. The general case looks like:
+%D
+%D \starttyping
+%D \postponenotes
+%D \.box{whatever we want with footnotes}
+%D \flushnotes
+%D \stoptyping
+%D
+%D This alternative can be used in headings, captions, tables
+%D etc. The latter one sometimes calls for notes local to
+%D the table, which can be realized by saying
+%D
+%D \starttyping
+%D \setlocalfootnotes
+%D some kind of table with local footnotes
+%D \placelocalfootnotes
+%D \stoptyping
+%D
+%D Postponing is accomplished by simply redefining the (local)
+%D insert operation. A not too robust method uses the
+%D \type{\insert} primitive when possible. This method fails in
+%D situations where it's not entirely clear in what mode \TEX\
+%D is. Therefore the auto method can is to be overruled when
+%D needed.
+
+\newconditional\postponingnotes
+
+% we need a proper state: normal, postponing, flushing
+
+\def\postponenotes
+ {\ifconditional\postponingnotes\else
+ \global\settrue\postponingnotes
+ \global\let\flushnotes\doflushnotes
+ \ctxlua{structures.notes.postpone()}%
+ \fi}
+
+\let\flushnotes\relax
+
+\def\doflushnotes
+ {\ifconditional\postponingnotes
+ \begingroup
+ \let\flushnotes \relax
+ \let\postponenotes\relax
+ \ctxlua{structures.notes.flushpostponed()}% this also resets the states !
+ \global\setfalse\postponednote
+ \global\setfalse\postponingnotes
+ \global\let\flushnotes\relax
+ \endgroup
+ \fi}
+
+%D \macros
+%D {startlocalfootnotes,placelocalfootnotes}
+%D
+%D The next two macros can be used in for instance tables, as
+%D we'll demonstrate later on.
+%D
+%D \showsetup{startlocalfootnotes}
+%D \showsetup{placelocalfootnotes}
+
+% todo: compatibility mode: when first arg is assignment or missing, then all
+
+\newtoks\everyplacelocalnotes
+
+\appendtoks
+ \let\flushnotes \relax
+ \let\postponenotes\relax
+\to \everyplacelocalnotes
+
+\newconditional\inlocalnotes
+
+\unexpanded\def\startlocalnotes
+ {\dosingleempty\strc_notes_local_start}
+
+\def\strc_notes_local_start[#1]%
+ {\def\localnoteslist{#1}%
+ \settrue\inlocalnotes
+ \processcommacommand[\localnoteslist]\strc_notes_local_start_step}
+
+\unexpanded\def\stoplocalnotes
+ {\processcommacommand[\localnoteslist]\strc_notes_local_stop_step
+ \setfalse\inlocalnotes}
+
+\def\strc_notes_local_start_step#1%
+ {\doifnot{\noteparameter\c!continue}\v!yes
+ {\strc_counters_save{#1}%
+ \strc_counters_reset{#1}}%
+ \ctxlua{structures.notes.save("#1","store")}}
+
+\def\strc_notes_local_stop_step#1%
+ {\doifnot{\noteparameter\c!continue}\v!yes
+ {\strc_counters_restore{#1}}%
+ \ctxlua{structures.notes.restore("#1")}}
+
+\unexpanded\def\placelocalnotes
+ {\dodoubleempty\strc_notes_local_place}
+
+\def\strc_notes_local_place[#1][#2]%
+ {\doif{\ctxlua{structures.notes.getstate("#1")}}{store}{\strc_notes_local_place_indeed{#2}{#1}}}
+
+\def\strc_notes_local_place_indeed#1#2% settings note
+ {\begingroup
+ \edef\currentnote{#2}% is already set?
+ \the\everyplacelocalnotes
+ % beware, we cannot trust setting \currentnote here
+ \setupcurrentnote[\c!width=\v!fit,\c!height=\v!fit,\c!strut=\v!no,\c!offset=\v!overlay,#1]% we only need a selective one
+ \strc_notes_place_local_alternative
+ \strc_notes_set_properties % restore globals (if needed)
+ \endgroup
+ }% TODO: just restore properties \the\everychecknote} % we need to restore the old state
+
+%D These commands can be used like:
+%D
+%D \startbuffer
+%D \startlocalnotes[width=.3\hsize,n=0]
+%D \placetable
+%D {Some Table}
+%D \placeontopofeachother
+%D {\starttable[|l|r|]
+%D \HL
+%D \VL Nota\footnote{Bene} \VL Bene\footnote{Nota} \VL\SR
+%D \VL Bene\footnote{Nota} \VL Nota\footnote{Bene} \VL\SR
+%D \HL
+%D \stoptable}
+%D {\placelocalnotes}
+%D \stoplocalnotes
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D Because this table placement macro expect box content, and
+%D thanks to the grouping of the local footnotes, we don't need
+%D additional braces.
+%D
+%D \getbuffer
+
+%D \macros
+%D {placefootnotes}
+%D
+%D We still have no decent command for placing footnotes
+%D somewhere else than at the bottom of the page (for which no
+%D user action is needed). Footnotes (endnotes) can be
+%D placed by using
+%D
+%D \showsetup{placefootnotes}
+
+\unexpanded\def\placebottomnotes
+ {\strc_notes_process\strc_notes_place_inserts}
+
+\unexpanded\def\placenotes
+ {\dodoubleempty\strc_notes_place}
+
+\def\strc_notes_place[#1][#2]%
+ {\processcommalist[#1]{\strc_notes_place_indeed{#2}}}
+
+\def\strc_notes_place_indeed#1#2% settings note
+ {\edef\currentnote{#2}% grouping ?
+ \doifelse{\ctxlua{structures.notes.getstate("#2")}}{store}
+ \strc_notes_local_place_indeed
+ \strc_notes_global_place_indeed
+ {#1}{#2}}
+
+\def\strc_notes_global_place_indeed#1#2%
+ {\begingroup
+ \setupnote[#2][#1]%
+ \strc_notes_place_inserts
+ \endgroup
+ \the\everysetupnote} % to be checked .. synchronize
+
+%D Placement
+
+\installcorenamespace{notealternative}
+
+\unexpanded\def\installnotealternative#1#2%
+ {\setvalue{\??notealternative#1}{#2}}
+
+\unexpanded\def\doifnotescollected#1%
+ {\ctxlua{structures.notes.doifcontent("#1")}}
+
+\def\strc_notes_place_local_alternative % will be a setup (wrapper)
+ {\doifnotescollected\currentnote
+ {\endgraf
+ \ifvmode
+ \whitespace
+ \noteparameter\c!before
+ \fi
+ \begingroup
+ \strc_notes_set_bodyfont
+ \getvalue{\??notealternative\noteparameter\c!alternative}%
+ \endgroup
+ \ifvmode
+ \noteparameter\c!after
+ \fi}}
+
+\setvalue{\??notealternative}{\getvalue{\??notealternative\v!none}}
+
+%D A stupid alternative is also provided:
+%D
+%D \starttyping
+%D \setupfootnotes[location=text,alternative=none]
+%D \stoptyping
+
+% setups ?
+
+% \def\flushlocalnotes#1{\ctxlua{structures.notes.flush("#1","store")}}
+\def\flushlocalnotes#1{\ctxlua{structures.notes.flush("#1","store","\noteparameter\c!criterium")}}
+
+\installnotealternative \v!none
+ {\flushlocalnotes\currentnote}
+
+\installnotealternative \v!grid % test if n > 0
+ {\begingroup
+ \setupcurrentnote[\c!location=]%
+ \snaptogrid\hbox
+ {\inheritednoteframed
+ {\flushlocalnotes\currentnote}}%
+ \endgroup}
+
+\installnotealternative \v!fixed % test if n > 0
+ {\begingroup
+ \setupcurrentnote[\c!location=]%
+ \inheritednoteframed
+ {\flushlocalnotes\currentnote}%
+ \endgroup}
+
+\installnotealternative \v!columns % redundant
+ {\begingroup
+ \setupcurrentnote[\c!location=]%
+ \inheritednoteframed
+ {\edef\currentnotewidth{\noteparameter\c!width}%
+ \doifdimensionelse\currentnotewidth\donothing
+ {\edef\currentnotewidth{\the\hsize}}%
+ \startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\currentnotewidth]%
+ \flushlocalnotes\currentnote
+ \stopsimplecolumns}%
+ \endgroup}
+
+% 0:page 1:firstcolumn 2:lastcolumn
+
+\newconstant\c_strc_notes_page_location
+
+\unexpanded\def\strc_notes_check_locations
+ {\edef\p_strc_notes_location{\rootnoteparameter\c!location}%
+ \c_strc_notes_page_location
+ \ifx\p_strc_notes_location\v!firstcolumn\plusone \else
+ \ifx\p_strc_notes_location\v!lastcolumn \plustwo \else
+ \zerocount\fi\fi}
+
+\appendtoks
+ \strc_notes_check_locations
+\to \everysynchronizenote
+
+% still semi public (but will change)
+
+\newif\ifnotespresent
+
+\unexpanded\def\checknotepresence
+ {\notespresentfalse
+ \strc_notes_process\strc_notes_check_presence}
+
+\def\strc_notes_check_presence
+ {\ifdim\ht\currentnoteins>\zeropoint
+ \notespresenttrue
+ \fi}
+
+%D \macros
+%D {fakenotes}
+
+ % used in page-mul
+
+ \ifdefined\currentnofcolumns\else \def\currentnofcolumns{\@@kln} \fi
+
+ \unexpanded\def\fakenotes
+ {\ifhmode\endgraf\fi\ifvmode
+ \calculatetotalclevernoteheight
+ \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
+ \fi}
+
+ \unexpanded\def\fakepagenotes
+ {\ifhmode\endgraf\fi\ifvmode
+ \calculatetotalpagenoteheight
+ \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
+ \fi}
+
+ \newdimen\totalnoteheight
+
+ \def\doaddtototalnoteheight#1%
+ {\ifdim\ht#1>\zeropoint
+ \ifcase\count#1\else
+ % todo: divide by count
+ \advance\totalnoteheight\ht #1%
+ \advance\totalnoteheight\skip#1%
+ \fi
+ \fi}
+
+ \def\docalculatetotalnoteheight
+ {\ifcase\c_strc_notes_page_location % tricky here ! ! ! to be sorted out ! ! !
+ \doaddtototalnoteheight\currentnoteins
+ \else
+ % \doaddtototalnoteheight\currentbackupnoteins
+ \fi}
+
+ \def\docalculatetotalclevernoteheight
+ {\ifcase\c_strc_notes_page_location \else % tricky here ! ! ! to be sorted out ! ! !
+ \doaddtototalnoteheight\currentnoteins
+ \fi}
+
+ \def\docalculatetotalpagenoteheight
+ {\doaddtototalnoteheight\currentnoteins}
+
+ \def\calculatetotalnoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalnoteheight}
+ \def\calculatetotalclevernoteheight{\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalclevernoteheight}
+ \def\calculatetotalpagenoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalpagenoteheight}
+
+%D Now how can this mechanism be hooked into \CONTEXT\ without
+%D explictly postponing footnotes? The solution turned out to
+%D be rather simple:
+%D
+%D \starttyping
+%D \everypar {...\flushnotes...}
+%D \neverypar {...\postponenotes}
+%D \stoptyping
+%D
+%D We can use \type{\neverypar} because in most commands
+%D sensitive to footnote gobbling we disable \type{\everypar}
+%D in favor for \type{\neverypar}. In fact, this footnote
+%D implementation is the first to use this scheme.
+
+%D This is a nasty and new secondary footnote flusher. It
+%D can be hooked into \type {\everypar} like:
+%D
+%D \starttyping
+%D \appendtoks \synchronizenotes \to \everypar
+%D \stoptyping
+
+% \def\dosynchronizenotes
+% {\ifvoid\currentnoteins\else\insert\currentnoteins{\unvbox\currentnoteins}\fi}
+%
+% \def\synchronizenotes
+% {\strc_notes_process\dosynchronizenotes}
+
+\let\synchronizenotes\relax
+
+%D When typesetting footnotes, we have to return to the
+%D footnote specific bodyfont size, which is in most cases derived
+%D from the global document bodyfont size. In the previous macros
+%D we already used a footnote specific font setting macro.
+
+\def\strc_notes_set_bodyfont
+ {\let\strc_notes_set_bodyfont\relax
+ \restoreglobalbodyfont
+ \switchtobodyfont[\noteparameter\c!bodyfont]%
+ \setupalign[\noteparameter\c!align]}
+
+%D The footnote mechanism defaults to a traditional one
+%D column way of showing them. By default we precede them by
+%D a small line.
+
+\definenote [\v!footnote]
+\definenote [\v!endnote ] [\c!location=\v!none] % else no break
+
+%D Compatibility macros:
+
+\unexpanded\def\setupfootnotedefinition{\setupnotedefinition [\v!footnote]}
+\unexpanded\def\setupfootnotes {\setupnote [\v!footnote]}
+ \def\footnotetext {\setnotetext [\v!footnote]}
+\unexpanded\def\placefootnotes {\dodoubleempty\strc_notes_place_footnotes [\v!footnote]}
+\unexpanded\def\placelocalfootnotes {\dodoubleempty\strc_notes_place_local_footnotes[\v!footnote]}
+\unexpanded\def\startlocalfootnotes {\startlocalnotes [\v!footnote]} % alleen footnote
+\unexpanded\def\stoplocalfootnotes {\stoplocalnotes }
+
+\def\strc_notes_place_footnotes [#1][#2]{\ifsecondargument\placenotes [#1][#2,\c!height=\textheight]\else\placenotes [#1]\fi}
+\def\strc_notes_place_local_footnotes[#1][#2]{\ifsecondargument\placelocalnotes[#1][#2,\c!height=\textheight]\else\placelocalnotes[#1]\fi}
+
+%D Goodies:
+%D
+%D \starttyping
+%D \dorecurse {100} {
+%D test \footnote{\doifnoteonsamepageelse[footnote]{ibidem}{aaa}}
+%D }
+%D \stoptyping
+
+\def\doifnoteonsamepageelse[#1]{\ctxlua{structures.notes.doifonsamepageasprevious("#1")}}
+
+%D New trickery:
+
+%D \macros
+%D {note}
+%D
+%D Refering to a note is accomplished by the rather short
+%D command:
+%D
+%D \showsetup{note}
+%D
+%D This command is implemented rather straightforward as:
+
+\installcorenamespace{notesymbol}
+
+\let\lastnotesymbol\relax % todo: per class
+
+\unexpanded\def\notesymbol
+ {\dodoubleempty\strc_notes_symbol}
+
+\def\strc_notes_symbol[#1][#2]%
+ {\dontleavehmode
+ \begingroup
+ \edef\currentnote{#1}%
+ \usenotestyleandcolor\c!textstyle\c!textcolor
+ \ifnotesenabled
+ \ifsecondargument
+ \unskip
+ \noteparameter\c!textcommand{\in[#2]}% command here?
+ \else
+ \noteparameter\c!textcommand\lastnotesymbol % check if command double
+ \fi
+ \fi
+ \endgroup}
+
+\unexpanded\def\note
+ {\dodoubleempty\strc_notes_note}
+
+\def\strc_notes_note[#1][#2]%
+ {\ifsecondargument
+ \strc_notes_symbol[#1][#2]%
+ \else
+ \secondargumenttrue
+ \strc_notes_symbol[\v!footnote][#1]%
+ \fi}
+
+% will be redone if needed
+%
+% \def\ownnotesymbol#1% #1 gets number passed
+% {\executeifdefined{\??notesymbol\currentnote}\empty}
+%
+% \unexpanded\def\setnotesymbol[#1]#2#3%
+% {\prewordbreak % prevent lookback
+% \setgvalue{\??notesymbol#1}{#3}
+% \strc_notes_inject_symbol}
+%
+% \unexpanded\def\ownnote[#1]#2#3#4%
+% {\setnotesymbol[#1]{#2}{#3}%
+% \setnotetext [#1]{#4}}
+%
+% \defineconversion
+% [ownnote]
+% [\ownnotesymbol]
+
+\protect \endinput
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index f093e1275..989bf5c23 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -274,11 +274,6 @@ function references.set(kind,prefix,tag,data)
end
end
-function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do internal automatically here
- references.set(kind,prefix,tag,data)
- texcount.lastdestinationattribute = references.setinternalreference(prefix,tag,nil,view) or -0x7FFFFFFF
-end
-
function references.enhance(prefix,tag)
local l = tobesaved[prefix][tag]
if l then
@@ -1534,6 +1529,8 @@ directives.register("references.linkmethod", function(v) -- page mixed names
references.setinnermethod(v)
end)
+-- this is inconsistent
+
function references.setinternalreference(prefix,tag,internal,view) -- needs checking
if innermethod == "page" then
return unsetvalue
@@ -1563,8 +1560,22 @@ function references.setinternalreference(prefix,tag,internal,view) -- needs chec
end
end
+function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do internal automatically here
+ references.set(kind,prefix,tag,data)
+ texcount.lastdestinationattribute = references.setinternalreference(prefix,tag,nil,view) or -0x7FFFFFFF
+end
+
function references.getinternalreference(n) -- n points into list (todo: registers)
local l = lists.collected[n]
+ return l and l.references.internal or n
+end
+
+function commands.setinternalreference(prefix,tag,internal,view) -- needs checking
+ context(references.setinternalreference(prefix,tag,internal,view))
+end
+
+function commands.getinternalreference(n) -- this will also be a texcount
+ local l = lists.collected[n]
context(l and l.references.internal or n)
end
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index b1268170b..88d491a31 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -223,7 +223,7 @@
%D For internal usage:
-\def\dosetsimplepagereference#label%
+\def\dosetsimplepagereference#label% beware, not that ok as it injects a dummy ... brrr
{\iflocation
\ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","#label",
{
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index 2602759dc..3d7655776 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -719,7 +719,7 @@
\docheckheadlayout
\fi\fi}%
{\docheckheadlayout}%
- \doifnot{\headparameter\c!aligntitle}\v!float\flushsidefloats
+ \doifnot{\headparameter\c!aligntitle}\v!float\page_otr_command_flush_side_floats
\headparameter\c!before
\relax
% \ifpagebreakdisabled
diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv
index a52e9b1af..61225329c 100644
--- a/tex/context/base/strc-tag.mkiv
+++ b/tex/context/base/strc-tag.mkiv
@@ -22,117 +22,122 @@
%D Eventually these labels will either move to the modules
%D where they're used, or they will en dup in mult-tag.
-\def\t!document {document} % Div
-
-\def\t!division {division} % Div
-\def\t!paragraph {paragraph} % P
-\def\t!p {p} % P
-\def\t!construct {construct} % Span
-\def\t!highlight {highlight} % Span
-
-\def\t!section {section} % Sect
-\def\t!sectiontitle {sectiontitle} % H
-\def\t!sectionnumber {sectionnumber} % H
-\def\t!sectioncontent {sectioncontent} % Div
-
-\def\t!itemgroup {itemgroup} % L
-\def\t!item {item} % Li
-\def\t!itemtag {itemtag} % Lbl
-\def\t!itemcontent {itemcontent} % LBody
-
-\def\t!description {description} % Li
-\def\t!descriptiontag {descriptiontag} % Lbl
-\def\t!descriptioncontent{descriptioncontent} % LBody
-\def\t!descriptionsymbol {descriptionsymbol} % Span
-
-\def\t!verbatimblock {verbatimblock} % Code
-\def\t!verbatimlines {verbatimlines} % Code
-\def\t!verbatimline {verbatimline} % Code
-\def\t!verbatim {verbatim} % Code
-
-\def\t!lines {lines} % Code
-\def\t!line {line} % Code
-
-\def\t!sorting {sorting} % Span
-\def\t!synonym {synonym} % Span
-
-\def\t!register {register} % Div
-\def\t!registersection {registersection} % Div
-\def\t!registertag {registertag} % Span
-\def\t!registerentries {registerentries} % Div
-\def\t!registerentry {registerentry} % Span
-\def\t!registersee {registersee} % Span
-\def\t!registerpages {registerpages} % Span
-\def\t!registerpage {registerpage} % Span
-\def\t!registerpagerange {registerpagerange} % Span
-
-\def\t!table {table} % Table
-\def\t!tablerow {tablerow} % TR
-\def\t!tablecell {tablecell} % TD
-\def\t!tabulate {tabulate} % Table
-\def\t!tabulaterow {tabulaterow} % TR
-\def\t!tabulatecell {tabulatecell} % TD
-
-\def\t!math {math} % math
-\def\t!mathtable {mtable} % Table
-\def\t!mathtablerow {mtr} % TR
-\def\t!mathtablecell {mtd} % TD
-\def\t!mathaction {maction} %
-
-\def\t!list {list} % TOC
-\def\t!listitem {listitem} % TOCI
-\def\t!listtag {listtag} % Lbl
-\def\t!listcontent {listcontent} % P
-\def\t!listdata {listdata} % P
-\def\t!listpage {listpage} % Reference
-
-\def\t!delimitedblock {delimited} % BlockQuote
-\def\t!delimited {delimited} % Quote
-\def\t!subsentence {subsentence} % Span
-
-\def\t!float {float} % Div
-\def\t!floatcaption {floatcaption} % Caption
-\def\t!floatlabel {floatlabel} % Span
-\def\t!floattext {floattext} % Span
-\def\t!floatnumber {floatnumber} % Span
-\def\t!floatcontent {floatcontent} % P
-
-\def\t!image {image} % P
-
-\def\t!mpgraphic {mpgraphic} % P
-
-\def\t!formulaset {formulaset} % Div
-\def\t!formula {formula} % Div
-\def\t!formulacaption {formulacaption} % Span
-\def\t!formulalabel {formulalabel} % Span
-\def\t!formulanumber {formulanumber} % P
-\def\t!formulacontent {formulacontent} % P
-\def\t!subformula {subformula} % Div
-
-\def\t!link {link} % Link
-
-\def\t!margintext {margintext} % Span
-\def\t!margintextblock {margintextblock} % Div
+\def\t!document {document} % Div
+
+\def\t!division {division} % Div
+\def\t!paragraph {paragraph} % P
+\def\t!p {p} % P
+\def\t!construct {construct} % Span
+\def\t!highlight {highlight} % Span
+
+\def\t!section {section} % Sect
+\def\t!sectiontitle {sectiontitle} % H
+\def\t!sectionnumber {sectionnumber} % H
+\def\t!sectioncontent {sectioncontent} % Div
+
+\def\t!itemgroup {itemgroup} % L
+\def\t!item {item} % Li
+\def\t!itemtag {itemtag} % Lbl
+\def\t!itemcontent {itemcontent} % LBody
+
+\def\t!description {description} % Li
+\def\t!descriptiontag {descriptiontag} % Lbl
+\def\t!descriptioncontent {descriptioncontent} % LBody
+\def\t!descriptionsymbol {descriptionsymbol} % Span
+
+\let\t!construction \t!description
+\let\t!constructiontag \t!descriptiontag
+\let\t!constructioncontent\t!descriptioncontent
+\let\t!constructionsymbol \t!descriptionsymbol
+
+\def\t!verbatimblock {verbatimblock} % Code
+\def\t!verbatimlines {verbatimlines} % Code
+\def\t!verbatimline {verbatimline} % Code
+\def\t!verbatim {verbatim} % Code
+
+\def\t!lines {lines} % Code
+\def\t!line {line} % Code
+
+\def\t!sorting {sorting} % Span
+\def\t!synonym {synonym} % Span
+
+\def\t!register {register} % Div
+\def\t!registersection {registersection} % Div
+\def\t!registertag {registertag} % Span
+\def\t!registerentries {registerentries} % Div
+\def\t!registerentry {registerentry} % Span
+\def\t!registersee {registersee} % Span
+\def\t!registerpages {registerpages} % Span
+\def\t!registerpage {registerpage} % Span
+\def\t!registerpagerange {registerpagerange} % Span
+
+\def\t!table {table} % Table
+\def\t!tablerow {tablerow} % TR
+\def\t!tablecell {tablecell} % TD
+\def\t!tabulate {tabulate} % Table
+\def\t!tabulaterow {tabulaterow} % TR
+\def\t!tabulatecell {tabulatecell} % TD
+
+\def\t!math {math} % math
+\def\t!mathtable {mtable} % Table
+\def\t!mathtablerow {mtr} % TR
+\def\t!mathtablecell {mtd} % TD
+\def\t!mathaction {maction} %
+
+\def\t!list {list} % TOC
+\def\t!listitem {listitem} % TOCI
+\def\t!listtag {listtag} % Lbl
+\def\t!listcontent {listcontent} % P
+\def\t!listdata {listdata} % P
+\def\t!listpage {listpage} % Reference
+
+\def\t!delimitedblock {delimited} % BlockQuote
+\def\t!delimited {delimited} % Quote
+\def\t!subsentence {subsentence} % Span
+
+\def\t!float {float} % Div
+\def\t!floatcaption {floatcaption} % Caption
+\def\t!floatlabel {floatlabel} % Span
+\def\t!floattext {floattext} % Span
+\def\t!floatnumber {floatnumber} % Span
+\def\t!floatcontent {floatcontent} % P
+
+\def\t!image {image} % P
+
+\def\t!mpgraphic {mpgraphic} % P
+
+\def\t!formulaset {formulaset} % Div
+\def\t!formula {formula} % Div
+\def\t!formulacaption {formulacaption} % Span
+\def\t!formulalabel {formulalabel} % Span
+\def\t!formulanumber {formulanumber} % P
+\def\t!formulacontent {formulacontent} % P
+\def\t!subformula {subformula} % Div
+
+\def\t!link {link} % Link
+
+\def\t!margintext {margintext} % Span
+\def\t!margintextblock {margintextblock} % Div
% we might opt for verbose variants so this is experimental:
-\def\t!label {label} % Span
-\def\t!number {number} % Span
+\def\t!label {label} % Span
+\def\t!number {number} % Span
-\def\t!ignore {ignore} % Span
+\def\t!ignore {ignore} % Span
-\def\t!sub {sub} % Span
-\def\t!sup {sup} % Span
-\def\t!subsup {subsup} % Span
+\def\t!sub {sub} % Span
+\def\t!sup {sup} % Span
+\def\t!subsup {subsup} % Span
-\def\t!unit {unit} % Span
-\def\t!quantity {quantity} % Span
-\def\t!number {number} % Span
+\def\t!unit {unit} % Span
+\def\t!quantity {quantity} % Span
+\def\t!number {number} % Span
-\def\t!combination {combination} % Span
-\def\t!combinationpair {combinationpair} % Span
-\def\t!combinationcontent{combinationcontent} % Span
-\def\t!combinationcaption{combinationcaption} % Span
+\def\t!combination {combination} % Span
+\def\t!combinationpair {combinationpair} % Span
+\def\t!combinationcontent {combinationcontent} % Span
+\def\t!combinationcaption {combinationcaption} % Span
% \setuptaglabeltext
% [en]
@@ -149,95 +154,85 @@
\def\strc_tags_set_backend[#1][#2]{\ctxcommand{settagproperty("#1","backend","#2")}}
\def\strc_tags_set_nature [#1][#2]{\ctxcommand{settagproperty("#1","nature", "#2")}}
-% todo: indirect macro for trialtypesetting
+\installcorenamespace{tagging}
+
+\installsetuponlycommandhandler \??tagging {tagging}
-\unexpanded\def\strc_tags_start_element
+\unexpanded\def\strc_tags_element_start_yes{\dodoubleempty\strc_tags_element_start_yes_indeed}
+\unexpanded\def\strc_tags_element_start_nop{\dodoubleempty\strc_tags_element_start_nop_indeed}
+
+\unexpanded\def\strc_tags_element_start_yes_indeed
{\iftrialtypesetting
- \expandafter\strc_tags_disabled_element_start
+ \expandafter\strc_tags_element_start_yes_indeed_yes
\else
- \expandafter\strc_tags_enabled_element_start
+ \expandafter\strc_tags_element_start_nop_indeed
\fi}
-\unexpanded\def\strc_tags_stop_element
+\unexpanded\def\strc_tags_element_stop
{\iftrialtypesetting
- \expandafter\strc_tags_disabled_element_stop_indeed
+ \expandafter\strc_tags_element_stop_yes
\else
- \expandafter\strc_tags_enabled_element_stop_indeed
+ \expandafter\strc_tags_element_stop_nop
\fi}
-\unexpanded\def\strc_tags_enabled_element_start {\dodoubleempty\strc_tags_enabled_element_start_indeed}
-\unexpanded\def\strc_tags_disabled_element_start{\dodoubleempty\strc_tags_disabled_element_start_indeed}
+\unexpanded\def\strc_tags_element_start_yes_indeed_yes[#1][#2]%
+ {\ctxcommand{starttag("#1",{label="\dogetupsometaglabeltext{#1}",userdata=\!!bs#2\!!es})}}
-\unexpanded\def\strc_tags_enabled_element_start_indeed[#1][#2]%
- {\ctxcommand{starttag("#1",{
- label = "\dogetupsometaglabeltext{#1}",
- userdata = \!!bs#2\!!es,
- })}}
+\unexpanded\def\strc_tags_element_stop_yes
+ {\ctxcommand{stoptag()}}
-\unexpanded\def\strc_tags_disabled_element_start_indeed[#1][#2]%
+\unexpanded\def\strc_tags_element_start_nop_indeed[#1][#2]%
{}
-\unexpanded\def\strc_tags_enabled_element_stop_indeed
- {\ctxcommand{stoptag()}}
-
-\unexpanded\def\strc_tags_disabled_element_stop_indeed
+\unexpanded\def\strc_tags_element_stop_nop
{}
+\unexpanded\def\strc_tags_enable_elements
+ {\setuplanguage[\s!default][\s!righthyphenchar="AD]% for the moment here
+ \let\startelement\strc_tags_element_start_yes
+ \let\stopelement \strc_tags_element_stop_yes}
+
+\unexpanded\def\strc_tags_disable_elements
+ {\let\startelement\strc_tags_element_start_nop
+ \let\stopelement \strc_tags_element_stop_nop}
+
% beware: making these unexpanded spoils tables (noalign problem)
\def\strc_tags_enabled_start
{\iftrialtypesetting
- \expandafter\strc_tags_disabled_start_indeed
+ \expandafter\strc_tags_start_nop
\else
- \expandafter\strc_tags_enabled_start_indeed
+ \expandafter\strc_tags_start_yes
\fi}
\def\strc_tags_enabled_stop
{\iftrialtypesetting
- \expandafter\strc_tags_disabled_stop
+ \expandafter\strc_tags_stop_nop
\else
- \expandafter\strc_tags_enabled_stop
+ \expandafter\strc_tags_stop_yes
\fi}
-\def\strc_tags_enabled_start_indeed#1#2%
- {\ctxcommand{starttag("#1",{
- label = "\dogetupsometaglabeltext{#1}",
- detail = "#2",
- })}}
+\def\strc_tags_start_yes#1#2% we could have a fast labeltext resolver
+ {\ctxcommand{starttag("#1",{label="\dogetupsometaglabeltext{#1}",detail="#2"})}}
-\def\strc_tags_enabled_stop_indeed
+\def\strc_tags_stop_yes
{\ctxcommand{stoptag()}}
-\def\strc_tags_disabled_start#1#2%
+\def\strc_tags_start_nop#1#2%
{}
-\def\strc_tags_disabled_stop
+\def\strc_tags_stop_nop
{}
-% end of beware
-
-\installcorenamespace{tagging}
-
-\installsetuponlycommandhandler \??tagging {tagging}
-
-\unexpanded\def\strc_tags_enable_elements
- {\setuplanguage[\s!default][\s!righthyphenchar="AD]% for the moment here
- \let\startelement\strc_tags_enabled_element_start
- \let\stopelement \strc_tags_enabled_element_stop }
-
-\unexpanded\def\strc_tags_disable_elements
- {\let\startelement\strc_tags_disabled_element_start
- \let\stopelement \strc_tags_disabled_element_stop}
-
-% this will become strc_tags_start and strc_tags_stop
-
\unexpanded\def\strc_tags_enable
- {\let\dostarttagged\strc_tags_enabled_start
- \let\dostoptagged \strc_tags_enabled_stop}
+ {\let\dostarttagged\strc_tags_start_yes
+ \let\dostoptagged \strc_tags_stop_yes}
\unexpanded\def\strc_tags_disable
- {\let\dostarttagged\strc_tags_disabled_start
- \let\dostoptagged \strc_tags_disabled_stop}
+ {\let\dostarttagged\strc_tags_start_nop
+ \let\dostoptagged \strc_tags_stop_nop}
+
+%D The triggers:
\newtoks\everyenableelements
\newtoks\everydisableelements
diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv
index 93ec8b3dd..f5433133a 100644
--- a/tex/context/base/supp-box.mkiv
+++ b/tex/context/base/supp-box.mkiv
@@ -19,6 +19,37 @@
% This file is partially cleaned up.
+% handy to have
+%
+% \hbox to \hsize
+% {\en
+% \switchnaarkorps[5pt]%
+% \emergencystretch2em
+% \dimen0=\baselineskip
+% \baselineskip=\dimen0 plus 1pt
+% \hsize=.2\hsize
+% \vsize=2\hsize
+% \ruledvbox to \vsize{\input tufte \par}\hss
+% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth}\hss
+% \ruledvbox to \vsize{\input tufte \par\kern0pt}\hss
+% \ruledvbox to \vsize{\input tufte \par\vfill}\hss
+% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth\vfill}}
+%
+% \hbox to \hsize
+% {\en
+% \switchnaarkorps[5pt]%
+% \emergencystretch2em
+% \dimen0=\baselineskip
+% \baselineskip=\dimen0 plus 1pt
+% \hsize=.18\hsize
+% \vsize=2.5\hsize
+% \setbox0=\vbox{\input tufte\relax}%
+% \ruledvbox to \vsize{\unvcopy0}\hss
+% \ruledvbox to \vsize{\unvcopy0\kern-\dp0}\hss
+% \ruledvbox to \vsize{\unvcopy0\kern0pt}\hss
+% \ruledvbox to \vsize{\unvcopy0\vfill}\hss
+% \ruledvbox to \vsize{\unvcopy0\kern-\dp0\vfill}}
+
%D \macros
%D {dontcomplain}
%D
@@ -2501,6 +2532,8 @@
\prependtoks \let\vcenter\normalvcenter \to \everymath
\prependtoks \let\vcenter\normalvcenter \to \everydisplay
+% \appendtoks \let\vcenter\normalvcenter \to \everymathematics
+
%D \macros
%D {frozenhbox}
%D
diff --git a/tex/context/base/syst-pln.mkiv b/tex/context/base/syst-pln.mkiv
index fc3bdd332..248113120 100644
--- a/tex/context/base/syst-pln.mkiv
+++ b/tex/context/base/syst-pln.mkiv
@@ -38,7 +38,7 @@
\finalhyphendemerits = 5000
%floatingpenalty = 0
%globaldefs = 0
-%hangafter = 1
+\hangafter = 1 % automatically set to 1 (no zero assignment)
\hbadness = 1000
%holdinginserts = 0
\hyphenpenalty = 50
diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv
index 145c702d2..6e2178f39 100644
--- a/tex/context/base/tabl-tbl.mkiv
+++ b/tex/context/base/tabl-tbl.mkiv
@@ -345,9 +345,12 @@
\ifdefined\dotagtabulatesignal \else \let\dotagtabulatesignal\relax \fi
\unexpanded\def\tabl_tabulate_check_local_color_first#1#2%
+ {\relax}
+
+\unexpanded\def\tabl_tabulate_check_local_color_second#1#2%
{\relax
\ifx\m_tabl_tabulate_color_local\empty
- \gdef\m_tabl_tabulate_color{#1}%
+ \xdef\m_tabl_tabulate_color{#1}%
\else
\global\let\m_tabl_tabulate_color\m_tabl_tabulate_color_local
\global\let\m_tabl_tabulate_color_local\empty
@@ -359,9 +362,6 @@
\global\c_tabl_tabulate_localcolorspan\zerocount
\fi}
-\unexpanded\def\tabl_tabulate_check_local_color_second#1#2%
- {\relax}
-
\unexpanded\def\tabl_tabulate_check_local_vrule_thickness#1%
{\relax
\ifcase\d_tabl_tabulate_vrulethickness_local
@@ -697,7 +697,7 @@
{\tabl_tabulate_set_preamble_step\tabl_tabulate_xbskip\tabl_tabulate_xeskip}
\def\tabl_tabulate_set_color_span#1#2%
- {\gdef\m_tabl_tabulate_color{#2}%
+ {\xdef\m_tabl_tabulate_color{#2}%
\global\c_tabl_tabulate_colorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax
\tabl_tabulate_set_preamble}
@@ -2208,4 +2208,11 @@
% \NC \digits $@@@.@@1,@@$ \NC\NR
% \stoptabulatie
+% we don't register the paragraph characteristics, only the
+% width
+
+\appendtoks
+ \setinnerparpositions % see "techniek" for application
+\to \everytabulate
+
\protect \endinput
diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua
index 2f422578e..6ac5e1835 100644
--- a/tex/context/base/tabl-xtb.lua
+++ b/tex/context/base/tabl-xtb.lua
@@ -59,6 +59,7 @@ local new_penalty = nodepool.penalty
local v_stretch = variables.stretch
local v_normal = variables.normal
local v_width = variables.width
+local v_height = variables.height
local v_repeat = variables["repeat"]
local v_max = variables.max
@@ -516,6 +517,28 @@ end
function xtables.reflow_height()
data.currentrow = 0
data.currentcolumn = 0
+ local settings = data.settings
+ if settings.options[v_height] then
+ local heights = data.heights
+ local depths = data.depths
+ local nofrows = data.nofrows
+ local totalheight = 0
+ local totaldepth = 0
+ for i=1,nofrows do
+ totalheight = totalheight + heights[i]
+ totalheight = totalheight + depths [i]
+ end
+ local total = totalheight + totaldepth
+ local leftover = settings.textheight - total
+ if leftover > 0 then
+ local leftheight = (totalheight / total ) * leftover / #heights
+ local leftdepth = (totaldepth / total ) * leftover / #depths
+ for i=1,nofrows do
+ heights[i] = heights[i] + leftheight
+ depths [i] = depths [i] + leftdepth
+ end
+ end
+ end
end
local function showspans(data)
diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi
index 6ddaf39e0..f6e1707e9 100644
--- a/tex/context/base/tabl-xtb.mkvi
+++ b/tex/context/base/tabl-xtb.mkvi
@@ -136,6 +136,7 @@
% \c!header=,
\c!spaceinbetween=,
\c!textwidth=\hsize,
+ \c!textheight=\vsize,
\c!distance=\zeropoint, % individual column
\c!columndistance=\zeropoint, % each column (whole table)
\c!leftmargindistance=\zeropoint, % whole table
@@ -240,6 +241,7 @@
\ctxcommand{x_table_create {
option = "\xtableparameter\c!option",
textwidth = \number\dimexpr\xtableparameter\c!textwidth,
+ textheight = \number\dimexpr\xtableparameter\c!textheight,
maxwidth = \number\dimexpr\xtableparameter\c!maxwidth,
lineheight = \number\openlineheight,
columndistance = \number\dimexpr\xtableparameter\c!columndistance,
diff --git a/tex/context/base/type-imp-buy.mkiv b/tex/context/base/type-imp-buy.mkiv
new file mode 100644
index 000000000..9815cc44b
--- /dev/null
+++ b/tex/context/base/type-imp-buy.mkiv
@@ -0,0 +1,37 @@
+%D \module
+%D [ file=type-buy,
+%D version=2003.07.08, % 2001.04.12,
+%D title=\CONTEXT\ Typescript Macros,
+%D subtitle=A Few Commercial Fonts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\starttypescriptcollection[sabon]
+
+\starttypescript [serif] [sabon] [name]
+
+ \definefontsynonym [Serif] [SabonMT]
+ \definefontsynonym [SerifItalic] [SabonMT-Italic]
+ \definefontsynonym [SerifSlanted] [SabonMT-Italic]
+ \definefontsynonym [SerifBold] [SabonMT-SemiBold]
+ \definefontsynonym [SerifBoldItalic] [SabonMT-SemiBoldItalic]
+ \definefontsynonym [SerifBoldSlanted] [SabonMT-SemiBoldItalic]
+ \definefontsynonym [SerifCaps] [SabonMT-RegularSC]
+
+ \definefontsynonym[SabonMT] [sab_____]
+ \definefontsynonym[SabonMT-Italic] [sabi____]
+ \definefontsynonym[SabonMT-ItalicOsF] [saboi___]
+ \definefontsynonym[SabonMT-SemiBoldOsF] [sabos___]
+ \definefontsynonym[SabonMT-SemiBold] [sabs____]
+ \definefontsynonym[SabonMT-RegularSC] [sabsc___]
+ \definefontsynonym[SabonMT-SemiBoldItalic] [sabsi___]
+ \definefontsynonym[SabonMT-SemiBoldItalicOsF][sasio___]
+\stoptypescript
+
+\stoptypescriptcollection
+
diff --git a/tex/context/base/type-cow.mkiv b/tex/context/base/type-imp-cow.mkiv
index 1cb825a11..1cb825a11 100644
--- a/tex/context/base/type-cow.mkiv
+++ b/tex/context/base/type-imp-cow.mkiv
diff --git a/tex/context/base/type-ghz.mkiv b/tex/context/base/type-imp-ghz.mkiv
index 0722c1dfe..0722c1dfe 100644
--- a/tex/context/base/type-ghz.mkiv
+++ b/tex/context/base/type-imp-ghz.mkiv
diff --git a/tex/context/base/type-hgz.mkiv b/tex/context/base/type-imp-hgz.mkiv
index a3c2a7841..a3c2a7841 100644
--- a/tex/context/base/type-hgz.mkiv
+++ b/tex/context/base/type-imp-hgz.mkiv
diff --git a/tex/context/base/type-buy.mkiv b/tex/context/base/type-imp-informal.mkiv
index bab9593d9..575a836e5 100644
--- a/tex/context/base/type-buy.mkiv
+++ b/tex/context/base/type-imp-informal.mkiv
@@ -2,7 +2,7 @@
%D [ file=type-buy,
%D version=2003.07.08, % 2001.04.12,
%D title=\CONTEXT\ Typescript Macros,
-%D subtitle=A Few Commercial Fonts,
+%D subtitle=Informal by M. Vulis,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
@@ -11,9 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\starttypescriptcollection[commercial fonts]
-
-% Informal : Vulis
+\starttypescriptcollection[informal]
\starttypescript [casual] [informal]
\definefontsynonym [Serif] [Informal-Regular]
@@ -50,33 +48,5 @@
\definetypeface[informal][mm][math] [informal][default]
\stoptypescript
-% Sabon
-
-\starttypescript [serif] [sabon] [name]
-
- \definefontsynonym [Serif] [SabonMT]
- \definefontsynonym [SerifItalic] [SabonMT-Italic]
- \definefontsynonym [SerifSlanted] [SabonMT-Italic]
- \definefontsynonym [SerifBold] [SabonMT-SemiBold]
- \definefontsynonym [SerifBoldItalic] [SabonMT-SemiBoldItalic]
- \definefontsynonym [SerifBoldSlanted] [SabonMT-SemiBoldItalic]
- \definefontsynonym [SerifCaps] [SabonMT-RegularSC]
-
- \definefontsynonym[SabonMT] [sab_____]
- \definefontsynonym[SabonMT-Italic] [sabi____]
- \definefontsynonym[SabonMT-ItalicOsF] [saboi___]
- \definefontsynonym[SabonMT-SemiBoldOsF] [sabos___]
- \definefontsynonym[SabonMT-SemiBold] [sabs____]
- \definefontsynonym[SabonMT-RegularSC] [sabsc___]
- \definefontsynonym[SabonMT-SemiBoldItalic] [sabsi___]
- \definefontsynonym[SabonMT-SemiBoldItalicOsF][sasio___]
-\stoptypescript
-
-% \definetypeface[sabon][rm][serif][sabon][default]
-% \setupbodyfont[sabon]
-% \starttext
-% \input tufte
-% \stoptext
-
\stoptypescriptcollection
diff --git a/tex/context/base/type-imp-latinmodern.mkiv b/tex/context/base/type-imp-latinmodern.mkiv
index 94195deca..a9fddad7d 100644
--- a/tex/context/base/type-imp-latinmodern.mkiv
+++ b/tex/context/base/type-imp-latinmodern.mkiv
@@ -11,58 +11,58 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\starttypescriptcollection[fallback]
-
- \starttypescript [fallback]
- \definetypeface [] [\s!rm] [\s!serif] [latin-modern-designsize] [\s!default] % maybe modern-base
- \definetypeface [] [\s!ss] [\s!sans] [latin-modern-designsize] [\s!default] % maybe modern-base
- \definetypeface [] [\s!tt] [\s!mono] [latin-modern-designsize] [\s!default] % maybe modern-base
- \definetypeface [] [\s!mm] [\s!math] [latin-modern-designsize] [\s!default] % maybe modern-base
- \quittypescriptscanning
- \stoptypescript
-
-\stoptypescriptcollection
+% \starttypescriptcollection[\s!fallback]
+% \starttypescript [\s!fallback]
+% \definetypeface [\s!fallback] [\s!rm] [\s!serif] [modern] [\s!default]
+% \definetypeface [\s!fallback] [\s!ss] [\s!sans] [modern] [\s!default]
+% \definetypeface [\s!fallback] [\s!tt] [\s!mono] [modern] [\s!default]
+% \definetypeface [\s!fallback] [\s!mm] [\s!math] [modern] [\s!default]
+% \quittypescriptscanning
+% \stoptypescript
+% \stoptypescriptcollection
%D Here comes good old Latin Modern, the default font, based on Knuths Computer
-%D Modern.
+%D Modern. The design size variants is:
+%D
+%D modern-designsize
\starttypescriptcollection[latinmodern]
- \starttypescript [modern,modern-designsize]
- \definetypeface [modern] [\s!rm] [\s!serif] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
- \definetypeface [modern] [\s!ss] [\s!sans] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
- \definetypeface [modern] [\s!tt] [\s!mono] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
- \definetypeface [modern] [\s!mm] [\s!math] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
+ \starttypescript [modern-designsize]
+ \definetypeface [\typescriptone] [\s!rm] [\s!serif] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
+ \definetypeface [\typescriptone] [\s!ss] [\s!sans] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
+ \definetypeface [\typescriptone] [\s!mm] [\s!math] [latin-modern-designsize] [\s!default] [\s!designsize=\s!auto]
\quittypescriptscanning
\stoptypescript
- \starttypescript [modern-base]
- \definetypeface [modern] [\s!rm] [\s!serif] [modern] [\s!default]
- \definetypeface [modern] [\s!ss] [\s!sans] [modern] [\s!default]
- \definetypeface [modern] [\s!tt] [\s!mono] [modern] [\s!default]
- \definetypeface [modern] [\s!mm] [\s!math] [modern] [\s!default]
+ \starttypescript [modern,modern-base]
+ \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!ss] [\s!sans] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!mm] [\s!math] [modern] [\s!default]
\quittypescriptscanning
\stoptypescript
\starttypescript [modernvariable,modern-variable]
- \definetypeface [modernvariable] [\s!rm] [\s!serif] [modern-variable] [\s!default]
- \definetypeface [modernvariable] [\s!tt] [\s!mono] [modern-variable] [\s!default]
- \definetypeface [modernvariable] [\s!mm] [\s!math] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern-variable] [\s!default]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [modern-variable] [\s!default]
+ \definetypeface [\typescriptone] [\s!mm] [\s!math] [modern] [\s!default]
\quittypescriptscanning
\stoptypescript
\starttypescript [modernvariablelight,modern-variable-light]
- \definetypeface [modernvariable] [\s!rm] [\s!serif] [modern-variable-light] [\s!default]
- \definetypeface [modernvariable] [\s!tt] [\s!mono] [modern-variable-light] [\s!default]
- \definetypeface [modernvariable] [\s!mm] [\s!math] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern-variable-light] [\s!default]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [modern-variable-light] [\s!default]
+ \definetypeface [\typescriptone] [\s!mm] [\s!math] [modern] [\s!default]
\quittypescriptscanning
\stoptypescript
\starttypescript [modern-mono,modern-base-mono]
- \definetypeface [modern] [\s!rm] [\s!serif] [modern] [\s!default]
- \definetypeface [modern] [\s!ss] [\s!sans] [modern] [\s!default]
- \definetypeface [modern] [\s!tt] [\s!mono] [modern-light] [\s!default]
- \definetypeface [modern] [\s!mm] [\s!math] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!ss] [\s!sans] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [modern-light] [\s!default]
+ \definetypeface [\typescriptone] [\s!mm] [\s!math] [modern] [\s!default]
\quittypescriptscanning
\stoptypescript
@@ -71,6 +71,7 @@
\stoptypescript
\starttypescript [\s!serif] [modern,latin-modern-designsize,latin-modern] [\s!name]
+ \loadfontgoodies[lm]
\definefontsynonym [\s!Serif] [LMRoman-Regular] [\s!features=\s!default]
\definefontsynonym [\s!SerifBold] [LMRoman-Bold] [\s!features=\s!default]
\definefontsynonym [\s!SerifItalic] [LMRoman-Italic] [\s!features=\s!default]
@@ -82,6 +83,7 @@
\stoptypescript
\starttypescript [\s!sans] [modern,latin-modern-designsize,latin-modern] [\s!name]
+ \loadfontgoodies[lm]
\definefontsynonym [\s!Sans] [LMSans-Regular] [\s!features=\s!default]
\definefontsynonym [\s!SansBold] [LMSans-Bold] [\s!features=\s!default]
\definefontsynonym [\s!SansItalic] [LMSans-Oblique] [\s!features=\s!default]
@@ -93,6 +95,7 @@
\stoptypescript
\starttypescript [\s!mono] [modern,latin-modern-designsize,latin-modern] [\s!name]
+ \loadfontgoodies[lm]
\definefontsynonym [\s!Mono] [LMTypewriter-Regular] [\s!features=\s!none]
\definefontsynonym [\s!MonoBold] [LMTypewriter-Dark] [\s!features=\s!none]
\definefontsynonym [\s!MonoItalic] [LMTypewriter-Italic] [\s!features=\s!none]
@@ -105,11 +108,14 @@
\stoptypescript
\starttypescript [\s!math] [modern,latin-modern-designsize,latin-modern] [\s!name]
+ \loadfontgoodies[lm]
+ \loadfontgoodies[lm-math]
\definefontsynonym [\s!MathRoman] [LMMathRoman-Regular]
\definefontsynonym [\s!MathRomanBold] [LMMathRoman-Bold]
\stoptypescript
\starttypescript [\s!serif] [modern-variable,latin-modern-variable-designsize,latin-modern-variable] [\s!name]
+ \loadfontgoodies[lm]
\definefontsynonym [\s!Serif] [LMTypewriterVarWd-Regular] [\s!features=\s!default]
\definefontsynonym [\s!SerifBold] [LMTypewriterVarWd-Oblique] [\s!features=\s!default]
\definefontsynonym [\s!SerifItalic] [LMTypewriterVarWd-Oblique] [\s!features=\s!default]
@@ -121,6 +127,7 @@
\stoptypescript
\starttypescript [\s!mono] [modern-condensed,latin-modern-condensed-designsize,latin-modern-condensed,modern-light-condensed,latin-modern-light-condensed] [\s!name]
+ \loadfontgoodies[lm]
\definefontsynonym [\s!Mono] [LMTypewriter-LightCondensed] [\s!features=\s!none]
\definefontsynonym [\s!MonoBold] [LMTypewriter-LightCondensed] [\s!features=\s!none]
\definefontsynonym [\s!MonoItalic] [LMTypewriter-LightCondensedOblique] [\s!features=\s!none]
@@ -132,6 +139,7 @@
\stoptypescript
\starttypescript [\s!mono] [modern-light,latin-modern-light-designsize,latin-modern-light] [\s!name]
+ \loadfontgoodies[lm]
\definefontsynonym [\s!Mono] [LMTypewriter-Light] [\s!features=\s!none]
\definefontsynonym [\s!MonoBold] [LMTypewriter-Light] [\s!features=\s!none]
\definefontsynonym [\s!MonoItalic] [LMTypewriter-LightOblique] [\s!features=\s!none]
@@ -145,6 +153,7 @@
% why not also [name]
\starttypescript [\s!serif] [modern,latin-modern]
+ \loadfontgoodies[lm]
\definefontsynonym [LMRoman-Regular] [\s!file:lmroman10-regular] [\s!features=\s!default]
\definefontsynonym [LMRoman-Bold] [\s!file:lmroman10-bold] [\s!features=\s!default]
\definefontsynonym [LMRoman-Demi] [\s!file:lmromandemi10-regular] [\s!features=\s!default]
@@ -164,6 +173,7 @@
\stoptypescript
\starttypescript [\s!sans] [modern,latin-modern]
+ \loadfontgoodies[lm]
\definefontsynonym [LMSans-Regular] [\s!file:lmsans10-regular] [\s!features=\s!default]
\definefontsynonym [LMSans-Bold] [\s!file:lmsans10-bold] [\s!features=\s!default]
\definefontsynonym [LMSans-Oblique] [\s!file:lmsans10-oblique] [\s!features=\s!default]
@@ -176,7 +186,8 @@
\definefontsynonym [LMSansQuotation-BoldOblique] [\s!file:lmsansquot8-boldoblique] [\s!features=\s!default]
\stoptypescript
- \starttypescript [\s!mono] [modern,latin-modern-designsize,latin-modern,modern-variable,latin-modern-variable,modern-condensed,latin-modern-condensed]
+ \starttypescript [\s!mono] [modern,latin-modern,modern-variable,latin-modern-variable,modern-condensed,latin-modern-condensed]
+ \loadfontgoodies[lm]
\definefontsynonym [LMTypewriter-Regular] [\s!file:lmmono10-regular] [\s!features=\s!none]
\definefontsynonym [LMTypewriter-Italic] [\s!file:lmmono10-italic] [\s!features=\s!none]
\definefontsynonym [LMTypewriter-Oblique] [\s!file:lmmonoslant10-regular] [\s!features=\s!none]
@@ -196,15 +207,10 @@
\definefontsynonym [LMTypewriterVarWd-DarkOblique] [\s!file:lmmonoproplt10-boldoblique] [\s!features=\s!default]
\stoptypescript
- \starttypescript [modern,latin-modern]
- \loadfontgoodies[lm]
- \loadfontgoodies[lm-math]
- \stoptypescript
-
\starttypescript [\s!math] [modern,latin-modern]
- % \loadfontgoodies[lm-math]
- \definefontsynonym [LMMathRoman-Regular] [\v!file:lmmath-regular.otf] [\s!features=\s!math]
- \definefontsynonym [LMMathRoman-Bold] [\v!file:lmmath-regular.otf] [\s!features=\s!math]
+ \loadfontgoodies[lm]
+ \definefontsynonym [LMMathRoman-Regular] [\v!file:lmmath-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm]
+ \definefontsynonym [LMMathRoman-Bold] [\v!file:lmmath-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm]
\stoptypescript
\stoptypescriptcollection
diff --git a/tex/context/base/type-imp-lmnames.mkiv b/tex/context/base/type-imp-lmnames.mkiv
index eea7a3560..620c5d03b 100644
--- a/tex/context/base/type-imp-lmnames.mkiv
+++ b/tex/context/base/type-imp-lmnames.mkiv
@@ -122,11 +122,6 @@
\definefontsynonym [LMMathRoman12-Bold] [LMMathRoman12-Regular]
\definefontsynonym [LMMathRoman17-Bold] [LMMathRoman17-Regular]
- % overloads lmmath.otf usage
- %
- % \definefontsynonym[MathRoman][LMMath10-Regular@lmroman10-math]
- % \definefontsynonym[MathBold] [MathRoman]
-
\loadfontgoodies[lm-math]
\stoptypescript
diff --git a/tex/context/base/type-mac.mkiv b/tex/context/base/type-imp-osx.mkiv
index e95c48649..16b8e0545 100644
--- a/tex/context/base/type-mac.mkiv
+++ b/tex/context/base/type-imp-osx.mkiv
@@ -10,32 +10,6 @@
%C This module is part of the \CONTEXT\ macro||package. See
%C mreadme.pdf for details.
-\definetypescriptprefix [f:andalemono] [andalemono]
-\definetypescriptprefix [f:chalkboard] [chalkboard]
-\definetypescriptprefix [f:cochin] [cochin]
-\definetypescriptprefix [f:comicsans] [comicsansms]
-\definetypescriptprefix [f:couriernew] [couriernew]
-\definetypescriptprefix [f:georgia] [georgia]
-\definetypescriptprefix [f:lucidagrande] [lucidagrande]
-\definetypescriptprefix [f:monaco] [monaco]
-\definetypescriptprefix [f:tahoma] [tahoma]
-\definetypescriptprefix [f:timesnewroman] [timesnewroman]
-\definetypescriptprefix [f:trebuchet] [trebuchetms]
-\definetypescriptprefix [f:verdana] [verdana]
-
-\definetypescriptprefix [n:andalemono] [AndaleMono]
-\definetypescriptprefix [n:chalkboard] [Chalkboard]
-\definetypescriptprefix [n:cochin] [Cochin]
-\definetypescriptprefix [n:comicsans] [ComicSans]
-\definetypescriptprefix [n:couriernew] [CourierNew]
-\definetypescriptprefix [n:georgia] [Georgia]
-\definetypescriptprefix [n:lucidagrande] [LucidaGrande]
-\definetypescriptprefix [n:monaco] [Monaco]
-\definetypescriptprefix [n:tahoma] [Tahoma]
-\definetypescriptprefix [n:timesnewroman] [TimesNewRoman]
-\definetypescriptprefix [n:trebuchet] [Trebuchet]
-\definetypescriptprefix [n:verdana] [Verdana]
-
\starttypescriptcollection [macosx]
% American Typewriter
diff --git a/tex/context/base/type-ini.mkvi b/tex/context/base/type-ini.mkvi
index 1d469b02a..8ca42854f 100644
--- a/tex/context/base/type-ini.mkvi
+++ b/tex/context/base/type-ini.mkvi
@@ -398,7 +398,7 @@
\settrue\autotypescripts
-\unexpanded\def\trycurrentfontclass#typeface% this will move to type-ini
+\unexpanded\def\trycurrentfontclass#typeface%
{\ifconditional\autotypescripts
\usetypescript[#typeface]%
\ifcsname\??fontclassyes#typeface\endcsname
@@ -488,9 +488,9 @@
\def\tsvar#key#default% undocumented and unofficial
{\expandafter\ifx\csname\??ts#key\endcsname\empty
- \csname\??ts#key\endcsname
- \else
#default%
+ \else
+ \csname\??ts#key\endcsname
\fi}
\def\font_typefaces_defining_stop
diff --git a/tex/context/base/type-msw.mkiv b/tex/context/base/type-msw.mkiv
deleted file mode 100644
index 2e741f7a0..000000000
--- a/tex/context/base/type-msw.mkiv
+++ /dev/null
@@ -1 +0,0 @@
-\input type-win.mkiv \endinput % could be a file synonym
diff --git a/tex/context/base/type-set.mkiv b/tex/context/base/type-set.mkiv
index 8a174c9b8..731e4e5e3 100644
--- a/tex/context/base/type-set.mkiv
+++ b/tex/context/base/type-set.mkiv
@@ -24,14 +24,14 @@
% \loadtypescriptfile[def] % meant for local usage only
% \loadtypescriptfile[lua] % meant for local usage only
% \loadtypescriptfile[siz] % meant for local usage only
-
\loadmarkfile{type-imp-latinmodern}
% \usetypescriptfile[latinmodern]
\usetypescriptfile[loc]
- % we want these names preset
-
- \usetypescript[serif,sans,mono,math] [latin-modern]
+ % We want these names preset but they conflict with later loads so from now on
+ % one has to define a proper typeface if they are needed.
+ %
+ % \usetypescript[serif,sans,mono,math] [latin-modern]
\else
@@ -78,4 +78,7 @@
\definefilesynonym [type-imp-antykwa-poltawskiego.mkiv] [type-imp-antykwapoltawskiego.mkiv]
+%definefilesynonym [type-imp-mac.mkiv] [type-imp-osx.mkiv]
+%definefilesynonym [type-imp-win.mkiv] [type-imp-mscore.mkiv]
+
\protect \endinput
diff --git a/tex/context/base/type-win.mkiv b/tex/context/base/type-win.mkiv
deleted file mode 100644
index 636f6f0a5..000000000
--- a/tex/context/base/type-win.mkiv
+++ /dev/null
@@ -1,118 +0,0 @@
-%D \module
-%D [ file=type-win,
-%D version=2009.03.10,
-%D title=\CONTEXT\ Typescript Macros,
-%D subtitle=MS Windows Definitions,
-%D author=Vyatcheslav Yatskovsky,
-%D date=\currentdate,
-%D copyright={Vyatcheslav Yatskovsky}]
-%C
-%C This module is part of the \CONTEXT\ macro||package. See
-%C mreadme.pdf for details.
-
-\starttypescriptcollection[windows]
-
-\starttypescript [serif] [georgia,palatino,times]
- \setups[font:fallback:serif]
- \definefontsynonym [Serif] [\typescripttwo-Regular] [features=default]
- \definefontsynonym [SerifBold] [\typescripttwo-Bold] [features=default]
- \definefontsynonym [SerifItalic] [\typescripttwo-Italic] [features=default]
- \definefontsynonym [SerifBoldItalic] [\typescripttwo-BoldItalic] [features=default]
-\stoptypescript
-
-\starttypescript [serif] [sylfaen]
- \setups[font:fallback:serif]
- \definefontsynonym [Serif] [\typescripttwo-Regular] [features=default]
-\stoptypescript
-
-\starttypescript [sans] [arial,trebuchet,verdana]
- \setups[font:fallback:sans]
- \definefontsynonym [Sans] [\typescripttwo-Regular] [features=default]
- \definefontsynonym [SansBold] [\typescripttwo-Bold] [features=default]
- \definefontsynonym [SansItalic] [\typescripttwo-Italic] [features=default]
- \definefontsynonym [SansBoldItalic] [\typescripttwo-BoldItalic] [features=default]
-\stoptypescript
-
-\starttypescript [sans] [arialblack,impact,lucidasans,microsans]
- \setups[font:fallback:sans]
- \definefontsynonym [Sans] [\typescripttwo-Regular] [features=default]
-\stoptypescript
-
-\starttypescript [sans] [comic,tahoma]
- \setups[font:fallback:sans]
- \definefontsynonym [Sans] [\typescripttwo-Regular] [features=default]
- \definefontsynonym [SansBold] [\typescripttwo-Bold] [features=default]
-\stoptypescript
-
-\starttypescript [sans] [franklin]
- \setups[font:fallback:sans]
- \definefontsynonym [Sans] [\typescripttwo-Regular] [features=default]
- \definefontsynonym [SansItalic] [\typescripttwo-Italic] [features=default]
-\stoptypescript
-
-\starttypescript [mono] [courier]
- \setups[font:fallback:mono]
- \definefontsynonym [Mono] [\typescripttwo-Regular] [features=default]
- \definefontsynonym [MonoBold] [\typescripttwo-Bold] [features=default]
- \definefontsynonym [MonoItalic] [\typescripttwo-Italic] [features=default]
- \definefontsynonym [MonoBoldItalic] [\typescripttwo-BoldItalic] [features=default]
-\stoptypescript
-
-\starttypescript [mono] [lucidaconsole]
- \setups[font:fallback:mono]
- \definefontsynonym [Mono] [\typescripttwo-Regular] [features=default]
-\stoptypescript
-
-\definetypescriptprefix [f:arial] [Arial]
-\definetypescriptprefix [f:arialblack] [Arial Black]
-\definetypescriptprefix [f:comic] [Comic Sans MS]
-\definetypescriptprefix [f:courier] [Courier New]
-\definetypescriptprefix [f:franklin] [Franklin Gothic Medium]
-\definetypescriptprefix [f:georgia] [Georgia]
-\definetypescriptprefix [f:impact] [Impact]
-\definetypescriptprefix [f:lucidaconsole] [Lucida Console]
-\definetypescriptprefix [f:lucidasans] [Lucida Sans Unicode]
-\definetypescriptprefix [f:microsans] [Microsoft Sans Serif]
-\definetypescriptprefix [f:palatino] [Palatino Linotype]
-\definetypescriptprefix [f:sylfaen] [Sylfaen]
-\definetypescriptprefix [f:tahoma] [Tahoma]
-\definetypescriptprefix [f:times] [Times New Roman]
-\definetypescriptprefix [f:trebuchet] [Trebuchet MS]
-\definetypescriptprefix [f:verdana] [Verdana]
-
-\starttypescript [serif] [georgia,palatino,sylfaen,times]
- \definefontsynonym [\typescripttwo-Regular] [name:\typescriptprefix{f:\typescripttwo}] [features=default]
- \definefontsynonym [\typescripttwo-Bold] [name:\typescriptprefix{f:\typescripttwo} Bold] [features=default]
- \definefontsynonym [\typescripttwo-Italic] [name:\typescriptprefix{f:\typescripttwo} Italic] [features=default]
- \definefontsynonym [\typescripttwo-BoldItalic] [name:\typescriptprefix{f:\typescripttwo} Bold Italic] [features=default]
-\stoptypescript
-
-\starttypescript [sans] [arial,arialblack,comic,franklin,impact,lucidasans,microsans,tahoma,trebuchet,verdana]
- \definefontsynonym [\typescripttwo-Regular] [name:\typescriptprefix{f:\typescripttwo}] [features=default]
- \definefontsynonym [\typescripttwo-Bold] [name:\typescriptprefix{f:\typescripttwo} Bold] [features=default]
- \definefontsynonym [\typescripttwo-Italic] [name:\typescriptprefix{f:\typescripttwo} Italic] [features=default]
- \definefontsynonym [\typescripttwo-BoldItalic] [name:\typescriptprefix{f:\typescripttwo} Bold Italic] [features=default]
-\stoptypescript
-
-\starttypescript [mono] [courier,lucidaconsole]
- \definefontsynonym [\typescripttwo-Regular] [name:\typescriptprefix{f:\typescripttwo}] [features=default]
- \definefontsynonym [\typescripttwo-Bold] [name:\typescriptprefix{f:\typescripttwo} Bold] [features=default]
- \definefontsynonym [\typescripttwo-Italic] [name:\typescriptprefix{f:\typescripttwo} Italic] [features=default]
- \definefontsynonym [\typescripttwo-BoldItalic] [name:\typescriptprefix{f:\typescripttwo} Bold Italic] [features=default]
-\stoptypescript
-
-\starttypescript [georgia,palatino,sylfaen,times]
- \definetypeface [\typescriptone] [rm] [serif] [\typescriptone] [default]
-\stoptypescript
-
-\starttypescript [arial,arialblack,comic,franklin,impact,lucidasans,microsans,tahoma,trebuchet,verdana]
- \definetypeface [\typescriptone] [ss] [sans] [\typescriptone] [default]
-\stoptypescript
-
-\starttypescript [courier,lucidaconsole]
- \definetypeface [\typescriptone] [tt] [mono] [\typescriptone] [default]
-\stoptypescript
-
-\stoptypescriptcollection
-
-\endinput
diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua
index 533ee2c03..00747a585 100644
--- a/tex/context/base/typo-mar.lua
+++ b/tex/context/base/typo-mar.lua
@@ -110,6 +110,8 @@ local v_normal = variables.normal
local v_yes = variables.yes
local v_continue = variables.continue
local v_first = variables.first
+local v_text = variables.text
+local v_column = variables.column
local has_attribute = node.has_attribute
local set_attribute = node.set_attribute
@@ -220,22 +222,13 @@ local defaults = {
dy = 0,
baseline = false,
inline = false,
+ leftskip = 0,
+ rightskip = 0,
}
}
local enablelocal, enableglobal -- forward reference (delayed initialization)
--- local function showstore(store,banner)
--- if #store == 0 then
--- report_margindata("%s: nothing stored",banner)
--- else
--- for i=1,#store do
--- local si =store[i]
--- report_margindata("%s: stored at %s: %s => %s",banner,i,si.name or "no name",nodes.toutf(si.box.list))
--- end
--- end
--- end
-
local function showstore(store,banner)
if next(store) then
for i, si in table.sortedpairs(store) do
@@ -268,10 +261,10 @@ function margins.save(t)
report_margindata("invalid scope: %s",scope)
return
end
- if enablelocal and scope == "local" then
+ if enablelocal and scope == v_local then
enablelocal()
end
- if enableglobal and scope == "global" then
+ if enableglobal and scope == v_global then
enableglobal()
end
nofsaved = nofsaved + 1
@@ -312,8 +305,8 @@ function margins.save(t)
local rightmargindistance = texdimen.naturalrightmargindistance
t.strutdepth = texbox.strutbox.depth
t.strutheight = texbox.strutbox.height
- t.leftskip = tex.leftskip.width
- t.rightskip = tex.rightskip.width
+ t.leftskip = tex.leftskip.width -- we're not in forgetall
+ t.rightskip = tex.rightskip.width -- we're not in forgetall
t.leftmargindistance = leftmargindistance
t.rightmargindistance = rightmargindistance
t.leftedgedistance = texdimen.naturalleftedgedistance
@@ -404,24 +397,48 @@ local function realign(current,candidate)
-- in order to get it right
current.width = 0
+ local anchornode, move_x
+
+ -- this mess is needed for alignments (combinations) so we use that
+ -- oportunity to add arbitrary anchoring
- if candidate.inline then -- this mess is needed for alignments (combinations)
+ -- always increment anchor is nicer for multipass when we add new ..
+
+ local inline = candidate.inline
+ local anchor = candidate.anchor
+ if not anchor or anchor == "" then
+ anchor = v_text
+ end
+ if inline or anchor ~= v_text then
h_anchors = h_anchors + 1
- local anchor = new_latelua(format("_plib_.setraw('_mh_:%s',pdf.h)",h_anchors))
- local blob_x = jobpositions.v("_mh_:"..h_anchors) or 0
- local text_x = jobpositions.x("text:"..texcount.realpageno) or 0
- local move_x = text_x - blob_x
+ anchornode = new_latelua(format("_plib_.set('md:h',%i,{x=true,c=true})",h_anchors))
+ local blob = jobpositions.get('md:h', h_anchors)
+ if blob then
+ local reference = jobpositions.getreserved(anchor,blob.c)
+ if reference then
+ if location == v_left then
+ move_x = (reference.x or 0) - (blob.x or 0)
+ elseif location == v_right then
+ move_x = (reference.x or 0) - (blob.x or 0) + (reference.w or 0) - hsize
+ else
+ -- not yet done
+ end
+ end
+ end
+ end
+
+ if move_x then
delta = delta - move_x
- current.list = hpack_nodes(link_nodes(anchor,new_kern(-delta),current.list,new_kern(delta)))
if trace_margindata then
report_margindata("realigned: %s, location: %s, margin: %s, move: %s",candidate.n,location,margin,points(move_x))
end
else
- current.list = hpack_nodes(link_nodes(new_kern(-delta),current.list,new_kern(delta)))
if trace_margindata then
report_margindata("realigned: %s, location: %s, margin: %s",candidate.n,location,margin)
end
end
+
+ current.list = hpack_nodes(link_nodes(anchornode,new_kern(-delta),current.list,new_kern(delta))) -- anchor == nil is ok in link_nodes
current.width = 0
end
@@ -443,39 +460,34 @@ end
-- table gets saved when the v_continue case is active. We use a special variant
-- of position tracking, after all we only need the page number and vertical position.
-local stacked = { }
-local cache = { }
+local stacked = { } -- left/right keys depending on location
+local cache = { }
local function resetstacked()
--- for i=1,#locations do
--- stacked[locations[i]] = false
--- end
stacked = { }
end
-- resetstacked()
-function margins.ha(tag)
+function margins.ha(tag) -- maybe l/r keys ipv left/right keys
local p = cache[tag]
- p.r = texcount.realpageno
- p.y = pdf.v
- _plib_.setraw('_mv_:'..tag,p)
+ p.p = true
+ p.y = true
+ jobpositions.set('md:v',tag,p)
cache[tag] = nil
end
local function markovershoot(current)
- h_anchors = h_anchors + 1
- cache[h_anchors] = stacked
- local anchor = new_latelua(format("typesetters.margins.ha(%s)",h_anchors)) -- todo: alleen als offset > line
+ v_anchors = v_anchors + 1
+ cache[v_anchors] = stacked
+ local anchor = new_latelua(format("typesetters.margins.ha(%s)",v_anchors)) -- todo: alleen als offset > line
current.list = hpack_nodes(link_nodes(anchor,current.list))
end
local function getovershoot(location)
- local previous = '_mv_:' .. h_anchors
- local current = '_mv_:' .. (h_anchors + 1)
- local p = jobpositions.v(previous)
- local c = jobpositions.v(current)
- if p and c and p.r and p.r == c.r then
+ local p = jobpositions.get("md:v",v_anchors)
+ local c = jobpositions.get("md:v",v_anchors+1)
+ if p and c and p.p and p.p == c.p then
local distance = p.y - c.y
local offset = p[location] or 0
local overshoot = offset - distance
@@ -530,7 +542,10 @@ local function inject(parent,head,candidate)
offset = offset + candidate.dy
shift = shift + offset
elseif stack == v_continue then
- offset = offset + candidate.dy + getovershoot(location)
+ offset = offset + candidate.dy
+ if firstonstack then
+ offset = offset + getovershoot(location)
+ end
shift = shift + offset
end
-- -- --
@@ -602,7 +617,7 @@ local function inject(parent,head,candidate)
lineheight = candidate.lineheight, -- only for tracing
}
offset = offset + height
- stacked[location] = offset
+ stacked[location] = offset -- weird, no table ?
-- todo: if no real depth then zero
if trace_margindata then
report_margindata("status, offset: %s",offset)
@@ -720,14 +735,14 @@ function margins.localhandler(head,group)
if conditionals.inhibitmargindata then
return head, false
elseif nofstored > 0 then
- return handler("local",head,group)
+ return handler(v_local,head,group)
else
return head, false
end
end
function margins.globalhandler(head,group) -- check group
---~ print(group)
+-- print(group)
if conditionals.inhibitmargindata or nofstored == 0 then
return head, false
elseif group == "hmode_par" then
diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv
index 987ce9a12..225f73cbb 100644
--- a/tex/context/base/typo-mar.mkiv
+++ b/tex/context/base/typo-mar.mkiv
@@ -119,6 +119,7 @@
\c!width=,
% \c!stack=,
\c!line=0,
+ \c!anchor=\v!text,
\c!bottomspace=\strutdepth, % slack used for keeptogether
\c!dy=\zeropoint,
\c!distance=\zeropoint,
@@ -185,7 +186,6 @@
\strc_references_set_page_only_destination_box_attribute\currentmarginreference\currentmarginreference
\fi
\edef\currentmargindatastrut{\margindataparameter\c!strut}%
- \the\everymargindatacontent
\dostarttagged\t!margintext\currentmargindata
\ifcsname\currentmarginframedhash\s!parent\endcsname
\setbox\nextbox\hbox \currentmarginreference \bgroup
@@ -251,6 +251,16 @@
\ifhmode
inline = true,
\fi
+ anchor = "\margindataparameter\c!anchor",
+ %
+ % we're not in forgetall
+ %
+ % \ifzeropt\leftskip \else
+ % leftskip = \number\leftskip,
+ % \fi
+ % \ifzeropt\leftskip \else
+ % rightskip = \number\rightskip,
+ % \fi
scope = "\margindataparameter\c!scope",
align = "\margindataparameter\c!align",
line = "\margindataparameter\c!line",
diff --git a/tex/context/base/util-seq.lua b/tex/context/base/util-seq.lua
index 3c5dc8ebb..c3361b7be 100644
--- a/tex/context/base/util-seq.lua
+++ b/tex/context/base/util-seq.lua
@@ -30,7 +30,9 @@ utilities.sequencers = sequencers
local functions = allocate()
sequencers.functions = functions
-local removevalue, insertaftervalue, insertbeforevalue = tables.removevalue, tables.insertaftervalue, tables.insertbeforevalue
+local removevalue = tables.removevalue
+local insertaftervalue = tables.insertaftervalue
+local insertbeforevalue = tables.insertbeforevalue
local function validaction(action)
if type(action) == "string" then
@@ -45,7 +47,11 @@ local function validaction(action)
return true
end
-function sequencers.reset(t)
+local compile
+
+local known = { } -- just a convenience, in case we want public access (only to a few methods)
+
+function sequencers.new(t) -- was reset
local s = {
list = { },
order = { },
@@ -59,85 +65,127 @@ function sequencers.reset(t)
s.arguments = t.arguments
s.returnvalues = t.returnvalues
s.results = t.results
+ local name = t.name
+ if name and name ~= "" then
+ s.name = name
+ known[name] = s
+ end
end
+ table.setmetatableindex(s,function(t,k)
+ -- this will automake a dirty runner
+ if k == "runner" then
+ local v = compile(t,t.compiler)
+ return v
+ end
+ end)
+ known[s] = s -- saves test for string later on
return s
end
function sequencers.prependgroup(t,group,where)
+ t = known[t]
if t then
local order = t.order
removevalue(order,group)
insertbeforevalue(order,where,group)
- t.list[group], t.dirty, t.runner = { }, true, nil
+ t.list[group] = { }
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.appendgroup(t,group,where)
+ t = known[t]
if t then
local order = t.order
removevalue(order,group)
insertaftervalue(order,where,group)
- t.list[group], t.dirty, t.runner = { }, true, nil
+ t.list[group] = { }
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.prependaction(t,group,action,where,kind,force)
+ t = known[t]
if t then
local g = t.list[group]
if g and (force or validaction(action)) then
removevalue(g,action)
insertbeforevalue(g,where,action)
- t.kind[action], t.dirty, t.runner = kind, true, nil
+ t.kind[action] = kind
+ t.dirty = true
+ t.runner = nil
end
end
end
function sequencers.appendaction(t,group,action,where,kind,force)
+ t = known[t]
if t then
local g = t.list[group]
if g and (force or validaction(action)) then
removevalue(g,action)
insertaftervalue(g,where,action)
- t.kind[action], t.dirty, t.runner = kind, true, nil
+ t.kind[action] = kind
+ t.dirty = true
+ t.runner = nil
end
end
end
-function sequencers.enableaction (t,action)
+function sequencers.enableaction(t,action)
+ t = known[t]
if t then
- t.askip[action], t.dirty, t.runner = false, true, nil
+ t.askip[action] = false
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.disableaction(t,action)
+ t = known[t]
if t then
- t.askip[action], t.dirty, t.runner = true, true, nil
+ t.askip[action] = true
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.enablegroup(t,group)
+ t = known[t]
if t then
- t.gskip[group], t.dirty, t.runner = false, true, nil
+ t.gskip[action] = false
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.disablegroup(t,group)
+ t = known[t]
if t then
- t.gskip[group], t.dirty, t.runner = true, true, nil
+ t.gskip[action] = true
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.setkind(t,action,kind)
+ t = known[t]
if t then
- t.kind[action], t.dirty, t.runner = kind, true, nil
+ t.kind[action] = kind
+ t.dirty = true
+ t.runner = nil
end
end
function sequencers.removeaction(t,group,action,force)
+ t = known[t]
local g = t and t.list[group]
if g and (force or validaction(action)) then
removevalue(g,action)
- t.dirty, t.runner = true, nil
+ t.dirty = true
+ t.runner = nil
end
end
@@ -145,7 +193,7 @@ local function localize(str)
return (gsub(str,"[%.: ]+","_"))
end
-local function construct(t,nodummy)
+local function construct(t)
local list, order, kind, gskip, askip = t.list, t.order, t.kind, t.gskip, t.askip
local arguments, returnvalues, results = t.arguments or "...", t.returnvalues, t.results
local variables, calls, n = { }, { }, 0
@@ -176,10 +224,9 @@ local function construct(t,nodummy)
end
end
t.dirty = false
- if nodummy and n == 0 then
- return nil
+ if n == 0 then
+ t.compiled = ""
else
- -- n == 0 we could just return the variables
variables = concat(variables,"\n")
calls = concat(calls,"\n")
if results then
@@ -187,46 +234,45 @@ local function construct(t,nodummy)
else
t.compiled = format("%s\nreturn function(%s)\n%s\nend",variables,arguments,calls)
end
- return t.compiled -- also stored so that we can trace
end
+ return t.compiled -- also stored so that we can trace
end
-sequencers.tostring = function(s) return construct(s,true) end
+sequencers.tostring = construct
sequencers.localize = localize
-local function compile(t,compiler,n)
+compile = function(t,compiler,n) -- already referred to in sequencers.new
local compiled
if not t or type(t) == "string" then
-- weird ... t.compiled = t .. so
return false
- elseif compiler then
+ end
+ if compiler then
compiled = compiler(t,n)
+ t.compiled = compiled
else
compiled = construct(t,n)
end
- local runner = compiled and loadstring(compiled)()
- t.compiled = compiled
+ local runner
+ if compiled == "" then
+ runner = false
+ else
+ runner = compiled and loadstring(compiled)()
+ end
t.runner = runner
- return runner -- faster
+ return runner
end
sequencers.compile = compile
-function sequencers.autocompile(t,compiler,n) -- to be used in tasks
- t.runner = compile(t,compiler,n)
- local autorunner = function(...)
- return (t.runner or compile(t,compiler,n))(...) -- ugly but less bytecode
- end
- t.autorunner = autorunner
- return autorunner -- one more encapsulation
-end
-
-- we used to deal with tail as well but now that the lists are always
-- double linked and the kernel function no longer expect tail as
-- argument we stick to head and done (done can probably also go
-- as luatex deals with return values efficiently now .. in the
-- past there was some copying involved, but no longer)
+-- todo: use sequencer (can have arguments and returnvalues etc now)
+
local template = [[
%s
return function(head%s)
diff --git a/tex/context/fonts/lm.lfg b/tex/context/fonts/lm.lfg
index 0d082c051..406902ef2 100644
--- a/tex/context/fonts/lm.lfg
+++ b/tex/context/fonts/lm.lfg
@@ -4,6 +4,13 @@ return {
comment = "Goodies that complement latin modern.",
author = "Hans Hagen",
copyright = "ConTeXt development team",
+ mathematics = {
+ tweaks = {
+ aftercopying = {
+ mathematics.tweaks.fixbadprime, -- prime is too low
+ },
+ },
+ },
designsizes = {
["LMMathRoman-Regular"] = {
["4pt"] = "LMMath5-Regular@lmroman5-math",
diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml
index f60efa79e..c4ad23ba9 100644
--- a/tex/context/interface/cont-nl.xml
+++ b/tex/context/interface/cont-nl.xml
@@ -2466,7 +2466,7 @@
<cd:parameter name="file">
<cd:constant type="cd:text"/>
</cd:parameter>
- <cd:parameter name="gebied">
+ <cd:parameter name="directory">
<cd:constant type="cd:text"/>
</cd:parameter>
<cd:parameter name="willekeur">
@@ -8534,7 +8534,7 @@
<cd:parameter name="xmax">
<cd:constant type="cd:number"/>
</cd:parameter>
- <cd:parameter name="gebied">
+ <cd:parameter name="directory">
<cd:constant type="cd:text"/>
</cd:parameter>
<cd:parameter name="plaats">
@@ -9490,7 +9490,7 @@
</cd:sequence>
<cd:arguments>
<cd:assignments n="1" interactive="exclusive" list="yes">
- <cd:parameter name="gebied">
+ <cd:parameter name="directory">
<cd:constant type="cd:text"/>
</cd:parameter>
</cd:assignments>
diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml
index 8561fb698..3cc669006 100644
--- a/tex/context/interface/keys-cs.xml
+++ b/tex/context/interface/keys-cs.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='zarovnejtitul'/>
<cd:constant name='alternative' value='alternativa'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='sipka'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='odkaz'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='odkazujici'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='oblastuvnitr'/>
<cd:constant name='regionout' value='oblastvne'/>
<cd:constant name='repeat' value='opakovat'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='barvatextu'/>
<cd:constant name='textcommand' value='textovyprikaz'/>
<cd:constant name='textdistance' value='textdistance'/>
+ <cd:constant name='textheight' value='vyskatextu'/>
<cd:constant name='textlayer' value='textlayer'/>
<cd:constant name='textmargin' value='textmargin'/>
<cd:constant name='textmethod' value='textmethod'/>
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index eb8faed5a..4e6959fbe 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='titelausrichten'/>
<cd:constant name='alternative' value='alternative'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='pfeil'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='referenz'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='referieren'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='regionin'/>
<cd:constant name='regionout' value='regionaus'/>
<cd:constant name='repeat' value='wiederholen'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='textfarbe'/>
<cd:constant name='textcommand' value='textbefehl'/>
<cd:constant name='textdistance' value='textdistance'/>
+ <cd:constant name='textheight' value='texthoehe'/>
<cd:constant name='textlayer' value='textlayer'/>
<cd:constant name='textmargin' value='textmargin'/>
<cd:constant name='textmethod' value='textmethod'/>
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index 97f3ab0dc..459a03ede 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='aligntitle'/>
<cd:constant name='alternative' value='alternative'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='arrow'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='reference'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='referencing'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='regionin'/>
<cd:constant name='regionout' value='regionout'/>
<cd:constant name='repeat' value='repeat'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='textcolor'/>
<cd:constant name='textcommand' value='textcommand'/>
<cd:constant name='textdistance' value='textdistance'/>
+ <cd:constant name='textheight' value='textheight'/>
<cd:constant name='textlayer' value='textlayer'/>
<cd:constant name='textmargin' value='textmargin'/>
<cd:constant name='textmethod' value='textmethod'/>
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index c83fcee1b..f49db065b 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='alignementtitre'/>
<cd:constant name='alternative' value='alternative'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='fleche'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='reference'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='referencing'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='entreregion'/>
<cd:constant name='regionout' value='regionexterieure'/>
<cd:constant name='repeat' value='repete'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='couleurtexte'/>
<cd:constant name='textcommand' value='commandetexte'/>
<cd:constant name='textdistance' value='distancetexte'/>
+ <cd:constant name='textheight' value='hauteurtexte'/>
<cd:constant name='textlayer' value='calquetexte'/>
<cd:constant name='textmargin' value='margetexte'/>
<cd:constant name='textmethod' value='textmethod'/>
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index 0d8f62ea9..1fc70f2dc 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='allineatitolo'/>
<cd:constant name='alternative' value='alternativa'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='freccia'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='riferimento'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='referencing'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='entraregione'/>
<cd:constant name='regionout' value='esciregione'/>
<cd:constant name='repeat' value='ripeti'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='coloretesto'/>
<cd:constant name='textcommand' value='comandotesto'/>
<cd:constant name='textdistance' value='distanzatesto'/>
+ <cd:constant name='textheight' value='altezzatesto'/>
<cd:constant name='textlayer' value='textlayer'/>
<cd:constant name='textmargin' value='textmargin'/>
<cd:constant name='textmethod' value='textmethod'/>
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index 638641a61..275e910e2 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='titeluitlijnen'/>
<cd:constant name='alternative' value='variant'/>
+ <cd:constant name='anchor' value='anker'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='pijl'/>
@@ -642,7 +643,7 @@
<cd:constant name='depth' value='diepte'/>
<cd:constant name='depthcorrection' value='dieptecorrectie'/>
<cd:constant name='direction' value='richting'/>
- <cd:constant name='directory' value='gebied'/>
+ <cd:constant name='directory' value='directory'/>
<cd:constant name='display' value='scherm'/>
<cd:constant name='distance' value='afstand'/>
<cd:constant name='dot' value='punt'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='verwijzing'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='refereren'/>
+ <cd:constant name='region' value='gebied'/>
<cd:constant name='regionin' value='gebiedin'/>
<cd:constant name='regionout' value='gebieduit'/>
<cd:constant name='repeat' value='herhaal'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='tekstkleur'/>
<cd:constant name='textcommand' value='tekstcommando'/>
<cd:constant name='textdistance' value='tekstafstand'/>
+ <cd:constant name='textheight' value='teksthoogte'/>
<cd:constant name='textlayer' value='tekstlaag'/>
<cd:constant name='textmargin' value='tekstmarge'/>
<cd:constant name='textmethod' value='tekstmethode'/>
diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml
index 64330dc06..9a965882b 100644
--- a/tex/context/interface/keys-pe.xml
+++ b/tex/context/interface/keys-pe.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='عنوان‌تنظیم'/>
<cd:constant name='alternative' value='جایگزین'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='پیکان'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='مرجع'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='مراجعه'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='ناحیه‌درون'/>
<cd:constant name='regionout' value='ناحیه‌بیرون'/>
<cd:constant name='repeat' value='تکرار'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='رنگ‌متن'/>
<cd:constant name='textcommand' value='فرمان‌متن'/>
<cd:constant name='textdistance' value='فاصله‌متن'/>
+ <cd:constant name='textheight' value='ارتفاع‌متن'/>
<cd:constant name='textlayer' value='لایه‌متن'/>
<cd:constant name='textmargin' value='حاشیه‌متن'/>
<cd:constant name='textmethod' value='روش‌متن'/>
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index 0f2a6457d..82ecda69f 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -543,6 +543,7 @@
<cd:constant name='alignsymbol' value='alignsymbol'/>
<cd:constant name='aligntitle' value='alinieretitlu'/>
<cd:constant name='alternative' value='alternativ'/>
+ <cd:constant name='anchor' value='anchor'/>
<cd:constant name='andtext' value='andtext'/>
<cd:constant name='apa' value='apa'/>
<cd:constant name='arrow' value='sageata'/>
@@ -904,6 +905,7 @@
<cd:constant name='reference' value='referinta'/>
<cd:constant name='referenceprefix' value='referenceprefix'/>
<cd:constant name='referencing' value='referinta'/>
+ <cd:constant name='region' value='region'/>
<cd:constant name='regionin' value='regiuneintrare'/>
<cd:constant name='regionout' value='regiuneiesire'/>
<cd:constant name='repeat' value='repeta'/>
@@ -1007,6 +1009,7 @@
<cd:constant name='textcolor' value='culoaretext'/>
<cd:constant name='textcommand' value='comandatext'/>
<cd:constant name='textdistance' value='textdistance'/>
+ <cd:constant name='textheight' value='inaltimetext'/>
<cd:constant name='textlayer' value='textlayer'/>
<cd:constant name='textmargin' value='textmargin'/>
<cd:constant name='textmethod' value='textmethod'/>
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 433aba544..3763c896b 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 01/25/12 14:16:54
+-- merge date : 02/08/12 21:04:08
do -- begin closure to overcome local limits and interference
@@ -3307,7 +3307,6 @@ local setmetatableindex = table.setmetatableindex
-- will be directives
constructors.dontembed = allocate()
-constructors.mathactions = { }
constructors.autocleanup = true
constructors.namemode = "fullpath" -- will be a function
@@ -3541,6 +3540,14 @@ function constructors.assignmathparameters(target,original) -- simple variant, n
end
end
+function constructors.beforecopyingcharacters(target,original)
+ -- can be used for additional tweaking
+end
+
+function constructors.aftercopyingcharacters(target,original)
+ -- can be used for additional tweaking
+end
+
function constructors.enhanceparameters(parameters)
local xheight = parameters.x_height
local quad = parameters.quad
@@ -3790,7 +3797,7 @@ function constructors.scale(tfmdata,specification)
--
local italickey = "italic"
--
- -- some context specific trickery (we might move this to a plug in into here
+ -- some context specific trickery (this will move to a plugin)
--
if hasmath then
if properties.mathitalics then
@@ -3816,6 +3823,8 @@ function constructors.scale(tfmdata,specification)
--
-- end of context specific trickery
--
+ constructors.beforecopyingcharacters(target,tfmdata)
+ --
local sharedkerns = { }
--
-- we can have a dumb mode (basemode without math etc) that skips most
@@ -4058,6 +4067,9 @@ function constructors.scale(tfmdata,specification)
end
targetcharacters[unicode] = chr
end
+ --
+ constructors.aftercopyingcharacters(target,tfmdata)
+ --
return target
end
@@ -12486,17 +12498,6 @@ function definers.resolve(specification)
else
specification.forced = specification.forced
end
- -- for the moment here (goodies set outside features)
- local goodies = specification.goodies
- if goodies and goodies ~= "" then
- local normal = specification.features.normal
- if not normal then
- specification.features.normal = { goodies = goodies }
- elseif not normal.goodies then
- normal.goodies = goodies
- end
- end
- --
specification.hash = lower(specification.name .. ' @ ' .. constructors.hashfeatures(specification))
if specification.sub and specification.sub ~= "" then
specification.hash = specification.sub .. ' @ ' .. specification.hash