diff --git a/crereader.lua b/crereader.lua index 29e1d0591..79085de0c 100644 --- a/crereader.lua +++ b/crereader.lua @@ -310,44 +310,44 @@ function CREReader:adjustCreReaderCommands() self.commands:del(KEY_N, MOD_SHIFT, "N") -- show highlights -- overwrite commands - self.commands:add(KEY_PGFWD, MOD_SHIFT, ">", + self.commands:add({KEY_PGFWD, KEY_LPGFWD}, MOD_SHIFT, ">", "increase font size", - function(cr) - cr.doc:zoomFont(1) - cr:redrawCurrentPage() + function(self) + self.doc:zoomFont(1) + self:redrawCurrentPage() end ) - self.commands:add(KEY_PGBCK, MOD_SHIFT, "<", + self.commands:add({KEY_PGBCK, KEY_LPGBCK}, MOD_SHIFT, "<", "decrease font size", - function(cr) - cr.doc:zoomFont(-1) - cr:redrawCurrentPage() + function(self) + self.doc:zoomFont(-1) + self:redrawCurrentPage() end ) - self.commands:add(KEY_PGFWD, MOD_ALT, ">", + self.commands:add({KEY_PGFWD, KEY_LPGFWD}, MOD_ALT, ">", "increase line spacing", - function(cr) + function(self) self.line_space_percent = self.line_space_percent + 10 if self.line_space_percent > 200 then self.line_space_percent = 200 end InfoMessage:show("line spacing "..self.line_space_percent.."%", 0) debug("line spacing set to", self.line_space_percent) - cr.doc:setDefaultInterlineSpace(self.line_space_percent) - cr:redrawCurrentPage() + self.doc:setDefaultInterlineSpace(self.line_space_percent) + self:redrawCurrentPage() end ) - self.commands:add(KEY_PGBCK, MOD_ALT, "<", + self.commands:add({KEY_PGBCK, KEY_LPGBCK}, MOD_ALT, "<", "decrease line spacing", - function(cr) + function(self) self.line_space_percent = self.line_space_percent - 10 if self.line_space_percent < 100 then self.line_space_percent = 100 end InfoMessage:show("line spacing "..self.line_space_percent.."%", 0) debug("line spacing set to", self.line_space_percent) - cr.doc:setDefaultInterlineSpace(self.line_space_percent) - cr:redrawCurrentPage() + self.doc:setDefaultInterlineSpace(self.line_space_percent) + self:redrawCurrentPage() end ) local numeric_keydefs = {} @@ -356,16 +356,16 @@ function CREReader:adjustCreReaderCommands() end self.commands:addGroup("[1..0]", numeric_keydefs, "jump to *10% of document", - function(cr, keydef) + function(self, keydef) debug('jump to position: '.. - math.floor(cr.doc:getFullHeight()*(keydef.keycode-KEY_1)/9).. - '/'..cr.doc:getFullHeight()) - cr:goto(math.floor(cr.doc:getFullHeight()*(keydef.keycode-KEY_1)/9)) + 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)) end ) self.commands:add(KEY_F, nil, "F", "change document font", - function(cr) + function(self) Screen:saveCurrentBB() local face_list = cre.getFontFaces() @@ -378,25 +378,25 @@ function CREReader:adjustCreReaderCommands() local item_no = fonts_menu:choose(0, G_height) debug(face_list[item_no]) if item_no then - cr.doc:setFontFace(face_list[item_no]) + self.doc:setFontFace(face_list[item_no]) self.font_face = face_list[item_no] InfoMessage:show("Redrawing with "..face_list[item_no], 0) end Screen:restoreFromSavedBB() - cr:redrawCurrentPage() + self:redrawCurrentPage() end ) self.commands:add(KEY_F, MOD_ALT, "F", "Toggle font bolder attribute", - function(cr) - cr.doc:toggleFontBolder() - cr:redrawCurrentPage() + function(self) + self.doc:toggleFontBolder() + self:redrawCurrentPage() end ) self.commands:add(KEY_B, MOD_ALT, "B", "add book mark to current page", - function(cr) - ok = cr:addBookmark(self.doc:getXPointer()) + function(self) + ok = self:addBookmark(self.doc:getXPointer()) if not ok then showInfoMsgWithDelay("Page already marked!", 2000, 1) else @@ -406,11 +406,11 @@ function CREReader:adjustCreReaderCommands() ) self.commands:add(KEY_BACK, nil, "Back", "go backward in jump history", - function(cr) - local prev_jump_no = cr.jump_history.cur - 1 + function(self) + local prev_jump_no = self.jump_history.cur - 1 if prev_jump_no >= 1 then - cr.jump_history.cur = prev_jump_no - cr:goto(cr.jump_history[prev_jump_no].page, true, "xpointer") + self.jump_history.cur = prev_jump_no + self:goto(self.jump_history[prev_jump_no].page, true, "xpointer") else showInfoMsgWithDelay("Already first jump!", 2000, 1) end @@ -418,11 +418,11 @@ function CREReader:adjustCreReaderCommands() ) self.commands:add(KEY_BACK, MOD_SHIFT, "Back", "go forward in jump history", - function(cr) - local next_jump_no = cr.jump_history.cur + 1 + function(self) + local next_jump_no = self.jump_history.cur + 1 if next_jump_no <= #self.jump_history then - cr.jump_history.cur = next_jump_no - cr:goto(cr.jump_history[next_jump_no].page, true, "xpointer") + self.jump_history.cur = next_jump_no + self:goto(self.jump_history[next_jump_no].page, true, "xpointer") else showInfoMsgWithDelay("Already last jump!", 2000, 1) end @@ -430,30 +430,30 @@ function CREReader:adjustCreReaderCommands() ) self.commands:add(KEY_VPLUS, nil, "vol+", "increase gamma", - function(cr) + function(self) cre.setGammaIndex(self.gamma_index + 1) self.gamma_index = cre.getGammaIndex() - cr:redrawCurrentPage() + self:redrawCurrentPage() end ) self.commands:add(KEY_VMINUS, nil, "vol-", "decrease gamma", - function(cr) + function(self) cre.setGammaIndex(self.gamma_index - 1) self.gamma_index = cre.getGammaIndex() - cr:redrawCurrentPage() + self:redrawCurrentPage() end ) self.commands:add(KEY_FW_UP, nil, "joypad up", "pan "..self.shift_y.." pixels upwards", - function(cr) - cr:goto(cr.pos - cr.shift_y) + function(self) + self:goto(self.pos - self.shift_y) end ) self.commands:add(KEY_FW_DOWN, nil, "joypad down", "pan "..self.shift_y.." pixels downwards", - function(cr) - cr:goto(cr.pos + cr.shift_y) + function(self) + self:goto(self.pos + self.shift_y) end ) end diff --git a/filesearcher.lua b/filesearcher.lua index fb80fcc5e..32283cb72 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -134,7 +134,7 @@ function FileSearcher:addAllCommands() self:nextItem() end ) - self.commands:add(KEY_PGFWD, nil, ">", + self.commands:add({KEY_PGFWD, KEY_LPGFWD}, nil, ">", "next page", function(self) if self.page < (self.items / self.perpage) then @@ -149,7 +149,7 @@ function FileSearcher:addAllCommands() end end ) - self.commands:add(KEY_PGBCK, nil, "<", + self.commands:add({KEY_PGBCK, KEY_LPGBCK}, nil, "<", "previous page", function(self) if self.page > 1 then diff --git a/helppage.lua b/helppage.lua index 89691a76d..2bc374d28 100644 --- a/helppage.lua +++ b/helppage.lua @@ -110,12 +110,12 @@ function HelpPage:show(ypos, height, commands) --debug("key code:"..ev.code) ev.code = adjustKeyEvents(ev) if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then - if ev.code == KEY_PGFWD then + if ev.code == KEY_PGFWD or ev.code == KEY_LPGFWD then if self.page < (self.items / perpage) then self.page = self.page + 1 is_pagedirty = true end - elseif ev.code == KEY_PGBCK then + elseif ev.code == KEY_PGBCK or ev.code == KEY_LPGBCK then if self.page > 1 then self.page = self.page - 1 is_pagedirty = true diff --git a/inputbox.lua b/inputbox.lua index 1aca2462d..239267d5b 100644 --- a/inputbox.lua +++ b/inputbox.lua @@ -138,8 +138,10 @@ end -- -- @title: input prompt for the box -- @d_text: default to nil (used to set default text in input slot) +-- @is_hint: if this arg is true, default text will be used as hint +-- message for input ---------------------------------------------------------------------- -function InputBox:input(ypos, height, title, d_text) +function InputBox:input(ypos, height, title, d_text, is_hint) self:init() -- do some initilization self.ypos = ypos @@ -161,10 +163,21 @@ function InputBox:input(ypos, height, title, d_text) self:drawHelpMsg(ypos, w, h) self:drawBox(ypos, w, h, title) if d_text then - self.input_string = d_text - self.input_cur_x = self.input_cur_x + (self.fwidth * d_text:len()) - self.cursor.x_pos = self.cursor.x_pos + (self.fwidth * d_text:len()) - self:refreshText() + if is_hint then + -- print hint text + fb.bb:paintRect(140, self.input_start_y-19, + self.input_slot_w, self.fheight, self.input_bg) + renderUtf8Text(fb.bb, self.input_start_x+5, self.input_start_y, + self.face, + d_text, 0) + fb.bb:dimRect(140, self.input_start_y-19, + self.input_slot_w, self.fheight, self.input_bg) + else + self.input_string = d_text + self.input_cur_x = self.input_cur_x + (self.fwidth * d_text:len()) + self.cursor.x_pos = self.cursor.x_pos + (self.fwidth * d_text:len()) + self:refreshText() + end end self.cursor:draw() fb:refresh(1, 20, ypos, w, h) diff --git a/keys.lua b/keys.lua index 849300754..b9a436bfc 100644 --- a/keys.lua +++ b/keys.lua @@ -129,8 +129,8 @@ end function setEmuKeycodes() KEY_PGFWD = 117 KEY_PGBCK = 112 - KEY_LPGBCK = 69 -- F3 - KEY_LPGFWD = 70 -- F4 + KEY_LPGBCK = 72 -- F6 + KEY_LPGFWD = 73 -- F7 KEY_HOME = 110 -- home KEY_BACK = 22 -- backspace KEY_DEL = 119 -- Delete diff --git a/unireader.lua b/unireader.lua index 4aa7dd0dd..40801215f 100644 --- a/unireader.lua +++ b/unireader.lua @@ -1803,22 +1803,32 @@ end -- command definitions function UniReader:addAllCommands() self.commands = Commands:new() - self.commands:addGroup("< >",{Keydef:new(KEY_PGBCK,nil),Keydef:new(KEY_LPGBCK,nil),Keydef:new(KEY_PGFWD,nil),Keydef:new(KEY_LPGFWD,nil)}, + self.commands:addGroup("< >",{ + Keydef:new(KEY_PGBCK,nil),Keydef:new(KEY_LPGBCK,nil), + Keydef:new(KEY_PGFWD,nil),Keydef:new(KEY_LPGFWD,nil)}, "previous/next page", function(unireader,keydef) unireader:goto( (keydef.keycode == KEY_PGBCK or keydef.keycode == KEY_LPGBCK) and unireader:prevView() or unireader:nextView()) end) - self.commands:addGroup(MOD_ALT.."< >",{Keydef:new(KEY_PGBCK,MOD_ALT),Keydef:new(KEY_PGFWD,MOD_ALT)}, + 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)}, "zoom out/in 10%", function(unireader,keydef) - unireader:setGlobalZoom(unireader.globalzoom + (keydef.keycode==KEY_PGBCK and -1 or 1)*unireader.globalzoom_orig*0.1) + is_zoom_out = (keydef.keycode == KEY_PGBCK or keydef.keycode == KEY_LPGBCK) + unireader:setGlobalZoom(unireader.globalzoom_orig + + (is_zoom_out and -1 or 1)*unireader.globalzoom_orig*0.1) end) - self.commands:addGroup(MOD_SHIFT.."< >",{Keydef:new(KEY_PGBCK,MOD_SHIFT),Keydef:new(KEY_PGFWD,MOD_SHIFT)}, + 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)}, "zoom out/in 20%", function(unireader,keydef) - unireader:setGlobalZoom(unireader.globalzoom + (keydef.keycode==KEY_PGBCK and -1 or 1)*unireader.globalzoom_orig*0.2) + is_zoom_out = (keydef.keycode == KEY_PGBCK or keydef.keycode == KEY_LPGBCK) + unireader:setGlobalZoom(unireader.globalzoom_orig + + ( is_zoom_out and -1 or 1)*unireader.globalzoom_orig*0.2) end) self.commands:add(KEY_BACK,nil,"Back", "go backward in jump history", @@ -1911,7 +1921,8 @@ function UniReader:addAllCommands() self.commands:add(KEY_G,nil,"G", "open 'go to page' input box", function(unireader) - local page = NumInputBox:input(G_height-100, 100, "Page:") + local page = NumInputBox:input(G_height-100, 100, + "Page:", "current page "..self.pageno, true) -- convert string to number if not pcall(function () page = page + 0 end) then page = unireader.pageno