2012-04-09 17:04:26 +00:00
|
|
|
require "font"
|
2012-03-28 16:16:00 +00:00
|
|
|
require "unireader"
|
|
|
|
require "inputbox"
|
2012-04-06 10:05:54 +00:00
|
|
|
require "selectmenu"
|
2012-03-28 16:16:00 +00:00
|
|
|
|
|
|
|
CREReader = UniReader:new{
|
2012-04-07 14:55:56 +00:00
|
|
|
pos = nil,
|
2012-03-31 12:22:22 +00:00
|
|
|
percent = 0,
|
2012-04-06 11:11:18 +00:00
|
|
|
|
2012-04-06 11:30:10 +00:00
|
|
|
gamma_index = 15,
|
2012-04-06 11:11:18 +00:00
|
|
|
font_face = nil,
|
2012-04-13 22:38:18 +00:00
|
|
|
|
|
|
|
line_space_percent = 100,
|
2012-03-28 16:16:00 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 04:06:33 +00:00
|
|
|
function CREReader:init()
|
2012-03-30 06:10:04 +00:00
|
|
|
self:addAllCommands()
|
2012-03-30 04:06:33 +00:00
|
|
|
self:adjustCreReaderCommands()
|
2012-04-09 17:04:26 +00:00
|
|
|
-- we need to initialize the CRE font list
|
|
|
|
local fonts = Font:getFontList()
|
|
|
|
for _k, _v in ipairs(fonts) do
|
|
|
|
local ok, err = pcall(cre.registerFont, Font.fontdir..'/'.._v)
|
|
|
|
if not ok then
|
2012-04-18 16:16:49 +00:00
|
|
|
debug(err)
|
2012-04-09 17:04:26 +00:00
|
|
|
end
|
|
|
|
end
|
2012-03-30 04:06:33 +00:00
|
|
|
end
|
|
|
|
|
2012-03-28 16:16:00 +00:00
|
|
|
-- open a CREngine supported file and its settings store
|
|
|
|
function CREReader:open(filename)
|
|
|
|
local ok
|
|
|
|
local file_type = string.lower(string.match(filename, ".+%.([^.]+)"))
|
2012-04-06 10:05:54 +00:00
|
|
|
-- these two format use the same css file
|
2012-04-05 02:31:31 +00:00
|
|
|
if file_type == "html" then
|
|
|
|
file_type = "htm"
|
|
|
|
end
|
2012-03-28 16:16:00 +00:00
|
|
|
local style_sheet = "./data/"..file_type..".css"
|
|
|
|
ok, self.doc = pcall(cre.openDocument, filename, style_sheet,
|
2012-04-09 07:42:19 +00:00
|
|
|
G_width, G_height)
|
2012-03-28 16:16:00 +00:00
|
|
|
if not ok then
|
|
|
|
return false, self.doc -- will contain error message
|
|
|
|
end
|
|
|
|
|
2012-04-13 22:38:18 +00:00
|
|
|
self.doc:setDefaultInterlineSpace(self.line_space_percent)
|
|
|
|
|
2012-03-28 16:16:00 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
----------------------------------------------------
|
|
|
|
-- setting related methods
|
|
|
|
----------------------------------------------------
|
2012-04-06 11:11:18 +00:00
|
|
|
function CREReader:loadSpecialSettings()
|
|
|
|
local font_face = self.settings:readSetting("font_face")
|
|
|
|
self.font_face = font_face or "FreeSerif"
|
|
|
|
self.doc:setFontFace(self.font_face)
|
2012-04-06 11:30:10 +00:00
|
|
|
|
|
|
|
local gamma_index = self.settings:readSetting("gamma_index")
|
|
|
|
self.gamma_index = gamma_index or self.gamma_index
|
|
|
|
cre.setGammaIndex(self.gamma_index)
|
2012-04-13 22:38:18 +00:00
|
|
|
|
|
|
|
local line_space_percent = self.settings:readSetting("line_space_percent")
|
|
|
|
self.line_space_percent = line_space_percent or self.line_space_percent
|
2012-04-06 11:11:18 +00:00
|
|
|
end
|
|
|
|
|
2012-03-30 06:25:36 +00:00
|
|
|
function CREReader:getLastPageOrPos()
|
2012-03-31 12:22:22 +00:00
|
|
|
local last_percent = self.settings:readSetting("last_percent")
|
|
|
|
if last_percent then
|
2012-04-07 14:55:56 +00:00
|
|
|
return math.floor((last_percent * self.doc:getFullHeight()) / 10000)
|
2012-03-31 12:22:22 +00:00
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
2012-03-30 06:25:36 +00:00
|
|
|
end
|
|
|
|
|
2012-04-06 12:26:53 +00:00
|
|
|
function CREReader:saveSpecialSettings()
|
2012-04-19 12:37:25 +00:00
|
|
|
self.settings:saveSetting("font_face", self.font_face)
|
|
|
|
self.settings:saveSetting("gamma_index", self.gamma_index)
|
|
|
|
self.settings:saveSetting("line_space_percent", self.line_space_percent)
|
2012-04-06 12:26:53 +00:00
|
|
|
end
|
|
|
|
|
2012-03-30 06:25:36 +00:00
|
|
|
function CREReader:saveLastPageOrPos()
|
2012-04-19 12:37:25 +00:00
|
|
|
self.settings:saveSetting("last_percent", self.percent)
|
2012-03-30 06:25:36 +00:00
|
|
|
end
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
----------------------------------------------------
|
|
|
|
-- render related methods
|
|
|
|
----------------------------------------------------
|
|
|
|
-- we don't need setzoom in CREReader
|
2012-03-29 10:17:32 +00:00
|
|
|
function CREReader:setzoom(page, preCache)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
function CREReader:redrawCurrentPage()
|
|
|
|
self:goto(self.pos)
|
2012-03-30 06:25:36 +00:00
|
|
|
end
|
|
|
|
|
2012-04-10 13:34:38 +00:00
|
|
|
-- there is no zoom mode in CREReader
|
|
|
|
function CREReader:setGlobalZoomMode()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
----------------------------------------------------
|
|
|
|
-- goto related methods
|
|
|
|
----------------------------------------------------
|
2012-04-18 15:54:17 +00:00
|
|
|
function CREReader:goto(pos, is_ignore_jump, pos_type)
|
2012-04-07 14:55:56 +00:00
|
|
|
local prev_xpointer = self.doc:getXPointer()
|
2012-04-09 07:42:19 +00:00
|
|
|
local width, height = G_width, G_height
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
if pos_type == "xpointer" then
|
|
|
|
self.doc:gotoXPointer(pos)
|
|
|
|
pos = self.doc:getCurrentPos()
|
2012-04-19 02:31:38 +00:00
|
|
|
else -- pos_type is position within document
|
2012-04-09 07:06:52 +00:00
|
|
|
pos = math.min(pos, self.doc:getFullHeight() - height)
|
2012-04-07 14:55:56 +00:00
|
|
|
pos = math.max(pos, 0)
|
|
|
|
self.doc:gotoPos(pos)
|
|
|
|
end
|
2012-03-29 11:35:56 +00:00
|
|
|
|
2012-04-18 16:04:41 +00:00
|
|
|
-- add to jump history, distinguish jump from normal page turn
|
2012-04-07 14:55:56 +00:00
|
|
|
-- NOTE:
|
|
|
|
-- even though we have called gotoPos() or gotoXPointer() previously,
|
|
|
|
-- self.pos hasn't been updated yet here, so we can still make use of it.
|
2012-04-18 15:54:17 +00:00
|
|
|
if not is_ignore_jump then
|
|
|
|
if self.pos and math.abs(self.pos - pos) > height then
|
|
|
|
self:addJump(prev_xpointer)
|
|
|
|
end
|
2012-03-29 11:35:56 +00:00
|
|
|
end
|
|
|
|
|
2012-03-28 16:16:00 +00:00
|
|
|
self.doc:drawCurrentPage(self.nulldc, fb.bb)
|
|
|
|
|
2012-04-18 16:16:49 +00:00
|
|
|
debug("## self.show_overlap "..self.show_overlap)
|
2012-04-09 13:06:05 +00:00
|
|
|
if self.show_overlap < 0 then
|
2012-04-09 13:52:36 +00:00
|
|
|
fb.bb:dimRect(0,0, width, -self.show_overlap)
|
2012-04-09 13:06:05 +00:00
|
|
|
elseif self.show_overlap > 0 then
|
2012-04-09 13:52:36 +00:00
|
|
|
fb.bb:dimRect(0,height - self.show_overlap, width, self.show_overlap)
|
2012-04-09 13:06:05 +00:00
|
|
|
end
|
|
|
|
self.show_overlap = 0
|
|
|
|
|
2012-04-19 06:14:08 +00:00
|
|
|
if self.rcount >= self.rcountmax then
|
2012-04-18 16:16:49 +00:00
|
|
|
debug("full refresh")
|
2012-04-19 06:14:08 +00:00
|
|
|
self.rcount = 0
|
2012-03-28 16:16:00 +00:00
|
|
|
fb:refresh(0)
|
|
|
|
else
|
2012-04-18 16:16:49 +00:00
|
|
|
debug("partial refresh")
|
2012-03-28 16:16:00 +00:00
|
|
|
self.rcount = self.rcount + 1
|
|
|
|
fb:refresh(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
self.pos = pos
|
|
|
|
self.pageno = self.doc:getCurrentPage()
|
2012-04-07 14:55:56 +00:00
|
|
|
self.percent = self.doc:getCurrentPercent()
|
2012-03-28 16:16:00 +00:00
|
|
|
end
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
function CREReader:gotoPercent(percent)
|
|
|
|
self:goto(percent * self.doc:getFullHeight() / 10000)
|
|
|
|
end
|
|
|
|
|
|
|
|
function CREReader:gotoTocEntry(entry)
|
2012-04-18 15:54:17 +00:00
|
|
|
self:goto(entry.xpointer, nil, "xpointer")
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function CREReader:nextView()
|
2012-04-09 13:06:05 +00:00
|
|
|
self.show_overlap = -self.pan_overlap_vertical
|
2012-04-09 07:42:19 +00:00
|
|
|
return self.pos + G_height - self.pan_overlap_vertical
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function CREReader:prevView()
|
2012-04-09 13:06:05 +00:00
|
|
|
self.show_overlap = self.pan_overlap_vertical
|
2012-04-09 07:42:19 +00:00
|
|
|
return self.pos - G_height + self.pan_overlap_vertical
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
----------------------------------------------------
|
2012-04-18 16:04:41 +00:00
|
|
|
-- jump history related methods
|
2012-04-07 14:55:56 +00:00
|
|
|
----------------------------------------------------
|
|
|
|
function CREReader:isSamePage(p1, p2)
|
|
|
|
return self.doc:getPageFromXPointer(p1) == self.doc:getPageFromXPointer(p2)
|
2012-03-28 16:16:00 +00:00
|
|
|
end
|
|
|
|
|
2012-04-18 15:54:17 +00:00
|
|
|
function CREReader:showJumpHist()
|
2012-04-07 14:55:56 +00:00
|
|
|
local menu_items = {}
|
2012-04-18 15:54:17 +00:00
|
|
|
for k,v in ipairs(self.jump_history) do
|
|
|
|
if k == self.jump_history.cur then
|
|
|
|
cur_sign = "*(Cur) "
|
|
|
|
else
|
|
|
|
cur_sign = ""
|
|
|
|
end
|
2012-04-07 14:55:56 +00:00
|
|
|
table.insert(menu_items,
|
2012-04-18 15:54:17 +00:00
|
|
|
cur_sign..v.datetime.." -> Page "
|
|
|
|
..self.doc:getPageFromXPointer(v.page).." "..v.notes)
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
2012-04-17 06:39:17 +00:00
|
|
|
|
|
|
|
if #menu_items == 0 then
|
|
|
|
showInfoMsgWithDelay(
|
|
|
|
"No jump history found.", 2000, 1)
|
2012-04-07 14:55:56 +00:00
|
|
|
else
|
2012-04-18 15:54:17 +00:00
|
|
|
-- if cur points to head, draw entry for current page
|
|
|
|
if self.jump_history.cur > #self.jump_history then
|
|
|
|
table.insert(menu_items,
|
|
|
|
"Current Page "..self.pageno)
|
|
|
|
end
|
|
|
|
|
2012-04-17 06:39:17 +00:00
|
|
|
jump_menu = SelectMenu:new{
|
2012-04-18 15:54:17 +00:00
|
|
|
menu_title = "Jump History",
|
2012-04-17 06:39:17 +00:00
|
|
|
item_array = menu_items,
|
|
|
|
}
|
|
|
|
item_no = jump_menu:choose(0, fb.bb:getHeight())
|
2012-04-18 15:54:17 +00:00
|
|
|
if item_no and item_no <= #self.jump_history then
|
|
|
|
local jump_item = self.jump_history[item_no]
|
|
|
|
self.jump_history.cur = item_no
|
|
|
|
self:goto(jump_item.page, true, "xpointer")
|
|
|
|
else
|
|
|
|
self:redrawCurrentPage()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
----------------------------------------------------
|
|
|
|
-- bookmarks related methods
|
|
|
|
----------------------------------------------------
|
|
|
|
function CREReader:showBookMarks()
|
|
|
|
local menu_items = {}
|
|
|
|
-- build menu items
|
|
|
|
for k,v in ipairs(self.bookmarks) do
|
|
|
|
table.insert(menu_items,
|
|
|
|
"Page "..self.doc:getPageFromXPointer(v.page)
|
|
|
|
.." "..v.notes.." @ "..v.datetime)
|
|
|
|
end
|
|
|
|
if #menu_items == 0 then
|
|
|
|
showInfoMsgWithDelay(
|
|
|
|
"No bookmark found.", 2000, 1)
|
|
|
|
else
|
|
|
|
toc_menu = SelectMenu:new{
|
|
|
|
menu_title = "Bookmarks",
|
|
|
|
item_array = menu_items,
|
|
|
|
}
|
|
|
|
item_no = toc_menu:choose(0, fb.bb:getHeight())
|
2012-04-17 06:39:17 +00:00
|
|
|
if item_no then
|
2012-04-18 15:54:17 +00:00
|
|
|
self:goto(self.bookmarks[item_no].page, nil, "xpointer")
|
2012-04-17 06:39:17 +00:00
|
|
|
else
|
|
|
|
self:redrawCurrentPage()
|
|
|
|
end
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-18 16:16:49 +00:00
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
----------------------------------------------------
|
|
|
|
-- TOC related methods
|
|
|
|
----------------------------------------------------
|
2012-04-19 01:49:46 +00:00
|
|
|
function CREReader:getTocTitleByPage(page_or_xpoint)
|
|
|
|
local page = 1
|
|
|
|
-- tranform xpointer to page
|
|
|
|
if type(page_or_xpoint) == "string" then
|
|
|
|
page = self.doc:getPageFromXPointer(page_or_xpoint)
|
|
|
|
else
|
|
|
|
page = page_or_xpoint
|
|
|
|
end
|
|
|
|
return self:_getTocTitleByPage(page)
|
|
|
|
end
|
|
|
|
|
2012-04-07 14:55:56 +00:00
|
|
|
function CREReader:getTocTitleOfCurrentPage()
|
2012-04-19 02:23:39 +00:00
|
|
|
return self:getTocTitleByPage(self.doc:getXPointer())
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
----------------------------------------------------
|
|
|
|
-- menu related methods
|
|
|
|
----------------------------------------------------
|
2012-03-30 06:00:41 +00:00
|
|
|
-- used in CREReader:showMenu()
|
|
|
|
function CREReader:_drawReadingInfo()
|
2012-04-09 07:42:19 +00:00
|
|
|
local ypos = G_height - 50
|
2012-03-31 12:22:22 +00:00
|
|
|
local load_percent = self.percent/100
|
2012-03-29 10:17:32 +00:00
|
|
|
|
2012-04-09 07:42:19 +00:00
|
|
|
fb.bb:paintRect(0, ypos, G_width, 50, 0)
|
2012-03-29 10:17:32 +00:00
|
|
|
|
|
|
|
ypos = ypos + 15
|
2012-04-09 17:04:26 +00:00
|
|
|
local face = Font:getFace("rifont", 22)
|
2012-04-07 14:55:56 +00:00
|
|
|
local cur_section = self:getTocTitleOfCurrentPage()
|
2012-03-29 10:17:32 +00:00
|
|
|
if cur_section ~= "" then
|
|
|
|
cur_section = "Section: "..cur_section
|
|
|
|
end
|
2012-04-09 17:04:26 +00:00
|
|
|
renderUtf8Text(fb.bb, 10, ypos+6, face,
|
2012-03-31 12:22:22 +00:00
|
|
|
"Position: "..load_percent.."%".." "..cur_section, true)
|
2012-03-29 10:17:32 +00:00
|
|
|
|
|
|
|
ypos = ypos + 15
|
2012-04-09 07:42:19 +00:00
|
|
|
blitbuffer.progressBar(fb.bb, 10, ypos, G_width - 20, 15,
|
2012-04-04 09:03:01 +00:00
|
|
|
5, 4, load_percent/100, 8)
|
2012-03-28 16:16:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-03-30 04:06:33 +00:00
|
|
|
|
|
|
|
function CREReader:adjustCreReaderCommands()
|
2012-03-30 04:31:09 +00:00
|
|
|
-- delete commands
|
2012-04-06 12:13:46 +00:00
|
|
|
self.commands:delGroup("[joypad]")
|
2012-03-30 04:06:33 +00:00
|
|
|
self.commands:del(KEY_G, nil, "G")
|
2012-04-13 04:46:33 +00:00
|
|
|
self.commands:del(KEY_J, MOD_SHIFT, "J")
|
|
|
|
self.commands:del(KEY_K, MOD_SHIFT, "K")
|
2012-03-30 04:06:33 +00:00
|
|
|
self.commands:del(KEY_Z, nil, "Z")
|
|
|
|
self.commands:del(KEY_Z, MOD_SHIFT, "Z")
|
|
|
|
self.commands:del(KEY_Z, MOD_ALT, "Z")
|
|
|
|
self.commands:del(KEY_A, nil, "A")
|
|
|
|
self.commands:del(KEY_A, MOD_SHIFT, "A")
|
|
|
|
self.commands:del(KEY_A, MOD_ALT, "A")
|
|
|
|
self.commands:del(KEY_S, nil, "S")
|
|
|
|
self.commands:del(KEY_S, MOD_SHIFT, "S")
|
|
|
|
self.commands:del(KEY_S, MOD_ALT, "S")
|
|
|
|
self.commands:del(KEY_D, nil, "D")
|
|
|
|
self.commands:del(KEY_D, MOD_SHIFT, "D")
|
|
|
|
self.commands:del(KEY_D, MOD_ALT, "D")
|
|
|
|
self.commands:del(KEY_F, MOD_SHIFT, "F")
|
|
|
|
self.commands:del(KEY_F, MOD_ALT, "F")
|
2012-04-11 20:52:48 +00:00
|
|
|
self.commands:del(KEY_N, nil, "N") -- highlight
|
|
|
|
self.commands:del(KEY_N, MOD_SHIFT, "N") -- show highlights
|
2012-03-30 04:31:09 +00:00
|
|
|
|
|
|
|
-- overwrite commands
|
2012-04-25 06:08:33 +00:00
|
|
|
|
|
|
|
self.commands:addGroup(MOD_SHIFT.."< >",{
|
|
|
|
Keydef:new(KEY_PGBCK,MOD_SHIFT),Keydef:new(KEY_PGFWD,MOD_SHIFT),
|
|
|
|
Keydef:new(KEY_LPGBCK,MOD_SHIFT),Keydef:new(KEY_LPGFWD,MOD_SHIFT)},
|
|
|
|
"increase/decrease font size",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
2012-04-25 06:08:33 +00:00
|
|
|
local delta = 1
|
|
|
|
if keydef.keycode == KEY_PGBCK or keydef.keycode == KEY_LPGBCK then
|
|
|
|
delta = -1
|
2012-04-13 22:38:18 +00:00
|
|
|
end
|
2012-04-25 06:08:33 +00:00
|
|
|
self.doc:zoomFont(delta)
|
2012-04-20 02:00:20 +00:00
|
|
|
self:redrawCurrentPage()
|
2012-04-13 22:38:18 +00:00
|
|
|
end
|
|
|
|
)
|
2012-04-25 06:08:33 +00:00
|
|
|
self.commands:addGroup(MOD_ALT.."< >",{
|
|
|
|
Keydef:new(KEY_PGBCK,MOD_ALT),Keydef:new(KEY_PGFWD,MOD_ALT),
|
|
|
|
Keydef:new(KEY_LPGBCK,MOD_ALT),Keydef:new(KEY_LPGFWD,MOD_ALT)},
|
|
|
|
"increase/decrease line spacing",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
2012-04-25 06:08:33 +00:00
|
|
|
if keydef.keycode == KEY_PGBCK or keydef.keycode == KEY_LPGBCK then
|
|
|
|
self.line_space_percent = self.line_space_percent - 10
|
|
|
|
if self.line_space_percent < 100 then
|
|
|
|
self.line_space_percent = 100
|
|
|
|
end
|
|
|
|
else
|
|
|
|
self.line_space_percent = self.line_space_percent + 10
|
|
|
|
if self.line_space_percent > 200 then
|
|
|
|
self.line_space_percent = 200
|
|
|
|
end
|
2012-04-13 22:38:18 +00:00
|
|
|
end
|
2012-04-16 19:30:27 +00:00
|
|
|
InfoMessage:show("line spacing "..self.line_space_percent.."%", 0)
|
2012-04-18 16:16:49 +00:00
|
|
|
debug("line spacing set to", self.line_space_percent)
|
2012-04-20 02:00:20 +00:00
|
|
|
self.doc:setDefaultInterlineSpace(self.line_space_percent)
|
|
|
|
self:redrawCurrentPage()
|
2012-03-30 04:31:09 +00:00
|
|
|
end
|
|
|
|
)
|
2012-03-30 04:38:41 +00:00
|
|
|
local numeric_keydefs = {}
|
|
|
|
for i=1,10 do
|
|
|
|
numeric_keydefs[i]=Keydef:new(KEY_1+i-1, nil, tostring(i%10))
|
|
|
|
end
|
|
|
|
self.commands:addGroup("[1..0]", numeric_keydefs,
|
|
|
|
"jump to <key>*10% of document",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self, keydef)
|
2012-04-18 16:16:49 +00:00
|
|
|
debug('jump to position: '..
|
2012-04-20 02:00:20 +00:00
|
|
|
math.floor(self.doc:getFullHeight()*(keydef.keycode-KEY_1)/9)..
|
|
|
|
'/'..self.doc:getFullHeight())
|
|
|
|
self:goto(math.floor(self.doc:getFullHeight()*(keydef.keycode-KEY_1)/9))
|
2012-03-30 04:38:41 +00:00
|
|
|
end
|
|
|
|
)
|
2012-04-06 10:05:54 +00:00
|
|
|
self.commands:add(KEY_F, nil, "F",
|
2012-04-16 19:56:16 +00:00
|
|
|
"change document font",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
2012-04-16 19:56:16 +00:00
|
|
|
Screen:saveCurrentBB()
|
|
|
|
|
2012-04-06 10:05:54 +00:00
|
|
|
local face_list = cre.getFontFaces()
|
|
|
|
|
|
|
|
local fonts_menu = SelectMenu:new{
|
|
|
|
menu_title = "Fonts Menu",
|
|
|
|
item_array = face_list,
|
|
|
|
}
|
|
|
|
|
2012-04-09 07:42:19 +00:00
|
|
|
local item_no = fonts_menu:choose(0, G_height)
|
2012-04-18 16:16:49 +00:00
|
|
|
debug(face_list[item_no])
|
2012-04-06 10:05:54 +00:00
|
|
|
if item_no then
|
2012-04-20 02:00:20 +00:00
|
|
|
self.doc:setFontFace(face_list[item_no])
|
2012-04-06 11:11:18 +00:00
|
|
|
self.font_face = face_list[item_no]
|
2012-04-19 14:18:27 +00:00
|
|
|
InfoMessage:show("Redrawing with "..face_list[item_no], 0)
|
2012-04-06 10:05:54 +00:00
|
|
|
end
|
2012-04-16 19:56:16 +00:00
|
|
|
Screen:restoreFromSavedBB()
|
2012-04-20 02:00:20 +00:00
|
|
|
self:redrawCurrentPage()
|
2012-04-06 10:05:54 +00:00
|
|
|
end
|
|
|
|
)
|
|
|
|
self.commands:add(KEY_F, MOD_ALT, "F",
|
|
|
|
"Toggle font bolder attribute",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
|
|
|
self.doc:toggleFontBolder()
|
|
|
|
self:redrawCurrentPage()
|
2012-04-06 10:05:54 +00:00
|
|
|
end
|
|
|
|
)
|
2012-04-18 15:54:17 +00:00
|
|
|
self.commands:add(KEY_B, MOD_ALT, "B",
|
2012-04-20 10:29:08 +00:00
|
|
|
"add bookmark to current page",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
|
|
|
ok = self:addBookmark(self.doc:getXPointer())
|
2012-04-18 15:54:17 +00:00
|
|
|
if not ok then
|
|
|
|
showInfoMsgWithDelay("Page already marked!", 2000, 1)
|
|
|
|
else
|
|
|
|
showInfoMsgWithDelay("Page marked.", 2000, 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
|
|
|
self.commands:add(KEY_BACK, nil, "Back",
|
|
|
|
"go backward in jump history",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
|
|
|
local prev_jump_no = self.jump_history.cur - 1
|
2012-04-18 15:54:17 +00:00
|
|
|
if prev_jump_no >= 1 then
|
2012-04-20 02:00:20 +00:00
|
|
|
self.jump_history.cur = prev_jump_no
|
|
|
|
self:goto(self.jump_history[prev_jump_no].page, true, "xpointer")
|
2012-04-18 15:54:17 +00:00
|
|
|
else
|
|
|
|
showInfoMsgWithDelay("Already first jump!", 2000, 1)
|
|
|
|
end
|
2012-04-07 15:03:29 +00:00
|
|
|
end
|
|
|
|
)
|
2012-04-18 15:54:17 +00:00
|
|
|
self.commands:add(KEY_BACK, MOD_SHIFT, "Back",
|
|
|
|
"go forward in jump history",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
|
|
|
local next_jump_no = self.jump_history.cur + 1
|
2012-04-18 15:54:17 +00:00
|
|
|
if next_jump_no <= #self.jump_history then
|
2012-04-20 02:00:20 +00:00
|
|
|
self.jump_history.cur = next_jump_no
|
|
|
|
self:goto(self.jump_history[next_jump_no].page, true, "xpointer")
|
2012-04-18 15:54:17 +00:00
|
|
|
else
|
|
|
|
showInfoMsgWithDelay("Already last jump!", 2000, 1)
|
2012-04-07 14:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
2012-04-21 08:08:25 +00:00
|
|
|
self.commands:addGroup("vol-/+",
|
|
|
|
{Keydef:new(KEY_VPLUS,nil), Keydef:new(KEY_VMINUS,nil)},
|
|
|
|
"decrease/increase gamma",
|
|
|
|
function(self, keydef)
|
|
|
|
local delta = 1
|
|
|
|
if keydef.keycode == KEY_VMINUS then
|
|
|
|
delta = -1
|
|
|
|
end
|
|
|
|
cre.setGammaIndex(self.gamma_index+delta)
|
2012-04-06 11:30:10 +00:00
|
|
|
self.gamma_index = cre.getGammaIndex()
|
2012-04-20 02:00:20 +00:00
|
|
|
self:redrawCurrentPage()
|
2012-04-06 11:30:10 +00:00
|
|
|
end
|
|
|
|
)
|
2012-04-06 12:26:53 +00:00
|
|
|
self.commands:add(KEY_FW_UP, nil, "joypad up",
|
|
|
|
"pan "..self.shift_y.." pixels upwards",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
|
|
|
self:goto(self.pos - self.shift_y)
|
2012-04-06 12:26:53 +00:00
|
|
|
end
|
|
|
|
)
|
|
|
|
self.commands:add(KEY_FW_DOWN, nil, "joypad down",
|
|
|
|
"pan "..self.shift_y.." pixels downwards",
|
2012-04-20 02:00:20 +00:00
|
|
|
function(self)
|
|
|
|
self:goto(self.pos + self.shift_y)
|
2012-04-06 12:26:53 +00:00
|
|
|
end
|
|
|
|
)
|
2012-03-30 04:06:33 +00:00
|
|
|
end
|