mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
added file chooser
This commit is contained in:
25
reader.lua
25
reader.lua
@@ -19,6 +19,7 @@
|
||||
|
||||
require "alt_getopt"
|
||||
require "pdfreader"
|
||||
require "filechooser"
|
||||
|
||||
-- option parsing:
|
||||
longopts = {
|
||||
@@ -41,6 +42,9 @@ if optarg["h"] or ARGV[optind] == nil then
|
||||
print(" currently one of \"kdxg\" (default), \"k3\"")
|
||||
print("-h, --help show this usage help")
|
||||
print("")
|
||||
print("If you give the name of a directory instead of a path, a file")
|
||||
print("chooser will show up and let you select a PDF file")
|
||||
print("")
|
||||
print("This software is licensed under the GPLv3.")
|
||||
print("See http://github.com/hwhw/kindlepdfviewer for more info.")
|
||||
return
|
||||
@@ -68,7 +72,20 @@ end
|
||||
fb = einkfb.open("/dev/fb0")
|
||||
width, height = fb:getSize()
|
||||
|
||||
PDFReader:open(ARGV[optind], optarg["p"])
|
||||
PDFReader:goto(tonumber(optarg["g"]) or tonumber(PDFReader.settings:readsetting("last_page") or 1))
|
||||
PDFReader:inputloop()
|
||||
|
||||
if lfs.attributes(ARGV[optind], "mode") == "directory" then
|
||||
local running = true
|
||||
while running do
|
||||
local pdffile = FileChooser:choose(ARGV[optind],0,height)
|
||||
if pdffile ~= nil then
|
||||
PDFReader:open(pdffile,"") -- TODO: query for password
|
||||
PDFReader:goto(tonumber(PDFReader.settings:readsetting("last_page") or 1))
|
||||
PDFReader:inputloop()
|
||||
else
|
||||
running = false
|
||||
end
|
||||
end
|
||||
else
|
||||
PDFReader:open(ARGV[optind], optarg["p"])
|
||||
PDFReader:goto(tonumber(optarg["g"]) or tonumber(PDFReader.settings:readsetting("last_page") or 1))
|
||||
PDFReader:inputloop()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user