summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlpsv/psv.wx.lua
diff options
context:
space:
mode:
authorStaszek Wawrykiewicz <staw@gust.org.pl>2009-07-06 17:30:42 +0000
committerStaszek Wawrykiewicz <staw@gust.org.pl>2009-07-06 17:30:42 +0000
commit678a72f4e0eacf1b939d7ca0d954378122d579de (patch)
tree5e3e4a2b5bcc46501fc7eb3a45fa3bad3b57ea1a /Master/tlpkg/tlpsv/psv.wx.lua
parentd8ae0710347d4e4dd75fe7710af9fc36fa8a6695 (diff)
ps_view 5.11
git-svn-id: svn://tug.org/texlive/trunk@14154 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlpsv/psv.wx.lua')
-rw-r--r--Master/tlpkg/tlpsv/psv.wx.lua95
1 files changed, 55 insertions, 40 deletions
diff --git a/Master/tlpkg/tlpsv/psv.wx.lua b/Master/tlpkg/tlpsv/psv.wx.lua
index 6c4f470b537..476d11d5a65 100644
--- a/Master/tlpkg/tlpsv/psv.wx.lua
+++ b/Master/tlpkg/tlpsv/psv.wx.lua
@@ -5,7 +5,7 @@
-- bop@bop.com.pl
-- Copyright: (c) 2008 BOP s.c.
-- Licence: GPL
--- Current version: 5.09; 02.07.2008
+-- Current version: 5.11; 06.07.2009
--
-- 4.95 -- first working version of Lua engine
-- 4.96 -- mouse interface added (and many other changes)
@@ -24,12 +24,14 @@
-- 5.07 -- post BachoTeX release
-- 5.08 -- full-screen mode
-- 5.09 -- LaTeX/HTML help added
+-- 5.10 -- bug in DSC reading corrected
+-- 5.11 -- some changes to compatibility with GS 8.64, and builtin inits
------------------------------------------------------------------------------]]
local PS_VIEW_NAME="PS_View"
-local PS_VIEW_VERSION=5.09
+local PS_VIEW_VERSION=5.11
local PS_VIEW_VERSION_STRING -- defined later, after locale loading
-local PSV_GsPars = {"-dNOPAUSE","-dDELAYBIND","-dNOEPS"}
+local PSV_DftGsPars = {"-dNOPAUSE","-dDELAYBIND","-dNOEPS"}
local frame, console = nil, nil
@@ -70,13 +72,12 @@ local gsargs = {
psvlib= "", -- path to PS_View files (from config file or discovered from
-- paths in progs or path to this program -- arg[0])
progs = {}, -- PostScript program to run during init (added at the end of args)
- dftpars = PSV_GsPars, -- default GS arguments (can be overriden by config file,
- -- added ath the begin of args)
+ cmd_pars = {}, -- default GS arguments (can be overriden by config file,
+ -- added at the begin of args)
psf_dir = "", -- directory with the curently opened file
psf_name = "", -- name of the curently opened file
}
local psvpars = {
- cmd_pars = "",
language = "",
}
local gsstat = {
@@ -398,24 +399,24 @@ local Mouse = { Cnone=0, Czoom=1, Cpane=2, Cmeasure=3, Cscroll=4,
bx=0, by=0, ex=0, ey=0, scroln=0, CMD=0, mod=0, timer=0,}
local Dobject = { n=0, id={},
-Oline=1, Orect=2, Ocros=3, }
-Dobject.pens={ [-1] = wx.wxTRANSPARENT_PEN, [0] =
-wx.wxBLACK_PEN, wx.wxPen("BLUE",1,wx.wxSOLID),
-wx.wxGREEN_PEN, wx.wxCYAN_PEN,
-wx.wxRED_PEN, wx.wxPen("MAGENTA",1,wx.wxSOLID),
-wx.wxPen("YELLOW",1,wx.wxSOLID), wx.wxWHITE_PEN,
-wx.wxPen("BLACK",3,wx.wxSOLID), wx.wxPen("BLUE",3,wx.wxSOLID),
-wx.wxPen("GREEN",3,wx.wxSOLID), wx.wxPen("CYAN",3,wx.wxSOLID),
-wx.wxPen("RED",3,wx.wxSOLID), wx.wxPen("MAGENTA",3,wx.wxSOLID),
-wx.wxPen("YELLOW",3,wx.wxSOLID), wx.wxPen("WHITE",3,wx.wxSOLID),
-}
-Dobject.brushess={ [-1] = wx.wxTRANSPARENT_BRUSH, [0] =
-wxBLACK_BRUSH, wx.wxBLUE_BRUSH,
-wxGREEN_BRUSH, wxCYAN_BRUSH,
-wxRED_BRUSH, wx.wxBrush("MAGENTA",wx.wxSOLID),
-wx.wxBrush("YELLOW",wx.wxSOLID), wxWHITE_BRUSH,
-wxGREY_BRUSH
-}
+ Oline=1, Orect=2, Ocros=3, }
+ Dobject.pens={ [-1] = wx.wxTRANSPARENT_PEN, [0] =
+ wx.wxBLACK_PEN, wx.wxPen("BLUE",1,wx.wxSOLID),
+ wx.wxGREEN_PEN, wx.wxCYAN_PEN,
+ wx.wxRED_PEN, wx.wxPen("MAGENTA",1,wx.wxSOLID),
+ wx.wxPen("YELLOW",1,wx.wxSOLID), wx.wxWHITE_PEN,
+ wx.wxPen("BLACK",3,wx.wxSOLID), wx.wxPen("BLUE",3,wx.wxSOLID),
+ wx.wxPen("GREEN",3,wx.wxSOLID), wx.wxPen("CYAN",3,wx.wxSOLID),
+ wx.wxPen("RED",3,wx.wxSOLID), wx.wxPen("MAGENTA",3,wx.wxSOLID),
+ wx.wxPen("YELLOW",3,wx.wxSOLID), wx.wxPen("WHITE",3,wx.wxSOLID),
+ }
+ Dobject.brushess={ [-1] = wx.wxTRANSPARENT_BRUSH, [0] =
+ wxBLACK_BRUSH, wx.wxBLUE_BRUSH,
+ wxGREEN_BRUSH, wxCYAN_BRUSH,
+ wxRED_BRUSH, wx.wxBrush("MAGENTA",wx.wxSOLID),
+ wx.wxBrush("YELLOW",wx.wxSOLID), wxWHITE_BRUSH,
+ wxGREY_BRUSH
+ }
local v_quiet,v_normal,v_verbose=2,6,10
@@ -615,7 +616,7 @@ function SendLocaleEvent(f,a)
SendEventCommand ("LOCALE","(%s) (%s) -1",a,a)
end
elseif f=="I" then
- SendEventCommand ("LOCALE","(%s) (%s) 0", gsobj.locale:GetLocale(),
+ SendEventCommand ("LOCALE","(%s) (%s) 0", gsobj.locale:GetLocale(),
string.sub(gsobj.locale:GetName(),1,2))
elseif f=="S" then
local lang=gsobj.locale.FindLanguageInfo(a)
@@ -689,14 +690,14 @@ function ReadDSCcomments(fname)
psb,pse = pstr:find("%%",pse,true)
if psb then
if pstr:sub(psb-1,pse):match("[\n\r]%%[%%D!]") then
- pseb,psee = pstr:find("[\n\r]+",pse)
+ pseb,psee = pstr:find("[\n\r]+",pse)
if pseb then
pse=psee
SendDSCComment(pstr:sub(psb,pseb-1),pp+psb,pp+pse)
elseif pn==psend then
pse=pstr:len()
SendDSCComment(pstr:sub(psb,pse),pp+psb,pp+pse)
- elseif psb+1024<pn then
+ elseif psb+1024<pstr:len() then
pse=psb+255
SendDSCComment(pstr:sub(psb,pse),pp+psb,pp+pse)
else
@@ -1031,11 +1032,11 @@ end
function DestroyOverlay()
if gsstat.inoverlay then
- gsstat.inoverlay=false
+ gsstat.inoverlay=false
if gsstat.drawoverlay then
gsobj.image=gsobj.overlay
gswin.gswindow:SetGsImage(gsobj.image)
- gsstat.drawoverlay=false
+ gsstat.drawoverlay=false
end
gsobj.overlay=nil
if gsobj.bbmp then gsobj.obmp:delete() gsobj.obmp=nil end
@@ -1081,7 +1082,7 @@ function OnPaintExtra(event)
-- draw objects
end
dc:delete()
-end
+end
function AddDrawObject(id,dim,pen)
if Dobject.n==0 then CreateDrawObjects() end
@@ -1138,7 +1139,7 @@ function MakeResizeEvent(f,s,x,y)
elseif s=="F" then frame:ShowFullScreen(false) end
elseif f=="S" then
end
-end
+end
function MouseButtonEvent(event)
local mod=wx.wxMOD_NONE
@@ -1920,10 +1921,20 @@ function FixGSPaths(gsargs)
if gsargs.dllloc~="" then
fname:Assign(gsargs.dllloc)
fname:RemoveDir(fname:GetDirCount()-1) fname:AppendDir("lib")
- fname:SetName("gs_init") fname:SetExt("ps")
+ fname:SetName("gs_il2_e") fname:SetExt("ps")
if fname:FileExists() then gslib = PSFName(fname:GetFullPath()) end
+ fname:Assign(gsargs.dllloc)
+ fname:RemoveDir(fname:GetDirCount()-1)
+ fname:AppendDir("Resource") fname:AppendDir("Init")
+ fname:SetName("gs_init") fname:SetExt("ps")
+ if fname:FileExists() then
+ if gslib=="" then gslib = PSFName(fname:GetFullPath())
+ else gslib = gslib .. sep .. PSFName(fname:GetFullPath()) end
+ end
end
end
+ if gslib=="" then gslib="%rom%lib/" .. sep .. "%rom%Resource/Init" end
+
if psvlib=="" then
for i,v in ipairs(gsargs.progs) do
@@ -1940,7 +1951,7 @@ function FixGSPaths(gsargs)
for i,v in ipairs(gsargs.libs) do
if libstr~="" then libstr=libstr..sep..v else libstr=v end
end
- if libstr=="" and libloc~="" then libstr=gslibloc end
+ if libstr=="" and libloc~="" then libstr=libloc end
if gslib~="" and not libstr:find(gslib,1,true) then
if libstr~="" then libstr=gslib..sep..libstr else libstr=gslib end
@@ -1954,7 +1965,8 @@ function FixGSPaths(gsargs)
gsargs.libloc, gsargs.gslib, gsargs.psvlib = libstr, gslib, psvlib
-- add default parameters at begining
- for i,v in ipairs(gsargs.dftpars) do table.insert(gsargs.args,i,v) end
+ if #gsargs.cmd_pars==0 then gsargs.cmd_pars = PSV_DftGsPars end
+ for i,v in ipairs(gsargs.cmd_pars) do table.insert(gsargs.args,i,v) end
-- and PS programs at the end
for i,v in ipairs(gsargs.progs) do table.insert(gsargs.args,v) end
end
@@ -1984,26 +1996,27 @@ function PrepareLocale()
return wx.wxGetTranslation(str)
end
PS_VIEW_VERSION_STRING=string.format(_T("%s, version %g"), PS_VIEW_NAME, PS_VIEW_VERSION)
- print("!!!!" .. psvpars.language.. "!".. lang .. PS_VIEW_VERSION_STRING .. "\n")
end
function CreateInstanceChecker()
local checker={}
function checker:Create()
+ local tname="." .. PS_VIEW_NAME
+ if wx.__WXMSW__ then tname="psview" end -- for Vista (?)
-- wx.wxFileName.GetTempDir() -- not implemented in wxLua
-- os.tmpname() -- gives bad result under MSW
local fname=wx.wxFileName()
- fname:AssignTempFileName("." .. PS_VIEW_NAME)
+ fname:AssignTempFileName(tname)
if fname:IsOk() then
wx.wxRemoveFile(fname:GetFullPath())
else return false end
fname:AssignDir(fname:GetPath(wx.wxPATH_GET_VOLUME))
- fname:AppendDir("." .. PS_VIEW_NAME)
+ fname:AppendDir(tname)
if not fname:DirExists() then
if not fname:Mkdir() then return false end
end
self.dname=wx.wxFileName(fname)
- fname:SetName("." .. PS_VIEW_NAME .. MakeNameHash()) fname:SetExt("lock")
+ fname:SetName(tname .. MakeNameHash()) fname:SetExt("lock")
self.fname=wx.wxFileName(fname)
self.created=false self.time=nil
end
@@ -2087,7 +2100,9 @@ function ConfigGetParameters()
gsobj.config:SetPath("/PSV_Parameters")
local _, _cmd = gsobj.config:Read("cmdpars", "")
local _, _lang = gsobj.config:Read("language", "")
- if psvpars.cmd_pars=="" and _cmd then psvpars.cmd_pars = _cmd end
+ if #gsargs.cmd_pars==0 and _cmd then
+ for i in string.gmatch(_cmd,"%S+") do table.insert(gsargs.cmd_pars,i) end
+ end
if psvpars.language=="" and _lang then psvpars.language = _lang end
end
@@ -2173,7 +2188,7 @@ function Main()
gsobj.instancechecker:Destroy()
return true
elseif force_open then gsobj.instancechecker.created=true end
-
+
ConfigGetPaths(gsargs)