diff options
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-low.lua | 20 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-prm.lua | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/spac-par.mkxl | 55 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 28081 -> 28039 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 254914 -> 254901 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/supp-box.lmt | 314 | ||||
-rw-r--r-- | tex/context/base/mkiv/supp-box.mkxl | 14 |
10 files changed, 260 insertions, 150 deletions
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 81c514628..6049160c8 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2020.08.06 18:55} +\newcontextversion{2020.08.07 23:34} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 2ff801015..7ced40420 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.08.06 18:55} +\edef\contextversion{2020.08.07 23:34} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index a29b15c14..313bf87ae 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.08.06 18:55} +\edef\contextversion{2020.08.07 23:34} %D Kind of special: diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index d7f781663..f96199655 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -68,13 +68,14 @@ return { "primeasciicode", "hyphenasciicode", -- "frozenhsizecode", "frozenleftskipcode", "frozenrightskipcode", "frozenhangindentcode", - "frozenhangaftercode", "frozenparindentcode", "frozenparfillskipcode", "frozenadjustspacingcode", - "frozenprotrudecharscode", "frozenpretolerancecode", "frozentolerancecode", "frozenemergencystretchcode", - "frozenloosenesscode", "frozenlastlinefitcode", "frozenlinepenaltycode", "frozeninterlinepenaltycode", - "frozenwidowpenaltycode", "frozenclubpenaltycode", "frozenbrokenpenaltycode", "frozenadjdemeritscode", + "frozenhangaftercode", "frozenparindentcode", "frozenparfillskipcode", "frozenparfillleftskipcode", + "frozenadjustspacingcode", "frozenprotrudecharscode", "frozenpretolerancecode", "frozentolerancecode", + "frozenemergencystretchcode", "frozenloosenesscode", "frozenlastlinefitcode", "frozenlinepenaltycode", + "frozeninterlinepenaltycode", "frozenclubpenaltycode", "frozenwidowpenaltycode", + "frozendisplaywidowpenaltycode", "frozenbrokenpenaltycode", "frozenadjdemeritscode", "frozendoublehyphendemeritscode", "frozenfinalhyphendemeritscode", "frozenparshapecode", - "frozeninterlinepenaltiescode", "frozenwidowpenaltiescode", "frozenclubpenaltiescode", - "paragraphupdatecodes", "paragraphpenaltycodes", "paragraphdemeritcodes", "paragraphshapecodes", + "frozeninterlinepenaltiescode", "frozenclubpenaltiescode", "frozenwidowpenaltiescode", + "frozendisplaywidowpenaltiescode", -- "activemathcharcode", -- @@ -502,8 +503,11 @@ return { -- "openout", "closeout", "write", "openin", "closein", "read", "readline", "readfromterminal", -- - "boxlines", "boxline", "setboxline", "copyboxline", "boxlineht", "boxlinedp", - "boxlinewd", "boxlinels", "boxliners", "boxlinelh", "boxlinerh", + "boxlines", "boxline", "setboxline", "copyboxline", + "boxlinewd","boxlineht", "boxlinedp", + "boxlinenw","boxlinenh", "boxlinend", + "boxlinels", "boxliners", "boxlinelh", "boxlinerh", "boxlinelp", "boxlinerp", "boxlinein", + "boxrangewd", "boxrangeht", "boxrangedp", } } diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 834cd29a1..c56b121c0 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -382,6 +382,7 @@ return { "nospaces", "novrule", "orelse", + "orunless", "outputbox", "parattr", "pardirection", diff --git a/tex/context/base/mkiv/spac-par.mkxl b/tex/context/base/mkiv/spac-par.mkxl index 60b35db13..73b1b267d 100644 --- a/tex/context/base/mkiv/spac-par.mkxl +++ b/tex/context/base/mkiv/spac-par.mkxl @@ -21,32 +21,35 @@ % this might move to syst-ini.mkxl -\setnewconstant\frozenhsizecode "0000001 -\setnewconstant\frozenleftskipcode "0000002 -\setnewconstant\frozenrightskipcode "0000004 -\setnewconstant\frozenhangindentcode "0000008 -\setnewconstant\frozenhangaftercode "0000010 -\setnewconstant\frozenparindentcode "0000020 -\setnewconstant\frozenparfillskipcode "0000040 -\setnewconstant\frozenadjustspacingcode "0000080 -\setnewconstant\frozenprotrudecharscode "0000100 -\setnewconstant\frozenpretolerancecode "0000200 -\setnewconstant\frozentolerancecode "0000400 -\setnewconstant\frozenemergencystretchcode "0000800 -\setnewconstant\frozenloosenesscode "0001000 -\setnewconstant\frozenlastlinefitcode "0002000 -\setnewconstant\frozenlinepenaltycode "0004000 -\setnewconstant\frozeninterlinepenaltycode "0008000 -\setnewconstant\frozenwidowpenaltycode "0010000 -\setnewconstant\frozenclubpenaltycode "0020000 -\setnewconstant\frozenbrokenpenaltycode "0040000 -\setnewconstant\frozenadjdemeritscode "0080000 -\setnewconstant\frozendoublehyphendemeritscode "0100000 -\setnewconstant\frozenfinalhyphendemeritscode "0200000 -\setnewconstant\frozenparshapecode "0400000 -\setnewconstant\frozeninterlinepenaltiescode "0800000 -\setnewconstant\frozenwidowpenaltiescode "1000000 -\setnewconstant\frozenclubpenaltiescode "2000000 +\setnewconstant\frozenhsizecode "00000001 +\setnewconstant\frozenleftskipcode "00000002 +\setnewconstant\frozenrightskipcode "00000004 +\setnewconstant\frozenhangindentcode "00000008 +\setnewconstant\frozenhangaftercode "00000010 +\setnewconstant\frozenparindentcode "00000020 +\setnewconstant\frozenparfillskipcode "00000040 +\setnewconstant\frozenparfillleftskipcode "00000080 +\setnewconstant\frozenadjustspacingcode "00000100 +\setnewconstant\frozenprotrudecharscode "00000200 +\setnewconstant\frozenpretolerancecode "00000400 +\setnewconstant\frozentolerancecode "00000800 +\setnewconstant\frozenemergencystretchcode "00001000 +\setnewconstant\frozenloosenesscode "00002000 +\setnewconstant\frozenlastlinefitcode "00004000 +\setnewconstant\frozenlinepenaltycode "00008000 +\setnewconstant\frozeninterlinepenaltycode "00010000 +\setnewconstant\frozenclubpenaltycode "00020000 +\setnewconstant\frozenwidowpenaltycode "00040000 +\setnewconstant\frozendisplaywidowpenaltycode "00080000 +\setnewconstant\frozenbrokenpenaltycode "00100000 +\setnewconstant\frozenadjdemeritscode "00200000 +\setnewconstant\frozendoublehyphendemeritscode "00400000 +\setnewconstant\frozenfinalhyphendemeritscode "00800000 +\setnewconstant\frozenparshapecode "01000000 +\setnewconstant\frozeninterlinepenaltiescode "02000000 +\setnewconstant\frozenclubpenaltiescode "04000000 +\setnewconstant\frozenwidowpenaltiescode "08000000 +\setnewconstant\frozendisplaywidowpenaltiescode "10000000 \setnewconstant\paragraphupdatecodes\numexpr \frozentolerancecode diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex ec3637371..469411908 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 3c1db9234..66ab0b9cf 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/supp-box.lmt b/tex/context/base/mkiv/supp-box.lmt index cee5cf1ad..95af07d9f 100644 --- a/tex/context/base/mkiv/supp-box.lmt +++ b/tex/context/base/mkiv/supp-box.lmt @@ -943,38 +943,62 @@ implement { do - local scaninteger = tokens.scanners.integer - local scanbox = tokens.scanners.box - local scandimen = tokens.scanners.dimen + local scaninteger = tokens.scanners.integer + local scanbox = tokens.scanners.box + local scandimen = tokens.scanners.dimen - local setsubtype = nuts.setsubtype - local removenode = nuts.remove - local getnormalizedline = nuts.getnormalizedline -- we can optimize this + local setsubtype = nuts.setsubtype + local removenode = nuts.remove + local getnormalizedline = nuts.getnormalizedline -- we can optimize this + local getdimensions = nuts.dimensions + local getrangedimensions = nuts.rangedimensions - local line_code = nodes.listcodes.line - local unknown_code = nodes.listcodes.unknown + local setprop = nuts.setprop + local getprop = nuts.getprop - local values = tokens.values - local dimension_value = values.dimension - local cardinal_value = values.cardinal - local list_value = values.list + local line_code = nodes.listcodes.line + local unknown_code = nodes.listcodes.unknown - local function boxlinecount(what) - local box = scaninteger() - local list = getbox(box) - local line = 0 - if list then - list = getlist(list) + local values = tokens.values + local dimension_value = values.dimension + local cardinal_value = values.cardinal + local list_value = values.list + + -- todo: make helper that formats + + local function reporterror(fmt,...) + tex.error(string.formatters[fmt](...)) + end + + -- The first variant did a linear lookup but for large boxes and lots of + -- analysis that is not nice. Okay, in practice performance is quite ok + -- (milliseconds for thousands of access) but still ... the next is nicer + -- and it's part of the experimental fun stuff anyway. + + local function countlines(box) + local prop = getprop(box,"boxlines") + if not prop then + local line = 0 + local list = getlist(box) + prop = { } if list then for n, subtype in nexthlist, list do if subtype == line_code then line = line + 1 + prop[line] = n end end end + setprop(box,"boxlines",prop) end + return prop + end + + local function boxlinecount(what) + local n = scaninteger() + local box = getbox(n) if what == "value" then - return cardinal_value, line + return cardinal_value, box and #countlines(box) or 0 end end @@ -983,32 +1007,62 @@ do local line = scaninteger() local box = getbox(n) if box then - local list = getlist(box) - if list then - for n, subtype in nexthlist, list do - if subtype == line_code then - if line == 1 then - return n, list, box - else - line = line - 1 - end + local prop = getprop(box,"boxlines") + if not prop then + prop = countlines(box) + end + local found = prop[line] + if found then + local props = getprop(found,"lineproperties") + if not props then + props = getnormalizedline(found) + props.width, props.height, props.depth = getwhd(found) + setprop(found,"lineproperties",props) + end + return props, line, found, box + end + end + reporterror("no line %i in box %i",line,n) + end + + local function findrange() + local n = scaninteger() + local first = scaninteger() + local last = scaninteger() + local box = getbox(n) + if box then + local prop = getprop(box,"boxlines") + if not prop then + prop = countlines(box) + end + if first > 0 and last <= #prop then + for i = first, last do + local found = prop[i] + local props = getprop(found,"lineproperties") + if not props then + props = getnormalizedline(found) + props.width, props.height, props.depth = getwhd(found) + setprop(found,"lineproperties",props) end end + return prop, first, last, box end end + reporterror("no lines %i - %i in box %i",first,last,n) end - local function getline(found,list,box,value) + local function getline(props,line,found,box,value) local p, n = getboth(found) local temp = new_hlist() setsubtype(temp,line_code) setwhd(temp,getwhd(found)) - if found == list then + if found == getlist(box) then setlink(temp,n) setlist(box,temp) else setlink(p,temp,n) end + getprop(box,"boxlines")[line] = temp setboth(found) setsubtype(found, unknown_code) found = tonode(found) @@ -1019,9 +1073,8 @@ do end end - local function copyline(found,list,box,value) - local p, n = getboth(found) - found = copy_list(found) + local function copyline(props,line,found,box,value) + found = copy_node(found) setsubtype(found, unknown_code) found = tonode(found) if value then @@ -1031,118 +1084,153 @@ do end end - local function setline(found,list,box) + local function setline(props,line,found,box) local p, n = getboth(found) local temp = scanbox() if temp then temp = tonut(temp) - if found == list then + if found == getlist(box) then setlink(temp,n) setlist(box,temp) else setlink(p,temp,n) end flush_node(found) + getprop(box,"boxlines")[line] = temp + end + end + + local function naturaldimensions(p,l,found) + if not p.naturalwidth then + p.naturalwidth, p.naturalheight, p.naturaldepth = getdimensions(getlist(found)) end + return p + end + + local function rangedimensions(p,f,l,box) + local w, h, d = getrangedimensions(box,p[f],getnext(p[l]),true) + return { width = w, height = h, depth = d } end - local getters = { - ["wd"] = function(found) return dimension_value, getwidth (found) end, - ["ht"] = function(found) return dimension_value, getheight(found) end, - ["dp"] = function(found) return dimension_value, getdepth (found) end, - ["ls"] = function(found) return dimension_value, getnormalizedline(found).leftskip end, - ["rs"] = function(found) return dimension_value, getnormalizedline(found).rightskip end, - ["lh"] = function(found) return dimension_value, getnormalizedline(found).lefthangskip end, - ["rh"] = function(found) return dimension_value, getnormalizedline(found).righthangskip end, - ["lp"] = function(found) return dimension_value, getnormalizedline(found).parfillleftskip end, - ["rp"] = function(found) return dimension_value, getnormalizedline(found).parfillrightskip end, - ["in"] = function(found) return dimension_value, getnormalizedline(found).indent end, - ["get"] = function(found,list,box) return getline(found,list,box,true) end, + + local getters_one = { + + ["wd"] = function(p,l,found) return dimension_value, p.width end, + ["ht"] = function(p,l,found) return dimension_value, p.height end, + ["dp"] = function(p,l,found) return dimension_value, p.depth end, + ["ls"] = function(p,l,found) return dimension_value, p.leftskip end, + ["rs"] = function(p,l,found) return dimension_value, p.rightskip end, + ["lh"] = function(p,l,found) return dimension_value, p.lefthangskip end, + ["rh"] = function(p,l,found) return dimension_value, p.righthangskip end, + ["lp"] = function(p,l,found) return dimension_value, p.parfillleftskip end, + ["rp"] = function(p,l,found) return dimension_value, p.parfillrightskip end, + ["in"] = function(p,l,found) return dimension_value, p.indent end, + + ["nw"] = function(p,l,found) return dimension_value, naturaldimensions(p,l,found).naturalwidth end, + ["nh"] = function(p,l,found) return dimension_value, naturaldimensions(p,l,found).naturalheigth end, + ["nd"] = function(p,l,found) return dimension_value, naturaldimensions(p,l,found).naturaldepth end, + + ["get"] = function(p,l,found,box) return getline(p,l,found,box,true) end, } - local setters = { - ["wd"] = function(found) return setwidth (found,scandimen(false,false,true)) end, - ["ht"] = function(found) return setheight(found,scandimen(false,false,true)) end, - ["dp"] = function(found) return setdepth (found,scandimen(false,false,true)) end, + local getters_two = { + ["wd"] = function(p,f,l,box) return dimension_value, rangedimensions(p,f,l,box).width end, + ["ht"] = function(p,f,l,box) return dimension_value, rangedimensions(p,f,l,box).height end, + ["dp"] = function(p,f,l,box) return dimension_value, rangedimensions(p,f,l,box).depth end, + } + + local setters_one = { + ["wd"] = function(p,l,found) return setwidth (found,scandimen(false,false,true)) end, + ["ht"] = function(p,l,found) return setheight(found,scandimen(false,false,true)) end, + ["dp"] = function(p,l,found) return setdepth (found,scandimen(false,false,true)) end, ["set"] = setline, ["get"] = getline, ["copy"] = copyline, } - local report = logs.reporter("tex", "boxlines") - local function boxline(name,what) - local found, list, box = findline() + local props, line, found, box = findline() if not found then - report("invalid box line specification, pass box number and line number") + -- elseif what == "value" then - local getter = getters[name] + local getter = getters_one[name] if getter then - return getter(found,list,box) + return getter(props,line,found,box) end else - local setter = setters[name] + local setter = setters_one[name] if setter then - return setter(found,list,box) + return setter(props,line,found,box) end end end + -- + + local function boxrange(name,what) + local prop, first, last, box = findrange() + if not prop then + -- + elseif what == "value" then + local getter = getters_two[name] + if getter then + return getter(prop,first,last,box) + end + else + local setter = setters_two[name] + if setter then + return setter(prop,first,last,box) + end + end + end + + local function define_one(name,action) + implement { + name = name, + public = true, + protected = true, + value = true, + actions = function(what) return boxline(action,what) end, + } + end + + local function define_two(name,action) + implement { + name = name, + public = true, + protected = true, + value = true, + actions = function(what) return boxrange(action,what) end, + } + end + implement { - name = "boxlines", public = true, protected = true, value = true, - actions = boxlinecount, - } - implement { - name = "boxline", public = true, protected = true, value = true, - actions = function(what) return boxline("get",what) end, - } - implement { - name = "setboxline", public = true, protected = true, value = true, - actions = function(what) return boxline("set",what) end, - } - implement { - name = "copyboxline", public = true, protected = true, value = true, - actions = function(what) return boxline("copy",what) end, - } - implement { - name = "boxlineht", public = true, protected = true, value = true, - actions = function(what) return boxline("ht",what) end, - } - implement { - name = "boxlinedp", public = true, protected = true, value = true, - actions = function(what) return boxline("dp",what) end, - } - implement { - name = "boxlinewd", public = true, protected = true, value = true, - actions = function(what) return boxline("wd",what) end, - } - implement { - name = "boxlinels", public = true, protected = true, value = true, - actions = function(what) return boxline("ls",what) end, - } - implement { - name = "boxliners", public = true, protected = true, value = true, - actions = function(what) return boxline("rs",what) end, - } - implement { - name = "boxlinelh", public = true, protected = true, value = true, - actions = function(what) return boxline("lh",what) end, - } - implement { - name = "boxlinerh", public = true, protected = true, value = true, - actions = function(what) return boxline("rh",what) end, - } - implement { - name = "boxlinelp", public = true, protected = true, value = true, - actions = function(what) return boxline("lp",what) end, - } - implement { - name = "boxlinerp", public = true, protected = true, value = true, - actions = function(what) return boxline("rp",what) end, - } - implement { - name = "boxlinein", public = true, protected = true, value = true, - actions = function(what) return boxline("in",what) end, + name = "boxlines", + public = true, + protected = true, + value = true, + actions = boxlinecount, } + define_one("boxline", "get") + define_one("setboxline", "set") + define_one("copyboxline", "copy") + define_one("boxlineht", "ht") + define_one("boxlinedp", "dp") + define_one("boxlinewd", "wd") + define_one("boxlinels", "ls") + define_one("boxliners", "rs") + define_one("boxlinelh", "lh") + define_one("boxlinerh", "rh") + define_one("boxlinelp", "lp") + define_one("boxlinerp", "rp") + define_one("boxlinein", "in") + define_one("boxlinenw", "nw") + define_one("boxlinenh", "nh") + define_one("boxlinend", "nd") + + define_two("boxrangewd", "wd") + define_two("boxrangeht", "ht") + define_two("boxrangedp", "dp") + end diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkiv/supp-box.mkxl index 90bc82667..c5afa1f8f 100644 --- a/tex/context/base/mkiv/supp-box.mkxl +++ b/tex/context/base/mkiv/supp-box.mkxl @@ -2802,8 +2802,22 @@ %D \boxlinelp <box> <line> %D \boxlinerp <box> <line> %D \boxlinein <box> <line> +%D \boxrangeht <box> <first line> <last line> +%D \boxrangedp <box> <first line> <last line> +%D \boxrangewd <box> <first line> <last line> %D \stoptyping +% To be discussed with ws. +% +% \installcorenamespace{namedboxes} +% +% \protected\def\newnamedbox#1% +% {\ifcsname\??namedboxes#1\endcsname\else +% \expandafter\newbox\csname\??namedboxes#1\endcsname +% \fi} +% +% \protected\def\namedbox#1{\csname\??namedboxes#1\endcsname} + \protect \endinput % a bit of test code: |