diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/l-pdfview.lua | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/l-pdfview.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/l-pdfview.lua | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/context/base/l-pdfview.lua b/Master/texmf-dist/tex/context/base/l-pdfview.lua index 6fd3ac24686..3f4a8bea5cf 100644 --- a/Master/texmf-dist/tex/context/base/l-pdfview.lua +++ b/Master/texmf-dist/tex/context/base/l-pdfview.lua @@ -8,35 +8,63 @@ if not modules then modules = { } end modules ['l-pdfview'] = { -- Todo: figure out pdfopen/pdfclose on linux. Calling e.g. okular directly -- doesn't work in linux when issued from scite as it blocks the editor (no --- & possible or so). +-- & possible or so). Unfortunately pdfopen keeps changing with not keeping +-- downward compatibility (command line arguments and so). + +-- no 2>&1 any more, needs checking on windows local format, concat = string.format, table.concat pdfview = pdfview or { } -local opencalls = { - ['default'] = "pdfopen --ax --file", -- "pdfopen --back --file" - ['xpdf'] = "xpdfopen", -} +local opencalls, closecalls, allcalls, runner -local closecalls= { - ['default'] = "pdfclose --ax --file", - ['xpdf'] = nil, -} +if os.type == "windows" then -local allcalls = { - ['default'] = "pdfclose --ax --all", - ['xpdf'] = nil, -} + opencalls = { + ['default'] = "pdfopen --ax --file", -- --back --file --ax + ['acrobat'] = "pdfopen --ax --file", -- --back --file --ax + ['okular'] = 'start "test" "c:/data/system/kde/bin/okular.exe" --unique' -- todo! + } + closecalls= { + ['default'] = "pdfclose --ax --file", -- --ax + ['acrobat'] = "pdfclose --ax --file", -- --ax + ['okular'] = false, + } + allcalls = { + ['default'] = "pdfclose --ax --all", -- --ax + ['acrobat'] = "pdfclose --ax --all", -- --ax + ['okular'] = false, + } + + pdfview.method = "acrobat" + + runner = function(...) + os.execute(...) + end -if os.type == "windows" then - -- opencalls['okular'] = 'start "test" "c:/program files/kde/bin/okular.exe" --unique' -- todo: get focus - opencalls['okular'] = 'start "test" "c:/data/system/kde/bin/okular.exe" --unique' -- todo: get focus else - opencalls['okular'] = 'okular --unique' -end -pdfview.method = "default" + opencalls = { + ['default'] = "pdfopen", -- we could pass the default here + ['okular'] = 'okular --unique' + } + closecalls= { + ['default'] = "pdfclose --file", + ['okular'] = false, + } + allcalls = { + ['default'] = "pdfclose --all", + ['okular'] = false, + } + + pdfview.method = "okular" + + runner = function(...) + os.spawn(...) + end + +end directives.register("pdfview.method", function(v) pdfview.method = (opencalls[v] and v) or 'default' @@ -69,7 +97,7 @@ function pdfview.open(...) for i=1,#t do local name = fullname(t[i]) if io.exists(name) then - os.execute(format('%s "%s" 2>&1', opencall, name)) + runner(format('%s "%s"', opencall, name)) openedfiles[name] = true end end @@ -83,7 +111,7 @@ function pdfview.close(...) for i=1,#t do local name = fullname(t[i]) if openedfiles[name] then - os.execute(format('%s "%s" 2>&1', closecall, name)) + runner(format('%s "%s"', closecall, name)) openedfiles[name] = nil else pdfview.closeall() @@ -96,7 +124,7 @@ end function pdfview.closeall() local allcall = allcalls[pdfview.method] if allcall then - os.execute(format('%s 2>&1', allcall)) + runner(format('%s', allcall)) end openedfiles = { } end |