Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Alt-R -> Alt-F -> Alt-C and MANY other things... #475

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) $(DJVULIBS) $(CRENGINELIBS)

INSTALL_DIR=kindlepdfviewer

LUA_FILES=alt_getopt.lua commands.lua crereader.lua dialog.lua djvureader.lua extentions.lua filechooser.lua filehistory.lua fileinfo.lua filesearcher.lua font.lua graphics.lua helppage.lua image.lua inputbox.lua keys.lua pdfreader.lua koptreader.lua picviewer.lua reader.lua rendertext.lua screen.lua selectmenu.lua settings.lua unireader.lua widget.lua
LUA_FILES=commands.lua crereader.lua dialog.lua djvureader.lua extentions.lua filechooser.lua filehistory.lua fileinfo.lua filesearcher.lua font.lua graphics.lua helppage.lua image.lua inputbox.lua keys.lua pdfreader.lua koptreader.lua picviewer.lua reader.lua rendertext.lua screen.lua selectmenu.lua settings.lua unireader.lua widget.lua

customupdate: all
# ensure that build binary is for ARM
Expand Down
166 changes: 0 additions & 166 deletions alt_getopt.lua

This file was deleted.

2 changes: 1 addition & 1 deletion crereader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ function CREReader:adjustCreReaderCommands()
self.commands:del(KEY_X, MOD_SHIFT, "X")
self.commands:del(KEY_L, MOD_SHIFT, "L")
self.commands:del(KEY_M, nil, "M")
self.commands:del(KEY_R, MOD_ALT,"R")
self.commands:del(KEY_C, MOD_ALT, "C")

-- CCW-rotation
self.commands:add(KEY_K, nil, "K",
Expand Down
6 changes: 3 additions & 3 deletions extentions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ ext = {
}


function ext:getReader(ftype, oldreader)
function ext:getReader(ftype, use_koptreader)
local s = ";"
if ftype == "" then
return nil
elseif string.find(self.pdfRead,s..ftype..s) then
if oldreader and oldreader.use_koptreader then
if use_koptreader then
return KOPTReader
else
return PDFReader
end
elseif string.find(self.djvuRead,s..ftype..s) then
if oldreader and oldreader.use_koptreader then
if use_koptreader then
return KOPTReader
else
return DJVUReader
Expand Down
6 changes: 3 additions & 3 deletions koptreader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function KOPTReader:drawOrCache(no, preCache)
local dc = self:setzoom(page, preCache)

-- check if we have relevant cache contents
local pagehash = no..'_'..(self.reflow_mode_enable and 1 or 0)..'_'..self.globalzoom..'_'..self.globalrotate..'_'..self.globalgamma
local pagehash = no..'_'..(self.reflow_mode_enable and 1 or 0)..'_'..self.globalzoom..'_'..self.globalrotate..'_'..self.globalgamma..'K'
Debug('page hash', pagehash)
if self.cache[pagehash] ~= nil then
-- we have something in cache
Expand Down Expand Up @@ -255,8 +255,8 @@ function KOPTReader:prevView()
end

function KOPTReader:setDefaults()
self.show_overlap_enable = true
self.show_links_enable = false
self.show_overlap_enable = true
self.show_links_enable = false
end

function KOPTReader:init()
Expand Down
2 changes: 1 addition & 1 deletion picviewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function PICViewer:adjustCommands()
self.commands:del(KEY_N, MOD_SHIFT, "N")
self.commands:del(KEY_J, MOD_SHIFT,"J")
self.commands:del(KEY_K, MOD_SHIFT,"K")
self.commands:del(KEY_R, MOD_ALT,"R")
self.commands:del(KEY_C, MOD_ALT,"C")
self.commands:del(KEY_BACK, nil,"Back")
self.commands:del(KEY_BACK, MOD_SHIFT,"Back")
self.commands:delGroup("[1, 2 .. 9, 0]")
Expand Down
57 changes: 16 additions & 41 deletions reader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
require "alt_getopt"
require "pdfreader"
require "djvureader"
require "koptreader"
Expand All @@ -29,15 +28,6 @@ require "commands"
require "dialog"
require "extentions"

-- option parsing:
longopts = {
password = "p",
goto = "g",
gamma = "G",
debug = "d",
help = "h"
}

function openFile(filename)
local file_type = string.lower(string.match(filename, ".+%.([^.]+)"))
local reader = nil
Expand All @@ -46,9 +36,12 @@ function openFile(filename)
if reader then
InfoMessage:inform("Opening document... ", nil, 0, MSG_AUX)
reader:preLoadSettings(filename)
-- re-establish the reader due to use_koptreader setting
reader = ext:getReader(file_type, reader)
reader:preLoadSettings(filename)
-- re-establish the reader if needed
if reader.use_koptreader == true then
reader.use_koptreader = false
reader = ext:getReader(file_type, true)
reader:preLoadSettings(filename)
end
local ok, err = reader:open(filename)
if ok then
reader:loadSettings(filename)
Expand All @@ -70,11 +63,8 @@ end

function showusage()
print("usage: ./reader.lua [OPTION] ... path")
print("Read PDFs and DJVUs on your E-Ink reader")
print("Read PDF/DjVu/ePub/MOBI/FB2/CHM/HTML/TXT/DOC/RTF/JPEG on your E-Ink reader")
print("")
print("-p, --password=PASSWORD set password for reading PDF document")
print("-g, --goto=page start reading on page")
print("-G, --gamma=GAMMA set gamma correction")
print("-d, --debug start in debug mode")
print(" (floating point notation, e.g. \"1.5\")")
print("-h, --help show this usage help")
Expand All @@ -89,21 +79,19 @@ function showusage()
return
end

optarg, optind = alt_getopt.get_opts(ARGV, "p:g:G:hg:dg:", longopts)
if optarg["h"] then
if ARGV[1] == "-h" then
return showusage()
end

if not optarg["d"] then
local argidx = 1
if ARGV[1] == "-d" then
argidx = argidx + 1
else
Debug = function() end
dump = function() end
debug = function() end
end

if optarg["G"] ~= nil then
globalgamma = optarg["G"]
end

local vfile = io.open("git-rev", "r")
if vfile then
G_program_version = vfile:read("*a") or "?"
Expand Down Expand Up @@ -156,9 +144,7 @@ end
FileChooser.filemanager_expert_mode = G_reader_settings:readSetting("filemanager_expert_mode") or 1
InfoMessage:initInfoMessageSettings()

-- initialize global settings shared among all readers
UniReader:initGlobalSettings(G_reader_settings)
-- initialize specific readers
PDFReader:init()
DJVUReader:init()
KOPTReader:init()
Expand All @@ -167,26 +153,15 @@ CREReader:init()

-- display directory or open file
local patharg = G_reader_settings:readSetting("lastfile")
if ARGV[optind] and lfs.attributes(ARGV[optind], "mode") == "directory" then
local running = true
FileChooser:setPath(ARGV[optind])
while running do
local file = FileChooser:choose(0, G_height)
if file then
running = openFile(file)
else
running = false
end
end
elseif ARGV[optind] and lfs.attributes(ARGV[optind], "mode") == "file" then
openFile(ARGV[optind], optarg["p"])
if ARGV[argidx] and lfs.attributes(ARGV[argidx], "mode") == "directory" then
FileChooser:setPath(ARGV[argidx])
FileChooser:choose(0, G_height)
elseif patharg and lfs.attributes(patharg, "mode") == "file" then
openFile(patharg, optarg["p"])
openFile(patharg)
else
return showusage()
end


-- save reader settings
G_reader_settings:saveSetting("fontmap", Font.fontmap)
InfoMessage:saveInfoMessageSettings()
Expand Down
Loading