forked from koreader/kindlepdfviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
picviewer.lua
69 lines (62 loc) · 2.45 KB
/
picviewer.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require "unireader"
PICViewer = UniReader:new{}
function PICViewer:setDefaults()
self.show_overlap_enable = DPICVIEWER_SHOW_OVERLAP_ENABLE
self.show_links_enable = DPICVIEWER_SHOW_LINKS_ENABLE
self.comics_mode_enable = DPICVIEWER_COMICS_MODE_ENABLE
self.rtl_mode_enable = DPICVIEWER_RTL_MODE_ENABLE
self.page_mode_enable = DPICVIEWER_PAGE_MODE_ENABLE
end
function PICViewer:open(filename)
ok, self.doc = pcall(pic.openDocument, filename)
if not ok then
return ok, self.doc
end
return ok
end
function PICViewer:_drawReadingInfo()
local width = G_width
local face = Font:getFace("rifont", 20)
local rss, data, stack, lib, totalvm = memUsage()
local page_width, page_height, page_components = self.doc:getOriginalPageSize()
-- display memory, time, battery and image info on top of page
fb.bb:paintRect(0, 0, width, 60+6*2, 0)
renderUtf8Text(fb.bb, 10, 15+6, face,
"M: "..
math.ceil( self.cache_current_memsize / 1024 ).."/"..math.ceil( self.cache_max_memsize / 1024 ).."k", true)
local txt = os.date("%a %d %b %Y %T").." ["..BatteryLevel().."]"
local w = sizeUtf8Text(0, width, face, txt, true).x
renderUtf8Text(fb.bb, width - w - 10, 15+6, face, txt, true)
renderUtf8Text(fb.bb, 10, 15+6+22, face,
"Gm:"..string.format("%.1f",self.globalgamma)..", "..
tostring(page_width).."x"..tostring(page_height).."x"..tostring(page_components)..
" ("..tostring(math.ceil(page_width*page_height*page_components/1024)).."k), "..
string.format("%.1fx", self.globalzoom), true)
renderUtf8Text(fb.bb, 10, 15+6+44, face,
"RSS:"..rss.." DAT:"..data.." STK:"..stack.." LIB:"..lib.." TOT:"..totalvm.."k", true)
end
function PICViewer:init()
self:addAllCommands()
self:adjustCommands()
end
function PICViewer:adjustCommands()
self.commands:del(KEY_G, nil, "G")
self.commands:del(KEY_T, nil, "T")
self.commands:del(KEY_B, nil, "B")
self.commands:del(KEY_B, MOD_ALT, "B")
self.commands:del(KEY_B, MOD_SHIFT, "B")
self.commands:del(KEY_R, MOD_SHIFT, "R")
self.commands:del(KEY_DOT, nil, ".")
self.commands:del(KEY_N, nil, "N")
self.commands:del(KEY_L, nil, "L")
self.commands:del(KEY_L, MOD_SHIFT, "L")
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_BACK, nil,"Back")
self.commands:del(KEY_BACK, MOD_SHIFT,"Back")
self.commands:delGroup("[1, 2 .. 9, 0]")
self.commands:delGroup(MOD_ALT.."H/J")
self.commands:delGroup(MOD_ALT.."K/L")
self.commands:del(KEY_P, nil, "P")
end