summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/font-ots.lmt9
-rw-r--r--tex/context/base/mkxl/lpdf-wid.lmt222
-rw-r--r--tex/context/base/mkxl/page-ini.lmt16
-rw-r--r--tex/context/base/mkxl/page-one.mkxl2
-rw-r--r--tex/context/base/mkxl/page-sid.mkxl9
-rw-r--r--tex/context/base/mkxl/scrn-wid.mklx70
-rw-r--r--tex/context/base/mkxl/spac-ver.lmt47
-rw-r--r--tex/context/base/mkxl/trac-vis.lmt6
10 files changed, 215 insertions, 170 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index c9e67279a..7d8c75b86 100644
--- a/tex/context/base/mkxl/cont-new.mkxl
+++ b/tex/context/base/mkxl/cont-new.mkxl
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2021.09.13 09:37}
+\newcontextversion{2021.09.14 21:39}
%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/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl
index 97035d34e..77f9ab4d4 100644
--- a/tex/context/base/mkxl/context.mkxl
+++ b/tex/context/base/mkxl/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\immutable\edef\contextformat {\jobname}
-\immutable\edef\contextversion{2021.09.13 09:37}
+\immutable\edef\contextversion{2021.09.14 21:39}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/font-ots.lmt b/tex/context/base/mkxl/font-ots.lmt
index f83fd8776..4d4c09495 100644
--- a/tex/context/base/mkxl/font-ots.lmt
+++ b/tex/context/base/mkxl/font-ots.lmt
@@ -3866,7 +3866,6 @@ do
local steps = sequence.steps
local nofsteps = sequence.nofsteps
local skiphash = sequence.skiphash
-
if not steps then
-- This permits injection, watch the different arguments. Watch out, the arguments passed
-- are not frozen as we might extend or change this. Is this used at all apart from some
@@ -3921,11 +3920,19 @@ do
local lookupcache = step.coverage
while start do
local nxt, char, id = isnextchar(start,font,dynamic,state) -- we can move the data/state checks here
+-- if forcetestrun and sequence.name == "s_s_7" then
+-- if nuts.getid(start) == nodecodes.glyph then
+-- print("C F D S",start,char,font,dynamic,state,nuts,getstate(start))
+-- end
+-- end
if char then
if skiphash and skiphash[char] then -- we never needed it here but let's try
start = nxt
else
local lookupmatch = lookupcache[char]
+-- if forcetestrun and sequence.name == "s_s_7" then
+-- print(lookupmatch)
+-- end
if lookupmatch then
currentscale, currentxscale, currentyscale = getscales(start)
local ok, df
diff --git a/tex/context/base/mkxl/lpdf-wid.lmt b/tex/context/base/mkxl/lpdf-wid.lmt
index 29b0b2a9f..5fde1b1a5 100644
--- a/tex/context/base/mkxl/lpdf-wid.lmt
+++ b/tex/context/base/mkxl/lpdf-wid.lmt
@@ -45,6 +45,7 @@ local nodes = nodes
local context = context
local texgetcount = tex.getcount
+local getmacro = tokens.getters.macro
local hpacknode = nodes.hpack
@@ -616,32 +617,45 @@ end
local ms, mu, mf = { }, { }, { }
local function delayed(label)
- local a = pdfreserveobject()
- mu[label] = a
- return pdfreference(a)
+ local reserved = mu[label]
+ if not reserved then
+ reserved = pdfreserveobject()
+ mu[label] = reserved
+ end
+ return pdfreference(reserved)
+end
+
+local function checkedreference(ref)
+ local set, bug = structures.references.identify("",ref)
+ if not bug and #set > 0 then
+ return pdfaction(set)
+ end
end
local function insertrenderingwindow(specification)
- local label = specification.label
- -- local openpage = specification.openpage
- -- local closepage = specification.closepage
- if specification.option == v_auto then
- if openpageaction then
- -- \handlereferenceactions{\v!StartRendering{#2}}
+ local actions = nil
+ local label = specification.label
+ local openpage = specification.openpage
+ local closepage = specification.closepage
+ local option = settings_to_hash(specification.option)
+ if option[v_auto] then
+ if not openpage or openpage == "" then
+ openpage = variables.StartCurrentRendering
end
- if closepageaction then
- -- \handlereferenceactions{\v!StopRendering {#2}}
+ if not closepage or closepage == "" then
+ closepage = variables.StopCurrentRendering
end
end
- local actions = nil
+ openpage = checkedreference(openpage)
+ closepage = checkedreference(closepage)
if openpage or closepage then
actions = pdfdictionary {
- PO = (openpage and lpdfaction(openpage )) or nil,
- PC = (closepage and lpdfaction(closepage)) or nil,
+ PO = openpage,
+ PC = closepage,
}
end
local page = tonumber(specification.page) or texgetcount("realpageno") -- todo
- local r = mu[label] or pdfreserveobject() -- why the reserve here?
+ local r = mu[label] or pdfreserveobject() -- reserve, child refers to parent
local a = pdfdictionary {
S = pdfconstant("Rendition"),
R = mf[label],
@@ -671,99 +685,79 @@ local function insertrendering(specification)
local option = settings_to_hash(specification.option)
if not mf[label] then
local filename = specification.filename
- local isurl = find(filename,"://",1,true)
- local mimetype = specification.mimetype or specification.mime
- -- local start = pdfdictionary {
- -- Type = pdfconstant("MediaOffset"),
- -- S = pdfconstant("T"), -- time
- -- T = pdfdictionary { -- time
- -- Type = pdfconstant("Timespan"),
- -- S = pdfconstant("S"),
- -- V = 3, -- time in seconds
- -- },
- -- }
- -- local start = pdfdictionary {
- -- Type = pdfconstant("MediaOffset"),
- -- S = pdfconstant("F"), -- frame
- -- F = 100 -- framenumber
- -- }
- -- local start = pdfdictionary {
- -- Type = pdfconstant("MediaOffset"),
- -- S = pdfconstant("M"), -- mark
- -- M = "somemark",
- -- }
- -- local parameters = pdfdictionary {
- -- BE = pdfdictionary {
- -- B = start,
- -- }
- -- }
- local parameters = pdfdictionary {
- Type = pdfconstant("MediaPermissions"),
- TF = pdfstring("TEMPALWAYS"), -- TEMPNEVER TEMPEXTRACT TEMPACCESS TEMPALWAYS / needed for acrobat/wmp
- }
- local descriptor = pdfdictionary {
- Type = pdfconstant("Filespec"),
- F = filename,
- }
- if isurl then
- descriptor.FS = pdfconstant("URL")
- descriptor = pdfreference(pdfflushobject(descriptor))
- elseif option[v_embed] then
- descriptor = codeinjections.embedfile {
- file = filename,
- mimetype = mimetype, -- yes or no
- title = option[v_title],
- compress = option[v_compress] or false,
- forcereference = option[v_list] ~= v_no,
+ if filename and filename ~= "" then
+ local isurl = find(filename,"://",1,true)
+ local mimetype = specification.mimetype or specification.mime
+ -- local start = pdfdictionary {
+ -- Type = pdfconstant("MediaOffset"),
+ -- S = pdfconstant("T"), -- time
+ -- T = pdfdictionary { -- time
+ -- Type = pdfconstant("Timespan"),
+ -- S = pdfconstant("S"),
+ -- V = 3, -- time in seconds
+ -- },
+ -- }
+ -- local start = pdfdictionary {
+ -- Type = pdfconstant("MediaOffset"),
+ -- S = pdfconstant("F"), -- frame
+ -- F = 100 -- framenumber
+ -- }
+ -- local start = pdfdictionary {
+ -- Type = pdfconstant("MediaOffset"),
+ -- S = pdfconstant("M"), -- mark
+ -- M = "somemark",
+ -- }
+ -- local parameters = pdfdictionary {
+ -- BE = pdfdictionary {
+ -- B = start,
+ -- }
+ -- }
+ local parameters = pdfdictionary {
+ Type = pdfconstant("MediaPermissions"),
+ TF = pdfstring("TEMPALWAYS"), -- TEMPNEVER TEMPEXTRACT TEMPACCESS TEMPALWAYS / needed for acrobat/wmp
}
+ local descriptor = pdfdictionary {
+ Type = pdfconstant("Filespec"),
+ F = filename,
+ }
+ if isurl then
+ descriptor.FS = pdfconstant("URL")
+ descriptor = pdfreference(pdfflushobject(descriptor))
+ elseif option[v_embed] then
+ descriptor = codeinjections.embedfile {
+ file = filename,
+ mimetype = mimetype, -- yes or no
+ title = option[v_title],
+ compress = option[v_compress] or false,
+ forcereference = option[v_list] ~= v_no,
+ }
+ end
+ local clip = pdfdictionary {
+ Type = pdfconstant("MediaClip"),
+ S = pdfconstant("MCD"),
+ N = label,
+ CT = mimetype,
+ Alt = pdfarray { "", "file not found" }, -- language id + message
+ D = descriptor,
+ P = pdfreference(pdfflushobject(parameters)),
+ }
+ local rendition = pdfdictionary {
+ Type = pdfconstant("Rendition"),
+ S = pdfconstant("MR"),
+ N = pdfunicode(label),
+ C = pdfreference(pdfflushobject(clip)),
+ }
+ mf[label] = pdfreference(pdfflushobject(rendition))
end
- local clip = pdfdictionary {
- Type = pdfconstant("MediaClip"),
- S = pdfconstant("MCD"),
- N = label,
- CT = mimetype,
- Alt = pdfarray { "", "file not found" }, -- language id + message
- D = descriptor,
- P = pdfreference(pdfflushobject(parameters)),
- }
- local rendition = pdfdictionary {
- Type = pdfconstant("Rendition"),
- S = pdfconstant("MR"),
- N = pdfunicode(label),
- C = pdfreference(pdfflushobject(clip)),
- }
- mf[label] = pdfreference(pdfflushobject(rendition))
- end
-end
-
-local function insertrenderingobject(specification) -- todo
- local label = specification.label
- if not mf[label] then
- report_media("unknown medium, label %a",label)
- local clip = pdfdictionary { -- does not work that well one level up
- Type = pdfconstant("MediaClip"),
- S = pdfconstant("MCD"),
- N = label,
- D = pdfreference(unknown), -- not label but objectname, hm .. todo?
- }
- local rendition = pdfdictionary {
- Type = pdfconstant("Rendition"),
- S = pdfconstant("MR"),
- N = label,
- C = pdfreference(pdfflushobject(clip)),
- }
- mf[label] = pdfreference(pdfflushobject(rendition))
end
end
function codeinjections.processrendering(label)
local specification = interactions.renderings.rendering(label)
- if not specification then
- -- error
- elseif specification.type == "external" then
+ if specification then
insertrendering(specification)
else
- insertrenderingobject(specification)
+ -- error
end
end
@@ -788,17 +782,23 @@ function codeinjections.insertrenderingwindow(specification)
ms[label] = insertrenderingwindow(specification)
end
-local function set(operation,arguments)
- codeinjections.processrendering(arguments)
- return pdfdictionary {
- S = pdfconstant("Rendition"),
- OP = operation,
- R = mf[arguments],
- AN = ms[arguments] or delayed(arguments),
- }
+local function set(operation,label)
+ if not label or label == "" then
+ -- This one is local to the window so unlikely to be set.
+ label = getmacro("currentrendering")
+ end
+ if label and label ~= "" then
+ codeinjections.processrendering(label)
+ return pdfdictionary {
+ S = pdfconstant("Rendition"),
+ OP = operation,
+ R = mf[label],
+ AN = ms[label] or delayed(label),
+ }
+ end
end
-function executers.startrendering (arguments) return set(0,arguments) end
-function executers.stoprendering (arguments) return set(1,arguments) end
-function executers.pauserendering (arguments) return set(2,arguments) end
-function executers.resumerendering(arguments) return set(3,arguments) end
+function executers.startrendering (label) return set(0,label) end
+function executers.stoprendering (label) return set(1,label) end
+function executers.pauserendering (label) return set(2,label) end
+function executers.resumerendering(label) return set(3,label) end
diff --git a/tex/context/base/mkxl/page-ini.lmt b/tex/context/base/mkxl/page-ini.lmt
index bb5ea2b5d..ef34687c6 100644
--- a/tex/context/base/mkxl/page-ini.lmt
+++ b/tex/context/base/mkxl/page-ini.lmt
@@ -354,3 +354,19 @@ implement {
ctx_doifelse(p)
end,
}
+
+-- implement {
+-- name = "pagestate",
+-- public = true,
+-- usage = "value",
+-- actions = function()
+-- local result = 0
+-- if nodes.nuts.getspeciallist("contribute_head") then
+-- result = result | 1
+-- end
+-- if nodes.nuts.getspeciallist("page_head") then
+-- result = result | 2
+-- end
+-- return tokens.values.integer, result
+-- end
+-- }
diff --git a/tex/context/base/mkxl/page-one.mkxl b/tex/context/base/mkxl/page-one.mkxl
index 116f2146d..e8f873422 100644
--- a/tex/context/base/mkxl/page-one.mkxl
+++ b/tex/context/base/mkxl/page-one.mkxl
@@ -66,7 +66,7 @@
-\d_page_floats_inserted_bottom
-\insertheights
\relax
- \insertheights\zeropoint}
+ }% no: \insertheights\zeropoint}
\protected\def\page_one_command_set_vsize
{\ifgridsnapping
diff --git a/tex/context/base/mkxl/page-sid.mkxl b/tex/context/base/mkxl/page-sid.mkxl
index 20e92ad19..37bea4fb3 100644
--- a/tex/context/base/mkxl/page-sid.mkxl
+++ b/tex/context/base/mkxl/page-sid.mkxl
@@ -420,7 +420,12 @@
{\iftracesidefloats
\enabletrackers[otr.forcestrutdepth]% \c_page_force_strut_depth_trace_mode\plusone
\fi
+ % flush what we have and check
\forcestrutdepth
+ % trigger pagebuilder
+ % \penalty\zerocount
+ \pageboundary
+ % catch up
\page_otr_command_set_vsize} % new, no longer really needed
\def\page_sides_flush_floats
@@ -734,7 +739,7 @@
% \ifdim\pagegoal=\maxdimen
% \pagegoal\textheight % maybe
% \fi
- \global\d_page_sides_page_total \pagetotal % global
+ \global\d_page_sides_page_total\pagetotal % global
\ifnum\c_page_sides_float_type<\plusfour
\global\d_page_sides_width \zeropoint
\orelse\ifnum\c_page_sides_float_type>\plusfive
@@ -746,7 +751,7 @@
\global\d_page_sides_width\zeropoint
\fi
\global\d_page_sides_hsize \dimexpr\hsize-\d_page_sides_width\relax
- \global\d_page_sides_height\dimexpr\ht\floatbox+\dp\floatbox+\d_page_sides_toptotal\relax
+ \global\d_page_sides_height\dimexpr\htdp\floatbox+\d_page_sides_toptotal\relax
\global\d_page_sides_vsize \dimexpr\d_page_sides_height+\d_page_sides_page_total\relax
\scratchdimenone\d_page_sides_vsize
\scratchdimentwo\pagegoal
diff --git a/tex/context/base/mkxl/scrn-wid.mklx b/tex/context/base/mkxl/scrn-wid.mklx
index b35047d94..76d4a14e6 100644
--- a/tex/context/base/mkxl/scrn-wid.mklx
+++ b/tex/context/base/mkxl/scrn-wid.mklx
@@ -605,14 +605,30 @@
\relax
\fi}
-%D Renderings (not yet tested in mkvi):
-
-% Todo: multiple instances and inheritance .. will be done when needed i.e. when I
-% see usage. Probaly by that time this feature is dropped (as are other media
-% rel;ated ones).
+%D Renderings (adapted to \MKIV\ by Michal Vlasák). We no longer have the \MKII\ internal
+%D and external rendering because over time all this widget stuff changed in \PDF\ and
+%D Acrobat.
+%D
+%D \starttyping
+%D \setupinteraction[state=start]
+%D
+%D \starttext
+%D \startTEXpage[offset=10pt]
+%D % \definerenderingwindow[myrenderingwindow][width=\textwidth, height=\textwidth]
+%D % \definerenderingwindow[myrenderingwindow][width=\textwidth, height=\textwidth, openpageaction=StartRendering{myvideo}]
+%D \definerenderingwindow[myrenderingwindow][width=\textwidth, height=\textwidth, openpageaction=StartCurrentRendering, closepageaction=StopCurrentRendering]
+%D % \userendering[myvideo][video/mp4][edited.mp4][embed=yes, auto]
+%D \userendering[myvideo][video/mp4][woodwork.mp4][embed=yes, auto]
+%D % auto = openpageaction=StartCurrentRendering, closepageaction=StopCurrentRendering
+%D \placerenderingwindow[myrenderingwindow][myvideo]
+%D \blank
+%D \goto{start}[StartRendering{myvideo}]
+%D \goto{stop}[StopRendering{myvideo}]
+%D \stopTEXpage
+%D \stoptext
+%D \stoptyping
\mutable\let\currentrendering \empty
-\mutable\let\currentrenderingtype \empty
\mutable\let\currentrenderingwindow\empty
\definereference[StartCurrentRendering] [\v!StartRendering {\currentrendering}]
@@ -620,31 +636,16 @@
\definereference[PauseCurrentRendering] [\v!PauseRendering {\currentrendering}]
\definereference[ResumeCurrentRendering][\v!ResumeRendering{\currentrendering}]
-\permanent\tolerant\protected\def\useexternalrendering[#tag]#spacer[#mime]#spacer[#file]#spacer[#option]%
+\permanent\tolerant\protected\def\userendering[#tag]#spacer[#mime]#spacer[#file]#spacer[#option]%
{\clf_registerrendering
- type {external}%
label {#tag}%
mime {#mime}%
filename {#file}%
option {#option}%
\relax}
-\permanent\tolerant\protected\def\setinternalrendering[#tag]#spacer[#option]% {content} % crappy
- {\bgroup
- \dowithnextbox
- {\clf_registerrendering
- type {internal}%
- label {#tag}%
- mime {IRO}% brrr
- filename {#tag}%
- option {#option}%
- \relax
- \let\objectoffset\zeropoint
- \setobject{IRO}{#tag}\hpack{\box\nextbox}%
- \egroup}%
- \hbox}
+\permanent\tolerant\protected\let\useexternalrendering\userendering
-\permanent\def\renderingtype #tag{\clf_renderingvar{#tag}{type}}
\permanent\def\renderingoption#tag{\clf_renderingvar{#tag}{option}}
\newdimen\d_scrn_rendering_width \d_scrn_rendering_width 8cm
@@ -681,13 +682,7 @@
\else
\edef\currentrenderingwindow{#window}%
\fi
- \edef\currentrenderingtype{\renderingtype\currentrendering}%
- \ifx\currentrenderingtype\s!internal
- \getobjectdimensions{IRO}\currentrendering
- \d_scrn_rendering_height\dimexpr\objectheight+\objectdepth\relax
- \d_scrn_rendering_width\objectwidth\relax
- \getobjectreferencepage{IRO}\currentrendering\m_scrn_rendering_page
- \orelse\ifx\currentrenderingwindow\s!default
+ \ifx\currentrenderingwindow\s!default
\d_scrn_rendering_height\vsize
\d_scrn_rendering_width \hsize
\let\m_scrn_rendering_page\realpageno
@@ -696,19 +691,18 @@
\d_scrn_rendering_width \renderingwindowparameter\c!width
\let\m_scrn_rendering_page\realpageno
\fi
- % todo:
- % \handlereferenceactions{\renderingwindowparameter\c!openpageaction }\dosetuprenderingopenpageaction
- % \handlereferenceactions{\renderingwindowparameter\c!closepageaction}\dosetuprenderingclosepageaction
\letrenderingwindowparameter\c!offset\v!overlay
\inheritedrenderingwindowframed
{\vfilll
\dontleavehmode
\clf_insertrenderingwindow
- label {\currentrendering}%
- width \d_scrn_rendering_width
- height \d_scrn_rendering_height
- option {\renderingoption\currentrendering}%
- page \m_scrn_rendering_page
+ label {\currentrendering}%
+ width \d_scrn_rendering_width
+ height \d_scrn_rendering_height
+ option {\renderingoption\currentrendering}%
+ page \m_scrn_rendering_page
+ openpage {\renderingwindowparameter\c!openpageaction}%
+ closepage {\renderingwindowparameter\c!closepageaction}%
\relax
\hfill}%
\egroup}
diff --git a/tex/context/base/mkxl/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt
index cd6dd46ad..c4da389f9 100644
--- a/tex/context/base/mkxl/spac-ver.lmt
+++ b/tex/context/base/mkxl/spac-ver.lmt
@@ -2438,8 +2438,10 @@ do
-- end
-- end
- local hlist_code = nodes.nodecodes.hlist
- local line_code = nodes.listcodes.line
+ local hlist_code = nodes.nodecodes.hlist
+ local insert_code = nodes.nodecodes.insert
+ local mark_code = nodes.nodecodes.mark
+ local line_code = nodes.listcodes.line
local nuts = nodes.nuts
local getid = nuts.getid
@@ -2464,23 +2466,40 @@ do
end
end)
+ local treversenode = nuts.treversers.node
+
function vspacing.forcestrutdepth()
-- check if in mvl
if texgetnest("ptr") == 0 then
- triggerbuildpage() -- return true when mvl
- local head, tail = getspeciallist("page_head")
- if tail and getid(tail) == hlist_code and getsubtype(tail) == line_code then -- isline(tail)
- local strutdp = texgetdimen("strutdp")
- local delta = strutdp - getdepth(tail)
- if delta > 0 then
- setdepth(tail,strutdp)
- texset("pagetotal",texget("pagetotal") + delta)
- texset("pagedepth",strutdp)
- if trace then
- trace(tail)
+ -- this flushes the contributions
+ while getspeciallist("contribute_head") do
+ triggerbuildpage()
+ end
+ -- now we consult the last line (if present)
+ local head, tail = getspeciallist("page_head")
+ if tail then
+ for n, id, subtype in treversenode, tail do
+ if id == hlist_code then
+ if subtype == line_code then
+ local strutdp = texgetdimen("strutdp")
+ local delta = strutdp - getdepth(n)
+ if delta > 0 then
+ setdepth(n,strutdp)
+ texset("pagetotal",texget("pagetotal") + delta)
+ texset("pagedepth",strutdp)
+ if trace then
+ trace(n)
+ end
+ end
+ end
+ break
+ elseif id == insert_code or id == mark_code then
+ -- prev
+ else
+ break
end
end
- end
+ end
else
local nest = texgetnest()
-- if abs(nest.mode) == vmode_code and nest.head then
diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt
index 3300d2f75..38078f08d 100644
--- a/tex/context/base/mkxl/trac-vis.lmt
+++ b/tex/context/base/mkxl/trac-vis.lmt
@@ -277,7 +277,11 @@ local function setvisual(n,a,what,list) -- this will become more efficient when
end
end
elseif type(n) == "number" then
- a = a | n
+ if not a or a == 0 or a == unsetvalue then
+ a = n
+ else
+ a = a | n
+ end
end
if not a or a == 0 or a == unsetvalue then
return unsetvalue