1. Just a minor fix to make sure that ".." is always the first item in the list.
filechooser.lua (line 48), changes are bold
Quote:
function FileChooser:readDir()
self.dirs = {}
self.files = {}
for f in lfs.dir(self.path) do
if lfs.attributes(self.path.."/"..f, "mode") == "directory" and f ~= "." and f~=".." and not string.match(f, "^%.[^.]") then
--debug(self.path.." -> adding: '"..f.."'")
table.insert(self.dirs, f)
else
local file_type = string.lower(string.match(f, ".+%.([^.]+)") or "")
if file_type == "djvu"
or file_type == "pdf" or file_type == "xps" or file_type == "cbz"
or file_type == "epub" or file_type == "txt" or file_type == "rtf"
or file_type == "htm" or file_type == "html" or file_type == "mobi"
or file_type == "fb2" or file_type == "chm" or file_type == "doc"
or file_type == "zip" then
table.insert(self.files, f)
end
end
end
--@TODO make sure .. is sortted to the first item 16.02 2012 -- fixed
table.sort(self.dirs)
if self.path~="/" then table.insert(self.dirs,1,"..") end
table.sort(self.files)
end
|
2. Just an idea... ATM, the file docfile.kpdfview.lua with the local preferences ("gamma_index", "jump_histoty", etc) is saved in the same folder where the docfile is stored. In other words, kindlepdfreader leaves a garbage that (if the folder structure is complex) might later be a bit difficult to find (afaik, kpdf remembers tle last docfile only) and remove manually. I've changed a bit settings.lua to store all setting-files to the fixed folder ./history/ (settings.lua, line 2, changes are bold)
Quote:
function fn(fullname)
local i,j = 1,0
while i ~= nil do
i = string.find(fullname,"/",i+1)
if i==nil then break end
j = i
end
local f = string.sub(fullname,j,-1)
if j>0 then
return f.." \["..string.gsub(string.sub(fullname,1,j),"/","#").."\]"
else
return f
end
end
function DocSettings pen(docfile)
lfs.mkdir("./history") -- to make sure it exists
local new = { file = "./history/"..fn(docfile)..".lua", data = {} }
local ok, stored = pcall(dofile,new.file)
if ok then
new.data = stored
end
return setmetatable(new, { __index = DocSettings})
end
|
Apart from avoiding a garbage, I want in future to use these lua-files in making a list of recently opened docs. An evident drawback
was that several files may have the same filename, but stored in various folders.
PS Fixed! In the current version the files are saved to ./history/-folder as
docfile [ path where "/"s are replaced by "#" ].lua
Example:
Bolaño, R. – Amberes.fb2.zip [#mnt#us#books#Tests#].lua
Thanks, knc1!