diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-07-10 16:30:53 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-07-10 16:30:53 +0200 |
commit | ff693671b6540fa81d2ad7aecdbe786a4df97335 (patch) | |
tree | 979066b446d6d47fcec40fa7da9978c31a2bf802 /tex | |
parent | f58860178fcd1497d52acaa3cb2ceda7531e46ac (diff) | |
download | context-ff693671b6540fa81d2ad7aecdbe786a4df97335.tar.gz |
2018-07-10 16:00:00
Diffstat (limited to 'tex')
34 files changed, 914 insertions, 687 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 7e089de90..a28121d0d 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{2018.07.06 19:07} +\newcontextversion{2018.07.10 15:52} %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 09be8b091..6a88fbd1c 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{2018.07.06 19:07} +\edef\contextversion{2018.07.10 15:52} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index 2bd9353d0..6e30e12ad 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -1027,6 +1027,7 @@ \setinterfaceconstant{otherstext}{otherstext} \setinterfaceconstant{outermargin}{outermargin} \setinterfaceconstant{overprint}{overprint} +\setinterfaceconstant{ownerpassword}{ownerpassword} \setinterfaceconstant{ownnumber}{eigenenummer} \setinterfaceconstant{page}{seite} \setinterfaceconstant{pageboundaries}{seitenbegrenzung} @@ -1268,6 +1269,7 @@ \setinterfaceconstant{up}{up} \setinterfaceconstant{urlalternative}{urlalternative} \setinterfaceconstant{urlspace}{urlspatium} +\setinterfaceconstant{userpassword}{userpassword} \setinterfaceconstant{validate}{validieren} \setinterfaceconstant{values}{values} \setinterfaceconstant{vcommand}{vbefehl} diff --git a/tex/context/base/mkiv/attr-ini.mkiv b/tex/context/base/mkiv/attr-ini.mkiv index e3d328e3d..3792b1c63 100644 --- a/tex/context/base/mkiv/attr-ini.mkiv +++ b/tex/context/base/mkiv/attr-ini.mkiv @@ -24,6 +24,7 @@ \installcorenamespace{attributecount} % the counter representing the attribute (attrdef'd) \installcorenamespace{attributeid} % the internal number \installcorenamespace{attributestack} % the attribute specific stack +\installcorenamespace{attributepickup} \unexpanded\def\pushattribute#1% {\global\advance\csname\??attributestack\string#1\endcsname\plusone @@ -40,12 +41,15 @@ \newtoks \t_attr_list_global \newtoks \t_attr_list_local +\newtoks \t_attr_list_pickup \newtoks \t_attr_list_nomath \ifdefined \s!global \else \def\s!global {global} \fi % for metatex % or hard check later \ifdefined \s!public \else \def\s!public {public} \fi % for metatex % or hard check later \ifdefined \s!private \else \def\s!private {private} \fi % for metatex % or hard check later \ifdefined \s!attribute \else \def\s!attribute{attribute} \fi % for metatex % or hard check later +\ifdefined \s!pickup \else \def\s!pickup {pickup} \fi % for metatex % or hard check later +\ifdefined \s!forget \else \def\s!forget {forget} \fi % for metatex % or hard check later \unexpanded\def\defineattribute {\dodoubleempty\attr_basics_define} \unexpanded\def\definesystemattribute{\dodoubleempty\attr_basics_define_system} @@ -53,6 +57,8 @@ \def\attr_basics_define {\attr_basics_define_indeed\s!public} \def\attr_basics_define_system{\attr_basics_define_indeed\s!private} + % here public means 'visible' so it's not to be confused with 'public' at the lua end + \def\attr_basics_define_indeed#1[#2][#3]% {\ifcsname\??attributecount#2\endcsname\else \scratchcounter\clf_defineattribute{#2}{#1}\relax @@ -66,11 +72,29 @@ {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% \doifinset\s!nomath{#3}% {\etoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% - % here public means 'visible' so it's not to be confused with 'public' at the lua end \doifinset\s!public{#3}% {\expandafter\let\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% + \doifinset\s!pickup{#3}% + {\expandafter\newconstant\csname\??attributepickup#2\endcsname + \csname\??attributepickup#2\endcsname\attributeunsetvalue + \etoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% + \ifcsname#2\s!attribute\endcsname + \expandafter\edef\csname\s!pickup#2\s!attribute\endcsname + {\csname\??attributepickup#2\endcsname\csname\??attributecount#2\endcsname}% + \expandafter\edef\csname\s!forget#2\s!attribute\endcsname + {\csname\??attributepickup#2\endcsname\attributeunsetvalue}% + \fi}% \fi} +\unexpanded\def\pickupattributes + {\the\t_attr_list_pickup\relax} + +% \unexpanded\def\pickupattribute#1% +% {\csname\??attributecount#1\endcsname\csname\??attributepickup#1\endcsname} + +% \unexpanded\def\pickupattributelater#1% +% {\csname\??attributepickup#1\endcsname\csname\??attributecount#1\endcsname} + \unexpanded\def\newattribute#1% {\attr_basics_define_indeed\s!public[\csstring#1][]% \expandafter\let\expandafter#1\csname\??attributeid\csstring#1\endcsname} diff --git a/tex/context/base/mkiv/buff-ini.lua b/tex/context/base/mkiv/buff-ini.lua index 970042c1b..632565fc7 100644 --- a/tex/context/base/mkiv/buff-ini.lua +++ b/tex/context/base/mkiv/buff-ini.lua @@ -182,7 +182,7 @@ local function collectcontent(name,separator) -- no print end local function loadcontent(name) -- no print - local content = collectcontent(name,"\n") -- tex likes \n + local content = collectcontent(name,"\n") -- tex likes \n hm, elsewhere \r local ok, err = load(content) if ok then return ok() diff --git a/tex/context/base/mkiv/buff-ini.mkiv b/tex/context/base/mkiv/buff-ini.mkiv index e487fc298..145f0f392 100644 --- a/tex/context/base/mkiv/buff-ini.mkiv +++ b/tex/context/base/mkiv/buff-ini.mkiv @@ -179,16 +179,16 @@ {\dosingleempty\buff_get} \unexpanded\def\buff_get[#1]% [name] - {\namedbufferparameter\empty\c!before + {\namedbufferparameter\empty\c!before\relax \doifelsenothing{#1} {\buff_get_stored_indeed\empty} {\processcommalist[#1]\buff_get_stored_indeed}% - \namedbufferparameter\empty\c!after} + \namedbufferparameter\empty\c!after\relax} \unexpanded\def\buff_get_stored#1#2% - {\namedbufferparameter{#1}\c!before + {\namedbufferparameter{#1}\c!before\relax \buff_get_stored_indeed{#2}% - \namedbufferparameter{#1}\c!after} + \namedbufferparameter{#1}\c!after\relax} \unexpanded\def\buff_get_stored_indeed#1% {\clf_getbuffer{#1}} diff --git a/tex/context/base/mkiv/buff-ver.mkiv b/tex/context/base/mkiv/buff-ver.mkiv index 47902ced7..7cf829b74 100644 --- a/tex/context/base/mkiv/buff-ver.mkiv +++ b/tex/context/base/mkiv/buff-ver.mkiv @@ -496,7 +496,7 @@ \def\buff_verbatim_typing_start_nop {\typingparameter\c!before - \startpacked[\v!blank] + \startpacked[\v!blank]% \buff_verbatim_setup_line_numbering \buff_verbatim_initialize_typing_one \buff_verbatim_setup_keep_together @@ -504,7 +504,7 @@ \def\buff_verbatim_typing_start_yes[#1]% {\typingparameter\c!before - \startpacked[\v!blank] + \startpacked[\v!blank]% \doifelseassignment{#1} {\setupcurrenttyping[#1]} {\doif\v!continue{#1}{\lettypingparameter\c!continue\v!yes}}% @@ -540,7 +540,7 @@ \dostoptagged \endofverbatimlines \dostoptagged - \csname#2\endcsname} + \begincsname#2\endcsname} \unexpanded\def\buff_verbatim_typing_stop#1% hm, currenttyping {\stoppacked diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua index dabdbb9b0..72f1276d2 100644 --- a/tex/context/base/mkiv/cldf-ini.lua +++ b/tex/context/base/mkiv/cldf-ini.lua @@ -1354,24 +1354,21 @@ do local sentinel = string.char(26) -- ASCII SUB character : endoffileasciicode : ignorecatcode local level = 0 - local function collect(c,...) -- can be optimized - -- snippets - for i=1,select("#",...) do + local function collect(c,a,...) -- can be optimized + if type(c) == "userdata" then nofcollected = nofcollected + 1 - collected[nofcollected] = select(i,...) + -- collected[nofcollected] = userdata(c) + collected[nofcollected] = "\\" .. c.csname + end + if a then + for i=1,select("#",a,...) do + local c = select(i,a,...) + nofcollected = nofcollected + 1 + collected[nofcollected] = type(c) == "userdata" and userdata(c) or c + end end end - -- local function collectdirect(c,...) -- can be optimized - -- -- lines - -- for i=1,select("#",...) do - -- n = n + 1 - -- t[n] = select(i,...) - -- n = n + 1 - -- t[n] = "\r" - -- end - -- end - local collectdirect = collect local permitted = true diff --git a/tex/context/base/mkiv/cldf-ver.lua b/tex/context/base/mkiv/cldf-ver.lua index 3710b2415..7a1c81301 100644 --- a/tex/context/base/mkiv/cldf-ver.lua +++ b/tex/context/base/mkiv/cldf-ver.lua @@ -13,32 +13,69 @@ if not modules then modules = { } end modules ['cldf-ver'] = { local concat, tohandle = table.concat, table.tohandle local splitlines, strip = string.splitlines, string.strip local tostring, type = tostring, type +local assignbuffer = buffers.assign local context = context -local function flush(...) - context(concat{...,"\r"}) -- was \n +context.tobuffer = assignbuffer -- (name,str,catcodes) + +function context.tolines(str,strip) + local lines = type(str) == "string" and splitlines(str) or str + for i=1,#lines do + if strip then + context(strip(lines[i]) .. " ") + else + context(lines[i] .. " ") + end + end end -local function t_tocontext(...) - context.starttyping { "typing" } -- else [1] is intercepted - context.pushcatcodes("verbatim") - tohandle(flush,...) -- ok? - context.stoptyping() - context.popcatcodes() +-- local function flush(...) +-- context(concat { ..., "\r" }) -- was \n +-- end +-- +-- somehow this doesn't work any longer .. i need to figure out why +-- +-- local function t_tocontext(t) +-- context.starttyping { "typing" } -- else [1] is intercepted +-- context.pushcatcodes("verbatim") +-- -- tohandle(flush,...) +-- context(table.serialize(t)) +-- context.stoptyping() +-- context.popcatcodes() +-- end +-- +-- local function s_tocontext(first,second,...) -- we need to catch {\} +-- context.type() +-- context("{") +-- context.pushcatcodes("verbatim") +-- if second then +-- context(concat({ first, second, ... }, " ")) +-- else +-- context(first) -- no need to waste a { } +-- end +-- context.popcatcodes() +-- context("}") +-- end + +local t_buffer = { "t_o_c_o_n_t_e_x_t" } +local t_typing = { "typing" } +local t_type = { "type" } + +local function flush(s,inline) + assignbuffer("t_o_c_o_n_t_e_x_t",s) + context[inline and "typeinlinebuffer" or "typebuffer"](t_buffer) + context.resetbuffer(t_buffer) end -local function s_tocontext(first,...) -- we need to catch {\} - context.type() - context("{") - context.pushcatcodes("verbatim") - if first then - context(first) -- no need to waste a { } - else - context(concat({first,...}," ")) - end - context.popcatcodes() - context("}") +local function t_tocontext(t) + local s = table.serialize(t) + context(function() flush(s,false) end) +end + +local function s_tocontext(first,second,...) -- we need to catch {\} + local s = second and concat({ first, second, ... }, " ") or first + context(function() flush(s,true) end) end local function b_tocontext(b) @@ -74,15 +111,3 @@ end) context.tocontext = tocontext -context.tobuffer = buffers.assign -- (name,str,catcodes) - -function context.tolines(str,strip) - local lines = type(str) == "string" and splitlines(str) or str - for i=1,#lines do - if strip then - context(strip(lines[i]) .. " ") - else - context(lines[i] .. " ") - end - end -end diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 277666af1..e2e0376c8 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.07.06 19:07} +\newcontextversion{2018.07.10 15:52} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. @@ -20,8 +20,22 @@ \writestatus\m!system{beware: some patches loaded from cont-new.mkiv} +% math-ini.mkiv + \ifnum\texenginefunctionality<6753\else \mathrulethicknessmode\zerocount \fi +% math-ini.mkiv + +\ifdefined\t \else \unexpanded\def\t{\mathortext\text\mathtext} \fi +\ifdefined\w \else \unexpanded\def\w{\mathortext\word\mathword} \fi + +\appendtoks + \let\t\mathtext + \let\w\mathword +\to \everymathematics + +% done + \protect \endinput diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 523af7cde..5407da02a 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.07.06 19:07} +\edef\contextversion{2018.07.10 15:52} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index ce37c7c62..dd57c9dfa 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -1941,8 +1941,10 @@ function figures.getinfo(name,page) end if name.name then local data = figures.push(name) - figures.identify() - figures.check() + data = figures.identify(data) + if data.status and data.status.status > 0 then + data = figures.check(data) + end figures.pop() return data end diff --git a/tex/context/base/mkiv/meta-blb.lua b/tex/context/base/mkiv/meta-blb.lua index 639e22052..76e9e3362 100644 --- a/tex/context/base/mkiv/meta-blb.lua +++ b/tex/context/base/mkiv/meta-blb.lua @@ -87,20 +87,20 @@ local function blob_raw_wipe(i) allblobs[i] = false end -mp.blob_raw_dimensions = blob_raw_dimensions -mp.blob_raw_content = blob_raw_content -mp.blob_raw_reset = blob_raw_reset -mp.blob_raw_wipe = blob_raw_wipe -mp.blob_raw_toutf = blob_raw_toutf +mp.mf_blob_raw_dimensions = blob_raw_dimensions +mp.mf_blob_raw_content = blob_raw_content +mp.mf_blob_raw_reset = blob_raw_reset +mp.mf_blob_raw_wipe = blob_raw_wipe +mp.mf_blob_raw_toutf = blob_raw_toutf -function mp.blob_new(category,text) +function mp.mf_blob_new(category,text) if trace then report("category %a, text %a",category,text) end texblobs[category].text = text end -function mp.blob_add(category,blob) +function mp.mf_blob_add(category,blob) local tb = texblobs[category].blobs local tn = #allblobs + 1 blob = hpack_nodes(blob) @@ -111,7 +111,7 @@ function mp.blob_add(category,blob) end end -function mp.blob_width(category,i) +function mp.mf_blob_width(category,i) local index = texblobs[category].blobs[i] local blob = allblobs[index] if blob then @@ -121,15 +121,15 @@ function mp.blob_width(category,i) end end -function mp.blob_size(category,i) +function mp.mf_blob_size(category,i) mpprint(#texblobs[category].blobs or 0) end -function mp.blob_index(category,i) +function mp.mf_blob_index(category,i) mpprint(texblobs[category].blobs[i] or 0) end -function mp.blob_dimensions(category,i) +function mp.mf_blob_dimensions(category,i) local index = texblobs[category].blobs[i] local blob = allblobs[index] if blob then @@ -163,7 +163,7 @@ local function injectblob(object,blob) end end -mp.blob_inject = injectblob +-- mp.mf_blob_inject = injectblob local function getblob(box,blob) texsetbox(box,blob_raw_content(blob)) @@ -221,8 +221,8 @@ local flatten_list = node.flatten_discretionaries local remove_node = nodes.remove local flush_node = nodes.flush -local addblob = mp.blob_add -local newblob = mp.blob_new +local addblob = mp.mf_blob_add +local newblob = mp.mf_blob_new local visible_code = { [nodecodes.glyph] = true, @@ -291,7 +291,7 @@ local ft_reset, ft_analyze, ft_process do local mp_category = 0 local mp_str = "" - function mp.InjectBlobB(category,str) + function mp.mf_inject_blob(category,str) newblob(category,str) -- only for tracing mp_category = category mp_str = str diff --git a/tex/context/base/mkiv/meta-ini.lua b/tex/context/base/mkiv/meta-ini.lua index 6c4768671..f320efe20 100644 --- a/tex/context/base/mkiv/meta-ini.lua +++ b/tex/context/base/mkiv/meta-ini.lua @@ -117,23 +117,23 @@ do local data = false - function mp.start_saving_data(n) + function mp.mf_start_saving_data(n) data = { } end - function mp.stop_saving_data() + function mp.mf_stop_saving_data() if data then -- nothing end end - function mp.finish_saving_data() + function mp.mf_finish_saving_data() if data then -- nothing end end - function mp.save_data(str) + function mp.mf_save_data(str) if data then data[#data+1] = str end diff --git a/tex/context/base/mkiv/meta-nod.lua b/tex/context/base/mkiv/meta-nod.lua index 119c276e2..422b4ee14 100644 --- a/tex/context/base/mkiv/meta-nod.lua +++ b/tex/context/base/mkiv/meta-nod.lua @@ -6,24 +6,76 @@ if not modules then modules = { } end modules ['meta-nod'] = { license = "see context related readme files" } +local tonumber = tonumber +local P, R, Cs, lpegmatch = lpeg.P, lpeg.R, lpeg.Cs, lpeg.match + local references = { } +local trace = false +local report = logs.reporter("metapost","nodes") -metapost.nodes = { +local context = context +local implement = interfaces.implement - initialize = function() - references = { } - end, +trackers.register("metapost.nodes", function(v) trace = v end) - register = function(s,r) - references[s] = r - end, +local word = R("AZ","az","__")^1 - resolve = function(s) - context(references[s] or ("\\number " .. (tonumber(s) or 0))) - end, +local pattern = Cs ( + ( + word / function(s) return references[s] or s end + + P("{") / "[" + + P("}") / "]" + + P(1) + )^1 +) + +implement { + name = "grph_nodes_initialize", + actions = function() + references = { } + end +} - reset = function() +implement { + name = "grph_nodes_reset", + actions = function() references = { } - end, + end +} + +implement { + name = "grph_nodes_register", + arguments = { "string", "integer" }, + actions = function(s,r) + if not tonumber(s) then + if trace then + report("register %i as %a",t,s) + end + references[s] = r + end + end +} +implement { + name = "grph_nodes_resolve", + arguments = "string", + actions = function(s) + local r = references[s] + if r then + if trace then + report("resolve %a to %i",s,r) + end + context(r) + return + end + local n = lpegmatch(pattern,s) + if s ~= n then + if trace then + report("resolve '%s' to %s",s,n) + end + context(n) + return + end + context(s) + end } diff --git a/tex/context/base/mkiv/meta-nod.mkiv b/tex/context/base/mkiv/meta-nod.mkiv index bf36e315c..9f966349c 100644 --- a/tex/context/base/mkiv/meta-nod.mkiv +++ b/tex/context/base/mkiv/meta-nod.mkiv @@ -110,6 +110,8 @@ %D Hm, we started out simple but it now quickly becomes the usual mess of %D \TEX, \METAPOST\ and \LUA. Hard to understand. +\newcount\c_meta_nodes_n + \unexpanded\def\startnodes {\dosingleempty\meta_nodes_start} @@ -121,11 +123,12 @@ \edef\p_meta_option{\metanodesparameter\c!option}% \edef\p_meta_alternative{\metanodesparameter\c!alternative}% \the\t_every_meta_nodes + \c_meta_nodes_n\zerocount \t_meta_nodes\emptytoks #2\removeunwantedspaces % for alan, will be commented: \writestatus{metanodes}{\detokenize\expandafter{\the\t_meta_nodes}}% - \ctxlua{metapost.nodes.initialize()}% + \clf_grph_nodes_initialize \startMPcode mfun_node_init(% \the\dimexpr\metanodesparameter\c!dx\relax,% @@ -135,7 +138,7 @@ \the\t_meta_nodes ; mfun_node_flush ; \stopMPcode - \ctxlua{metapost.nodes.reset()}% + \clf_grph_nodes_reset \egroup} \unexpanded\def\grph_nodes_node @@ -149,10 +152,10 @@ \ifsecondargument \setupcurrentmetanodes[#3]% \fi - \edef\p_label {#4}% + \edef\p_label{#4}% \edef\p_reference{\metanodesparameter\c!reference}% \ifx\p_reference\empty\else - \ctxlua{metapost.nodes.register("\p_reference",\number#1)}% + \clf_grph_nodes_register{\p_reference}\c_meta_nodes_n\relax \fi \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{% mfun_node_make(\number#1,\number#2% @@ -162,7 +165,8 @@ ,"\metanodesparameter\c!command{\p_label}"% \fi );% - }}} + }}% + \advance\c_meta_nodes_n\plusone} \appendtoks \let\placenode\grph_nodes_node @@ -210,7 +214,7 @@ mfun_nodes_fromto\begincsname\??metanodesposition\metanodesparameter\c!position\endcsname(% \metanodesparameter\c!offset,% % \number#1,\number#2% - \ctxlua{metapost.nodes.resolve("#1")},\ctxlua{metapost.nodes.resolve("#2")}% + \clf_grph_nodes_resolve{#1},\clf_grph_nodes_resolve{#2}% \ifx\p_label\empty ,""% \else diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua index 5d0ab1ab6..785d3c947 100644 --- a/tex/context/base/mkiv/mlib-lua.lua +++ b/tex/context/base/mkiv/mlib-lua.lua @@ -28,121 +28,16 @@ local trace_enabled = true local be_tolerant = true directives.register("metapost.lua.tolerant", function(v) be_tolerant = v end) -mp = mp or { } -- system namespace -MP = MP or { } -- user namespace +local get, set, aux = { }, { }, { } -local buffer = { } -local n = 0 -local max = 20 -- we reuse upto max -local nesting = 0 - -function mp._f_() - if trace_enabled and trace_luarun then - local result = concat(buffer," ",1,n) - if n > max then - buffer = { } - end - n = 0 - report_luarun("%i: data: %s",nesting,result) - return result - else - if n == 0 then - return "" - end - local result - if n == 1 then - result = buffer[1] - else - result = concat(buffer," ",1,n) - end - if n > max then - buffer = { } - end - n = 0 - return result - end -end - -local f_code = formatters["%s return mp._f_()"] - -local f_integer = formatters["%i"] - --- local f_numeric = formatters["%.16f"] --- local f_pair = formatters["(%.16f,%.16f)"] --- local f_triplet = formatters["(%.16f,%.16f,%.16f)"] --- local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"] - -local f_numeric = formatters["%n"] -local f_pair = formatters["(%n,%n)"] -local f_ctrl = formatters["(%n,%n) .. controls (%n,%n) and (%n,%n)"] -local f_triplet = formatters["(%n,%n,%n)"] -local f_quadruple = formatters["(%n,%n,%n,%n)"] - -local f_points = formatters["%p"] -local f_pair_pt = formatters["(%p,%p)"] -local f_ctrl_pt = formatters["(%p,%p) .. controls (%p,%p) and (%p,%p)"] -local f_triplet_pt = formatters["(%p,%p,%p)"] -local f_quadruple_pt = formatters["(%p,%p,%p,%p)"] - -local function mpprint(...) -- we can optimize for n=1 - for i=1,select("#",...) do - local value = select(i,...) - if value ~= nil then - n = n + 1 - local t = type(value) - if t == "number" then - buffer[n] = f_numeric(value) - elseif t == "string" then - buffer[n] = value - elseif t == "table" then - buffer[n] = "(" .. concat(value,",") .. ")" - else -- boolean or whatever - buffer[n] = tostring(value) - end - end - end -end - -local r = P('%') / "percent" - + P('"') / "dquote" - + P('\n') / "crlf" - -- + P(' ') / "space" -local a = Cc("&") -local q = Cc('"') -local p = Cs(q * (r * a)^-1 * (a * r * (P(-1) + a) + P(1))^0 * q) - -local function mpvprint(...) -- variable print - for i=1,select("#",...) do - local value = select(i,...) - if value ~= nil then - n = n + 1 - local t = type(value) - if t == "number" then - buffer[n] = f_numeric(value) - elseif t == "string" then - buffer[n] = lpegmatch(p,value) - elseif t == "table" then - local m = #t - if m == 2 then - buffer[n] = f_pair(unpack(t)) - elseif m == 3 then - buffer[n] = f_triplet(unpack(t)) - elseif m == 4 then - buffer[n] = f_quadruple(unpack(t)) - else -- error - buffer[n] = "" - end - else -- boolean or whatever - buffer[n] = tostring(value) - end - end - end -end - -mp.cleaned = function(s) return lpegmatch(p,s) or s end +mp = mp or { -- system namespace + set = set, + get = get, + aux = aux, +} -mp.print = mpprint -mp.vprint = mpvprint +MP = MP or { -- user namespace +} -- We had this: -- @@ -157,238 +52,486 @@ mp.vprint = mpvprint -- lua.mp("somedefdname","foo") table.setmetatablecall(mp,function(t,k,...) return t[k](...) end) +table.setmetatablecall(MP,function(t,k,...) return t[k](...) end) -function mp.boolean(b) - n = n + 1 - buffer[n] = b and "true" or "false" -end - -function mp.numeric(f) - n = n + 1 - buffer[n] = f and f_numeric(f) or "0" -end +do -function mp.integer(i) - n = n + 1 - -- buffer[n] = i and f_integer(i) or "0" - buffer[n] = i or "0" -end + local currentmpx = nil + local stack = { } -function mp.points(i) - n = n + 1 - buffer[n] = i and f_points(i) or "0pt" -end + local get_numeric = mplib.get_numeric + local get_string = mplib.get_string + local get_boolean = mplib.get_boolean + local get_path = mplib.get_path + local set_path = mplib.set_path -function mp.pair(x,y) - n = n + 1 - if type(x) == "table" then - buffer[n] = f_pair(x[1],x[2]) - else - buffer[n] = f_pair(x,y) - end -end + get.numeric = function(s) return get_numeric(currentmpx,s) end + get.string = function(s) return get_string (currentmpx,s) end + get.boolean = function(s) return get_boolean(currentmpx,s) end + get.path = function(s) return get_path (currentmpx,s) end + get.number = function(s) return get_numeric(currentmpx,s) end -function mp.pairpoints(x,y) - n = n + 1 - if type(x) == "table" then - buffer[n] = f_pair_pt(x[1],x[2]) - else - buffer[n] = f_pair_pt(x,y) - end -end + set.path = function(s,t) return set_path(currentmpx,s,t) end -- not working yet -function mp.triplet(x,y,z) - n = n + 1 - if type(x) == "table" then - buffer[n] = f_triplet(x[1],x[2],x[3]) - else - buffer[n] = f_triplet(x,y,z) + function metapost.pushscriptrunner(mpx) + insert(stack,mpx) + currentmpx = mpx end -end -function mp.tripletpoints(x,y,z) - n = n + 1 - if type(x) == "table" then - buffer[n] = f_triplet_pt(x[1],x[2],x[3]) - else - buffer[n] = f_triplet_pt(x,y,z) + function metapost.popscriptrunner() + currentmpx = remove(stack,mpx) end -end -function mp.quadruple(w,x,y,z) - n = n + 1 - if type(w) == "table" then - buffer[n] = f_quadruple(w[1],w[2],w[3],w[4]) - else - buffer[n] = f_quadruple(w,x,y,z) - end end -function mp.quadruplepoints(w,x,y,z) - n = n + 1 - if type(w) == "table" then - buffer[n] = f_quadruple_pt(w[1],w[2],w[3],w[4]) - else - buffer[n] = f_quadruple_pt(w,x,y,z) - end -end +do -local function mppath(f2,f6,t,connector,cycle) - if type(t) == "table" then - local tn = #t - if tn > 0 then - if connector == true then - connector = "--" - cycle = true - elseif not connector then - connector = "--" + local buffer = { } + local n = 0 + local max = 20 -- we reuse upto max + local nesting = 0 + local runs = 0 + + local function _f_() + if trace_enabled and trace_luarun then + local result = concat(buffer," ",1,n) + if n > max then + buffer = { } end - local ti = t[1] - n = n + 1 ; - if #ti == 6 then - local tn = t[2] or t[1] - buffer[n] = f6(ti[1],ti[2],ti[5],ti[6],tn[3],tn[4]) + n = 0 + report_luarun("%i: data: %s",nesting,result) + return result + else + if n == 0 then + return "" + end + local result + if n == 1 then + result = buffer[1] else - buffer[n] = f2(ti[1],ti[2]) + result = concat(buffer," ",1,n) end - for i=2,tn do - local ti = t[i] - n = n + 1 ; buffer[n] = connector - n = n + 1 ; - if #ti == 6 and (i < tn or cycle) then - local tn = t[i+1] or t[1] - buffer[n] = f6(ti[1],ti[2],ti[5],ti[6],tn[3],tn[4]) - else - buffer[n] = f2(ti[1],ti[2]) + if n > max then + buffer = { } + end + n = 0 + return result + end + end + + mp._f_ = _f_ -- convenient to have it in a top module + aux.flush = _f_ + + local f_code = formatters["%s return mp._f_()"] + + local f_integer = formatters["%i"] + -- local f_numeric = formatters["%.16f"] + -- local f_pair = formatters["(%.16f,%.16f)"] + -- local f_triplet = formatters["(%.16f,%.16f,%.16f)"] + -- local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"] + + -- %N + + local f_numeric = formatters["%n"] + local f_pair = formatters["(%n,%n)"] + local f_ctrl = formatters["(%n,%n) .. controls (%n,%n) and (%n,%n)"] + local f_triplet = formatters["(%n,%n,%n)"] + local f_quadruple = formatters["(%n,%n,%n,%n)"] + + local f_points = formatters["%p"] + local f_pair_pt = formatters["(%p,%p)"] + local f_ctrl_pt = formatters["(%p,%p) .. controls (%p,%p) and (%p,%p)"] + local f_triplet_pt = formatters["(%p,%p,%p)"] + local f_quadruple_pt = formatters["(%p,%p,%p,%p)"] + + local r = P('%') / "percent" + + P('"') / "dquote" + + P('\n') / "crlf" + -- + P(' ') / "space" + local a = Cc("&") + local q = Cc('"') + local p = Cs(q * (r * a)^-1 * (a * r * (P(-1) + a) + P(1))^0 * q) + + mp.cleaned = function(s) return lpegmatch(p,s) or s end + + local function mpprint(...) -- we can optimize for n=1 + for i=1,select("#",...) do + local value = select(i,...) + if value ~= nil then + n = n + 1 + local t = type(value) + if t == "number" then + buffer[n] = f_numeric(value) + elseif t == "string" then + buffer[n] = value + elseif t == "table" then + buffer[n] = "(" .. concat(value,",") .. ")" + else -- boolean or whatever + buffer[n] = tostring(value) end end - if cycle then - n = n + 1 ; buffer[n] = connector - n = n + 1 ; buffer[n] = "cycle" + end + end + + local function mpvprint(...) -- variable print + for i=1,select("#",...) do + local value = select(i,...) + if value ~= nil then + n = n + 1 + local t = type(value) + if t == "number" then + buffer[n] = f_numeric(value) + elseif t == "string" then + buffer[n] = lpegmatch(p,value) + elseif t == "table" then + local m = #t + if m == 2 then + buffer[n] = f_pair(unpack(t)) + elseif m == 3 then + buffer[n] = f_triplet(unpack(t)) + elseif m == 4 then + buffer[n] = f_quadruple(unpack(t)) + else -- error + buffer[n] = "" + end + else -- boolean or whatever + buffer[n] = tostring(value) + end end end end -end -function mp.path(...) - mppath(f_pair,f_ctrl,...) -end + local function mpboolean(b) + n = n + 1 + buffer[n] = b and "true" or "false" + end -function mp.pathpoints(...) - mppath(f_pair_pt,f_ctrl_pt,...) -end + local function mpnumeric(f) + n = n + 1 + buffer[n] = f and f_numeric(f) or "0" + end + local function mpinteger(i) + n = n + 1 + -- buffer[n] = i and f_integer(i) or "0" + buffer[n] = i or "0" + end -function mp.pathpoints(t,connector,cycle) - if type(t) == "table" then - local tn = #t - if tn > 0 then - if connector == true then - connector = "--" - cycle = true - elseif not connector then - connector = "--" - end - local ti = t[1] - n = n + 1 ; - if #ti == 6 then - buffer[n] = f_pair_pt_ctrl(ti[1],ti[2],ti[3],ti[4],ti[5],ti[6]) - else - buffer[n] = f_pair_pt(ti[1],ti[2]) - end - for i=2,tn do - local ti = t[i] - n = n + 1 ; buffer[n] = connector + local function mppoints(i) + n = n + 1 + buffer[n] = i and f_points(i) or "0pt" + end + + local function mppair(x,y) + n = n + 1 + if type(x) == "table" then + buffer[n] = f_pair(x[1],x[2]) + else + buffer[n] = f_pair(x,y) + end + end + + local function mppairpoints(x,y) + n = n + 1 + if type(x) == "table" then + buffer[n] = f_pair_pt(x[1],x[2]) + else + buffer[n] = f_pair_pt(x,y) + end + end + + local function mptriplet(x,y,z) + n = n + 1 + if type(x) == "table" then + buffer[n] = f_triplet(x[1],x[2],x[3]) + else + buffer[n] = f_triplet(x,y,z) + end + end + + local function mptripletpoints(x,y,z) + n = n + 1 + if type(x) == "table" then + buffer[n] = f_triplet_pt(x[1],x[2],x[3]) + else + buffer[n] = f_triplet_pt(x,y,z) + end + end + + local function mpquadruple(w,x,y,z) + n = n + 1 + if type(w) == "table" then + buffer[n] = f_quadruple(w[1],w[2],w[3],w[4]) + else + buffer[n] = f_quadruple(w,x,y,z) + end + end + + local function mpquadruplepoints(w,x,y,z) + n = n + 1 + if type(w) == "table" then + buffer[n] = f_quadruple_pt(w[1],w[2],w[3],w[4]) + else + buffer[n] = f_quadruple_pt(w,x,y,z) + end + end + + -- local function mp_path(f2,f6,t,connector,cycle) + -- if type(t) == "table" then + -- local tn = #t + -- if tn > 0 then + -- if connector == true then + -- connector = "--" + -- cycle = true + -- elseif not connector then + -- connector = "--" + -- end + -- local ti = t[1] + -- n = n + 1 ; + -- if #ti == 6 then + -- local tn = t[2] or t[1] + -- buffer[n] = f6(ti[1],ti[2],ti[5],ti[6],tn[3],tn[4]) + -- else + -- buffer[n] = f2(ti[1],ti[2]) + -- end + -- for i=2,tn do + -- local ti = t[i] + -- n = n + 1 ; buffer[n] = connector + -- n = n + 1 ; + -- if #ti == 6 and (i < tn or cycle) then + -- local tn = t[i+1] or t[1] + -- buffer[n] = f6(ti[1],ti[2],ti[5],ti[6],tn[3],tn[4]) + -- else + -- buffer[n] = f2(ti[1],ti[2]) + -- end + -- end + -- if cycle then + -- n = n + 1 ; buffer[n] = connector + -- n = n + 1 ; buffer[n] = "cycle" + -- end + -- end + -- end + -- end + + local function mp_path(f2,f6,t,connector,cycle) + if type(t) == "table" then + local tn = #t + if tn > 0 then + if connector == true then + connector = "--" + cycle = true + elseif not connector then + connector = "--" + end + local ti = t[1] n = n + 1 ; if #ti == 6 then - buffer[n] = f_pair_pt_ctrl(ti[1],ti[2],ti[3],ti[4],ti[5],ti[6]) + buffer[n] = f6(ti[1],ti[2],ti[3],ti[4],ti[5],ti[6]) else - buffer[n] = f_pair_pt(ti[1],ti[2]) + buffer[n] = f2(ti[1],ti[2]) + end + for i=2,tn do + local ti = t[i] + n = n + 1 ; buffer[n] = connector + n = n + 1 ; + if #ti == 6 then + buffer[n] = f6(ti[1],ti[2],ti[3],ti[4],ti[5],ti[6]) + else + buffer[n] = f2(ti[1],ti[2]) + end + end + if cycle then + n = n + 1 ; buffer[n] = connector + n = n + 1 ; buffer[n] = "cycle" end - end - if cycle then - n = n + 1 ; buffer[n] = connector - n = n + 1 ; buffer[n] = "cycle" end end end -end -function mp.size(t) - n = n + 1 - buffer[n] = type(t) == "table" and f_numeric(#t) or "0" -end + local function mppath(...) + mp_path(f_pair,f_pair_ctrl,...) + end -local mpnamedcolor = attributes.colors.mpnamedcolor + local function mppathpoints(...) + mp_path(f_pair_pt,f_pair_pt_ctrl,...) + end -mp.NamedColor = function(str) - mpprint(mpnamedcolor(str)) -end + local function mpsize(t) + n = n + 1 + buffer[n] = type(t) == "table" and f_numeric(#t) or "0" + end --- experiment: names can change + local replacer = lpeg.replacer("@","%%") + + local function mpfprint(fmt,...) + n = n + 1 + if not find(fmt,"%",1,true) then + fmt = lpegmatch(replacer,fmt) + end + buffer[n] = formatters[fmt](...) + end -local datasets = { } -mp.datasets = datasets + local function mpquoted(fmt,s,...) + n = n + 1 + if s then + if not find(fmt,"%",1,true) then + fmt = lpegmatch(replacer,fmt) + end + -- buffer[n] = '"' .. formatters[fmt](s,...) .. '"' + buffer[n] = lpegmatch(p,formatters[fmt](s,...)) + elseif fmt then + -- buffer[n] = '"' .. fmt .. '"' + buffer[n] = lpegmatch(p,fmt) + else + -- something is wrong + end + end -function datasets.load(tag,filename) - if not filename then - tag, filename = file.basename(tag), tag + aux.print = mpprint + aux.vprint = mpvprint + aux.boolean = mpboolean + aux.numeric = mpnumeric + aux.number = mpnumeric + aux.integer = mpinteger + aux.points = mppoints + aux.pair = mppair + aux.pairpoints = mppairpoints + aux.triplet = mptriplet + aux.tripletpoints = mptripletpoints + aux.quadruple = mpquadruple + aux.quadruplepoints = mpquadruplepoints + aux.path = mppath + aux.pathpoints = mppathpoints + aux.size = mpsize + aux.fprint = mpfprint + aux.quoted = mpquoted + + -- we need access to the variables + + function metapost.nofscriptruns() + return runs + end + + -- there is no gain in: + -- + -- local cache = table.makeweak() + -- + -- f = cache[code] + -- if not f then + -- f = loadstring(f_code(code)) + -- if f then + -- cache[code] = f + -- elseif be_tolerant then + -- f = loadstring(code) + -- if f then + -- cache[code] = f + -- end + -- end + -- end + + function metapost.runscript(code) + nesting = nesting + 1 + local trace = trace_enabled and trace_luarun + if trace then + report_luarun("%i: code: %s",nesting,code) + end + runs = runs + 1 + local f = loadstring(f_code(code)) + if not f and be_tolerant then + f = loadstring(code) + end + if f then + local _buffer_, _n_ = buffer, n + buffer, n = { }, 0 + local result = f() + if result then + local t = type(result) + if t == "number" then + result = f_numeric(result) + elseif t ~= "string" then + result = tostring(result) + end + if trace then + if #result == 0 then + report_luarun("%i: no result",nesting) +-- print(debug.traceback()) + else + report_luarun("%i: result: %s",nesting,result) + end + end + buffer, n = _buffer_, _n_ + nesting = nesting - 1 + return result + elseif trace then + report_luarun("%i: no result",nesting) +-- print(debug.traceback()) + end + buffer, n = _buffer_, _n_ + else + report_luarun("%i: no result, invalid code: %s",nesting,code) + end + nesting = nesting - 1 + return "" end - local data = mp.dataset(io.loaddata(filename) or "") - datasets[tag] = { - Data = data, - Line = function(n) mp.path(data[n or 1]) end, - Size = function() mp.size(data) end, - } -end --- + -- for the moment -local replacer = lpeg.replacer("@","%%") + for k, v in next, aux do mp[k] = v end -function mp.fprint(fmt,...) - n = n + 1 - if not find(fmt,"%",1,true) then - fmt = lpegmatch(replacer,fmt) - end - buffer[n] = formatters[fmt](...) end -local function mpquoted(fmt,s,...) - n = n + 1 - if s then - if not find(fmt,"%",1,true) then - fmt = lpegmatch(replacer,fmt) - end - -- buffer[n] = '"' .. formatters[fmt](s,...) .. '"' - buffer[n] = lpegmatch(p,formatters[fmt](s,...)) - elseif fmt then - -- buffer[n] = '"' .. fmt .. '"' - buffer[n] = lpegmatch(p,fmt) - else - -- something is wrong +do + + local mpnamedcolor = attributes.colors.mpnamedcolor + local mpprint = aux.print + + mp.mf_named_color = function(str) + mpprint(mpnamedcolor(str)) end -end -mp.quoted = mpquoted +end -function mp.n(t) +function mp.n(t) -- used ? return type(t) == "table" and #t or 0 end -local whitespace = lpegpatterns.whitespace -local newline = lpegpatterns.newline -local setsep = newline^2 -local comment = (S("#%") + P("--")) * (1-newline)^0 * (whitespace - setsep)^0 -local value = (1-whitespace)^1 / tonumber -local entry = Ct( value * whitespace * value) -local set = Ct((entry * (whitespace-setsep)^0 * comment^0)^1) -local series = Ct((set * whitespace^0)^1) +do + + -- experiment: names can change + + local mppath = aux.mppath + local mpsize = aux.mpsize -local pattern = whitespace^0 * series + local whitespace = lpegpatterns.whitespace + local newline = lpegpatterns.newline + local setsep = newline^2 + local comment = (S("#%") + P("--")) * (1-newline)^0 * (whitespace - setsep)^0 + local value = (1-whitespace)^1 / tonumber + local entry = Ct( value * whitespace * value) + local set = Ct((entry * (whitespace-setsep)^0 * comment^0)^1) + local series = Ct((set * whitespace^0)^1) + + local pattern = whitespace^0 * series + + local datasets = { } + mp.datasets = datasets + + function mp.dataset(str) + return lpegmatch(pattern,str) + end + + function datasets.load(tag,filename) + if not filename then + tag, filename = file.basename(tag), tag + end + local data = lpegmatch(pattern,io.loaddata(filename) or "") + datasets[tag] = { + Data = data, + Line = function(n) mppath(data[n or 1]) end, + Size = function() mpsize(data) end, + } + end -function mp.dataset(str) - return lpegmatch(pattern,str) end -- \startluacode @@ -420,269 +563,183 @@ end -- endfor ; -- \stopMPpage -local runs = 0 - -function metapost.nofscriptruns() - return runs -end - --- there is no gain in: --- --- local cache = table.makeweak() --- --- f = cache[code] --- if not f then --- f = loadstring(f_code(code)) --- if f then --- cache[code] = f --- elseif be_tolerant then --- f = loadstring(code) --- if f then --- cache[code] = f --- end --- end --- end - -function metapost.runscript(code) - nesting = nesting + 1 - local trace = trace_enabled and trace_luarun - if trace then - report_luarun("%i: code: %s",nesting,code) - end - runs = runs + 1 - local f = loadstring(f_code(code)) - if not f and be_tolerant then - f = loadstring(code) - end - if f then - local _buffer_, _n_ = buffer, n - buffer, n = { }, 0 - local result = f() - if result then - local t = type(result) - if t == "number" then - result = f_numeric(result) - elseif t ~= "string" then - result = tostring(result) - end - if trace then - if #result == 0 then - report_luarun("%i: no result",nesting) - else - report_luarun("%i: result: %s",nesting,result) - end - end - buffer, n = _buffer_, _n_ - nesting = nesting - 1 - return result - elseif trace then - report_luarun("%i: no result",nesting) - end - buffer, n = _buffer_, _n_ - else - report_luarun("%i: no result, invalid code: %s",nesting,code) - end - nesting = nesting - 1 - return "" -end +-- texts: do - local get_numeric = mplib.get_numeric - local get_string = mplib.get_string - local get_boolean = mplib.get_boolean - local get_path = mplib.get_path - local get_number = get_numeric + local mptriplet = mp.triplet - local set_path = mplib.set_path + local bpfactor = number.dimenfactors.bp + local textexts = nil + local mptriplet = mp.triplet + local nbdimensions = nodes.boxes.dimensions - local currentmpx = nil - local stack = { } - local getters = { } - local setters = { } - - getters.numeric = function(s) return get_numeric(currentmpx,s) end - getters.string = function(s) return get_string (currentmpx,s) end - getters.boolean = function(s) return get_boolean(currentmpx,s) end - getters.path = function(s) return get_path (currentmpx,s) end - getters.number = mp.numeric - - setters.path = function(s,t) return set_path(currentmpx,s,t) end + function mp.mf_tt_initialize(tt) + textexts = tt + end - function metapost.pushscriptrunner(mpx) - insert(stack,mpx) - currentmpx = mpx + function mp.mf_tt_dimensions(n) + local box = textexts and textexts[n] + if box then + -- could be made faster with nuts but not critical + mptriplet(box.width*bpfactor,box.height*bpfactor,box.depth*bpfactor) + else + mptriplet(0,0,0) + end end - function metapost.popscriptrunner() - currentmpx = remove(stack,mpx) + function mp.mf_tb_dimensions(category,name) + local w, h, d = nbdimensions(category,name) + mptriplet(w*bpfactor,h*bpfactor,d*bpfactor) end - mp.get = getters - mp.set = setters + function mp.report(a,b) + if b then + report_message("%s : %s",a,b) + elseif a then + report_message("%s : %s","message",a) + end + end end --- texts: +do -local factor = 65536*(7227/7200) -local textexts = nil -local mptriplet = mp.triplet -local nbdimensions = nodes.boxes.dimensions + local mpprint = aux.print + local mpvprint = aux.vprint -function mp.tt_initialize(tt) - textexts = tt -end + local hashes = { } --- function mp.tt_wd(n) --- local box = textexts and textexts[n] --- mpprint(box and box.width/factor or 0) --- end --- function mp.tt_ht(n) --- local box = textexts and textexts[n] --- mpprint(box and box.height/factor or 0) --- end --- function mp.tt_dp(n) --- local box = textexts and textexts[n] --- mpprint(box and box.depth/factor or 0) --- end - -function mp.tt_dimensions(n) - local box = textexts and textexts[n] - if box then - -- could be made faster with nuts but not critical - mptriplet(box.width/factor,box.height/factor,box.depth/factor) - else - mptriplet(0,0,0) + function mp.newhash() + for i=1,#hashes+1 do + if not hashes[i] then + hashes[i] = { } + mpvprint(i) + return + end + end end -end -function mp.tb_dimensions(category,name) - local w, h, d = nbdimensions(category,name) - mptriplet(w/factor,h/factor,d/factor) -end - -function mp.report(a,b) - if b then - report_message("%s : %s",a,b) - elseif a then - report_message("%s : %s","message",a) + function mp.disposehash(n) + hashes[n] = nil end -end - --- -local hashes = { } + function mp.inhash(n,key) + local h = hashes[n] + mpprint(h and h[key] and true or false) + end -function mp.newhash() - for i=1,#hashes+1 do - if not hashes[i] then - hashes[i] = { } - mpprint(i) - return + function mp.tohash(n,key) + local h = hashes[n] + if h then + h[key] = true end end -end -function mp.disposehash(n) - hashes[n] = nil end -function mp.inhash(n,key) - local h = hashes[n] - mpprint(h and h[key] and true or false) -end +do + + local mpprint = aux.print + local modes = tex.modes + local systemmodes = tex.systemmodes -function mp.tohash(n,key) - local h = hashes[n] - if h then - h[key] = true + function mp.mode(s) + mpprint(modes[s] and true or false) end -end -local modes = tex.modes -local systemmodes = tex.systemmodes + function mp.systemmode(s) + mpprint(systemmodes[s] and true or false) + end -function mp.mode(s) - mpprint(modes[s] and true or false) -end + mp.processingmode = mp.mode -function mp.systemmode(s) - mpprint(systemmodes[s] and true or false) end -- for alan's nodes: -function mp.isarray(str) - mpprint(find(str,"%d") and true or false) -end +do -function mp.prefix(str) - mpquoted(match(str,"^(.-)[%d%[]") or str) -end + local mpprint = aux.print + local mpquoted = aux.quoted + + function mp.isarray(str) + mpprint(find(str,"%d") and true or false) + end --- function mp.dimension(str) --- local n = 0 --- for s in gmatch(str,"%[?%-?%d+%]?") do --todo: lpeg --- n = n + 1 --- end --- mpprint(n) --- end + function mp.prefix(str) + mpquoted(match(str,"^(.-)[%d%[]") or str) + end -mp.dimension = lpeg.counter(P("[") * lpegpatterns.integer * P("]") + lpegpatterns.integer,mpprint) + -- function mp.dimension(str) + -- local n = 0 + -- for s in gmatch(str,"%[?%-?%d+%]?") do --todo: lpeg + -- n = n + 1 + -- end + -- mpprint(n) + -- end --- faster and okay as we don't have many variables but probably only --- basename makes sense and even then it's not called that often + mp.dimension = lpeg.counter(P("[") * lpegpatterns.integer * P("]") + lpegpatterns.integer,mpprint) --- local hash = table.setmetatableindex(function(t,k) --- local v = find(k,"%d") and true or false --- t[k] = v --- return v --- end) --- --- function mp.isarray(str) --- mpprint(hash[str]) --- end --- --- local hash = table.setmetatableindex(function(t,k) --- local v = '"' .. (match(k,"^(.-)%d") or k) .. '"' --- t[k] = v --- return v --- end) --- --- function mp.prefix(str) --- mpprint(hash[str]) --- end + -- faster and okay as we don't have many variables but probably only + -- basename makes sense and even then it's not called that often + + -- local hash = table.setmetatableindex(function(t,k) + -- local v = find(k,"%d") and true or false + -- t[k] = v + -- return v + -- end) + -- + -- function mp.isarray(str) + -- mpprint(hash[str]) + -- end + -- + -- local hash = table.setmetatableindex(function(t,k) + -- local v = '"' .. (match(k,"^(.-)%d") or k) .. '"' + -- t[k] = v + -- return v + -- end) + -- + -- function mp.prefix(str) + -- mpprint(hash[str]) + -- end + +end -local getdimen = tex.getdimen -local getcount = tex.getcount -local gettoks = tex.gettoks -local setdimen = tex.setdimen -local setcount = tex.setcount -local settoks = tex.settoks +do + + local getdimen = tex.getdimen + local getcount = tex.getcount + local gettoks = tex.gettoks + local setdimen = tex.setdimen + local setcount = tex.setcount + local settoks = tex.settoks -local mpprint = mp.print -local mpquoted = mp.quoted + local mpprint = mp.print + local mpquoted = mp.quoted -local factor = number.dimenfactors.bp + local bpfactor = number.dimenfactors.bp --- more helpers + -- more helpers -function mp.getdimen(k) mpprint (getdimen(k)*factor) end -function mp.getcount(k) mpprint (getcount(k)) end -function mp.gettoks (k) mpquoted(gettoks (k)) end -function mp.setdimen(k,v) setdimen(k,v/factor) end -function mp.setcount(k,v) setcount(k,v) end -function mp.settoks (k,v) settoks (k,v) end + function mp.getdimen(k) mpprint (getdimen(k)*bpfactor) end + function mp.getcount(k) mpprint (getcount(k)) end + function mp.gettoks (k) mpquoted(gettoks (k)) end --- def foo = lua.mp.foo ... enddef ; % loops due to foo in suffix + function mp.setdimen(k,v) setdimen(k,v/factor) end + function mp.setcount(k,v) setcount(k,v) end + function mp.settoks (k,v) settoks (k,v) end -mp._get_dimen_ = mp.getdimen -mp._get_count_ = mp.getcount -mp._get_toks_ = mp.gettoks -mp._set_dimen_ = mp.setdimen -mp._set_count_ = mp.setcount -mp._set_toks_ = mp.settoks + -- def foo = lua.mp.foo ... enddef ; % loops due to foo in suffix + + mp._get_dimen_ = mp.getdimen + mp._get_count_ = mp.getcount + mp._get_toks_ = mp.gettoks + mp._set_dimen_ = mp.setdimen + mp._set_count_ = mp.setcount + mp._set_toks_ = mp.settoks + +end -- position fun @@ -796,7 +853,7 @@ do local mpvprint = mp.vprint - local stores = { } + local stores = { } function mp.newstore(name) stores[name] = { } @@ -826,59 +883,50 @@ end do - local mpprint = mp.print - local texmodes = tex.modes - - function mp.processingmode(s) - mpprint(tostring(texmodes[s])) - end - -end - -do - -- a bit overkill: just a find(str,"mf_object=") can be enough - local p1 = P("mf_object=") - local p2 = lpeg.patterns.eol * p1 - local pattern = (1-p2)^0 * p2 + p1 + local mpboolean = aux.boolean + + local p1 = P("mf_object=") + local p2 = lpegpatterns.eol * p1 + local pattern = (1-p2)^0 * p2 + p1 function mp.isobject(str) - mp.boolean(pattern and str ~= "" and lpegmatch(p,str)) + mpboolean(pattern and str ~= "" and lpegmatch(p,str)) end end do - local mpnumeric = mp.numeric - local mppair = mp.pair - local mpgetpath = mp.get.path + local mpnumeric = aux.numeric + local mppair = aux.pair + local mpgetpath = get.path local p = nil local n = 0 - function mp.mfun_path_length(name) - p = mp.get.path(name) + local function mf_path_length(name) + p = mpgetpath(name) n = p and #p or 0 mpnumeric(n) end - function mp.mfun_path_point(i) + local function mf_path_point(i) if i > 0 and i <= n then local pi = p[i] mppair(pi[1],pi[2]) end end - function mp.mfun_path_left(i) + local function mf_path_left(i) if i > 0 and i <= n then local pi = p[i] mppair(pi[5],pi[6]) end end - function mp.mfun_path_right(i) + local function mf_path_right(i) if i > 0 and i <= n then local pn if i == 1 then @@ -890,9 +938,15 @@ do end end - function mp.mfun_path_reset() + local function mf_path_reset() p = nil n = 0 end + mp.mf_path_length = mf_path_length mp.pathlength = mf_path_length + mp.mf_path_point = mf_path_point mp.pathpoint = mf_path_point + mp.mf_path_left = mf_path_left mp.pathleft = mf_path_left + mp.mf_path_right = mf_path_right mp.pathright = mf_path_right + mp.mf_path_reset = mf_path_reset mp.pathreset = mf_path_reset + end diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 237efe901..39b80e344 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -101,16 +101,18 @@ local f_f3 = formatters["%.3F"] local f_gray = formatters["%.3F g %.3F G"] local f_rgb = formatters["%.3F %.3F %.3F rg %.3F %.3F %.3F RG"] local f_cmyk = formatters["%.3F %.3F %.3F %.3F k %.3F %.3F %.3F %.3F K"] -local f_cm = formatters["q %F %F %F %F %F %F cm"] +local f_cm_b = formatters["q %F %F %F %F %F %F cm"] local f_shade = formatters["MpSh%s"] +local s_cm_e = "Q" + directives.register("metapost.stripzeros",function() f_f = formatters["%N"] f_f3 = formatters["%.3N"] f_gray = formatters["%.3N g %.3N G"] f_rgb = formatters["%.3N %.3N %.3N rg %.3N %.3N %.3N RG"] f_cmyk = formatters["%.3N %.3N %.3N %.3N k %.3N %.3N %.3N %.3N K"] - f_cm = formatters["q %N %N %N %N %N %N cm"] + f_cm_b = formatters["q %N %N %N %N %N %N cm"] f_shade = formatters["MpSh%s"] end) @@ -606,7 +608,7 @@ function metapost.preparetextextsdata() end end end - mp.tt_initialize(collected) + mp.mf_tt_initialize(collected) end metapost.intermediate = metapost.intermediate or { } @@ -989,7 +991,7 @@ local function cm(object) if op then local first, second, fourth = op[1], op[2], op[4] if fourth then - local tx, ty = first.x_coord , first.y_coord + local tx, ty = first.x_coord, first.y_coord local sx, sy = second.x_coord - tx, fourth.y_coord - ty local rx, ry = second.y_coord - ty, fourth.x_coord - tx if sx == 0 then sx = 0.00001 end @@ -1095,7 +1097,7 @@ local tx_reset, tx_analyze, tx_process do end end - function mp.SomeText(index,str) + function mp.mf_some_text(index,str) mp_target = index mp_index = index mp_c = nil @@ -1111,8 +1113,8 @@ local tx_reset, tx_analyze, tx_process do local madetext = nil - function mp.MadeText(index) - mp.SomeText(index,madetext) + function mp.mf_made_text(index) + mp.mf_some_text(index,madetext) end function metapost.maketext(s,mode) @@ -1129,7 +1131,7 @@ local tx_reset, tx_analyze, tx_process do end end - function mp.SomeFormattedText(index,fmt,...) + function mp.mf_formatted_text(index,fmt,...) local t = { } for i=1,select("#",...) do local ti = select(i,...) @@ -1139,7 +1141,7 @@ local tx_reset, tx_analyze, tx_process do end local f = lpegmatch(cleaner,fmt) local s = formatters[f](unpack(t)) or "" - mp.SomeText(index,s) + mp.mf_some_text(index,s) end interfaces.implement { @@ -1433,7 +1435,7 @@ local gt_reset, gt_analyze, gt_process do function metapost.intermediate.actions.makempy() end - function mp.GraphicText(index,str) + function mp.mf_graphic_text(index,str) if not graphics[index] then mp_index = index mp_str = str @@ -1613,7 +1615,7 @@ end local function bm_process(object,prescript,before,after) local bm_xresolution = prescript.bm_xresolution if bm_xresolution then - before[#before+1] = f_cm(cm(object)) + before[#before+1] = f_cm_b(cm(object)) before[#before+1] = function() figures.bitmapimage { xresolution = tonumber(bm_xresolution), @@ -1623,7 +1625,7 @@ local function bm_process(object,prescript,before,after) data = object.postscript } end - before[#before+1] = "Q" + before[#before+1] = s_cm_e object.path = false object.color = false object.grouped = true @@ -1651,14 +1653,33 @@ end -- figures +-- local sx, rx, ry, sy, tx, ty = cm(object) +-- sxsy(box.width,box.height,box.depth)) + +function mp.mf_external_figure(filename) + local f = figures.getinfo(filename) + local w = 0 + local h = 0 + if f then + local u = f.used + if u and u.fullname then + w = u.width or 0 + h = u.height or 0 + end + else + report_metapost("external figure %a not found",filename) + end + mp.triplet(w/65536,h/65536,0) +end + local function fg_process(object,prescript,before,after) local fg_name = prescript.fg_name if fg_name then - before[#before+1] = f_cm(cm(object)) -- beware: does not use the cm stack + before[#before+1] = f_cm_b(cm(object)) -- beware: does not use the cm stack before[#before+1] = function() context.MPLIBfigure(fg_name,prescript.fg_mask or "") end - before[#before+1] = "Q" + before[#before+1] = s_cm_e object.path = false object.grouped = true end @@ -1835,7 +1856,7 @@ local ot_reset, ot_analyze, ot_process do local mp_kind = "" local mp_str = "" - function mp.OutlineText(index,str,kind) + function mp.mf_outline_text(index,str,kind) if not outlinetexts[index] then mp_index = index mp_kind = kind @@ -1879,7 +1900,7 @@ local ot_reset, ot_analyze, ot_process do end } - function mp.get_outline_text(index) -- maybe we need a more private namespace + function mp.mf_get_outline_text(index) -- maybe we need a more private namespace mp.print(outlinetexts[index] or "draw origin;") end diff --git a/tex/context/base/mkiv/mlib-pps.mkiv b/tex/context/base/mkiv/mlib-pps.mkiv index bc4ce5a04..051130585 100644 --- a/tex/context/base/mkiv/mlib-pps.mkiv +++ b/tex/context/base/mkiv/mlib-pps.mkiv @@ -78,10 +78,15 @@ {\clf_mpgettext\MPtextbox #1% \vpack to \zeropoint{\vss\hpack to \zeropoint{\scale[\c!sx=#2,\c!sy=#3]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}} +% \unexpanded\def\MPLIBfigure#1#2% +% {\setbox\scratchbox\hpack{\externalfigure[#1][\c!mask=#2]}% +% \clf_mpsetsxsy\wd\scratchbox\ht\scratchbox\zeropoint +% \vpack to \zeropoint{\vss\hpack to \zeropoint{\scale[\c!sx=\sx,\c!sy=\sy]{\box\scratchbox}\hss}}} + \unexpanded\def\MPLIBfigure#1#2% {\setbox\scratchbox\hpack{\externalfigure[#1][\c!mask=#2]}% \clf_mpsetsxsy\wd\scratchbox\ht\scratchbox\zeropoint - \vpack to \zeropoint{\vss\hpack to \zeropoint{\scale[\c!sx=\sx,\c!sy=\sy]{\box\scratchbox}\hss}}} + \vpack to \zeropoint{\vss\hpack to \zeropoint{\fastsxsy{\sx}{\sy}{\box\scratchbox}\hss}}} % horrible (we could inline scale and matrix code): diff --git a/tex/context/base/mkiv/mult-prm.mkiv b/tex/context/base/mkiv/mult-prm.mkiv index 3480cded5..5ffb84d38 100644 --- a/tex/context/base/mkiv/mult-prm.mkiv +++ b/tex/context/base/mkiv/mult-prm.mkiv @@ -68,7 +68,7 @@ "pdftracingfonts", "pdftrailer", "pdftrailerid", "pdfuniformdeviate", "pdfuniqueresname", "pdfvorigin", "pdfxform", "pdfxformattr", "pdfxformmargin", "pdfxformname", "pdfxformresources", "pdfximage", - "pdfomitcidset", + "pdfomitcidset", "pdfomitcharset", }, aleph = { -- we don't bother "Alephminorversion", "Alephrevision", "Alephversion", diff --git a/tex/context/base/mkiv/mult-sys.mkiv b/tex/context/base/mkiv/mult-sys.mkiv index 7000eed7b..22c14ff9c 100644 --- a/tex/context/base/mkiv/mult-sys.mkiv +++ b/tex/context/base/mkiv/mult-sys.mkiv @@ -240,6 +240,7 @@ \definesystemconstant {next} \definesystemconstant {pickup} +\definesystemconstant {forget} \definesystemconstant {ascii} \definesystemconstant {default} \definesystemconstant {unknown} diff --git a/tex/context/base/mkiv/page-ini.mkiv b/tex/context/base/mkiv/page-ini.mkiv index dc94edf76..1a9968759 100644 --- a/tex/context/base/mkiv/page-ini.mkiv +++ b/tex/context/base/mkiv/page-ini.mkiv @@ -256,7 +256,10 @@ \box\pagebox \egroup \ifconditional\c_page_boxes_save_page_body \copy\b_page_boxes_saved_page_body \fi} -\appendtoks \restoreglobalbodyfont \to \everybeforepagebody +\appendtoks + \restoreglobalbodyfont + \pickupattributes +\to \everybeforepagebody \ifdefined\nestednewbox \else \newbox\nestednextbox \fi % hm, still needed? diff --git a/tex/context/base/mkiv/scrp-ini.mkiv b/tex/context/base/mkiv/scrp-ini.mkiv index 8f28f505d..4567e6791 100644 --- a/tex/context/base/mkiv/scrp-ini.mkiv +++ b/tex/context/base/mkiv/scrp-ini.mkiv @@ -18,9 +18,9 @@ \registerctxluafile{scrp-eth}{} \registerctxluafile{scrp-tha}{} -\definesystemattribute[scriptinjection][public] -\definesystemattribute[scriptsplitting][public] -\definesystemattribute[scriptstatus] [public] +\definesystemattribute[scriptinjection][public,pickup] +\definesystemattribute[scriptsplitting][public,pickup] +\definesystemattribute[scriptstatus] [public,pickup] %D Since scripts need specific \LUA\ code we use hard coded attribute %D values, but we might have more tricks at some time, so we use a @@ -43,10 +43,23 @@ \unexpanded\def\scripts_basics_set {\clf_setscript{\currentscript}{\scriptparameter\c!method}{\scriptparameter\c!preset}} -\unexpanded\def\setscript[#1]% +% \unexpanded\def\setscript[#1]% +% {\edef\currentscript{#1}% +% \scripts_basics_set} + +\unexpanded\def\setglobalscript[#1]% + {\edef\currentscript{#1}% + \scripts_basics_set + \pickupscriptinjectionattribute + \pickupscriptsplittingattribute + \pickupscriptstatusattribute} + +\unexpanded\def\setlocalscript[#1]% {\edef\currentscript{#1}% \scripts_basics_set} +\let\setscript\setlocalscript + \unexpanded\def\resetscript {\clf_resetscript} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex d94a27382..72d03ba70 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 78ada2867..47a682ba6 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-not.mkvi b/tex/context/base/mkiv/strc-not.mkvi index e2c60d1b1..403247b9c 100644 --- a/tex/context/base/mkiv/strc-not.mkvi +++ b/tex/context/base/mkiv/strc-not.mkvi @@ -1057,18 +1057,6 @@ \newskip \s_strc_notes_distance % we need to implement stretch \newcount\c_strc_notes_columns -% \def\strc_notes_set_distance -% {\begingroup -% \setbox\scratchbox\vbox % no reuse as it can mirror -% {\forgetall -% \restoreglobalbodyfont % really needed -% \dontcomplain -% \noteparameter\c!before -% \placenoterule -% \noteparameter\c!after}% -% \expandafter\endgroup\expandafter -% \s_strc_notes_distance\the\htdp\scratchbox\relax} % also dp now - \newskip \s_strc_notes_before \newskip \s_strc_notes_inbetween \newconditional\c_strc_notes_first_flushed @@ -1382,19 +1370,22 @@ \fi} \appendtoks - \strc_notes_set_penalties - \forgetall % again - \strc_notes_set_bodyfont - \redoconvertfont % to undo \undo calls in in headings etc - \splittopskip\strutht % not actually needed here - \splitmaxdepth\strutdp % not actually needed here - % not: -% \leftmargindistance \noteparameter\c!margindistance -% \rightmargindistance\leftmargindistance -% \ifnum\noteparameter\c!n=\zerocount % no ifcase new 31-07-99 ; always ? -% \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize % ? -% \fi - % + \strc_notes_set_penalties + \forgetall % again + \strc_notes_set_bodyfont + \redoconvertfont % to undo \undo calls in in headings etc + \splittopskip\strutht % not actually needed here + \splitmaxdepth\strutdp % not actually needed here + % + % not: + % + % \leftmargindistance \noteparameter\c!margindistance + % \rightmargindistance\leftmargindistance + % \ifnum\noteparameter\c!n=\zerocount % no ifcase new 31-07-99 ; always ? + % \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize % ? + % \fi + % + \pickupattributes \to \everyinsidenoteinsert % maybe but better use [scope=local] here diff --git a/tex/context/base/mkiv/syst-ini.mkiv b/tex/context/base/mkiv/syst-ini.mkiv index 799fccc7a..6e5ced525 100644 --- a/tex/context/base/mkiv/syst-ini.mkiv +++ b/tex/context/base/mkiv/syst-ini.mkiv @@ -605,7 +605,10 @@ %D A few shortcuts: -\normalprotected\def\glet {\global \let } +\ifdefined\glet \else + \normalprotected\def\glet{\global\let} +\fi + \normalprotected\def\udef {\normalprotected\def } \normalprotected\def\ugdef{\normalprotected\gdef} \normalprotected\def\uedef{\normalprotected\edef} @@ -1107,6 +1110,8 @@ \edef\pdfinclusioncopyfonts {\pdfvariable inclusioncopyfonts} \pdfinclusioncopyfonts \plusone \edef\pdfinclusionerrorlevel {\pdfvariable inclusionerrorlevel} \pdfinclusionerrorlevel \zerocount \edef\pdfgentounicode {\pdfvariable gentounicode} \pdfgentounicode \plusone +%edef\pdfomitcidset {\pdfvariable omitcidset } \pdfomitcidset \zerocount +%edef\pdfomitcharset {\pdfvariable omitcharset} \pdfomitcharset \plusone \edef\pdfpagebox {\pdfvariable pagebox} \pdfpagebox \zerocount \edef\pdfmajorversion {\pdfvariable majorversion} % \pdfmajorversion \plusone \edef\pdfminorversion {\pdfvariable minorversion} \pdfminorversion \plusseven diff --git a/tex/context/base/mkiv/typo-dir.mkiv b/tex/context/base/mkiv/typo-dir.mkiv index dd0a03329..9d8d6b968 100644 --- a/tex/context/base/mkiv/typo-dir.mkiv +++ b/tex/context/base/mkiv/typo-dir.mkiv @@ -18,7 +18,7 @@ \unprotect -\registerctxluafile{typo-dir}{} +\registerctxluafile{typo-dir}{optimize} \registerctxluafile{typo-dha}{} \registerctxluafile{typo-dua}{} \registerctxluafile{typo-dub}{} @@ -28,7 +28,7 @@ \registerctxluafile{typo-duc}{} } -\definesystemattribute[directions][public,global] +\definesystemattribute[directions][public,pickup] \installcorenamespace{directions} \installcorenamespace{directionsbidimode} @@ -69,8 +69,9 @@ \expandafter\glet\csname\??directionsbidimode\currentbidistamp\endcsname\currentbidimode} \appendtoks + \edef\p_bidi{\directionsparameter\c!bidi}% \edef\currentbidistamp - {\directionsparameter\c!bidi + {\p_bidi :\directionsparameter\c!method :\directionsparameter\c!fences}% \expandafter\let\expandafter\currentbidimode\csname\??directionsbidimode\currentbidistamp\endcsname @@ -83,6 +84,11 @@ \else \setdirection[\number\directionsbidimode]% \fi + \ifx\p_bidi\v!global + \pickupdirectionsattribute + \else + \forgetdirectionsattribute + \fi \to \everysetupdirections \appendtoks diff --git a/tex/context/base/mkiv/typo-mar.mkiv b/tex/context/base/mkiv/typo-mar.mkiv index f265f173c..10a47e705 100644 --- a/tex/context/base/mkiv/typo-mar.mkiv +++ b/tex/context/base/mkiv/typo-mar.mkiv @@ -155,6 +155,7 @@ \forgetall \tf \resetallattributes % \deactivatecolor % needed, but maybe we should switch to maintextcolor: \onlyinheritmaintextcolor + \pickupattributes \to \everymargindatacontent % trialtypesetting: no need for margin stuff while trialing as diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml index 9b742d4b1..e5db3a6f4 100644 --- a/tex/context/interface/mkii/keys-de.xml +++ b/tex/context/interface/mkii/keys-de.xml @@ -1033,6 +1033,7 @@ <cd:constant name='otherstext' value='otherstext'/> <cd:constant name='outermargin' value='outermargin'/> <cd:constant name='overprint' value='overprint'/> + <cd:constant name='ownerpassword' value='ownerpassword'/> <cd:constant name='ownnumber' value='eigenenummer'/> <cd:constant name='page' value='seite'/> <cd:constant name='pageboundaries' value='seitenbegrenzung'/> @@ -1274,6 +1275,7 @@ <cd:constant name='up' value='up'/> <cd:constant name='urlalternative' value='urlalternative'/> <cd:constant name='urlspace' value='urlspatium'/> + <cd:constant name='userpassword' value='userpassword'/> <cd:constant name='validate' value='validieren'/> <cd:constant name='values' value='values'/> <cd:constant name='vcommand' value='vbefehl'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex c92ba194a..e12fb62d5 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 04f5a960f..0d42c03d2 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/x-setups-overview.mkiv b/tex/context/modules/mkiv/x-setups-overview.mkiv index f6dff12f5..512db3bd1 100644 --- a/tex/context/modules/mkiv/x-setups-overview.mkiv +++ b/tex/context/modules/mkiv/x-setups-overview.mkiv @@ -102,8 +102,9 @@ numeric h, w; boolean mapping ; path p, q, r ; color f, d ; pair s ; h := OverlayHeight ; w := 2*OverlayWidth ; r := unitsquare xyscaled (w,h) ; - fill r withcolor \MPcolor{lightgray} ; - mapping := lua.mp.processingmode("setups:mapping") ; + fill r withcolor resolvedcolor("lightgray") ; + % mapping := lua.mp.processingmode("setups:mapping") ; + mapping := lua.mp("processingmode","setups:mapping") ; if mapping : set_grid(w,h,w/8,w/160) ; pickup pensquare yscaled (w/80) ; @@ -114,8 +115,8 @@ forever : s := center r randomized (w,h) ; if new_on_grid(xpart s, ypart s) : - d := .5[\MPcolor{LocalColor},\MPcolor{lightgray}] randomized (.5,.9) ; - f := \MPcolor{lightgray} randomized (.5,.9) ; + d := .5[resolvedcolor("LocalColor"),resolvedcolor("lightgray")] randomized (.5,.9) ; + f := resolvedcolor("lightgray") randomized (.5,.9) ; s := (dx,dy) ; if mapping : p := (-w/4,0) -- (w/4,0) ; diff --git a/tex/generic/context/luatex/luatex-pdf.tex b/tex/generic/context/luatex/luatex-pdf.tex index bd6690860..569f8664f 100644 --- a/tex/generic/context/luatex/luatex-pdf.tex +++ b/tex/generic/context/luatex/luatex-pdf.tex @@ -135,6 +135,8 @@ \xdef\pdfinclusioncopyfonts {\pdfvariable inclusioncopyfonts} \xdef\pdfinclusionerrorlevel {\pdfvariable inclusionerrorlevel} \xdef\pdfgentounicode {\pdfvariable gentounicode} + \xdef\pdfomitcidset {\pdfvariable omitcidset} + \xdef\pdfomitcharset {\pdfvariable omitcharset} \xdef\pdfpagebox {\pdfvariable pagebox} \xdef\pdfmajorversion {\pdfvariable majorversion} \xdef\pdfminorversion {\pdfvariable minorversion} @@ -178,6 +180,8 @@ \global\pdfinclusioncopyfonts 0 \global\pdfinclusionerrorlevel 0 \global\pdfgentounicode 0 + % \global\pdfomitcidset 0 + % \global\pdfomitcharset 0 \global\pdfpagebox 0 % \global\pdfmajorversion 1 \global\pdfminorversion 4 |