summaryrefslogtreecommitdiff
path: root/tex/context
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-08-11 16:54:53 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-08-11 16:54:53 +0200
commit4f97d7d7cd942dfe76cd4bb54fc3f5b890654235 (patch)
tree5fad3eb091bfa3b05b46f4975d2e5f6284e4ed97 /tex/context
parenta8723a3d1ee935e8d403bd0f5d96a072c0974755 (diff)
downloadcontext-4f97d7d7cd942dfe76cd4bb54fc3f5b890654235.tar.gz
2020-08-11 15:59:00
Diffstat (limited to 'tex/context')
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/back-out.lmt6
-rw-r--r--tex/context/base/mkiv/back-pdf.mkxl1
-rw-r--r--tex/context/base/mkiv/back-pdp.lua40
-rw-r--r--tex/context/base/mkiv/cldf-ini.lua9
-rw-r--r--tex/context/base/mkiv/cldf-lmt.lmt174
-rw-r--r--tex/context/base/mkiv/cldf-scn.lua2
-rw-r--r--tex/context/base/mkiv/colo-ini.mkxl16
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkxl2
-rw-r--r--tex/context/base/mkiv/core-lmt.lmt93
-rw-r--r--tex/context/base/mkiv/font-ini.mklx8
-rw-r--r--tex/context/base/mkiv/lang-ini.mkxl42
-rw-r--r--tex/context/base/mkiv/lang-mis.mkxl8
-rw-r--r--tex/context/base/mkiv/lpdf-fmt.lua4
-rw-r--r--tex/context/base/mkiv/lpdf-lmt.lmt16
-rw-r--r--tex/context/base/mkiv/math-ini.mkxl2
-rw-r--r--tex/context/base/mkiv/meta-ini.mkxl4
-rw-r--r--tex/context/base/mkiv/meta-mac.mkxl4
-rw-r--r--tex/context/base/mkiv/mult-aux.mkxl6
-rw-r--r--tex/context/base/mkiv/mult-low.lua10
-rw-r--r--tex/context/base/mkiv/pack-mrl.mkxl18
-rw-r--r--tex/context/base/mkiv/spac-hor.mkxl24
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin28037 -> 28040 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin254999 -> 256074 bytes
-rw-r--r--tex/context/base/mkiv/strc-itm.mklx8
-rw-r--r--tex/context/base/mkiv/supp-box.lmt30
-rw-r--r--tex/context/base/mkiv/supp-box.mkxl8
-rw-r--r--tex/context/base/mkiv/syst-aux.mkxl30
-rw-r--r--tex/context/base/mkiv/syst-con.lua18
-rw-r--r--tex/context/base/mkiv/syst-ini.mkxl8
-rw-r--r--tex/context/base/mkiv/syst-lua.lmt19
-rw-r--r--tex/context/base/mkiv/tabl-ntb.mkxl4
-rw-r--r--tex/context/base/mkiv/tabl-tbl.mkxl6
-rw-r--r--tex/context/base/mkiv/toks-aux.lmt30
-rw-r--r--tex/context/base/mkiv/toks-scn.lua2
-rw-r--r--tex/context/base/mkiv/trac-log.lua2
-rw-r--r--tex/context/base/mkiv/util-prs.lua4
40 files changed, 406 insertions, 260 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index a49342e78..76ad69c75 100644
--- a/tex/context/base/mkii/cont-new.mkii
+++ b/tex/context/base/mkii/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2020.08.09 22:00}
+\newcontextversion{2020.08.11 15:56}
%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/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index f3a860662..3937f8327 100644
--- a/tex/context/base/mkii/context.mkii
+++ b/tex/context/base/mkii/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2020.08.09 22:00}
+\edef\contextversion{2020.08.11 15:56}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/back-out.lmt b/tex/context/base/mkiv/back-out.lmt
index af66d18c4..7d3ab3078 100644
--- a/tex/context/base/mkiv/back-out.lmt
+++ b/tex/context/base/mkiv/back-out.lmt
@@ -242,9 +242,9 @@ function nodepool.setmatrix(rx,sx,sy,ry,tx,ty)
return t
end
-interfaces.implement { name = "openout", actions = openout, public = true, protected = true, value = "none" }
-interfaces.implement { name = "write", actions = write, public = true, protected = true, value = "none" }
-interfaces.implement { name = "closeout", actions = closeout, public = true, protected = true, value = "none" }
+interfaces.implement { name = "openout", actions = openout, public = true, usage = "value" }
+interfaces.implement { name = "write", actions = write, public = true, usage = "value" }
+interfaces.implement { name = "closeout", actions = closeout, public = true, usage = "value" }
interfaces.implement { name = "latelua", actions = latelua, public = true, protected = true }
interfaces.implement { name = "special", actions = scanstring, public = true, protected = true }
diff --git a/tex/context/base/mkiv/back-pdf.mkxl b/tex/context/base/mkiv/back-pdf.mkxl
index 9c55654d0..b2312bccd 100644
--- a/tex/context/base/mkiv/back-pdf.mkxl
+++ b/tex/context/base/mkiv/back-pdf.mkxl
@@ -58,6 +58,7 @@
\unexpanded\def\pdfextension{\clf_pdfextension}
\def\pdffeedback {\clf_pdffeedback}
+ \def\pdfvariable {\clf_pdfvariable}
%D For the moment we keep this for tikz but hopefully it will at some point use
%D the proper ones. Consider them obsolete:
diff --git a/tex/context/base/mkiv/back-pdp.lua b/tex/context/base/mkiv/back-pdp.lua
index 6e663f1dd..036c81177 100644
--- a/tex/context/base/mkiv/back-pdp.lua
+++ b/tex/context/base/mkiv/back-pdp.lua
@@ -214,7 +214,7 @@ local function pdfextension()
if e then
e()
else
- report("\\pdfextension: unknown %a",w)
+ report("\\pdfextension: unsupported %a",w)
end
end
end
@@ -235,7 +235,7 @@ local function pdffeedback()
if f then
f()
else
- report("\\pdffeedback: unknown %a",w)
+ report("\\pdffeedback: unsupported %a",w)
end
end
end
@@ -248,28 +248,30 @@ end
-- linkmargin threadmargin vorigin xformmargin (tokenlists:) pageattr pageresources
-- pagesattr pkmode trailerid xformattr xformresources
--- local variables = {
--- }
---
--- local function pdfvariable()
--- local w = scanword()
--- if w then
--- local f = variables[w]
--- if f then
--- f()
--- else
--- print("invalid variable",w)
--- end
--- else
--- print("missing variable")
--- end
--- end
+local variables = {
+ minorversion = function() context(lpdf.minorversion()) end,
+ majorversion = function() context(lpdf.majorversion()) end,
+}
+
+local function pdfvariable()
+ local w = scanword()
+ if w then
+ local f = variables[w]
+ if f then
+ f()
+ else
+ report("\\pdfvariable: unsupported %a",w)
+ end
+ else
+ print("missing variable")
+ end
+end
-- kept:
implement { name = "pdfextension", actions = pdfextension }
implement { name = "pdffeedback", actions = pdffeedback }
---------- { name = "pdfvariable", actions = pdfvariable }
+implement { name = "pdfvariable", actions = pdfvariable }
-- for the moment (tikz)
diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua
index 62a4d8e8a..9afe4c723 100644
--- a/tex/context/base/mkiv/cldf-ini.lua
+++ b/tex/context/base/mkiv/cldf-ini.lua
@@ -375,17 +375,14 @@ interfaces.storedscanners = storedscanners
storage.register("interfaces/storedscanners", storedscanners, "interfaces.storedscanners")
-local function registerscanner(name,action,protected,public,value,condition) -- todo: combine value and condition
+local function registerscanner(name,action,protected,public,usage) -- todo: combine value and condition
rawset(interfacescanners,name,action)
local n = storedscanners[name]
n = registerfunction("interfaces.scanners."..name,true,n)
storedscanners[name] = n
name = public and name or (privatenamespace .. name)
- setluatoken(name,n,"global", -- always
- protected and "protected" or "",
- value and "value" or "",
- condition and "condition" or ""
- )
+ -- print(">>",name,protected and "protected" or "",usage or "macro")
+ setluatoken(name,n,"global",protected and "protected" or "",usage or "macro")
end
interfaces.registerscanner = registerscanner
diff --git a/tex/context/base/mkiv/cldf-lmt.lmt b/tex/context/base/mkiv/cldf-lmt.lmt
index d53abc444..f0ed8a40d 100644
--- a/tex/context/base/mkiv/cldf-lmt.lmt
+++ b/tex/context/base/mkiv/cldf-lmt.lmt
@@ -7,10 +7,12 @@ if not modules then modules = { } end modules ['cldf-lmt'] = {
}
local next, load = next, load
+local gmatch, gsub, byte = string.gmatch, string.gsub, string.byte
local setmetatableindex = table.setmetatableindex
local setmetatablenewindex = table.setmetatablenewindex
local serialize = table.serialize
+local concat = table.concat
local random = math.random
local randomseed = math.randomseed
@@ -36,6 +38,9 @@ local scantoken = scanners.token
local scancsname = scanners.csname
local scankeyword = scanners.keyword
+local peekchar = scanners.peekchar
+local skipnext = scanners.skip
+
local getindex = token.get_index
local texsetdimen = tex.setdimen
@@ -60,10 +65,10 @@ local cardinals = { }
local numbers = { }
implement {
- name = "luafloat",
- public = true,
- value = true,
- actions = function(b)
+ name = "luafloat",
+ public = true,
+ usage = "value",
+ actions = function(b)
local n = scanword()
if b == "value" then
context("%.99g",floats[n] or 0)
@@ -75,10 +80,10 @@ implement {
}
implement {
- name = "luainteger",
- public = true,
- value = true,
- actions = function(b)
+ name = "luainteger",
+ public = true,
+ usage = "value",
+ actions = function(b)
local n = scanword()
if b == "value" then
context("%i",integers[n] or 0)
@@ -89,10 +94,10 @@ implement {
}
implement {
- name = "luacount",
- public = true,
- value = true,
- actions = function(b)
+ name = "luacount",
+ public = true,
+ usage = "value",
+ actions = function(b)
local n = scanword()
if b == "value" then
return integer_code, integers[n] or 0
@@ -103,10 +108,10 @@ implement {
}
implement {
- name = "luadimen",
- public = true,
- value = true,
- actions = function(b)
+ name = "luadimen",
+ public = true,
+ usage = "value",
+ actions = function(b)
local n = scanword()
if b == "value" then
return dimension_code, integers[n] or 0
@@ -117,10 +122,10 @@ implement {
}
implement {
- name = "luacardinal",
- public = true,
- value = true,
- actions = function(b)
+ name = "luacardinal",
+ public = true,
+ usage = "value",
+ actions = function(b)
local n = scanword()
if b == "value" then
context("%1.0f",cardinals[n] or 0)
@@ -131,10 +136,10 @@ implement {
}
implement {
- name = "luanumber",
- public = true,
- value = true,
- actions = function(b)
+ name = "luanumber",
+ public = true,
+ usage = "value",
+ actions = function(b)
local n = scanword()
if b == "value" then
context("%N",floats[n] or integers[n] or cardinals[n] or 0) -- maybe %N
@@ -146,10 +151,10 @@ implement {
}
implement {
- name = "luarandom",
- public = true,
- value = true,
- actions = function(b)
+ name = "luarandom",
+ public = true,
+ usage = "value",
+ actions = function(b)
if b == "value" then
return integer_code, random(scanluainteger(),scanluainteger())
else
@@ -236,10 +241,10 @@ implement {
}
implement {
- name = "arrayvalue",
- public = true,
- value = true,
- actions = function(b)
+ name = "arrayvalue",
+ public = true,
+ usage = "value",
+ actions = function(b)
local name = scanstring()
if name then
local a = arrays[name]
@@ -267,10 +272,10 @@ implement {
}
implement {
- name = "arrayequals",
- public = true,
- value = true,
- actions = function(b)
+ name = "arrayequals",
+ public = true,
+ usage = "value",
+ actions = function(b)
local name = scanstring()
if name then
local a = arrays[name]
@@ -291,10 +296,10 @@ implement {
}
implement {
- name = "arraycompare",
- public = true,
- value = true,
- actions = function(b)
+ name = "arraycompare",
+ public = true,
+ usage = "value",
+ actions = function(b)
local name = scanstring()
if name then
local a = arrays[name]
@@ -382,10 +387,10 @@ implement {
local dimenfactors = number.dimenfactors
implement {
- name = "nodimen",
- public = true,
- value = true,
- actions = function(b)
+ name = "nodimen",
+ public = true,
+ usage = "value",
+ actions = function(b)
if b == "value" then
local how = scanword()
local what = scandimen()
@@ -535,7 +540,6 @@ end
implement {
name = "newluatable",
protected = true,
- -- public = true,
arguments = "csname",
actions = newluatable,
}
@@ -543,7 +547,6 @@ implement {
implement {
name = "useluatable",
protected = true,
- -- public = true,
arguments = { "csname", true },
actions = newluatable,
}
@@ -695,7 +698,7 @@ local function newtable(array)
interfaces.implement {
name = name,
public = true,
- value = true,
+ usage = "value",
actions = function(b)
handletable(t,b,array)
end,
@@ -738,7 +741,7 @@ end
implement {
name = "bitwiseset",
public = true,
- value = true,
+ usage = "value",
actions = function(what)
local a = scancardinal()
if what == "value" then
@@ -752,7 +755,7 @@ implement {
implement {
name = "bitwiseand",
public = true,
- value = true,
+ usage = "value",
actions = function(what)
local a = scancardinal()
scankeyword("with")
@@ -768,7 +771,7 @@ implement {
implement {
name = "bitwiseor",
public = true,
- value = true,
+ usage = "value",
actions = function(what)
local a = scancardinal()
scankeyword("with")
@@ -784,7 +787,7 @@ implement {
implement {
name = "bitwisexor",
public = true,
- value = true,
+ usage = "value",
actions = function(what)
local a = scancardinal()
scankeyword("with")
@@ -800,7 +803,7 @@ implement {
implement {
name = "bitwisenot",
public = true,
- value = true,
+ usage = "value",
actions = function(what)
local a = scancardinal()
if what == "value" then
@@ -814,7 +817,7 @@ implement {
implement {
name = "bitwisenil",
public = true,
- value = true,
+ usage = "value",
actions = function(what)
local a = scancardinal()
scankeyword("with")
@@ -830,10 +833,73 @@ implement {
implement {
name = "ifbitwiseand",
public = true,
- condition = true,
+ usage = "condition",
actions = function(what)
local a = scancardinal()
local b = scancardinal()
return boolean_code, (a & b) ~= 0
end
}
+
+interfaces.implement {
+ name = "bitwise",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ local b = 0
+ while true do
+ local c = peekchar()
+ if c == 48 or c == 49 then
+ skipnext()
+ b = (b << 1) + (c - 48)
+ if b == 0xFFFFFFFF then
+ break
+ end
+ else
+ break
+ end
+ end
+ return 1, b
+ else
+ local b = scancardinal()
+ local t = nil
+ local n = 0
+ for i=1,32 do
+ if (b & (0x100000000 >> i)) == 0 then
+ if n > 0 then
+ n = n + 1
+ t[n] = "0"
+ end
+ elseif t then
+ n = n + 1
+ t[n] = "1"
+ else
+ n = 1
+ t = { "1" }
+ end
+ end
+ context(n > 0 and table.concat(t) or "0")
+ end
+ end,
+}
+
+-- something to play with, this might move to syst-aux.lmt when we have that
+
+local escape = function(s) return "\\" .. byte(s) end
+
+interfaces.implement {
+ name = "ctxluamatch",
+ public = true,
+ value = true,
+ actions = function()
+ local command = context[scancsname()]
+ local pattern = gsub(scanstring(),"\\.",escape)
+ local input = gsub(scanstring(),"\\.",escape)
+ for a, b, c, d, e, f, g, h, i in gmatch(input,pattern) do
+ command(a, b or "", c or "", d or "", e or "", f or "", g or "", h or "", i or "")
+ end
+ return none_code
+ end,
+}
+
diff --git a/tex/context/base/mkiv/cldf-scn.lua b/tex/context/base/mkiv/cldf-scn.lua
index 8fd4f2978..fa7ff042c 100644
--- a/tex/context/base/mkiv/cldf-scn.lua
+++ b/tex/context/base/mkiv/cldf-scn.lua
@@ -77,7 +77,7 @@ function interfaces.implement(specification)
if knownscanner(name) and not specification.overload then
report("warning: interface scanner %a is overloaded",name)
end
- register(name,scanner,specification.protected,specification.public,specification.value,specification.condition)
+ register(name,scanner,specification.protected,specification.public,specification.usage)
if private then
return
end
diff --git a/tex/context/base/mkiv/colo-ini.mkxl b/tex/context/base/mkiv/colo-ini.mkxl
index 398465a8d..72ee3db32 100644
--- a/tex/context/base/mkiv/colo-ini.mkxl
+++ b/tex/context/base/mkiv/colo-ini.mkxl
@@ -1195,15 +1195,10 @@
\setvalue{\??colorattribute currentcolor}{\the\c_attr_color} % for mpcolor
\setvalue{\??transparencyattribute currentcolor}{\the\c_attr_transparency} % for mpcolor
-%def\colo_helpers_inherited_current_ca#1{\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname}
-%def\colo_helpers_inherited_current_cs#1{\csname\??colorsetter \ifcsname\??colorsetter \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorsetter #1\endcsname#1\fi\fi\endcsname}
-%def\colo_helpers_inherited_current_ta#1{\csname\??transparencyattribute\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencyattribute#1\endcsname#1\fi\fi\endcsname}
-%def\colo_helpers_inherited_current_ts#1{\csname\??transparencysetter \ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencysetter #1\endcsname#1\fi\fi\endcsname}
-
-\def\colo_helpers_inherited_current_ca#1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi\fi}
-\def\colo_helpers_inherited_current_cs#1{\ifcsname\??colorsetter \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??colorsetter #1\endcsname\lastnamedcs\else\fi\fi}
-\def\colo_helpers_inherited_current_ta#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi\fi}
-\def\colo_helpers_inherited_current_ts#1{\ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\else\fi\fi}
+\def\colo_helpers_inherited_current_ca#1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_current_cs#1{\ifcsname\??colorsetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
+\def\colo_helpers_inherited_current_ta#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_current_ts#1{\ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
%D Low level defs:
@@ -1272,9 +1267,6 @@
\def\thecolormodelattribute {\the\c_attr_colormodel}
-%def\thecolorattribute #1{\number\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname}
-%def\thetransparencyattribute#1{\number\csname\??transparencyattribute\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencyattribute#1\endcsname#1\fi\fi\endcsname}
-
\def\rawcolorattribute #1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
\def\rawtransparencyattribute#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index e3523284e..92ff8565e 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.09 22:00}
+\newcontextversion{2020.08.11 15:56}
%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 ad7844715..367f7ea0f 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.09 22:00}
+\edef\contextversion{2020.08.11 15:56}
%D Kind of special:
diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl
index 2d67ceca0..4f413f726 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.09 22:00}
+\edef\contextversion{2020.08.11 15:56}
%D Kind of special:
diff --git a/tex/context/base/mkiv/core-lmt.lmt b/tex/context/base/mkiv/core-lmt.lmt
index 700ce4721..ccbdcc0df 100644
--- a/tex/context/base/mkiv/core-lmt.lmt
+++ b/tex/context/base/mkiv/core-lmt.lmt
@@ -6,29 +6,90 @@ if not modules then modules = { } end modules ['core-lmt'] = {
license = "see context related readme files"
}
+-- Kind of obsolete ... old school directions.
+
local implement = interfaces.implement
local scankeyword = tokens.scanners.keyword
+local scaninteger = tokens.scanners.integer
+
+local settextdir = tex.settextdir
+local setlinedir = tex.setlinedir
+local setpardir = tex.setpardir
+local setboxdir = tex.setboxdir
+
+local gettextdir = tex.gettextdir
+local getlinedir = tex.getlinedir
+local getpardir = tex.getpardir
+local getboxdir = tex.getboxdir
-local settextdir = tex.settextdir
-local setlinedir = tex.setlinedir
-local setpardir = tex.setpardir
-local setboxdir = tex.setboxdir
+local none_code = tokens.values.none
-local function scandir(what)
+local context = context
+
+local function scandir()
if scankeyword("tlt") then
- what(0)
+ return 0
elseif scankeyword("trt") then
- what(1)
- -- elseif scankeyword("rtt") then
- -- what(2)
- -- elseif scankeyword("ltl") then
- -- what(3)
+ return 1
else
- what(0)
+ return 0
end
end
-implement { name = "textdir", public = true, protected = true, actions = function() scandir(settextdir) end }
-implement { name = "linedir", public = true, protected = true, actions = function() scandir(setlinedir) end }
-implement { name = "pardir", public = true, protected = true, actions = function() scandir(setpardir) end }
-implement { name = "boxdir", public = true, protected = true, actions = function() scandir(setboxdir) end }
+local function showdir(d)
+ context(d == 1 and "TRT" or "LTL")
+ return none_code
+end
+
+implement {
+ name = "textdir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ showdir(gettextdir())
+ else
+ settextdir(scandir())
+ end
+ end
+}
+
+implement {
+ name = "linedir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ return showdir(getlinedir())
+ else
+ setlinedir(scandir())
+ end
+ end
+}
+
+implement {
+ name = "pardir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ return showdir(getpardir())
+ else
+ setpardir(scandir())
+ end
+ end
+}
+
+implement {
+ name = "boxdir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local n = scaninteger()
+ if what == "value" then
+ return showdir(getboxdir(n))
+ else
+ setboxdir(n,scandir())
+ end
+ end
+}
diff --git a/tex/context/base/mkiv/font-ini.mklx b/tex/context/base/mkiv/font-ini.mklx
index f386d45d1..882f879a2 100644
--- a/tex/context/base/mkiv/font-ini.mklx
+++ b/tex/context/base/mkiv/font-ini.mklx
@@ -2075,22 +2075,22 @@
{\currentxfontsize\plusone
\ifmmode
\scriptstyle
- \else\ifconditional\c_font_inherit_scale
+ \orelse\ifconditional\c_font_inherit_scale
\font_scale_inherit_x
\else
\font_scale_defined_x
- \fi\fi
+ \fi
\let\tx\txx}
\unexpanded\def\txx
{\currentxfontsize\plustwo
\ifmmode
\scriptscriptstyle
- \else\ifconditional\c_font_inherit_scale
+ \orelse\ifconditional\c_font_inherit_scale
\font_scale_inherit_xx
\else
\font_scale_defined_xx
- \fi\fi
+ \fi
\let\tx \empty
\let\txx\empty}
diff --git a/tex/context/base/mkiv/lang-ini.mkxl b/tex/context/base/mkiv/lang-ini.mkxl
index b7a589b47..3afbf5680 100644
--- a/tex/context/base/mkiv/lang-ini.mkxl
+++ b/tex/context/base/mkiv/lang-ini.mkxl
@@ -195,20 +195,6 @@
\unexpanded\def\installlanguage
{\dodoubleargument\lang_basics_install}
-% \def\lang_basics_install[#1][#2]%
-% {\doifelseassignment{#2}
-% {\doifelselanguage{#1}
-% {\getparameters[\??language#1][#2]}
-% {\setvalue{\??languagelinked#1}{#1}%
-% \lang_basics_install_indeed{#1}{#1}%
-% \getparameters[\??language#1][\c!state=\v!start,#2]}%
-% \edef\currentsetuplanguage{#1}%
-% \clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}%
-% \the\everysetuplanguage}
-% {\setvalue{\??languagelinked#1}{#2}%
-% \clf_setlanguagesynonym{#1}{#2}%
-% \lang_basics_install_indeed{#1}{#2}}}
-
\def\lang_basics_install[#1][#2]%
{\ifcondition\validassignment{#2}%
\doifelselanguage{#1}
@@ -426,17 +412,20 @@
% But this one is nicer because we do keep the language set as well as don't mess
% with the min values (it's more efficient too). We might get some more bits in
% this mode (engine specific).
-%
-% \let \hyphenationenabledcode \plusone
-% \let \hyphenationuppercasecode \plustwo
-%
-% \protected\def\dohyphens
-% {\hyphenationmode \numexpr
-% \hyphenationenabledcode
-% +\hyphenationuppercasecode
-% \relax}
-\unexpanded\def\dohyphens{\hyphenationmode\plusthree}
+\exhyphenchar 45 % to permit breaking at explicit hyphens
+
+% \uchyph\plusone :
+
+\chardef \completehyphenationmodecode \numexpr
+ \normalhyphenationmodecode % \discretionary
+ + \automatichyphenationmodecode % -
+ + \explicithyphenationmodecode % \-
+ + \syllablehyphenationmodecode % pattern driven
+ + \uppercasehyphenationmodecode % uchyph
+\relax
+
+\unexpanded\def\dohyphens{\hyphenationmode\completehyphenationmodecode}
\unexpanded\def\nohyphens{\hyphenationmode\zerocount}
\unexpanded\def\usehyphensparameter#1%
@@ -737,11 +726,6 @@
\unexpanded\def\hyphenation
{\clf_setlanguageexceptions{\currentlanguage}}
-%D For the moment here:
-
-\uchyph 1 % also treat uppercase
-\exhyphenchar 45 % to permit breaking at explicit hyphens
-
%D New:
\unexpanded\def\traceddiscretionary#1#2#3%
diff --git a/tex/context/base/mkiv/lang-mis.mkxl b/tex/context/base/mkiv/lang-mis.mkxl
index c01a3eada..d7e359d90 100644
--- a/tex/context/base/mkiv/lang-mis.mkxl
+++ b/tex/context/base/mkiv/lang-mis.mkxl
@@ -213,11 +213,11 @@
\csname\??discretionarymode
\ifcase\discretionarymode
n%
- \else\ifmmode
+ \orelse\ifmmode
m%
\else
t%
- \fi\fi
+ \fi
\endcsname}
\setvalue{\??discretionarymode n}#1%
@@ -387,13 +387,13 @@
{\ifconditional\spaceafterdiscretionary
%prewordbreak\hbox{#1}\relax
\wordboundary\hbox{#1}\relax
- \else\ifconditional\punctafterdiscretionary
+ \orelse\ifconditional\punctafterdiscretionary
%prewordbreak\hbox{#1}\relax
\wordboundary\hbox{#1}\relax
\else
%\prewordbreak#2\postwordbreak % was prewordbreak
\wordboundary#2\wordboundary
- \fi\fi}
+ \fi}
\definetextmodediscretionary {}
{\lang_discretionaries_hyphen_like\textmodehyphen\textmodehyphendiscretionary}
diff --git a/tex/context/base/mkiv/lpdf-fmt.lua b/tex/context/base/mkiv/lpdf-fmt.lua
index 388db0be3..c6a3f25ff 100644
--- a/tex/context/base/mkiv/lpdf-fmt.lua
+++ b/tex/context/base/mkiv/lpdf-fmt.lua
@@ -885,8 +885,8 @@ function codeinjections.setformat(s)
end
local pdf_version = spec.pdf_version * 10
local inject_metadata = spec.inject_metadata
- local majorversion = math.div(pdf_version,10)
- local minorversion = math.mod(pdf_version,10)
+ local majorversion = math.floor(math.div(pdf_version,10))
+ local minorversion = math.floor(math.mod(pdf_version,10))
local objectcompression = spec.object_compression and pdf_version >= 15
local compresslevel = level or lpdf.compresslevel() -- keep default
local objectcompresslevel = (objectcompression and (level or lpdf.objectcompresslevel())) or 0
diff --git a/tex/context/base/mkiv/lpdf-lmt.lmt b/tex/context/base/mkiv/lpdf-lmt.lmt
index 48297846e..2bbf5ba61 100644
--- a/tex/context/base/mkiv/lpdf-lmt.lmt
+++ b/tex/context/base/mkiv/lpdf-lmt.lmt
@@ -2216,6 +2216,7 @@ local openfile, closefile do
local inmemory = false
local close = false
+ local update = false
-- local removefile = os.remove
@@ -2225,13 +2226,16 @@ local openfile, closefile do
f = { }
flush = function(f,s)
n = n + 1 f[n] = s
-offset = offset + #s
+ -- offset = offset + #s
end
close = function(f)
f = concat(f)
io.savedata(filename,f)
f = false
end
+ update = function(f,s)
+ f[1] = s
+ end
-- local n = 0
-- f = {
-- write = function(self,s)
@@ -2253,8 +2257,11 @@ offset = offset + #s
local m = getmetatable(f)
flush = m.write or m.__index.write
close = m.close or m.__index.close
+ update = function(f,s)
+ f:seek("set",0)
+ f:write(s)
+ end
end
- --
local v = f_pdf(majorversion,minorversion)
-- local b = "%\xCC\xD5\xC1\xD4\xC5\xD8\xD0\xC4\xC6\010" -- LUATEXPDF (+128)
local b = "%\xC3\xCF\xCE\xD4\xC5\xD8\xD4\xD0\xC4\xC6\010" -- CONTEXTPDF (+128)
@@ -2265,7 +2272,7 @@ offset = offset + #s
closefile = function(abort)
if abort then
- f:close()
+ close(f)
if not environment.arguments.nodummy then
f = io.open(abort,"wb")
if f then
@@ -2464,7 +2471,8 @@ offset = offset + #s
flush(f,f_trailer_no(trailer(),xrefoffset))
end
end
- f:close()
+ update(f,f_pdf(majorversion,minorversion))
+ close(f)
end
io.flush()
closefile = function() end
diff --git a/tex/context/base/mkiv/math-ini.mkxl b/tex/context/base/mkiv/math-ini.mkxl
index c2a92fe5d..672ef04cc 100644
--- a/tex/context/base/mkiv/math-ini.mkxl
+++ b/tex/context/base/mkiv/math-ini.mkxl
@@ -2743,7 +2743,7 @@
% 0x002B=plus 0x2212=minus 0x2013=endash
\unexpanded\def\mathplus {+}
-\unexpanded\def\mathminus {\ifmmode –\else\iffontchar\font`−−\else –\fi\fi}
+\unexpanded\def\mathminus {\ifmmode –\orelse\iffontchar\font`−−\else –\fi}
\unexpanded\def\mathplusminus{±}
%D The \type {\displaywidth} is only known inside a display formula, so we need to catch
diff --git a/tex/context/base/mkiv/meta-ini.mkxl b/tex/context/base/mkiv/meta-ini.mkxl
index 513f87ae2..28fe09b9e 100644
--- a/tex/context/base/mkiv/meta-ini.mkxl
+++ b/tex/context/base/mkiv/meta-ini.mkxl
@@ -587,13 +587,13 @@
\def\meta_prepare_variable_yes
{\ifchkdim\m_meta_current_variable\or
\meta_prepare_variable_dimension
- \else\ifchknum\m_meta_current_variable\or
+ \orelse\ifchknum\m_meta_current_variable\or
\meta_prepare_variable_number
\else
\doifelsecolor\m_meta_current_variable
\meta_prepare_variable_color
\meta_prepare_variable_dimension
- \fi\fi}
+ \fi}
\let\MPvar \MPvariable
\let\setMPvariables\setupMPvariables
diff --git a/tex/context/base/mkiv/meta-mac.mkxl b/tex/context/base/mkiv/meta-mac.mkxl
index 3bf38b4c8..7ced2aff9 100644
--- a/tex/context/base/mkiv/meta-mac.mkxl
+++ b/tex/context/base/mkiv/meta-mac.mkxl
@@ -46,7 +46,7 @@
\meta_process_graphic{lmt_#2;}%
\clf_lmt_parameters_reset{#2}%
\meta_end_graphic_group
- \else\ifsecondargument
+ \orelse\ifsecondargument
\doifelseassignment{#2}
{\let\currentMPinstance\defaultMPinstance
\meta_enable_include
@@ -61,6 +61,6 @@
\let\currentMPinstance\defaultMPinstance
\meta_enable_include
\meta_process_graphic{lmt_#1;}%
- \fi\fi}
+ \fi}
\protect
diff --git a/tex/context/base/mkiv/mult-aux.mkxl b/tex/context/base/mkiv/mult-aux.mkxl
index fef40ec2c..1df5bcf24 100644
--- a/tex/context/base/mkiv/mult-aux.mkxl
+++ b/tex/context/base/mkiv/mult-aux.mkxl
@@ -853,14 +853,14 @@
% \ifsecondargument
% \edef#2{##1}%
% #3[##2]%
-% \else\iffirstargument
+% \orelse\iffirstargument
% \doifelseassignment{##1}
% {\let#2\empty
% #3[##1]}%
% {\edef#2{##1}}%
% \else
% \let#2\empty
-% \fi\fi
+% \fi
% \directsetup{handler:action:#1}%
% \endgroup}}
@@ -922,7 +922,7 @@
%def\v_interfaces_prefix_template{\characters\c_mult_interfaces_n_of_namespaces>}
%def\v_interfaces_prefix_template % consistently %03i>
-% {\ifnum\c_mult_interfaces_n_of_namespaces<\plusten00\else\ifnum\c_mult_interfaces_n_of_namespaces<\plushundred0\fi\fi
+% {\ifnum\c_mult_interfaces_n_of_namespaces<\plusten00\orelse\ifnum\c_mult_interfaces_n_of_namespaces<\plushundred0\fi
% \number\c_mult_interfaces_n_of_namespaces>}
\def\v_interfaces_prefix_template
diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua
index 9275f2a56..f830b7473 100644
--- a/tex/context/base/mkiv/mult-low.lua
+++ b/tex/context/base/mkiv/mult-low.lua
@@ -158,6 +158,9 @@ return {
"startlmtxmode", "stoplmtxmode", "startmkivmode", "stopmkivmode",
--
"wildcardsymbol",
+ --
+ "normalhyphenationmodecode", "automatichyphenationmodecode", "explicithyphenationmodecode",
+ "syllablehyphenationmodecode", "uppercasehyphenationmodecode", "completehyphenationmodecode",
},
["helpers"] = {
--
@@ -369,6 +372,7 @@ return {
"gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals",
--
"dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "fastloopindex", "fastloopfinal", "dowith",
+ "doloopovermatch", "doloopoverlist",
--
"newconstant", "setnewconstant", "setconstant", "setconstantvalue",
"newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue",
@@ -453,7 +457,7 @@ return {
"ctxlua", "luacode", "lateluacode", "directluacode",
"registerctxluafile", "ctxloadluafile",
"luaversion", "luamajorversion", "luaminorversion",
- "ctxluacode", "luaconditional", "luaexpanded",
+ "ctxluacode", "luaconditional", "luaexpanded", "ctxluamatch",
"startluaparameterset", "stopluaparameterset", "luaparameterset",
"definenamedlua",
"obeylualines", "obeyluatokens",
@@ -511,6 +515,8 @@ return {
"boxrangewd", "boxrangeht", "boxrangedp",
--
"bitwiseset", "bitwiseand", "bitwiseor", "bitwisexor", "bitwisenot", "bitwisenil",
- "ifbitwiseand",
+ "ifbitwiseand", "bitwise",
+ -- old ... very low level
+ "textdir", "linedir", "pardir", "boxdir",
}
}
diff --git a/tex/context/base/mkiv/pack-mrl.mkxl b/tex/context/base/mkiv/pack-mrl.mkxl
index 2c3a2f174..7b09b2406 100644
--- a/tex/context/base/mkiv/pack-mrl.mkxl
+++ b/tex/context/base/mkiv/pack-mrl.mkxl
@@ -52,18 +52,18 @@
\edef\p_depth {\directblackrulesparameter\c!depth }%
\ifx\p_height\v!max
\setstrut
- \else\ifx\p_depth\v!max
+ \orelse\ifx\p_depth\v!max
\setstrut
- \fi\fi
+ \fi
\useblackrulesstyleandcolor\c!style\c!color
\ifcsname\??blackruletype\directblackrulesparameter\c!type\endcsname
\lastnamedcs
\else
\vrule
\fi
- \ifx\p_width \v!max\s!width \emwidth\else\ifx\p_width \empty\else\s!width \p_width \fi\fi
- \ifx\p_height\v!max\s!height\strutht\else\ifx\p_height\empty\else\s!height\p_height\fi\fi
- \ifx\p_depth \v!max\s!depth \strutdp\else\ifx\p_depth \empty\else\s!depth \p_depth \fi\fi
+ \ifx\p_width \v!max\s!width \emwidth\orelse\ifx\p_width \empty\else\s!width \p_width \fi
+ \ifx\p_height\v!max\s!height\strutht\orelse\ifx\p_height\empty\else\s!height\p_height\fi
+ \ifx\p_depth \v!max\s!depth \strutdp\orelse\ifx\p_depth \empty\else\s!depth \p_depth \fi
\egroup}
\setupblackrules
@@ -283,11 +283,11 @@
\linewidth\dimexpr\directthinrulesparameter\c!rulethickness/\plustwo\relax
\ifzeropt\linewidth
\c_pack_thinrules_type\zerocount
- \else\ifx\p_frame\v!on
+ \orelse\ifx\p_frame\v!on
\c_pack_thinrules_type\expandnamespaceparameter\??thinrulealternatives\directthinrulesparameter\c!alternative\v!b\relax
\else
\c_pack_thinrules_type\zerocount
- \fi\fi
+ \fi
\ifnum\c_pack_thinrules_type=\plusone
\ifx\p_height\v!max
\scratchheight\strutht
@@ -755,11 +755,11 @@
\ifx\p_width\v!fit
\scratchdistance\zeropoint
\hbox
- \else\ifx\p_width\v!broad
+ \orelse\ifx\p_width\v!broad
\hbox
\else
\hbox to \directfillinrulesparameter\c!width
- \fi\fi
+ \fi
\bgroup
\usefillinrulesstyleandcolor\c!style\c!color
\strut
diff --git a/tex/context/base/mkiv/spac-hor.mkxl b/tex/context/base/mkiv/spac-hor.mkxl
index c9ac0a992..c3bcccf93 100644
--- a/tex/context/base/mkiv/spac-hor.mkxl
+++ b/tex/context/base/mkiv/spac-hor.mkxl
@@ -120,22 +120,22 @@
% \def\spac_indentation_apply_step_one#1%
% {\ifcsname\??indentingpreset#1\endcsname
% \spac_indentation_apply_step_one_nested{#1}%
-% \else\ifcsname\??indentingmethod#1\endcsname
+% \orelse\ifcsname\??indentingmethod#1\endcsname
% % case two
% \else
% \edef\v_spac_indentation_current{#1}% single entry in list
% \let\normalindentation\v_spac_indentation_current
% \spac_indentation_setup_size
-% \fi\fi}
+% \fi}
%
% \def\spac_indentation_apply_step_two#1%
% {\ifcsname\??indentingpreset#1\endcsname
% \spac_indentation_apply_step_two_nested{#1}%
-% \else\ifcsname\??indentingmethod#1\endcsname
+% \orelse\ifcsname\??indentingmethod#1\endcsname
% \lastnamedcs
% \else
% % case one
-% \fi\fi}
+% \fi}
\def\spac_indentation_apply_step_one_nested
{\expandafter\processcommacommand\expandafter[\lastnamedcs]\spac_indentation_apply_step_one}
@@ -146,22 +146,22 @@
\def\spac_indentation_apply_step_one#1%
{\ifcsname\??indentingpreset#1\endcsname
\spac_indentation_apply_step_one_nested
- \else\ifcsname\??indentingmethod#1\endcsname
+ \orelse\ifcsname\??indentingmethod#1\endcsname
% case two
\else
\edef\v_spac_indentation_current{#1}% single entry in list
\let\normalindentation\v_spac_indentation_current
\spac_indentation_setup_size
- \fi\fi}
+ \fi}
\def\spac_indentation_apply_step_two#1%
{\ifcsname\??indentingpreset#1\endcsname
\spac_indentation_apply_step_two_nested
- \else\ifcsname\??indentingmethod#1\endcsname
+ \orelse\ifcsname\??indentingmethod#1\endcsname
\lastnamedcs
\else
% case one
- \fi\fi}
+ \fi}
\unexpanded\def\indenting % kind of obsolete
{\doifelsenextoptionalcs\spac_indentation_setup_options\relax}
@@ -1045,11 +1045,11 @@
\hskip % always a skip even when 0pt
\ifsecondargument
\hspaceamount{#1}{#2}%
- \else\iffirstargument
+ \orelse\iffirstargument
\hspaceamount\empty{#1}%
\else
\hspaceamount\empty\s!default
- \fi\fi
+ \fi
\expandafter\ignorespaces
\fi}
@@ -1271,12 +1271,12 @@
\def\spac_ignore_spaces_body
{\ifzeropt\lastskip
\exitloop
- \else\ifdim\lastskip=\s_spac_ignore_spaces
+ \orelse\ifdim\lastskip=\s_spac_ignore_spaces
\unskip
\exitloop
\else
\unskip
- \fi\fi}
+ \fi}
%D \macros
%D {obeyfollowingtoken}
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 622a6ffe8..68817dcd6 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index a23a64b94..4d7f938ca 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/strc-itm.mklx b/tex/context/base/mkiv/strc-itm.mklx
index 46fb90c9e..51f2cd4b6 100644
--- a/tex/context/base/mkiv/strc-itm.mklx
+++ b/tex/context/base/mkiv/strc-itm.mklx
@@ -914,12 +914,12 @@
\letitemgroupparameter\c!inbetween\empty
\fi
\ifconditional\c_strc_itemgroups_columns
- \ifinsidecolumns\else\ifcase\c_strc_itemgroups_column_depth
+ \ifinsidecolumns\orelse\ifcase\c_strc_itemgroups_column_depth
\global\c_strc_itemgroups_column_depth\c_strc_itemgroups_nesting % global ?
\strc_itemgroups_before_command
\strc_itemgroups_tag_start_group
\strc_itemgroups_start_columns
- \fi\fi
+ \fi
\fi
\ifconditional\c_strc_itemgroups_fitting
\ifdim\d_strc_itemgroups_max_width>\zeropoint
@@ -1494,9 +1494,9 @@
\strc_itemgroups_make_destination_box
\ifconditional\c_strc_itemgroups_fitting
\strc_itemgroups_make_fitting_box
- \else\ifdim\d_strc_itemgroups_asked_width>\zeropoint
+ \orelse\ifdim\d_strc_itemgroups_asked_width>\zeropoint
\strc_itemgroups_make_aligned_box
- \fi\fi
+ \fi
\let\m_strc_itemgroups_destination\empty
\ht\b_strc_itemgroups\strutheight % just in case a symbols is not yet available in
\dp\b_strc_itemgroups\strutdepth % the current run (more a mkii mp side artifact)
diff --git a/tex/context/base/mkiv/supp-box.lmt b/tex/context/base/mkiv/supp-box.lmt
index 96e0330e5..98bf828b5 100644
--- a/tex/context/base/mkiv/supp-box.lmt
+++ b/tex/context/base/mkiv/supp-box.lmt
@@ -855,8 +855,7 @@ implement {
implement {
name = "widthuptohere",
public = true,
- protected = true,
- value = true,
+ usage = "value",
actions = function()
local n = texgetnest()
local w = 0
@@ -1195,30 +1194,27 @@ do
local function define_one(name,action)
implement {
- name = name,
- public = true,
- -- protected = true,
- value = true,
- actions = function(what) return boxline(action,what) end,
+ name = name,
+ public = true,
+ usage = "value",
+ 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,
+ name = name,
+ public = true,
+ usage = "value",
+ actions = function(what) return boxrange(action,what) end,
}
end
implement {
- name = "boxlines",
- public = true,
- -- protected = true,
- value = true,
- actions = boxlinecount,
+ name = "boxlines",
+ public = true,
+ usage = "value",
+ actions = boxlinecount,
}
define_one("boxline", "get")
diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkiv/supp-box.mkxl
index c5afa1f8f..d3220052e 100644
--- a/tex/context/base/mkiv/supp-box.mkxl
+++ b/tex/context/base/mkiv/supp-box.mkxl
@@ -621,15 +621,15 @@
%D {\def\syst_boxes_with_next_box{#1}%
%D \ifx#2\hbox
%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else\ifx#2\vbox
+%D \orelse\ifx#2\vbox
%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else\ifx#2\vtop
+%D \orelse\ifx#2\vtop
%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else\ifx#2\normalvcenter
+%D \orelse\ifx#2\normalvcenter
%D \afterassignment\syst_boxes_with_next_box_indeed
%D \else
%D \afterassignment\syst_boxes_with_next_box
-%D \fi\fi\fi\fi
+%D \fi
%D \setbox\nextbox#2}
%D \stoptyping
%D
diff --git a/tex/context/base/mkiv/syst-aux.mkxl b/tex/context/base/mkiv/syst-aux.mkxl
index 1951e166f..0c5ff3f76 100644
--- a/tex/context/base/mkiv/syst-aux.mkxl
+++ b/tex/context/base/mkiv/syst-aux.mkxl
@@ -3290,6 +3290,32 @@
\globalpopmacro\recurseaction
\global\advance\outerrecurse\minusone}
+%D This is some \LMTX\ experiment:
+%D
+%D Think of:
+%D
+%D \starttyping
+%D \domatch {(\letterpercent w+) *(\letterpercent w*)} {aa bb cc dd} {
+%D [
+%D \domatch{(\letterpercent w)(\letterpercent w)} {#1} {(##1 ##2)}
+%D \domatch{(\letterpercent w)(\letterpercent w)} {#2} {(##1 ##2)}
+%D ]
+%D }
+%D
+%D and:
+%D
+%D \stoptyping
+%D
+%D \starttyping
+%D \def\MyMacro#1{(#1)} \ctxluamatch \MyMacro {(.)} {abcd}
+%D \stoptyping
+
+\protected\def\doloopovermatch#1#2#3%
+ {\pushmacro\matchloopcommand
+ \def\matchloopcommand##1##2##3##4##5##6##7##8##9{#3}%
+ \ctxluamatch\matchloopcommand{#1}{#2}%
+ \popmacro\matchloopcommand}
+
%D \macros
%D {newevery,everyline,EveryLine,EveryPar}
%D
@@ -3463,7 +3489,7 @@
\assignmentfalse
\fi}
-\protected\def\validassignment #1{\ifhastok={#1}}
+\protected\def\validassignment #1{\ifhastok={#1}} % can become: {\ifhastok=} as we enforce {}
\protected\def\novalidassignment#1{\ifnum\ifhastok={#1}\zerocount\else\plusone\fi=\plusone}
%D In \ETEX\ we can use \type {\detokenize} and gain some speed, but in general far
@@ -5367,7 +5393,7 @@
%D first version was:
%D
%D \starttyping
-%D \def\dontleavehmode{\ifhmode\else\ifmmode\else$ $\fi\fi}
+%D \def\dontleavehmode{\ifhmode\orelse\ifmmode\else$ $\fi}
%D \stoptyping
%D
%D Next, Taco came with a better alternative (using mathsurround):
diff --git a/tex/context/base/mkiv/syst-con.lua b/tex/context/base/mkiv/syst-con.lua
index 1af2d9a5d..6e998bdfd 100644
--- a/tex/context/base/mkiv/syst-con.lua
+++ b/tex/context/base/mkiv/syst-con.lua
@@ -30,12 +30,18 @@ function converters.octstringtonumber(n) tonumber(n, 8) end
function converters.rawcharacter (n) utfchar(0x110000+n) end
-local lchexnumber = formatters["%x"]
-local uchexnumber = formatters["%X"]
-local lchexnumbers = formatters["%02x"]
-local uchexnumbers = formatters["%02X"]
-local octnumber = formatters["%03o"]
-local nicenumber = formatters["%0.6F"]
+local f_lchexnumber = formatters["%x"]
+local f_uchexnumber = formatters["%X"]
+local f_lchexnumbers = formatters["%02x"]
+local f_uchexnumbers = formatters["%02X"]
+local f_octnumber = formatters["%03o"]
+local nicenumber = formatters["%0.6F"]
+
+local lchexnumber = function(n) if n < 0 then n = 0x100000000 + n end return f_lchexnumber (n) end
+local uchexnumber = function(n) if n < 0 then n = 0x100000000 + n end return f_uchexnumber (n) end
+local lchexnumbers = function(n) if n < 0 then n = 0x100000000 + n end return f_lchexnumbers(n) end
+local uchexnumbers = function(n) if n < 0 then n = 0x100000000 + n end return f_uchexnumbers(n) end
+local octnumber = function(n) if n < 0 then n = 0x100000000 + n end return f_octnumber (n) end
converters.lchexnumber = lchexnumber
converters.uchexnumber = uchexnumber
diff --git a/tex/context/base/mkiv/syst-ini.mkxl b/tex/context/base/mkiv/syst-ini.mkxl
index 46daa66ca..c8c16b773 100644
--- a/tex/context/base/mkiv/syst-ini.mkxl
+++ b/tex/context/base/mkiv/syst-ini.mkxl
@@ -325,11 +325,11 @@
\def\syst_basics_allocate#1#2#3#4#5% last class method max name
{\ifx#5\undefined
\expandafter\syst_basics_allocate_yes
- \else\ifx#5\relax
- \expandafter\expandafter\expandafter\syst_basics_allocate_yes
+ \orelse\ifx#5\relax
+ \expandafter\syst_basics_allocate_yes
\else
- \expandafter\expandafter\expandafter\syst_basics_allocate_nop
- \fi\fi
+ \expandafter\syst_basics_allocate_nop
+ \fi
#1#2#3#4#5}
%D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of
diff --git a/tex/context/base/mkiv/syst-lua.lmt b/tex/context/base/mkiv/syst-lua.lmt
index effba14d9..d74b27689 100644
--- a/tex/context/base/mkiv/syst-lua.lmt
+++ b/tex/context/base/mkiv/syst-lua.lmt
@@ -337,8 +337,7 @@ do
implement {
name = "openin",
public = true,
- -- protected = true,
- value = true,
+ usage = "value",
actions = function()
local n = scaninteger()
scankeyword("=")
@@ -359,8 +358,7 @@ do
implement {
name = "closein",
public = true,
- -- protected = true,
- value = true,
+ usage = "value",
actions = function()
local n = scaninteger()
local c = channels[n]
@@ -374,8 +372,7 @@ do
implement {
name = "read",
public = true,
- -- protected = true,
- value = true,
+ usage = "value",
actions = function(prefix)
local n = scaninteger()
scankeyword("to")
@@ -393,8 +390,7 @@ do
implement {
name = "readline",
public = true,
- -- protected = true,
- value = true,
+ usage = "value",
actions = function(prefix)
local n = scaninteger()
scankeyword("to")
@@ -409,15 +405,10 @@ do
end,
}
- -- callback.register("if_end_of_file", function(n)
- -- return not channels[n]
- -- end)
-
implement {
name = "ifeof",
public = true,
- -- protected = true,
- condition = true,
+ usage = "condition",
actions = function(prefix)
local n = scaninteger()
return tokens.values.boolean, not channels[n]
diff --git a/tex/context/base/mkiv/tabl-ntb.mkxl b/tex/context/base/mkiv/tabl-ntb.mkxl
index ada655fa9..680429822 100644
--- a/tex/context/base/mkiv/tabl-ntb.mkxl
+++ b/tex/context/base/mkiv/tabl-ntb.mkxl
@@ -132,11 +132,11 @@
% \par
% \ifhmode
% % \removeunwantedspaces
-% \else\ifdim\prevdepth<\zeropoint % =-1000pt ?
+% \orelse\ifdim\prevdepth<\zeropoint % =-1000pt ?
% \vskip-\strutdp
% \else
% \removebottomthings
-% \fi\fi
+% \fi
% \fi}
\newcount\c_tabl_ntb_row
diff --git a/tex/context/base/mkiv/tabl-tbl.mkxl b/tex/context/base/mkiv/tabl-tbl.mkxl
index 8bed65a9f..4b2f31721 100644
--- a/tex/context/base/mkiv/tabl-tbl.mkxl
+++ b/tex/context/base/mkiv/tabl-tbl.mkxl
@@ -780,7 +780,7 @@
% \def\tabl_tabulate_set_color_span#1#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
+% \global\c_tabl_tabulate_colorspan\if#1L\plusone\orelse\if#1M\plustwo\orelse\if#1R\plusthree\else\zerocount\fi\relax
% \tabl_tabulate_set_preamble}
\installcorenamespace{tabulatecolorspec}
@@ -2188,9 +2188,9 @@
% %\ifcase#1\or % todo: check what this does
% \ifnum\noftabulatelines=\zerocount
% \glet\dotabulateautoline\donothing
-% \else\ifnum\noftabulatelines=\totalnoftabulatelines
+% \orelse\ifnum\noftabulatelines=\totalnoftabulatelines
% \glet\dotabulateautoline\donothing
-% \fi\fi
+% \fi
% %\fi
% \dotabulatenobreak
% \stoptabulatenoalign
diff --git a/tex/context/base/mkiv/toks-aux.lmt b/tex/context/base/mkiv/toks-aux.lmt
index d46a5872a..9c392f006 100644
--- a/tex/context/base/mkiv/toks-aux.lmt
+++ b/tex/context/base/mkiv/toks-aux.lmt
@@ -85,24 +85,32 @@ if CONTEXTLMTXMODE > 0 then
end
}
- -- for the moment here, will move to initex only (also see node-ini.lua) :
+ -- For the moment here, will move to initex only (also see node-ini.lua); we need
+ -- to actually store these.
+
+ local groupcodes = { }
+ local hyphenationcodes = { }
+
+ for k, v in next, tex.getgroupvalues() do
+ groupcodes[k] = gsub(v,"_","")
+ end
+ for k, v in next, tex.gethyphenationvalues() do
+ hyphenationcodes[k] = gsub(v,"_","")
+ end
if environment.initex then
local texchardef = tex.chardef
- local groupcodes = { }
- for k, v in next, tex.getgroupvalues() do
- groupcodes[k] = gsub(v,"_","")
- end
+ for k, v in next, groupcodes do texchardef(v .. "groupcode", k) end
+ for k, v in next, hyphenationcodes do texchardef(v .. "hyphenationmodecode",k) end
- groupcodes = utilities.storage.allocate(table.swapped(groupcodes,groupcodes))
- tex.groupcodes = groupcodes
+ end
- for i=0,#groupcodes do
- texchardef(groupcodes[i] .. "groupcode",i)
- end
+ groupcodes = utilities.storage.allocate(table.swapped(groupcodes, groupcodes))
+ hyphenationcodes = utilities.storage.allocate(table.swapped(hyphenationcodes,hyphenationcodescodes))
- end
+ tex.groupcodes = groupcodes
+ tex.hyphenationcodes = hyphenationcodes
end
diff --git a/tex/context/base/mkiv/toks-scn.lua b/tex/context/base/mkiv/toks-scn.lua
index b6f4d78d3..abf39a319 100644
--- a/tex/context/base/mkiv/toks-scn.lua
+++ b/tex/context/base/mkiv/toks-scn.lua
@@ -478,7 +478,7 @@ function tokens.compile(specification)
return scanners[ti]
end
elseif #t == 0 then
- if specification.value then
+ if specification.usage == "value" then
code = "b"
args = "_,b"
else
diff --git a/tex/context/base/mkiv/trac-log.lua b/tex/context/base/mkiv/trac-log.lua
index 142d8baa3..4917c0ec8 100644
--- a/tex/context/base/mkiv/trac-log.lua
+++ b/tex/context/base/mkiv/trac-log.lua
@@ -1035,7 +1035,7 @@ do
local texerror = tex and tex.error or print
local formatters = string.formatters
- function logs.texerrormessage(...) -- for the moment we put this function here
+ function logs.texerrormessage(fmt,first,...) -- for the moment we put this function here
texerror(first and formatters[fmt](first,...) or fmt)
end
diff --git a/tex/context/base/mkiv/util-prs.lua b/tex/context/base/mkiv/util-prs.lua
index 8915c3e9e..57ac2b58e 100644
--- a/tex/context/base/mkiv/util-prs.lua
+++ b/tex/context/base/mkiv/util-prs.lua
@@ -373,7 +373,9 @@ hashes.settings_to_set = table.setmetatableindex(function(t,k) -- experiment, n
return v
end)
-getmetatable(hashes.settings_to_set).__mode = "kv" -- could be an option (maybe sharing makes sense)
+-- as we use a next, we are not sure when the gc kicks in
+--
+-- getmetatable(hashes.settings_to_set).__mode = "kv" -- could be an option (maybe sharing makes sense)
function parsers.simple_hash_to_string(h, separator)
local t = { }