summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2010-04-09 11:49:00 +0200
committerHans Hagen <pragma@wxs.nl>2010-04-09 11:49:00 +0200
commita5d3707be9e544069a94b3c8d7b51c7b31e506e5 (patch)
tree61a4efc87be96d39acbefd9f24774a31739dbd74
parentc63da592cc7ecde38ec1749525c072e79adebdcf (diff)
downloadcontext-a5d3707be9e544069a94b3c8d7b51c7b31e506e5.tar.gz
beta 2010.04.09 11:49
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.mkiv1
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/math-def.mkiv45
-rw-r--r--tex/context/base/math-ext.lua1
-rw-r--r--tex/context/base/math-vfu.lua4
-rw-r--r--tex/context/base/page-flt.lua227
-rw-r--r--tex/context/base/page-flt.mkiv233
-rw-r--r--tex/context/base/page-ini.mkiv2
-rw-r--r--tex/context/base/page-lay.mkiv8
-rw-r--r--tex/context/base/page-mis.mkiv48
-rw-r--r--tex/context/base/page-mul.mkiv160
-rw-r--r--tex/context/base/page-one.mkiv104
-rw-r--r--tex/context/base/page-set.mkiv13
-rw-r--r--tex/context/base/page-txt.mkiv25
-rw-r--r--tex/context/base/sort-ini.lua9
-rw-r--r--tex/context/base/sort-lan.lua5
-rw-r--r--tex/context/base/strc-flt.mkiv240
-rw-r--r--tex/context/base/strc-pag.lua9
-rw-r--r--tex/context/base/strc-pag.mkiv26
-rw-r--r--tex/context/base/supp-fil.lua6
21 files changed, 703 insertions, 467 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 448da9f1a..b5700b4f9 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2010.04.07 17:58}
+\newcontextversion{2010.04.09 11:49}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 12cd3d747..8b533a34d 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -193,6 +193,7 @@
\loadmarkfile{core-sys}
\loadmarkfile{page-ini}
+\loadmarkfile{page-flt}
\loadmarkfile{page-bck}
\loadmarkfile{page-not}
\loadmarkfile{page-one}
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 0806a0f40..0e9520600 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2010.04.07 17:58}
+\edef\contextversion{2010.04.09 11:49}
%D For those who want to use this:
diff --git a/tex/context/base/math-def.mkiv b/tex/context/base/math-def.mkiv
index 923ac5a71..604e2d8d2 100644
--- a/tex/context/base/math-def.mkiv
+++ b/tex/context/base/math-def.mkiv
@@ -106,15 +106,42 @@
% using attributes
-\def\choosemathbig#1#2%
- {\attribute\mathsizeattribute#1\relax
- \left#2\right.%
- \attribute\mathsizeattribute\attributeunsetvalue}
-
-\definemathcommand [big] {\choosemathbig\plusone }
-\definemathcommand [Big] {\choosemathbig\plustwo }
-\definemathcommand [bigg] {\choosemathbig\plusthree}
-\definemathcommand [Bigg] {\choosemathbig\plusfour }
+\chardef\bigmathdelimitermethod\plusone
+
+\def\plainbigdelimiters % traditional method
+ {\chardef\bigmathdelimitermethod\plustwo}
+
+\def\doplainbigmath#1#2%
+ {{\hbox{$%
+ \nulldelimiterspace\zeropoint\relax
+ \mathsurround\zeropoint
+ $}}}
+
+\def\doleftbigmath #1{\ifx#1\relax\else\left#1\expandafter\doleftbigmath \fi}
+\def\dorightbigmath#1{\ifx#1\relax\else\right.\expandafter\dorightbigmath\fi}
+
+\def\choosemathbig#1#2% so we accent \big{||} as well
+ {{\hbox{$%
+ \ifcase\bigmathdelimitermethod
+ \doleftbigmath#2\relax
+ \dorightbigmath#2\relax
+ \or
+ \attribute\mathsizeattribute#1\relax
+ \doleftbigmath#2\relax
+ \dorightbigmath#2\relax
+ \else
+ \doleftbigmath#2\relax
+ \vbox\!!to\getvalue{\??mm:b:\number#1}\bodyfontsize{}%
+ \dorightbigmath#2\relax
+ \fi
+ \nulldelimiterspace\zeropoint\relax
+ \mathsurround\zeropoint
+ $}}}
+
+\definemathcommand [big] {\choosemathbig\plusone } \setvalue{\??mm:b:1}{0.85}
+\definemathcommand [Big] {\choosemathbig\plustwo } \setvalue{\??mm:b:2}{1.15}
+\definemathcommand [bigg] {\choosemathbig\plusthree} \setvalue{\??mm:b:3}{1.45}
+\definemathcommand [Bigg] {\choosemathbig\plusfour } \setvalue{\??mm:b:4}{1.75}
\definemathcommand [bigl] [open] [one] {\big}
\definemathcommand [bigm] [rel] [one] {\big}
diff --git a/tex/context/base/math-ext.lua b/tex/context/base/math-ext.lua
index fd65592c3..673103677 100644
--- a/tex/context/base/math-ext.lua
+++ b/tex/context/base/math-ext.lua
@@ -152,4 +152,3 @@ mathematics.extras.add(0xFE323, {
--~ \Umathchardef\bracerd="0 "1 "FF07B
--~ \Umathchardef\bracelu="0 "1 "FF07C
--~ \Umathchardef\braceru="0 "1 "FF07D
-
diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua
index 4d5d9d613..6097fbecb 100644
--- a/tex/context/base/math-vfu.lua
+++ b/tex/context/base/math-vfu.lua
@@ -245,6 +245,10 @@ function fonts.vf.math.alas(main,id,size)
vertbar(main,id,size,0xFF601,0.30,0xFF602) -- Big : 1.15 bodyfontsize
vertbar(main,id,size,0xFF602,0.30,0xFF603) -- bigg : 1.45 bodyfontsize
vertbar(main,id,size,0xFF603,0.30,0xFF604) -- Bigg : 1.75 bodyfontsize
+ vertbar(main,id,size,0x02225,0.10,0xFF605)
+ vertbar(main,id,size,0xFF605,0.30,0xFF606)
+ vertbar(main,id,size,0xFF606,0.30,0xFF607)
+ vertbar(main,id,size,0xFF607,0.30,0xFF608)
end
local unique = 0 -- testcase: \startTEXpage \math{!\text{-}\text{-}\text{-}} \stopTEXpage
diff --git a/tex/context/base/page-flt.lua b/tex/context/base/page-flt.lua
new file mode 100644
index 000000000..74d1e4e8c
--- /dev/null
+++ b/tex/context/base/page-flt.lua
@@ -0,0 +1,227 @@
+if not modules then modules = { } end modules ['page-flt'] = {
+ version = 1.001,
+ comment = "companion to page-flt.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local setdimen, setbox, setcount, texbox = tex.setdimen, tex.setbox, tex.setcount, tex.box
+local insert, remove = table.insert, table.remove
+local texwrite, texsprint, ctxcatcodes = tex.write, tex.sprint, tex.ctxcatcodes
+
+local copy_node_list = node.copy_list
+
+local trace_floats = false trackers.register("graphics.floats", function(v) trace_floats = v end) -- name might change
+
+-- we use floatbox, floatwidth, floatheight
+-- text page leftpage rightpage (todo: top, bottom, margin, order)
+
+floats = floats or { }
+
+local noffloats, last, default, pushed = 0, nil, "text", { }
+
+local function initialize()
+ return {
+ text = { },
+ page = { },
+ leftpage = { },
+ rightpage = { },
+ }
+end
+
+local stacks = initialize()
+
+-- list location
+
+function floats.stacked(which) -- floats.thenofstacked
+ return #stacks[which or default]
+end
+
+function floats.thestacked(which)
+ return texwrite(#stacks[which or default])
+end
+
+function floats.push()
+ insert(pushed,stacks)
+ stacks = initialize()
+ setcount("global","savednoffloats",0)
+end
+
+function floats.pop()
+ local popped = remove(pushed)
+ if popped then
+ for which, stack in next, stacks do
+ for i=1,#stack do
+ insert(popped[which],stack[i])
+ end
+ end
+ stacks = popped
+ setcount("global","savednoffloats",#stacks[default])
+ end
+end
+
+local function setdimensions(b)
+ local w, h, d = 0, 0, 0
+ if b then
+ w, h, d = b.width, b.height, b.depth
+ end
+ setdimen("global","floatwidth", w)
+ setdimen("global","floatheight", h+d)
+ return w, h, d
+end
+
+local function get(stack,n)
+ n = n or #stack
+ if n > 0 then
+ local t = stack[n]
+ if t then
+ return t, t.box, n
+ end
+ end
+end
+
+function floats.save(which,data)
+ which = which or default
+ local stack = stacks[which]
+ noffloats = noffloats + 1
+ local b = texbox.floatbox
+ local w, h, d = b.width, b.height, b.depth
+ local t = {
+ n = noffloats,
+ data = data or { },
+ box = copy_node_list(b),
+ }
+ texbox.floatbox = nil
+ insert(stack,t)
+ setcount("global","savednoffloats",#stacks[default])
+ if trace_floats then
+ logs.report("floats","saving %s float %s in slot %s (%i,%i,%i)",which,noffloats,#stack,w,h,d)
+ else
+ interfaces.showmessage("floatblocks",2,noffloats)
+ end
+end
+
+function floats.resave(which)
+ if last then
+ which = which or default
+ local stack = stacks[which]
+ local b = texbox.floatbox
+ local w, h, d = b.width, b.height, b.depth
+ last.box = copy_node_list(b)
+ texbox.floatbox = nil
+ insert(stack,1,last)
+ setcount("global","savednoffloats",#stacks[default])
+ if trace_floats then
+ logs.report("floats","resaving %s float %s in slot %s (%i,%i,%i)",which,noffloats,#stack,w,h,d)
+ else
+ interfaces.showmessage("floatblocks",2,noffloats)
+ end
+ else
+ logs.report("floats","unable to resave float")
+ end
+end
+
+function floats.flush(which,n)
+ which = which or default
+ local stack = stacks[which]
+ local t, b, n = get(stack,n or 1)
+ if t then
+ local w, h, d = setdimensions(b)
+ if trace_floats then
+ logs.report("floats","flushing %s float %s from slot %s (%i,%i,%i)",which,t.n,n,w,h,d)
+ else
+ interfaces.showmessage("floatblocks",3,t.n)
+ end
+ texbox.floatbox = b
+ last = remove(stack,n)
+ last.box = nil
+ setcount("global","savednoffloats",#stacks[default])
+ else
+ setdimensions()
+ end
+end
+
+function floats.thevar(name,default)
+ local value = last and last.data[name] or default
+ if value and value ~= "" then
+ texsprint(ctxcatcodes,value)
+ end
+end
+
+function floats.consult(which,n)
+ which = which or default
+ local stack = stacks[which]
+ local t, b, n = get(stack,n)
+ if t then
+ local w, h, d = setdimensions(b)
+ if trace_floats then
+ logs.report("floats","consulting %s float %s in slot %s (%i,%i,%i)",which,t.n,n,w,h,d)
+ end
+ return t, b, n
+ else
+ if trace_floats then
+ logs.report("floats","nothing to consult")
+ end
+ setdimensions()
+ end
+end
+
+function floats.collect(which,maxwidth,distance)
+ which = which or default
+ local stack = stacks[which]
+ local n, m = #stack, 0
+ for i=1,n do
+ local t, b, n = get(stack,i)
+ if t then
+ local w, h, d = setdimensions(b)
+ if w + distance < maxwidth then
+ m = m + 1
+ maxwidth = maxwidth - w - distance
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ if m == 0 then
+ m = 1
+ end
+ setcount("global","nofcollectedfloats",m)
+end
+
+function commands.doifsavedfloatelse(which)
+ local stack = stacks[which or default]
+ commands.doifelse(#stack>0)
+end
+
+function floats.thecheckedpagefloat(packed)
+ local result = ""
+ if structure.pages.is_odd() then
+ if #stacks.rightpage > 0 then
+ result = "rightpage"
+ elseif #stacks.page > 0 then
+ result = "page"
+ elseif #stacks.leftpage > 0 then
+ if packed then
+ result = "leftpage"
+ else
+ result = "empty"
+ end
+ end
+ else
+ if #stacks.leftpage > 0 then
+ result = "leftpage"
+ elseif #stacks.page > 0 then
+ result = "page"
+ elseif #stacks.rightpage > 0 then
+ if packed then
+ result = "rightpage"
+ else
+ result = "empty"
+ end
+ end
+ end
+ texsprint(ctxcatcodes,result)
+end
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
new file mode 100644
index 000000000..8ba0e9142
--- /dev/null
+++ b/tex/context/base/page-flt.mkiv
@@ -0,0 +1,233 @@
+%D \module
+%D [ file=page-flt,
+%D version=2010.04,08,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Float Management,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Page Macros / Float Management}
+
+%D This module has code that previously was in other modules. There is
+%D also float related code in \type {strc-flt.mkiv}.
+
+\registerctxluafile{page-flt}{1.001}
+
+\unprotect
+
+%D To be checked:
+
+%def\dosavefloatinfo {\showmessage\m!floatblocks2{\the\totalnoffloats}}
+\def\doinsertfloatinfo {\showmessage\m!floatblocks4{\the\totalnoffloats}}
+%def\dofloatflushedinfo{\showmessage\m!floatblocks3{\the\numexpr\totalnoffloats-\savednoffloats\relax}}
+
+%D Extra float registers.
+
+\newif\ifsomefloatwaiting \somefloatwaitingfalse
+\newif\ifroomforfloat \roomforfloattrue
+\newif\ifnofloatpermitted \nofloatpermittedfalse
+\newif\ifcenterfloatbox \centerfloatboxtrue
+\newif\iflocalcenterfloatbox \localcenterfloatboxfalse
+\newif\ifglobalcenterfloatbox \globalcenterfloatboxfalse
+\newif\ifflushingfloats \flushingfloatsfalse
+\newif\ifpackflushedfloats \packflushedfloatstrue % for the moment
+\newif\ifpackcolumnfloats \packcolumnfloatstrue
+
+\newcount\totalnoffloats
+\newcount\savednoffloats
+\newcount\noffloatinserts
+\newcount\nofcollectedfloats % communication channel
+
+\newbox \floatlist
+\newbox \savedfloatlist
+\newbox \floattext
+
+\newdimen\floatwidth
+\newdimen\floatheight
+\newdimen\floatdepth
+\newdimen\floattextwidth
+\newdimen\floattextheight
+
+\newbox \floatbox
+\newbox \savedfloatbox
+
+%D From now on we manage the float stack at the \LUA\ end instead of packing
+%D them in a box and splitting off stacked floats. It's not so much less code
+%D but it's cleaner this way. It also opens op some posibilities as we can now
+%D more conveniently cary additional information around.
+
+\newtoks \everyfloatscheck
+
+\appendtoks
+ \ifcase\savednoffloats
+ \global\somefloatwaitingfalse
+ \else
+ \global\somefloatwaitingtrue
+ \fi
+\to \everyfloatscheck
+
+\def\dofloatsflush#1#2%
+ {\ctxlua{floats.flush("#1",\number#2)}%
+ \the\everyfloatscheck}
+
+\def\dofloatssave#1%
+ {\ctxlua{floats.save("#1")}%
+ \the\everyfloatscheck}
+
+\def\dofloatsresave#1%
+ {\ctxlua{floats.resave("#1")}%
+ \the\everyfloatscheck}
+
+\def\dopushsavedfloats
+ {\ctxlua{floats.push()}%
+ \the\everyfloatscheck}
+
+\def\dopopsavedfloats
+ {\ctxlua{floats.pop()}%
+ \the\everyfloatscheck}
+
+\def\dofloatsgetinfo#1%
+ {\ctxlua{floats.consult("#1")}}
+
+\def\doifsavedfloatelse#1%
+ {\ctxlua{commands.doifsavedfloatelse("#1")}}
+
+\def\dofloatscollect#1#2#3%
+ {\ctxlua{floats.collect("#1",\number\dimexpr#2,\number\dimexpr#3)}}
+
+\def\dofloatsnofstacked#1%
+ {\ctxlua{floats.thestacked("#1")}}
+
+\def\dofloatsgetvariable#1%
+ {\ctxlua{floats.thevar("specification")}}
+
+\let\dopushcolumnfloats\dopushsavedfloats
+\let\dopopcolumnfloats \dopopsavedfloats
+
+\def\dofloatssavepagefloat#1#2%
+ {\ctxlua{floats.save("#1", { specification = "#2" })}}
+
+%D The following code is in transition as we don't want to break the
+%D current single column, multi column, and columnset mechanism.
+%D
+%D First we reimplement some helpers.
+
+\def\dogetfloat
+ {\ifsomefloatwaiting
+ \dofloatsflush{text}{1}%
+ \ifcenterfloatbox
+ \ifdim\wd\globalscratchbox<\hsize
+ \global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
+ \else
+ % retain special alignments
+ \ifinsidecolumns
+ \ifdim\wd\floatbox>\makeupwidth
+ \global\wd\floatbox\makeupwidth
+ \fi
+ \fi
+ \fi
+ \fi
+ \else
+ \global\savednoffloats\zerocount
+ \global\setbox\floatbox\emptybox
+ \fi}
+
+\def\dosavefloat
+ {\dofloatssave{text}%
+ \nonoindentation} % brrr nonoindentation here
+
+\def\doresavefloat
+ {\dofloatsresave{text}}
+
+\def\doreversesavefloat
+ {\dofloatsresave{text}}
+
+\def\doflushsavedfloats % simplified \OTRONEdodoflushfloats
+ {\doloop
+ {\ifsomefloatwaiting
+ \docheckiffloatfits
+ \ifroomforfloat
+ \dogetfloat
+ \doplacefloatbox
+ \else
+ \exitloop
+ \fi
+ \else
+ \exitloop
+ \fi}}
+
+%D Page floats use different stacks.
+
+\newtoks \everybeforeflushedpagefloat
+
+\def\doflushsomepagefloat#1% future releases can do more clever things
+ {\dofloatsflush{#1}{1}%
+ \edef\floatspecification{\dofloatsgetvariable{specification}}%
+ \the\everybeforeflushedpagefloat
+ \vbox to \textheight
+ {\doifnotinset\v!high\floatspecification\vfill
+ \box\floatbox
+ \doifnotinset\v!low\floatspecification\vfill}%
+ \vfill\eject}
+
+% \def\doflushpagefloats
+% {\doifoddpageelse
+% {\ifnum\dofloatsnofstacked{rightpage}>\zerocount
+% \doflushsomepagefloat{rightpage}%
+% \else\ifnum\dofloatsnofstacked{page}>\zerocount
+% \doflushsomepagefloat{page}
+% \else\ifnum\dofloatsnofstacked{leftpage}>\zerocount
+% \null\vfill\eject
+% %\doflushsomepagefloat{leftpage}%
+% \fi\fi\fi}
+% {\ifnum\dofloatsnofstacked{leftpage}>\zerocount
+% \doflushsomepagefloat{leftpage}%
+% \else\ifnum\dofloatsnofstacked{page}>\zerocount
+% \doflushsomepagefloat{page}
+% \else\ifnum\dofloatsnofstacked{rightpage}>\zerocount
+% \null\vfill\eject
+% %\doflushsomepagefloat{rightpage}%
+% \fi\fi\fi}}
+
+\def\doflushpagefloats
+ {\edef\checkedpagefloat{\ctxlua{floats.thecheckedpagefloat()}}% (true) for packed
+ \ifx\checkedpagefloat\empty
+ % nothing
+ \else\ifx\checkedpagefloat\v!empty
+ \null\vfill\eject
+ \else
+ \doflushsomepagefloat\checkedpagefloat
+ \fi\fi}
+
+\def\uncenteredfloatbox
+ {\ifcenterfloatbox
+ \ifhbox\floatbox\relax % remove centering
+ \ifdim\wd\floatbox=\hsize
+ \ifhbox\floatbox
+ \setbox\scratchbox\hbox
+ {\unhbox\floatbox
+ \unskip\unskip
+ \global\setbox\globalscratchbox\lastbox}%
+ \box\globalscratchbox
+ \else
+ \box\floatbox
+ \fi
+ \else
+ \box\floatbox
+ \fi
+ \else
+ \box\floatbox
+ \fi
+ \else
+ \box\floatbox
+ \fi}
+
+\ifdefined\doflushfloats\else \let\doflushfloats\relax \fi
+\ifdefined\flushfloatbox\else \let\flushfloatbox\relax \fi
+
+\protect \endinput
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index 568314ff8..a02781bdf 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -443,8 +443,6 @@
\newif\ifbalancingcolumns
\newif\ifcollectingcontent
\newif\ifcolumnoverflow
-\newif\iffinalflushingfloats
-\newif\ifpackflushedfloats \packflushedfloatstrue % for the moment
\newdimen\intercolumnwidth
\newdimen\localcolumnwidth
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 4fb3e04a2..4953f2063 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -993,14 +993,12 @@
%D it is used in cross referencing. The next switch is set
%D when we start at an even page.
-\newif\ifshiftedrealpageno
-
% We could use nested if here plus some \@EAEAEA's but but the
% next variant has less expansion which is nicer in tracing.
-\def\doifoddpageelse {\ifshiftedrealpageno\expandafter\doifoddpageelseyes \else\expandafter\doifoddpageelsenop \fi}
-\def\doifoddpageelseyes{\ifodd \realpageno\expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments \fi}
-\def\doifoddpageelsenop{\ifodd \realpageno\expandafter\firstoftwoarguments \else\expandafter\secondoftwoarguments\fi}
+\def\doifoddpageelse {\ifodd\pagenoshift\expandafter\doifoddpageelseyes \else\expandafter\doifoddpageelsenop \fi}
+\def\doifoddpageelseyes{\ifodd\realpageno \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments \fi}
+\def\doifoddpageelsenop{\ifodd\realpageno \expandafter\firstoftwoarguments \else\expandafter\secondoftwoarguments\fi}
\let\doifonevenpaginaelse\doifoddpageelse
diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv
index 14a35fb70..8bc040064 100644
--- a/tex/context/base/page-mis.mkiv
+++ b/tex/context/base/page-mis.mkiv
@@ -43,11 +43,11 @@
\unvcopy\marginbox
\ifvoid\marginbox\else\expandafter\@@mbinbetween\fi
\box\floatbox\filbreak}%
- \ifdim\ht\marginbox>\textheight
- \dosavefloatinfo
- \else
- \doinsertfloatinfo
- \fi}
+ \ifdim\ht\marginbox>\textheight
+ % \dosavefloatinfo
+ \else
+ \doinsertfloatinfo
+ \fi}
\newbox\preparedmarginbox
@@ -164,44 +164,6 @@
% \ifinpostponing: handhaven, want gebruikt in stijlen ! ! ! ! !
-\def\doflushoddpagefloats
- {\ifvoid\collectedleftpagefloats
- \ifvoid\collectedrightpagefloats\else
- \unvbox\collectedrightpagefloats
- \page
- %\the\everytopofpage
- \fi
- \fi}
-
-\def\doflushevenpagefloats
- {\ifvoid\collectedleftpagefloats\else
- \unvbox\collectedleftpagefloats
- \page
- %\the\everytopofpage
- \fi
- \ifvoid\collectedrightpagefloats\else
- \unvbox\collectedrightpagefloats
- \page
- %\the\everytopofpage
- \fi}
-
-\def\doflushcommonpagefloats
- {\ifvoid\collectedpagefloats\else
- % message
- \unvbox\collectedpagefloats
- \fi}
-
-\def\doflushpagefloats
- {\doifoddpageelse
- \doflushoddpagefloats
- \doflushevenpagefloats
- \doflushcommonpagefloats}
-
-% \def\flushrestfloats
-% {\doif{\floatsharedparameter\c!cache}\v!no\doflushfloats}
-
-% \let\flushrestfloats\relax
-
\def\dodoflushpostponedblocks
{\bgroup % we need the font switch, else problems inside split verbatim
\setnormalcatcodes % postponing in verbatim
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index 4ede65a11..4cce67c3a 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -424,18 +424,7 @@
%\setcolumntextheight\relax
\widowpenalty\zerocount % is gewoon beter
\clubpenalty \zerocount % zeker bij grids
- \ifsomefloatwaiting
- \showmessage\m!columns6{\the\savednoffloats}%
- \global\setbox\savedfloatlist\box\floatlist
- \xdef\restoresavedfloats
- {\global\savednoffloats\the\savednoffloats
- \global\setbox\floatlist\box\savedfloatlist
- \global\noexpand\somefloatwaitingtrue}%
- \global\savednoffloats\zerocount
- \global\somefloatwaitingfalse
- \else
- \global\let\restoresavedfloats\relax
- \fi
+ \dopushcolumnfloats
\dimen0\dimexpr\pagetotal+\parskip+\openlineheight\relax
\ifdim\dimen0<\pagegoal
\allowbreak
@@ -525,7 +514,7 @@
\synchronizeoutput % new may 2004 / we need to: \pagegoal\vsize
\checkendcolumnfootnotes
\dosomebreak\allowbreak
- \restoresavedfloats}
+ \dopopcolumnfloats}
%D Because some initializations happen three times, we
%D defined a macro for them. Erasing \type{\everypar} is
@@ -1228,30 +1217,51 @@
%D When all those floats are flushed, we switch to the local
%D flushing routine.
-\def\setcolumnfloats
- {\xdef\globalsavednoffloats{\the\savednoffloats}%
- \ifnum\globalsavednoffloats>\zerocount
- \setglobalcolumnfloats
+\def\dopushcolumnfloats
+ {\ifsomefloatwaiting
+ \showmessage\m!columns6{\the\savednoffloats}%
+ \global\setbox\savedfloatlist\box\floatlist
+ \xdef\dopopcolumnfloats
+ {\global\savednoffloats\the\savednoffloats
+ \global\setbox\floatlist\box\savedfloatlist
+ \global\noexpand\somefloatwaitingtrue}%
+ \global\savednoffloats\zerocount
+ \global\somefloatwaitingfalse
\else
- \setlocalcolumnfloats
+ \global\let\dopopcolumnfloats\relax
\fi}
-\def\setglobalcolumnfloats
- {\everypar\emptytoks
- \let\flushcolumnfloat\relax
- %\let\doroomfloat\relax
- \let\docheckiffloatfits\relax
- \let\flushcolumnfloats\noflushcolumnfloats}
+\let\dopopcolumnfloats\relax
+
+% \def\setcolumnfloats % messy as it adapts everypar
+% {\xdef\globalsavednoffloats{\the\savednoffloats}%
+% \ifnum\globalsavednoffloats>\zerocount
+% \setglobalcolumnfloats % hm, we always push so this never happens
+% \else
+% \setlocalcolumnfloats
+% \fi}
+
+\def\setcolumnfloats % messy as it adapts everypar, we need to adapt this
+ {\setlocalcolumnfloats}
+
+\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}
\def\setlocalcolumnfloats
- {\everypar{\flushnotes\flushcolumnfloat\flushmargincontents\checkindentation}%
+ {\settrue\onlylocalcolumnfloats
+ \everypar{\flushnotes\flushcolumnfloat\flushmargincontents\checkindentation}%
\let\flushcolumnfloat\doflushcolumnfloat
- %\let\doroomfloat\docolumnroomfloat
- \let\docheckiffloatfits\docolumnroomfloat
- \let\flushcolumnfloats\doflushcolumnfloats
- \let\doflushfloats\doflushcolumnfloats % new
- \let\dosetbothinserts\relax
- \let\dotopinsertions\relax}
+ \let\flushcolumnfloats\doflushcolumnfloats}
+
+\def\setglobalcolumnfloats
+ {\setfalse\onlylocalcolumnfloats
+ \everypar\emptytoks
+ \let\flushcolumnfloat\relax
+ \let\flushcolumnfloats\noflushcolumnfloats}
\def\noflushcolumnfloats
{\bgroup
@@ -1316,24 +1326,17 @@
\else
\bgroup
\getcolumnstatus\column\count255\total\dimen0\goal\dimen2\\%
- \advance\dimen0 2\openlineheight % nog nodig ?
- %\ifnum\count255=\nofcolumns
- % \getinsertionheight
- % %\message{\insertionheight}\wait
- % \advance\dimen0 \insertionheight
- %\fi
+ \dofloatsgetinfo{text}%
\setbox\scratchbox\vbox % tricky met objecten ?
{\blank[\@@bkspacebefore]
- \snaptogrid\vbox{\copy\floatbox}}%
- \advance\dimen0 \ht\scratchbox
- \advance\dimen0 .5\lineheight % needed because goal a bit higher
- %\message{column: \the\count255; total: \the\dimen0; goal: \the\dimen2}\wait
+ \snaptogrid\vbox{\vskip\floatheight}}% copy?
+ \advance\dimen0\dimexpr\ht\scratchbox+2\openlineheight+.5\lineheight\relax\relax % needed because goal a bit higher
\ifdim\dimen0>\dimen2
\global\roomforfloatfalse
\else
\global\roomforfloattrue
\fi
- \ifdim\wd\floatbox>\hsize
+ \ifdim\floatwidth>\hsize
\showmessage\m!columns{11}\empty
\global\roomforfloatfalse
\fi
@@ -1353,40 +1356,33 @@
\let\doflushcolumnfloat\relax
\getcolumnstatus\column\mofcolumns\total\dimen0\goal\dimen2\\%
\ifdim\dimen0>\zeropoint
- \dogetfloat
- \ifdim\wd\floatbox>\hsize
- \doresavefloat
+ \dofloatsgetinfo{text}%
+ \ifdim\floatwidth>\hsize
+ % dropped ?
\else
- %\setbox2=\vbox
- % {\blank[\@@bkspacebefore]
- % \snaptogrid\vbox{\copy\floatbox}%
- % \blank[\@@bkspaceafter]
- \setbox2=\vbox
+ \setbox2\vbox
{\blank[\@@bkspacebefore]
- \snaptogrid\vbox{\copy\floatbox}}%
+ \snaptogrid\vbox{\vskip\floatheight}}%
\advance\dimen0 \ht2
\ifdim\dimen0>\dimen2
\ifnum\mofcolumns<\nofcolumns
\advance\mofcolumns \plusone
-%% bug %% \edef\currenttopcolumnbox{\getvalue{\@@topcol\the\count255}}%
\ifdim\ht\currenttopcolumnbox=\zeropoint
+ \dofloatsflush{text}{1}%
\global\setbox\currenttopcolumnbox\vbox
- {\snaptogrid\vbox{\copy\floatbox}
+ {\snaptogrid\vbox{\box\floatbox}
\whitespace % nodig ?
\blank[\@@bkspaceafter]}%
- \dimen4=\ht\currenttopcolumnbox
- \advance\dimen4 \dp\currenttopcolumnbox
+ \dimen4=\htdp\currenttopcolumnbox
\global\advance\vsize -\dimen4
\advance\dimen4 -\pagegoal
\global\pagegoal-\dimen4
\showmessage\m!columns{12}a%
\else
\showmessage\m!columns{12}b%
- \doresavefloat
\fi
\else
\showmessage\m!columns{12}c%
- \doresavefloat
\fi
\else
\ifhmode{\setbox0\lastbox}\fi% waar is die er in geslopen
@@ -1396,6 +1392,7 @@
\blank[\@@bkspacebefore]
\nobreak
\fi
+ \dofloatsflush{text}{1}%
\flushfloatbox
\blank[\@@bkspaceafter]
\fi
@@ -1418,6 +1415,7 @@
%D When handling lots of (small) floats spacing can get worse
%D because of lining out the columns.
+
\def\doflushcolumnfloats
{\ifpostponecolumnfloats\else
\bgroup
@@ -1432,53 +1430,49 @@
\global\setbox\currenttopcolumnbox\vbox
{\snaptogrid\vbox
{\copy\currenttopcolumnbox
- \hbox{\vphantom{\copy\floatbox}}}
+ \hbox{\vphantom{\vskip\floatheight}}}% known from previous
\whitespace % nodig ?
\blank[\@@bkspaceafter]}%
\else
- \dogetfloat
- \ifdim\wd\floatbox>\finalcolumntextwidth % better somewhere else too
- \global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
- \fi % otherwise the graphic may disappear
- \ifdim\wd\floatbox>\hsize
- \dimen0\wd\floatbox
- \advance\dimen0 \intercolumnwidth
- \dimen2\hsize
- \advance\dimen2 \intercolumnwidth
- \advance\dimen0 .5pt % hm, why 1
- \advance\dimen2 .5pt % hm, why 2
+ \dofloatsgetinfo{text}%
+ \ifdim\floatwidth>\hsize
+ \dimen0\dimexpr\floatwidth+\intercolumnwidth+.5pt\relax
+ \dimen2\dimexpr\hsize +\intercolumnwidth+.5pt\relax
\divide\dimen0 \dimen2
\count0\dimen0
\advance\count0 \plusone
\ifnum\count0>\count2
- \doresavefloat
\count0\zerocount
\else
- \dimen0=\count0\hsize
- \advance\dimen0 \count0\intercolumnwidth
- \advance\dimen0 -\intercolumnwidth
+ \dimen0\dimexpr\count0\hsize+\count0\intercolumnwidth-\intercolumnwidth\relax
+ \dofloatsflush{text}{1}%
+ \ifdim\floatwidth>\finalcolumntextwidth % better somewhere else too
+ \global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
+ \fi % otherwise the graphic may disappear
\global\setbox\floatbox\hbox to \dimen0
- %{\hss\hbox{\copy\floatbox}\hss}%
{\processaction[\@@bklocation] % how easy to forget
- [ \v!left=>\copy\floatbox\hss,
- \v!right=>\hss\copy\floatbox,
- \s!default=>\hss\copy\floatbox\hss,
- \s!unknown=>\hss\copy\floatbox\hss]}%
+ [ \v!left=>\box\floatbox\hss,
+ \v!right=>\hss\box\floatbox,
+ \s!default=>\hss\box\floatbox\hss,
+ \s!unknown=>\hss\box\floatbox\hss]}%
\fi
\showmessage\m!columns{13}\empty
\else
- % \showmessage\m!columns{13}\empty
+ \dofloatsflush{text}{1}%
+ \ifdim\floatwidth>\finalcolumntextwidth % better somewhere else too
+ \global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
+ \fi % otherwise the graphic may disappear
+ % \showmessage\m!columns{13}\empty
\fi
\ifdim\ht\floatbox>\zeropoint\relax
\global\setbox\currenttopcolumnbox\vbox
{\snaptogrid\vbox
- {\copy\currenttopcolumnbox
- \copy\floatbox}
+ {\box\currenttopcolumnbox % was copy
+ \box\floatbox}
\whitespace % nodig ?
\blank[\@@bkspaceafter]}%
\fi
- \dimen6\ht\currenttopcolumnbox
- \advance\dimen6 \dp\currenttopcolumnbox
+ \dimen6\htdp\currenttopcolumnbox
\fi
\ifdim\dimen4<\ht\currenttopcolumnbox
\dimen4\ht\currenttopcolumnbox
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index 6e078596f..bbd35181e 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -176,28 +176,6 @@
\newif\iftopofinsert
-% \def\OTRONEdosettopinserts
-% {\bgroup
-% \ifsomefloatwaiting
-% \noffloatinserts\zerocount
-% \let\totaltopinserted\!!zeropoint
-% \OTRONEdodosettopinserts
-% \ifnum\@@bknbottom=\zerocount
-% \ifnum\@@bknlines>\zerocount
-% \ifdim\totaltopinserted>\zeropoint\relax
-% \dimen0=\lineheight
-% \dimen0=\@@bknlines\dimen0
-% \advance\dimen0 \totaltopinserted\relax
-% \ifdim\dimen0>\textheight
-% \showmessage\m!floatblocks8\@@bknlines
-% \vfilll\eject
-% \fi
-% \fi
-% \fi
-% \fi
-% \fi
-% \egroup}
-
\def\OTRONEdosettopinserts
{\bgroup
\ifsomefloatwaiting
@@ -357,57 +335,35 @@
\def\OTRONEflushfloatbox % nog verder doorvoeren en meer info in marge
{\ifcenterfloatbox \ifdim\wd\floatbox<\hsize
- \setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
+ \global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
\fi \fi
- \snaptogrid\hbox{\iftestfloatbox\ruledhbox\fi{\copy\floatbox}}}
+ \snaptogrid\hbox{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}} % was copy
\def\OTRONEdodoflushfloats % much in common with OTRSET
{\ifsomefloatwaiting
\ifpackflushedfloats
- \centerfloatboxfalse
- \dogetfloat
- \ifdim\wd\floatbox>\makeupwidth
- \global\setbox\floatbox\hbox to \makeupwidth{\hss\box\floatbox\hss}%
- \fi
+ \centerfloatboxfalse % not needed as we do call directly
+ \dofloatscollect{text}{\hsize}{1em}%
\OTRONEsetvsize
- \!!widtha\wd\floatbox
- \dofloatflushedinfo
- \doloop
- {\ifsomefloatwaiting
- \dosavefloatstatus
- \dogetfloat
- \advance\!!widtha 1em % variable
- \advance\!!widtha \wd\floatbox\relax
- \ifdim\!!widtha>\hsize
- \dorestorefloatstatus
- \global\somefloatwaitingtrue
- \exitloop
- \else
- \global\setbox\floatbox\hbox
- {\ifcase\columndirection % nog document wide
- \ifvoid\savedfloatbox\else
- \ifhbox\savedfloatbox\unhbox\else\box\fi\savedfloatbox\hfil
- \fi
- \ifhbox\floatbox\unhbox\else\box\fi\floatbox
- \else
- \ifhbox\floatbox\unhbox\else\box\fi\floatbox
- \ifvoid\savedfloatbox\else
- \hfil\ifhbox\savedfloatbox\unhbox\else\box\fi\savedfloatbox
- \fi
- \fi}%
- \dofloatflushedinfo
- \fi
- \else
- \exitloop
- \fi}%
\global\setbox\floatbox\hbox to \hsize
- {\hfil\ifhbox\floatbox\unhbox\else\box\fi\floatbox\hfil}%
+ {\hfil
+ \dorecurse\nofcollectedfloats
+ {\ifcase\columndirection % nog document wide
+ \dofloatsflush{text}{1}%
+ \else
+ \dofloatsflushn{text}{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
+ \fi
+ \ifdim\wd\floatbox>\makeupwidth % \hsize
+ \hbox to \makeupwidth{\hss\box\floatbox\hss}%
+ \else
+ \box\floatbox
+ \fi
+ \ifnum\recurselevel<\nofcollectedfloats
+ \hfil
+ \fi}%
+ \hfil}%
\else
- %\bgroup % \box\floatbox can be in use!? messy
\dogetfloat
- %\doplacefloatbox
- %\egroup
- \dofloatflushedinfo
\fi
% there is a chance that due to rounding errors, the float
% fits on a page where it was first rejected, in which case
@@ -428,8 +384,7 @@
\fi
% should be an option
\endgroup
- \dimen0\dimexpr\pagetotal+\ht\floatbox+\dp\floatbox+\floattopskip-\pageshrink\relax
- %\message{c:\the\mofcolumns,t:\the\pagetotal,g:\the\pagegoal}%\wait
+ \dimen0\dimexpr\pagetotal+\floatheight+\floattopskip-\pageshrink\relax
\dimen2\pagegoal
\relax % needed
\ifcase\textfloatmethod
@@ -535,20 +490,9 @@
\doifinset\v!tall{#1}\flushsidefloatsafterpar
\fi}
-\def\OTRONEdosomepagefloat#1[#2]%
- {%\checkwaitingfloats{#1}%
- \global\setbox#1\vbox
- {\unvbox#1%
- \vbox to \textheight
- {\doifnotinset\v!high{#2}\vfill
- \box\floatbox
- \doifnotinset\v!low{#2}\vfill}%
- \goodbreak}%
- \doinsertfloatinfo}
-
-\def\OTRONEsomepagefloat {\OTRONEdosomepagefloat\collectedpagefloats}
-\def\OTRONEsomeleftpagefloat {\OTRONEdosomepagefloat\collectedleftpagefloats}
-\def\OTRONEsomerightpagefloat{\OTRONEdosomepagefloat\collectedrightpagefloats}
+\def\OTRONEsomepagefloat [#1]{\dofloatssavepagefloat{page} {#1}}
+\def\OTRONEsomeleftpagefloat [#1]{\dofloatssavepagefloat{leftpage} {#1}}
+\def\OTRONEsomerightpagefloat[#1]{\dofloatssavepagefloat{rightpage}{#1}}
\def\OTRONEsometopsfloat[#1]%
{\ifdim\topinserted=\zeropoint
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index ca256d97c..e75f7528b 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -1329,13 +1329,15 @@
\global\setbox\floatbox\lastbox}%
\fi}
+% for the moment resave is still needed here
+
\def\OTRSETsavebox#1% clean up the skips
{\OTRSETunpreparebox{#1}%
- \dosavefloat}
+ \dofloatssave{text}}
\def\OTRSETresavebox#1% clean up the skips
{\OTRSETunpreparebox{#1}%
- \doresavefloat}
+ \dofloatsresave{text}}
\def\OTRSETflushfloatbox % nog verder doorvoeren en meer info in marge
{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
@@ -1345,10 +1347,11 @@
\def\OTRSETsavebox##1{\!!doneafalse}%
\doloop
{\ifsomefloatwaiting
-\OTRSETskipstart
- \dogetfloat
- \ifdim\wd\floatbox>\zeropoint
+ \OTRSETskipstart
+ \dofloatsgetinfo{text}%
+ \ifdim\floatwidth>\zeropoint
\!!doneatrue
+ \dofloatsflush{text}{1}%
\dp\floatbox\zeropoint
\OTRSETstoreincolumnslot{TBLR}\floatbox
\if!!donea
diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv
index 5cdc0cf5c..156bcfd9c 100644
--- a/tex/context/base/page-txt.mkiv
+++ b/tex/context/base/page-txt.mkiv
@@ -236,8 +236,21 @@
%D the \type {status} variable. This is handled by the next
%D couple of macros.
+% \def\settextlinestatus#1%
+% {\edef\textlinestatus{\csname\??tk#1\c!state\endcsname}}
+
\def\settextlinestatus#1%
- {\edef\textlinestatus{\csname\??tk#1\c!state\endcsname}}
+ {\ifcase0\csname\??tk#1\c!n\endcsname\relax
+ \edef\textlinestatus{\csname\??tk#1\c!state\endcsname}%
+ \else
+ \setxvalue{\??tk#1\c!n}{\the\numexpr\csname\??tk#1\c!n\endcsname-1}%
+ \let\textlinestatus\v!stop
+ \fi}
+
+\appendtoks
+ \doifinset\v!header\floatspecification{\setxvalue{\??tk\v!header\c!n}{1}}%
+ \doifinset\v!footer\floatspecification{\setxvalue{\??tk\v!footer\c!n}{1}}%
+\to \everybeforeflushedpagefloat
\def\resettextlinestatus#1% postpone
{\expandafter\gdef\csname\??tk#1\s!reset\endcsname{\global\expandafter\let\csname\??tk#1\c!state\endcsname\v!normal}}
@@ -822,11 +835,11 @@
%D While the header and footer lines are moved away from the
%D main text, the top and bottom lines are centered.
-\setuptop [\c!state=\v!normal,\c!before=\vss,\c!after=\vss,\c!strut=]
-\setupheader[\c!state=\v!normal,\c!before=, \c!after=\vss,\c!strut=\v!yes]
-\setuptext [\c!state=\v!normal,\c!before=\vss,\c!after=\vss,\c!strut=]
-\setupfooter[\c!state=\v!normal,\c!before=\vss,\c!after=, \c!strut=\v!yes]
-\setupbottom[\c!state=\v!normal,\c!before=\vss,\c!after=\vss,\c!strut=]
+\setuptop [\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
+\setupheader[\c!state=\v!normal,\c!n=0,\c!before=, \c!after=\vss,\c!strut=\v!yes]
+\setuptext [\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
+\setupfooter[\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=, \c!strut=\v!yes]
+\setupbottom[\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
\setuptop [\c!style=,\c!color=]
\setupheader[\c!style=,\c!color=]
diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua
index e59759311..a94eed946 100644
--- a/tex/context/base/sort-ini.lua
+++ b/tex/context/base/sort-ini.lua
@@ -27,9 +27,12 @@ sorters.mappings = { }
sorters.replacements = { }
sorters.language = 'en'
+local mappings = sorters.mappings
+local entries = sorters.entries
+
function sorters.comparers.basic(sort_a,sort_b)
-- sm assignment is slow, will become sorters.initialize
- local sm = sorters.mappings[sorters.language or sorters.defaultlanguage] or sorters.mappings.en
+ local sm = mappings[sorters.language or sorters.defaultlanguage] or mappings.en
if #sort_a > #sort_b then
if #sort_b == 0 then
return 1
@@ -115,7 +118,7 @@ end
function sorters.firstofsplit(split)
-- numbers are left padded by spaces
- local se = sorters.entries[sorters.language or sorters.defaultlanguage] -- slow, will become sorters.initialize
+ local se = entries[sorters.language or sorters.defaultlanguage] or entries.en-- slow, will become sorters.initialize
local vs = split[1]
local entry = (vs and vs[1]) or ""
return entry, (se and se[entry]) or "\000"
@@ -127,7 +130,7 @@ sorters.defaultlanguage = 'en'
function sorters.splitters.utf(str) -- brrr, todo: language
local r = sorters.replacements[sorters.language] or sorters.replacements[sorters.defaultlanguage] or { }
- -- local m = sorters.mappings [sorters.language] or sorters.mappings [sorters.defaultlanguage] or { }
+ -- local m = mappings [sorters.language] or mappings [sorters.defaultlanguage] or { }
local u = characters.uncompose
local b = utf.byte
local t = { }
diff --git a/tex/context/base/sort-lan.lua b/tex/context/base/sort-lan.lua
index ab04077e8..477a5ab0e 100644
--- a/tex/context/base/sort-lan.lua
+++ b/tex/context/base/sort-lan.lua
@@ -158,6 +158,11 @@ sorters.mappings['cz'] = {
[uc(0x017E)] = 40, -- zcaron
}
+-- French
+
+sorters.entries ['fr'] = sorters.entries ['en']
+sorters.mappings['fr'] = sorters.mappings['en']
+
-- German (by Wolfgang Schuster)
-- DIN 5007-1
diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv
index 40df985df..89e015c46 100644
--- a/tex/context/base/strc-flt.mkiv
+++ b/tex/context/base/strc-flt.mkiv
@@ -982,175 +982,44 @@
\newdimen\botinserted
\newdimen\topinserted
-%D Extra float registers.
-
-\newif\ifsomefloatwaiting \somefloatwaitingfalse
-\newif\ifroomforfloat \roomforfloattrue
-\newif\ifnofloatpermitted \nofloatpermittedfalse
-
-\newcount\totalnoffloats \totalnoffloats =0
-\newcount\savednoffloats \savednoffloats =0
-\newcount\noffloatinserts \noffloatinserts=0
-
-\newbox\floatlist
-\newbox\savedfloatlist
-
-\newif\ifflushingfloats \flushingfloatsfalse
-
-\newbox\floattext
+\newif\iftopofinsert
+\newif\iftestfloatbox
-\newdimen\floattextwidth
-\newdimen\floattextheight
+\newdimen\floatsideskip \floatsideskip =12pt
+\newdimen\floattopskip \floattopskip =\floattopskip
+\newdimen\floatbottomskip \floatbottomskip=\floattopskip
-\newbox\floatbox
-\newbox\savedfloatbox
+\newdimen\sidefloattopskip \sidefloattopskip =\floattopskip
+\newdimen\sidefloatbottomskip \sidefloatbottomskip=\floatbottomskip
-\newdimen\floatwidth
-\newdimen\floatheight
-\newdimen\floatdepth
-
-\def\dosavefloatinfo {\showmessage\m!floatblocks2{\the\totalnoffloats}}
-\def\doinsertfloatinfo {\showmessage\m!floatblocks4{\the\totalnoffloats}}
-\def\dofloatflushedinfo{\showmessage\m!floatblocks3{\the\numexpr\totalnoffloats-\savednoffloats\relax}}
-
-\def\dogetfloat
- {\ifsomefloatwaiting
- \global\setbox\floatlist\vbox
- {\unvbox\floatlist
- \global\setbox\globalscratchbox\lastbox}%
- \ifcenterfloatbox
- \ifdim\wd\globalscratchbox<\hsize
- \setbox\floatbox\hbox to \hsize{\hss\box\globalscratchbox\hss}%
- \else
- \setbox\floatbox\box\globalscratchbox % local !
- % retain special alignments
- \ifinsidecolumns
- \ifdim\wd\floatbox>\makeupwidth
- \wd\floatbox\makeupwidth
- \fi
- \fi
- \fi
- \else
- \setbox\floatbox\box\globalscratchbox % local !
- \fi
- \global\advance\savednoffloats \minusone
- \ifcase\savednoffloats
- \global\somefloatwaitingfalse
- \fi
- \else
- \global\savednoffloats\zerocount
- \global\setbox\floatbox\emptybox
- \fi}
+\newskip\sidefloatdownshift
+\newskip\sidefloatleftshift
+\newskip\sidefloatrightshift
-\def\uncenteredfloatbox
- {\ifcenterfloatbox
- \ifhbox\floatbox\relax % remove centering
- \ifdim\wd\floatbox=\hsize
- \ifhbox\floatbox
- \setbox\scratchbox\hbox
- {\unhbox\floatbox
- \unskip\unskip
- \global\setbox\globalscratchbox\lastbox}%
- \box\globalscratchbox
- \else
- \box\floatbox
- \fi
- \else
- \box\floatbox
- \fi
- \else
- \box\floatbox
- \fi
- \else
- \box\floatbox
- \fi}
+\def\sidefloattopoffset {\openstrutdepth} % {\strutdp}
-\def\dosavefloat
- {\global\setbox\floatlist\vbox
- {\nointerlineskip
- \uncenteredfloatbox
- \unvbox\floatlist}%
- \global\advance\savednoffloats \plusone
- \global\somefloatwaitingtrue
- \dosavefloatinfo
- \nonoindentation}
-
-\def\doresavefloat
- {\global\setbox\floatlist\vbox
- {\nointerlineskip
- \unvbox\floatlist
- \uncenteredfloatbox}%
- \global\advance\savednoffloats \plusone
- \global\somefloatwaitingtrue}
-
-\def\doreversesavefloat
- {\global\setbox\floatlist\vbox
- {\nointerlineskip
- \unvbox\floatlist
- \uncenteredfloatbox}%
- \global\advance\savednoffloats \plusone
- \global\somefloatwaitingtrue
- \dosavefloatinfo}
-
-% better (todo): \savednofsavedfloats
-
-\def\dosavefloatstatus
- {\global\setbox\savedfloatlist\copy\floatlist
- \global\setbox\savedfloatbox \copy\floatbox
- \xdef\dorestorefloatstatus
- {\global\setbox\floatlist\box\savedfloatlist
- \global\setbox\floatbox \box\savedfloatbox
- \global\savednoffloats\the\savednoffloats}}
-
-\let\dorestorefloatstatus\relax
-
-\ifdefined\doflushfloats\else \let\doflushfloats\relax \fi
-\ifdefined\flushfloatbox\else \let\flushfloatbox\relax \fi
-
-% needed in the splitter:
-
-\newcount\savedsavednoffloats
-
-\let\dopopsavedfloats\relax
-
-\def\dopushsavedfloats
- {\global\setbox\savedfloatlist\box\floatlist
- \global\savedsavednoffloats\savednoffloats
- \global\savednoffloats\savednoffloats
- \global\somefloatwaitingfalse
- \gdef\dopopsavedfloats
- {\global\advance\savednoffloats\savedsavednoffloats
- \global\setbox\floatlist\vbox\bgroup
- \ifvoid\floatlist \else\unvbox\floatlist \fi
- \ifvoid\savedfloatlist\else\unvbox\savedfloatlist\fi
- \egroup
- \global\ifcase\savednoffloats
- \somefloatwaitingfalse\else\somefloatwaitingtrue\fi
- \globallet\dopopsavedfloats\relax}}
-
-\def\doflushsavedfloats % simplified \OTRONEdodoflushfloats
- {\doloop
- {\ifsomefloatwaiting
- \dogetfloat
- \dofloatflushedinfo
- \docheckiffloatfits
- \ifroomforfloat
- \doplacefloatbox
- \else
- \doreversesavefloat
- \exitloop
- \fi
- \else
- \exitloop
- \fi}}
+\newcount\noftopfloats \noftopfloats=2
+\newcount\nofbotfloats \nofbotfloats=0
-% top and bottom
+\def\docalculatefloatskip#1#2%
+ {\doifelsenothing{#2}
+ {\global#1\zeropoint}
+ {\doifelse{#2}\v!none
+ {\global#1\zeropoint}
+ {\setbox\scratchbox\vbox{\whitespace\normalexpanded{\noexpand\blank[#2]}}%
+ \global#1\ht\scratchbox}}}
-\newif\iftopofinsert
-\newif\iftestfloatbox
-\newif\ifcenterfloatbox \centerfloatboxtrue
-\newif\iflocalcenterfloatbox \localcenterfloatboxfalse
-\newif\ifglobalcenterfloatbox \globalcenterfloatboxfalse
+\def\calculatefloatskips
+ {{\docalculatefloatskip\floattopskip{\floatsharedparameter\c!spacebefore}%
+ \docalculatefloatskip\floatbottomskip{\floatsharedparameter\c!spaceafter}%
+ \docalculatefloatskip\sidefloattopskip{\floatsharedparameter\c!sidespacebefore}%
+ \docalculatefloatskip\sidefloatbottomskip{\floatsharedparameter\c!sidespaceafter}%
+ \gdef\sidefloattopoffset{\openstrutdepth}% was \def
+ \global\floatsideskip\floatsharedparameter\c!margin
+ \global\sidefloatleftshift\floatparameter\c!leftmargindistance
+ \global\sidefloatrightshift\floatparameter\c!rightmargindistance
+ \global\noftopfloats\floatsharedparameter\c!ntop\relax
+ \global\nofbotfloats\floatsharedparameter\c!nbottom\relax}}
% beter de laatste skip buiten de \insert uitvoeren,
% bovendien bij volle flush onder baseline.
@@ -1166,7 +1035,7 @@
\def\betweenfloatblanko% assumes that spaceafter is present
{\blank[\floatsharedparameter\c!spacebefore]} % or v!back,....
-
+
\def\doplacefloatbox
{%\forgetall % NO
\whitespace
@@ -1320,51 +1189,6 @@
{\placesomebotsfloat[#1]}
{\placesomeherefloat[#1]}}}}
-% De onderstaande macro wordt gebruikt bij de macros
-% voor het plaatsen van tabellen en figuren (klopt niet
-% meer).
-%
-% \dofloat {plaats} {label1} {label2}
-% \docompletefloat {nummer} {referentie} {plaats} {label} {inhoud}
-% \box\floatbox inhoud+referentie
-% \do???float#1 #1 = boxnummer
-
-\newdimen\floatsideskip \floatsideskip =12pt
-\newdimen\floattopskip \floattopskip =\floattopskip
-\newdimen\floatbottomskip \floatbottomskip=\floattopskip
-
-\newdimen\sidefloattopskip \sidefloattopskip =\floattopskip
-\newdimen\sidefloatbottomskip \sidefloatbottomskip=\floatbottomskip
-
-\newskip\sidefloatdownshift
-\newskip\sidefloatleftshift
-\newskip\sidefloatrightshift
-
-\def\sidefloattopoffset {\openstrutdepth} % {\strutdp}
-
-\newcount\noftopfloats \noftopfloats=2
-\newcount\nofbotfloats \nofbotfloats=0
-
-\def\docalculatefloatskip#1#2%
- {\doifelsenothing{#2}
- {\global#1\zeropoint}
- {\doifelse{#2}\v!none
- {\global#1\zeropoint}
- {\setbox\scratchbox\vbox{\whitespace\normalexpanded{\noexpand\blank[#2]}}%
- \global#1\ht\scratchbox}}}
-
-\def\calculatefloatskips
- {{\docalculatefloatskip\floattopskip{\floatsharedparameter\c!spacebefore}%
- \docalculatefloatskip\floatbottomskip{\floatsharedparameter\c!spaceafter}%
- \docalculatefloatskip\sidefloattopskip{\floatsharedparameter\c!sidespacebefore}%
- \docalculatefloatskip\sidefloatbottomskip{\floatsharedparameter\c!sidespaceafter}%
- \gdef\sidefloattopoffset{\openstrutdepth}% was \def
- \global\floatsideskip\floatsharedparameter\c!margin
- \global\sidefloatleftshift\floatparameter\c!leftmargindistance
- \global\sidefloatrightshift\floatparameter\c!rightmargindistance
- \global\noftopfloats\floatsharedparameter\c!ntop\relax
- \global\nofbotfloats\floatsharedparameter\c!nbottom\relax}}
-
\def\borderedfloatbox
{\localframed
[\??fl\currentfloat]
diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua
index a8f8af14f..261059587 100644
--- a/tex/context/base/strc-pag.lua
+++ b/tex/context/base/strc-pag.lua
@@ -230,3 +230,12 @@ function helpers.prefix(data,prefixspec)
end
end
end
+
+function pages.is_odd(n)
+ n = n or texcount.realpageno
+ if texcount.pagenoshift % 2 == 0 then
+ return n % 2 == 0
+ else
+ return n % 2 ~= 0
+ end
+end
diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv
index 2f0e3d4fe..14c3d0361 100644
--- a/tex/context/base/strc-pag.mkiv
+++ b/tex/context/base/strc-pag.mkiv
@@ -23,10 +23,11 @@
% Allocation:
-\countdef\realpageno = 0 \realpageno = 1
-\countdef\userpageno = 1 \userpageno = 1
-\countdef\subpageno = 2 \subpageno = 0 % !!
-\countdef\arrangeno = 3 \arrangeno = 0 % !!
+\countdef\realpageno = 0 \realpageno = 1
+\countdef\userpageno = 1 \userpageno = 1
+\countdef\subpageno = 2 \subpageno = 0 % !!
+\countdef\arrangeno = 3 \arrangeno = 0 % !!
+\countdef\pagenoshift = 4 \pagenoshift = 0 % !!
\let\pageno\userpageno
@@ -280,8 +281,6 @@
\setvalue{\??pn+\v!empty}{\doincrementpagenumber\dosynchronizepagenumber}
\letvalue{\??pn+\v!keep }\dosynchronizepagenumber
-% todo: check if number set, and reset it after testing; also take care of \global\shiftedrealpagenotrue
-
% Control:
\def\getpagestatus % hierboven gebruiken
@@ -427,13 +426,6 @@
{\chardef\overallpagenumberstate\zerocount}%
\to \everysetuppagenumbering
-% \appendtoks % todo: set state: none, start, stop, reset
-% % this makes starting at an even page possible
-% \ifnum\realpageno=1 \ifodd\pageno \else
-% \global\shiftedrealpagenotrue
-% \fi \fi
-% \to \everysetupuserpagenumber
-
% Done
% \c!way=\v!by\v!part
@@ -483,10 +475,10 @@
\def\checkpagenumbershift
{\userpageno\rawstructurecounter[\s!userpage]\relax
\ifnum\realpageno=\plusone
- \ifodd\userpageno
- \else
- \global\shiftedrealpagenotrue
- \fi
+ \ifodd\userpageno
+ \else
+ \global\pagenoshift\plusone
+ \fi
\fi}
\appendtoks % todo: set state: none, start, stop, reset
diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua
index 1baa9acbe..d938045a1 100644
--- a/tex/context/base/supp-fil.lua
+++ b/tex/context/base/supp-fil.lua
@@ -243,17 +243,17 @@ function support.usemodules(prefix,askedname,truename)
if trace_modules then
logs.report("modules","skipping '%s' (not found)",truename)
else
- context.showmessage("systems",6,askedname)
+ interfaces.showmessage("systems",6,askedname)
end
elseif status == 1 then
if not trace_modules then
- context.showmessage("systems",5,askedname)
+ interfaces.showmessage("systems",5,askedname)
end
else
if trace_modules then
logs.report("modules","skipping '%s' (already loaded)",truename)
else
- context.showmessage("systems",7,askedname)
+ interfaces.showmessage("systems",7,askedname)
end
end
modstatus[hashname] = status