From 4fa7af67efbde2eae64e632c6ac853432412d404 Mon Sep 17 00:00:00 2001
From: Marius <mariausol@gmail.com>
Date: Wed, 13 Oct 2010 10:31:28 +0300
Subject: beta 2010.10.13 00:33

---
 tex/context/base/char-ini.lua               |  10 +--
 tex/context/base/cont-new.tex               |   2 +-
 tex/context/base/context.tex                |   2 +-
 tex/context/base/lpdf-wid.lua               | 114 +++++++++++++++++++---------
 tex/context/base/sort-lan.lua               |   3 +-
 tex/generic/context/luatex-fonts-merged.lua |   2 +-
 6 files changed, 89 insertions(+), 44 deletions(-)

diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua
index 369b4f2d2..a6b033b08 100644
--- a/tex/context/base/char-ini.lua
+++ b/tex/context/base/char-ini.lua
@@ -434,9 +434,9 @@ if texsetcatcode then
         end
 
         if tobelettered then -- shared
-         -- local saved = tex.catcodetable
-         -- for i=1,#tobelettered do
-         --     tex.catcodetable = tobelettered[i]
+          local saved = tex.catcodetable
+          for i=1,#tobelettered do
+              tex.catcodetable = tobelettered[i]
                 if trace_defining then
                     report_defining("defining letters (global, shared)")
                 end
@@ -452,8 +452,8 @@ if texsetcatcode then
                 end
                 texsetcatcode(0x200C,11) -- non-joiner
                 texsetcatcode(0x200D,11) -- joiner
-         -- end
-         -- tex.catcodetable = saved
+          end
+          tex.catcodetable = saved
         end
 
         local nofactivated = #tobeactivated
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 0fe4d2057..fff5c1c4e 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2010.10.12 17:13}
+\newcontextversion{2010.10.13 00:33}
 
 %D This file is loaded at runtime, thereby providing an
 %D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 8412ea74e..a2798b45d 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2010.10.12 17:13}
+\edef\contextversion{2010.10.13 00:33}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index e45e9727c..a948fcedc 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -30,6 +30,7 @@ local pdfstring            = lpdf.string
 local pdfcolorspec         = lpdf.colorspec
 local pdfflushobject       = lpdf.flushobject
 local pdfreserveannotation = lpdf.reserveannotation
+local pdfreserveobject     = lpdf.reserveobject
 local pdfimmediateobject   = lpdf.immediateobject
 local pdfpagereference     = lpdf.pagereference
 
@@ -254,8 +255,8 @@ end
 -- P  media play parameters (evt /BE for controls etc
 -- A  boolean (audio)
 -- C  boolean (captions)
----O  boolean (overdubs)
----S  boolean (subtitles)
+-- O  boolean (overdubs)
+-- S  boolean (subtitles)
 -- PL pdfconstant("ADBE_MCI"),
 
 -- F        = flags,
@@ -274,7 +275,8 @@ local function delayed(label)
     return pdfreference(a)
 end
 
-local function insertrenderingwindow(label,width,height,specification)
+local function insertrenderingwindow(specification)
+    local label = specification.label
 --~     local openpage = specification.openpage
 --~     local closepage = specification.closepage
     if specification.options == variables.auto then
@@ -293,62 +295,104 @@ local function insertrenderingwindow(label,width,height,specification)
         }
     end
     local page = tonumber(specification.page) or texcount.realpageno -- todo
+    local r = mu[label] or pdfreserveannotation() -- why the reserve here?
+    local a = pdfdictionary {
+        S  = pdfconstant("Rendition"),
+        R  = mf[label],
+        OP = 0,
+        AN = pdfreference(r),
+    }
     local d = pdfdictionary {
         Subtype = pdfconstant("Screen"),
         P       = pdfreference(pdfpagereference(page)),
-        A       = mf[label],
+        A       = a, -- needed in order to make the annotation clickable (i.e. don't bark)
         Border  = pdf_border,
         AA      = actions,
     }
-    local r = mu[label] or pdfreserveannotation()
-    write_node(pdfannotation_node(width,height,0,d(),r)) -- save ref
+    write_node(pdfannotation_node(specification.width or 0,specification.height or 0,0,d(),r)) -- save ref
     return pdfreference(r)
 end
 
+-- some dictionaries can have a MH (must honor) or BE (best effort) capsule
+
 local function insertrendering(specification)
     local label = specification.label
     if not mf[label] then
         local filename = specification.filename
         local isurl = find(filename,"://")
-        local d = pdfdictionary {
+    --~ 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
+    --~ }
+        local descriptor = pdfdictionary {
+            Type = pdfconstant("Filespec"),
+            F    = filename,
+        }
+        if isurl then
+            descriptor.FS = pdfconstant("URL")
+        elseif specification.embed then
+            descriptor.EF = codeinjections.embedfile(filename)
+        end
+        local clip = pdfdictionary {
+            Type = pdfconstant("MediaClip"),
+            S    = pdfconstant("MCD"),
+            N    = label,
+            CT   = specification.mime,
+            Alt  = pdfarray { "", "file not found" }, -- language id + message
+            D    = pdfreference(pdfflushobject(descriptor)),
+         -- P    = pdfreference(pdfflushobject(parameters)),
+        }
+        local rendition = pdfdictionary {
             Type = pdfconstant("Rendition"),
-            S    = pdfconstant("MR"), -- or SR for selector
-            N    = label, -- here too?
-            C    = pdfdictionary {
-                Type = pdfconstant("MediaClip"),
-                S    = pdfconstant("MCD"),
-                N    = label,
-             -- P    = pdfdictionary { TF = pdfstring("TEMPALWAYS") }, -- TEMPNEVER TEMPEXTRACT TEMPACCESS TEMPALWAYS
-                CT   = specification.mime, -- also /PL needs to be present then
-                Alt  = pdfarray {
-                    "", "file not found", -- language id + message
-                },
-                D    = pdfdictionary {
-                    Type = pdfconstant("Filespec"),
-                    F    = filename,
-                    FS   = (isurl and pdfconstant("URL")) or nil,
-                }
-            }
+            S    = pdfconstant("MR"),
+            N    = label,
+            C    = pdfreference(pdfflushobject(clip)),
         }
-        mf[label] = pdfreference(pdfflushobject(d))
+        mf[label] = pdfreference(pdfflushobject(rendition))
     end
 end
 
-local function insertrenderingobject(specification)
+local function insertrenderingobject(specification) -- todo
     local label = specification.label
     if not mf[label] then
         report_media("todo: unknown medium '%s'",label or "?")
-        local d = pdfdictionary {
+        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"),
-            C    = pdfdictionary {
-                Type = pdfconstant("MediaClip"),
-                S    = pdfconstant("MCD"),
-                N    = label,
-                D    = pdfreference(unknown), -- not label but objectname, hm .. todo?
-            }
+            N    = label,
+            C    = pdfreference(pdfflushobject(clip)),
         }
-        mf[label] = pdfreference(pdfflushobject(d))
+        mf[label] = pdfreference(pdfflushobject(rendition))
     end
 end
 
@@ -366,7 +410,7 @@ end
 function codeinjections.insertrenderingwindow(specification)
     local label = specification.label
     codeinjections.processrendering(label)
-    ms[label] = insertrenderingwindow(label,specification.width,specification.height,specification)
+    ms[label] = insertrenderingwindow(specification)
 end
 
 local function set(operation,arguments)
diff --git a/tex/context/base/sort-lan.lua b/tex/context/base/sort-lan.lua
index 338ba747b..8137bac13 100644
--- a/tex/context/base/sort-lan.lua
+++ b/tex/context/base/sort-lan.lua
@@ -14,9 +14,10 @@ local utfchar           = utf.char
 local sorters           = sorters
 local definitions       = sorters.definitions
 local replacementoffset = sorters.constants.replacementoffset
+local variables         = interfaces.variables
 
 definitions["default"] = {
-    method  = "before",
+    method  = variables.before,
     replacements = {
         -- no replacements
     },
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index aee369864..673f7e682 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 10/12/10 17:13:41
+-- merge date  : 10/13/10 00:33:49
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3