From b8da531d8dcbeaac50de010183e10e33715fbd92 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 20 Apr 2012 20:48:17 +0800 Subject: [PATCH 01/13] add "searching file" message missed in previous commit --- filechooser.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/filechooser.lua b/filechooser.lua index 1bfd7a7d1..64cff9cd9 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -197,6 +197,7 @@ function FileChooser:choose(ypos, height) settings menu in the future. --]] return nil, function() + InfoMessage:show("Searching...",0) FileSearcher:init( self.path ) FileSearcher:choose(keywords) end From 1a2be0453dfe18fa63adf63a142518ebe2f58cc2 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 21 Apr 2012 09:46:30 +0800 Subject: [PATCH 02/13] fix bug in highlight engine handle left end of line in highlight delete. --- unireader.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/unireader.lua b/unireader.lua index 97be99b79..72fad45e5 100644 --- a/unireader.lua +++ b/unireader.lua @@ -638,6 +638,10 @@ function UniReader:startHighLightMode() end end elseif ev.code == KEY_DEL then + -- handle left end of line as special case + if w.cur == 0 then + w.cur = 1 + end if self.highlight[self.pageno] then for k, text_item in ipairs(self.highlight[self.pageno]) do for _, line_item in ipairs(text_item) do @@ -646,14 +650,15 @@ function UniReader:startHighLightMode() and t[l.cur][w.cur].x0 >= line_item.x0 and t[l.cur][w.cur].x1 <= line_item.x1 then self.highlight[self.pageno][k] = nil + -- remove page entry if empty + if #self.highlight[self.pageno] == 0 then + self.highlight[self.pageno] = nil + end + return end end -- for line_item end -- for text_item end -- if not highlight table - if #self.highlight[self.pageno] == 0 then - self.highlight[self.pageno] = nil - end - return elseif ev.code == KEY_FW_PRESS then l.new, w.new = l.cur, w.cur l.start, w.start = l.cur, w.cur From a99a0a94891bb3305ffaf9551d694dd3ee5c345b Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 21 Apr 2012 12:14:35 +0800 Subject: [PATCH 03/13] fix bug in highlight engine only goto next view when the word is in next view. same for previous view --- djvureader.lua | 12 +++++ unireader.lua | 118 +++++++++++++++++++++++++++++-------------------- 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/djvureader.lua b/djvureader.lua index f9142c366..6bb7a89cd 100644 --- a/djvureader.lua +++ b/djvureader.lua @@ -45,6 +45,18 @@ function DJVUReader:zoomedRectCoordTransform(x0, y0, x1, y1) (y1 - y0) * self.globalzoom end +-- make sure at least part of the box can be seen in next/previous view +-- @FIXME only works in FIT_TO_CONTENT_WIDTH mode 21.04 2012 (houqp) +-- @TODO use zoomedRectCoordTransform in unireader, no need to overwrite +-- it in here. +function DJVUReader:_isBoxInNextView(box) + return self.cur_full_height - (box.y0 * self.globalzoom) > -self.offset_y + G_height +end + +function DJVUReader:_isBoxInPrevView(box) + return self.cur_full_height - (box.y1 * self.globalzoom) < -self.offset_y +end + -- y axel in djvulibre starts from bottom function DJVUReader:_isEntireWordInScreenHeightRange(w) return (w ~= nil) and diff --git a/unireader.lua b/unireader.lua index 72fad45e5..81cef0f3f 100644 --- a/unireader.lua +++ b/unireader.lua @@ -27,7 +27,7 @@ UniReader = { -- zoom state: globalzoom = 1.0, globalzoom_orig = 1.0, - globalzoommode = -1, -- ZOOM_FIT_TO_PAGE + globalzoom_mode = -1, -- ZOOM_FIT_TO_PAGE globalrotate = 0, @@ -174,6 +174,16 @@ function UniReader:getRectInScreen(x0, y0, x1, y1) return x, y, w, h end +-- make sure at least part of the box can be seen in next/previous view +-- @FIXME only works in FIT_TO_CONTENT_WIDTH mode 21.04 2012 (houqp) +function UniReader:_isBoxInNextView(box) + return box.y1 * self.globalzoom > -self.offset_y + G_height +end + +function UniReader:_isBoxInPrevView(box) + return box.y0 * self.globalzoom < -self.offset_y +end + -- make sure the whole word/line can be seen in screen -- @TODO when not in FIT_TO_CONTENT_WIDTH mode, -- self.offset_{x,y} might be negative. 12.04 2012 (houqp) @@ -218,6 +228,18 @@ function UniReader:_isWordInScreenRange(w) (not is_entire_word_out_of_screen_width) end +function UniReader:_isWordInNextView(w) + return self:_isBoxInNextView(w) +end + +function UniReader:_isLineInNextView(l) + return self:_isBoxInNextView(l) +end + +function UniReader:_isLineInPrevView(l) + return self:_isBoxInPrevView(l) +end + function UniReader:toggleTextHighLight(word_list) for _,text_item in ipairs(word_list) do for _,line_item in ipairs(text_item) do @@ -540,7 +562,7 @@ function UniReader:startHighLightMode() self.cursor:clear() if w.new ~= 0 - and not self:_isEntireLineInScreenHeightRange(t[l.new]) + and self:_isLineInPrevView(t[l.new]) and self:_isEntireWordInScreenWidthRange(t[l.new][w.new]) then -- word is in previous view local pageno = self:prevView() @@ -569,7 +591,7 @@ function UniReader:startHighLightMode() if tmp_w == 0 then tmp_w = 1 end - if not self:_isEntireLineInScreenHeightRange(t[l.new]) + if self:_isLineInNextView(t[l.new]) and self:_isEntireWordInScreenWidthRange(t[l.new][tmp_w]) then local pageno = self:nextView() self:goto(pageno) @@ -595,7 +617,7 @@ function UniReader:startHighLightMode() if tmp_w == 0 then tmp_w = 1 end - if not self:_isEntireLineInScreenHeightRange(t[l.new]) + if self:_isLineInPrevView(t[l.new]) and self:_isEntireWordInScreenWidthRange(t[l.new][tmp_w]) then -- goto next view of current page local pageno = self:prevView() @@ -621,7 +643,7 @@ function UniReader:startHighLightMode() if w.cur == 0 then tmp_w = 1 end - if not self:_isEntireLineInScreenHeightRange(t[l.new]) + if self:_isLineInNextView(t[l.new]) and self:_isEntireWordInScreenWidthRange(t[l.new][tmp_w]) then -- goto next view of current page local pageno = self:nextView() @@ -693,7 +715,7 @@ function UniReader:startHighLightMode() end if w.new ~= 0 and - not self:_isEntireLineInScreenHeightRange(t[l.new]) then + self:_isLineInPrevView(t[l.new]) then -- word out of left and right sides of current view should -- not trigger pan by page if self:_isEntireWordInScreenWidthRange(t[l.new][w.new]) then @@ -730,7 +752,7 @@ function UniReader:startHighLightMode() is_meet_end = true end - if not self:_isEntireLineInScreenHeightRange(t[l.new]) then + if self:_isLineInNextView(t[l.new]) then if self:_isEntireWordInScreenWidthRange(t[l.new][w.new]) then local pageno = self:nextView() self:goto(pageno) @@ -959,7 +981,7 @@ function UniReader:loadSettings(filename) self.bbox = bbox self.globalzoom = self.settings:readSetting("globalzoom") or 1.0 - self.globalzoommode = self.settings:readSetting("globalzoommode") or -1 + self.globalzoom_mode = self.settings:readSetting("globalzoom_mode") or -1 self:loadSpecialSettings() return true @@ -1173,8 +1195,8 @@ function UniReader:setzoom(page, preCache) debug("page::getUsedBBox", x0, y0, x1, y1 ) - if self.globalzoommode == self.ZOOM_FIT_TO_PAGE - or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT then + if self.globalzoom_mode == self.ZOOM_FIT_TO_PAGE + or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT then self.globalzoom = width / pwidth self.offset_x = 0 self.offset_y = (height - (self.globalzoom * pheight)) / 2 @@ -1184,21 +1206,21 @@ function UniReader:setzoom(page, preCache) self.offset_y = 0 end self.pan_by_page = false - elseif self.globalzoommode == self.ZOOM_FIT_TO_PAGE_WIDTH - or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH then + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_PAGE_WIDTH + or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH then self.globalzoom = width / pwidth self.offset_x = 0 self.offset_y = (height - (self.globalzoom * pheight)) / 2 self.pan_by_page = false - elseif self.globalzoommode == self.ZOOM_FIT_TO_PAGE_HEIGHT - or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_PAGE_HEIGHT + or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then self.globalzoom = height / pheight self.offset_x = (width - (self.globalzoom * pwidth)) / 2 self.offset_y = 0 self.pan_by_page = false end - if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT then + if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT then if (x1 - x0) < pwidth then self.globalzoom = width / (x1 - x0) if height / (y1 - y0) < self.globalzoom then @@ -1207,7 +1229,7 @@ function UniReader:setzoom(page, preCache) end self.offset_x = -1 * x0 * self.globalzoom self.offset_y = -1 * y0 * self.globalzoom - elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH then + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH then if (x1 - x0) < pwidth then self.globalzoom = width / (x1 - x0) end @@ -1215,8 +1237,8 @@ function UniReader:setzoom(page, preCache) self.offset_y = -1 * y0 * self.globalzoom self.content_top = self.offset_y -- enable pan mode in ZOOM_FIT_TO_CONTENT_WIDTH - self.globalzoommode = self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN - elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then + self.globalzoom_mode = self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then if self.content_top == -2012 then -- We must handle previous page turn as a special cases, -- because we want to arrive at the bottom of previous page. @@ -1228,16 +1250,16 @@ function UniReader:setzoom(page, preCache) self.content_top = -1 * y0 * self.globalzoom self.offset_y = fb.bb:getHeight() - self.fullheight end - elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then if (y1 - y0) < pheight then self.globalzoom = height / (y1 - y0) end self.offset_x = -1 * x0 * self.globalzoom self.offset_y = -1 * y0 * self.globalzoom - elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH - or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN then + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH + or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN then local margin = self.pan_margin - if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH then margin = 0 end + if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH then margin = 0 end local pg_margin = 0 -- margin scaled to page size if margin > 0 then pg_margin = margin * 2 / self.globalzoom end self.globalzoom = width / (x1 - x0 + pg_margin) @@ -1246,7 +1268,7 @@ function UniReader:setzoom(page, preCache) self.offset_y = -1 * y0 * self.globalzoom * 2 + margin self.globalzoom = width / (x1 - x0 + pg_margin) * 2 debug("column mode offset:", self.offset_x, self.offset_y, " zoom:", self.globalzoom); - self.globalzoommode = self.ZOOM_BY_VALUE -- enable pan mode + self.globalzoom_mode = self.ZOOM_BY_VALUE -- enable pan mode self.pan_x = self.offset_x self.pan_y = self.offset_y self.pan_by_page = true @@ -1297,11 +1319,11 @@ function UniReader:show(no) self.dest_x = (width - (bb:getWidth() - offset_x)) / 2 end if bb:getHeight() - offset_y < height and - self.globalzoommode ~= self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then + self.globalzoom_mode ~= self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then -- we can't fill the whole output height and not in -- ZOOM_FIT_TO_CONTENT_WIDTH_PAN mode, center the content self.dest_y = (height - (bb:getHeight() - offset_y)) / 2 - elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN and + elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN and self.offset_y > 0 then -- if we are in ZOOM_FIT_TO_CONTENT_WIDTH_PAN mode and turning to -- the top of the page, we might leave an empty space between the @@ -1447,10 +1469,10 @@ end function UniReader:nextView() local pageno = self.pageno - if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then + if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then if self.offset_y <= self.min_offset_y then -- hit content bottom, turn to next page - self.globalzoommode = self.ZOOM_FIT_TO_CONTENT_WIDTH + self.globalzoom_mode = self.ZOOM_FIT_TO_CONTENT_WIDTH pageno = pageno + 1 else -- goto next view of current page @@ -1474,7 +1496,7 @@ end function UniReader:prevView() local pageno = self.pageno - if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then + if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then if self.offset_y >= self.content_top then -- hit content top, turn to previous page -- set self.content_top with magic num to signal self:setZoom @@ -1507,9 +1529,9 @@ function UniReader:modifyGamma(factor) end -- adjust zoom state and trigger re-rendering -function UniReader:setGlobalZoomMode(newzoommode) - if self.globalzoommode ~= newzoommode then - self.globalzoommode = newzoommode +function UniReader:setglobalzoom_mode(newzoommode) + if self.globalzoom_mode ~= newzoommode then + self.globalzoom_mode = newzoommode self:redrawCurrentPage() end end @@ -1517,7 +1539,7 @@ end -- adjust zoom state and trigger re-rendering function UniReader:setGlobalZoom(zoom) if self.globalzoom ~= zoom then - self.globalzoommode = self.ZOOM_BY_VALUE + self.globalzoom_mode = self.ZOOM_BY_VALUE self.globalzoom = zoom self:redrawCurrentPage() end @@ -1796,7 +1818,7 @@ function UniReader:inputLoop() self.settings:saveSetting("bookmarks", self.bookmarks) self.settings:saveSetting("bbox", self.bbox) self.settings:saveSetting("globalzoom", self.globalzoom) - self.settings:saveSetting("globalzoommode", self.globalzoommode) + self.settings:saveSetting("globalzoom_mode", self.globalzoom_mode) self.settings:saveSetting("highlight", self.highlight) self:saveSpecialSettings() self.settings:close() @@ -1886,42 +1908,42 @@ function UniReader:addAllCommands() self.commands:add(KEY_A,nil,"A", "zoom to fit page", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_PAGE) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_PAGE) end) self.commands:add(KEY_A,MOD_SHIFT,"A", "zoom to fit content", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT) end) self.commands:add(KEY_S,nil,"S", "zoom to fit page width", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_PAGE_WIDTH) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_PAGE_WIDTH) end) self.commands:add(KEY_S,MOD_SHIFT,"S", "zoom to fit content width", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_WIDTH) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_WIDTH) end) self.commands:add(KEY_D,nil,"D", "zoom to fit page height", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_PAGE_HEIGHT) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_PAGE_HEIGHT) end) self.commands:add(KEY_D,MOD_SHIFT,"D", "zoom to fit content height", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_HEIGHT) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_HEIGHT) end) self.commands:add(KEY_F,nil,"F", "zoom to fit margin 2-column mode", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN) end) self.commands:add(KEY_F,MOD_SHIFT,"F", "zoom to fit content 2-column mode", function(unireader) - unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH) + unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH) end) self.commands:add(KEY_G,nil,"G", "open 'go to page' input box", @@ -1978,8 +2000,8 @@ function UniReader:addAllCommands() "rotate screen 90° clockwise", function(unireader) unireader:screenRotate("clockwise") - if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then - self:setGlobalZoomMode(self.ZOOM_FIT_TO_CONTENT_WIDTH) + if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then + self:setglobalzoom_mode(self.ZOOM_FIT_TO_CONTENT_WIDTH) else self:redrawCurrentPage() end @@ -1993,8 +2015,8 @@ function UniReader:addAllCommands() "rotate screen 90° counterclockwise", function(unireader) unireader:screenRotate("anticlockwise") - if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then - self:setGlobalZoomMode(self.ZOOM_FIT_TO_CONTENT_WIDTH) + if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then + self:setglobalzoom_mode(self.ZOOM_FIT_TO_CONTENT_WIDTH) else self:redrawCurrentPage() end @@ -2024,7 +2046,7 @@ function UniReader:addAllCommands() unireader.bbox[unireader:oddEven(unireader.pageno)] = bbox unireader.bbox.enabled = true debug("bbox", unireader.pageno, unireader.bbox) - unireader.globalzoommode = unireader.ZOOM_FIT_TO_CONTENT -- use bbox + unireader.globalzoom_mode = unireader.ZOOM_FIT_TO_CONTENT -- use bbox showInfoMsgWithDelay("Manual crop setting saved.", 2000, 1) end) self.commands:add(KEY_Z,MOD_SHIFT,"Z", @@ -2057,9 +2079,9 @@ function UniReader:addAllCommands() "pan the active view; use Shift or Alt for smaller steps", function(unireader,keydef) if keydef.keycode ~= KEY_FW_PRESS then - unireader.globalzoommode = unireader.ZOOM_BY_VALUE + unireader.globalzoom_mode = unireader.ZOOM_BY_VALUE end - if unireader.globalzoommode == unireader.ZOOM_BY_VALUE then + if unireader.globalzoom_mode == unireader.ZOOM_BY_VALUE then local x local y if keydef.modifier==MOD_SHIFT then -- shift always moves in small steps From 5e6d4cfdb3d58f03b615720801360704765abe2b Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 21 Apr 2012 16:08:25 +0800 Subject: [PATCH 04/13] fix message for gamma settings in crereader's help page --- crereader.lua | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/crereader.lua b/crereader.lua index d686056b4..8b0f14a4f 100644 --- a/crereader.lua +++ b/crereader.lua @@ -428,18 +428,15 @@ function CREReader:adjustCreReaderCommands() end end ) - self.commands:add(KEY_VPLUS, nil, "vol+", - "increase gamma", - function(self) - cre.setGammaIndex(self.gamma_index + 1) - self.gamma_index = cre.getGammaIndex() - self:redrawCurrentPage() - end - ) - self.commands:add(KEY_VMINUS, nil, "vol-", - "decrease gamma", - function(self) - cre.setGammaIndex(self.gamma_index - 1) + 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) self.gamma_index = cre.getGammaIndex() self:redrawCurrentPage() end From 18f0cf804397961579b52e04277eaa2faea47803 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 21 Apr 2012 14:18:23 +0200 Subject: [PATCH 05/13] added mobi to CREReader #131 --- filechooser.lua | 2 +- filesearcher.lua | 2 +- reader.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/filechooser.lua b/filechooser.lua index 64cff9cd9..6d7d2c88a 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -57,7 +57,7 @@ function FileChooser:readDir() if file_type == "djvu" or file_type == "pdf" or file_type == "xps" or file_type == "cbz" or file_type == "epub" or file_type == "txt" or file_type == "rtf" - or file_type == "htm" or file_type == "html" + or file_type == "htm" or file_type == "html" or file_type == "mobi" or file_type == "fb2" or file_type == "chm" then table.insert(self.files, f) end diff --git a/filesearcher.lua b/filesearcher.lua index 0fc2f948f..e1228b09d 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -38,7 +38,7 @@ function FileSearcher:readDir() or file_type == "xps" or file_type == "cbz" or file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" - or file_type == "html" + or file_type == "html" or file_type == "mobi" or file_type == "fb2" or file_type == "chm" then file_entry = {dir=d, name=f,} table.insert(self.files, file_entry) diff --git a/reader.lua b/reader.lua index 73bf2ba41..230e0eba5 100755 --- a/reader.lua +++ b/reader.lua @@ -44,7 +44,7 @@ function openFile(filename) reader = DJVUReader elseif file_type == "pdf" or file_type == "xps" or file_type == "cbz" then reader = PDFReader - elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" then + elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" or file_type == "mobi" then reader = CREReader end if reader then From 1c98aef6a174c9ddd74603cae7230e8d7d02e48f Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 22 Apr 2012 09:40:43 +0800 Subject: [PATCH 06/13] fix bug in selectmenu five way press is not working when menu if full of items --- selectmenu.lua | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/selectmenu.lua b/selectmenu.lua index 51a49efcf..186f6fb4d 100644 --- a/selectmenu.lua +++ b/selectmenu.lua @@ -134,13 +134,10 @@ function SelectMenu:addAllCommands() self.commands:add(KEY_FW_PRESS, nil, "", "select menu item", function(sm) - if sm.last_shortcut < 30 then - if sm.items == 0 then - return "break" - else - self.selected_item = (sm.perpage * (sm.page - 1) - + sm.current) - end + if sm.items == 0 then + return "break" + else + self.selected_item = (sm.perpage * (sm.page - 1) + sm.current) end end ) @@ -282,9 +279,9 @@ function SelectMenu:choose(ypos, height) renderUtf8Text(fb.bb, 50, y, cface, self.item_array[i], true) - end -- EOF if i <= self.items - end -- EOF for - end -- EOF if + end -- if i <= self.items + end -- for c=1, self.perpage + end -- if self.items == 0 -- draw footer y = ypos + self.title_H + (self.spacing * self.perpage) From 1ff8cfd299fa0187ea9d487b93fb62206e15fd0a Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 24 Apr 2012 10:07:41 +0800 Subject: [PATCH 07/13] bump crengine to cr3.0.57-1 --- cre.cpp | 3 ++- kpvcrlib/crengine | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cre.cpp b/cre.cpp index 6cb9dd49d..7f5dd3e73 100644 --- a/cre.cpp +++ b/cre.cpp @@ -269,6 +269,7 @@ static int setFontFace(lua_State *L) { const char *face = luaL_checkstring(L, 2); doc->text_view->setDefaultFontFace(lString8(face)); + //fontMan->SetFallbackFontFace(lString8(face)); return 0; } @@ -364,6 +365,7 @@ static int cursorRight(lua_State *L) { //LVDocView *tv = doc->text_view; //ldomXPointer p = tv->getCurrentPageMiddleParagraph(); + //lString16 s = p.getText(); //lString16 s = p.toString(); //printf("~~~~~~~~~~%s\n", UnicodeToLocal(s).c_str()); @@ -378,7 +380,6 @@ static int cursorRight(lua_State *L) { //LVPageWordSelector sel(doc->text_view); //doc->text_view->doCommand(DCMD_SELECT_FIRST_SENTENCE); //sel.moveBy(DIR_RIGHT, 2); - //sel.updateSelection(); //printf("---------------- %s\n", UnicodeToLocal(sel.getSelectedWord()->getText()).c_str()); return 0; diff --git a/kpvcrlib/crengine b/kpvcrlib/crengine index 73805ee9b..7a73d1666 160000 --- a/kpvcrlib/crengine +++ b/kpvcrlib/crengine @@ -1 +1 @@ -Subproject commit 73805ee9b00c03160816e63239df5d1968f66a9d +Subproject commit 7a73d1666538fe9dd7d84d7e18135b03c21be2ca From c961fbd5155b91f5e6bff1ec4b90928cd390bee4 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 24 Apr 2012 11:04:31 +0800 Subject: [PATCH 08/13] add dirty hack for child node font settings. --- Makefile | 4 ++++ kpvcrlib/lvrend_node_type_face.patch | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 kpvcrlib/lvrend_node_type_face.patch diff --git a/Makefile b/Makefile index c54b68d6d..0685ea60a 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,10 @@ fetchthirdparty: # CREngine patch: disable fontconfig grep USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h && grep -v USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h > /tmp/new && mv /tmp/new $(CRENGINEDIR)/crengine/include/crsetup.h || echo "USE_FONTCONFIG already disabled" test -f mupdf-thirdparty.zip || wget http://www.mupdf.com/download/mupdf-thirdparty.zip + # CREngine patch: change child nodes' type face + # @TODO replace this dirty hack 24.04 2012 (houqp) + cd kpvcrlib/crengine/crengine/src && \ + patch -N -p0 < ../../../lvrend_node_type_face.patch unzip mupdf-thirdparty.zip -d mupdf # dirty patch in MuPDF's thirdparty liby for CREngine cd mupdf/thirdparty/jpeg-*/ && \ diff --git a/kpvcrlib/lvrend_node_type_face.patch b/kpvcrlib/lvrend_node_type_face.patch new file mode 100644 index 000000000..933208c95 --- /dev/null +++ b/kpvcrlib/lvrend_node_type_face.patch @@ -0,0 +1,12 @@ +--- lvrend.cpp 2012-04-24 10:27:33.000000000 +0800 ++++ lvrend-patched.cpp 2012-04-24 10:27:28.000000000 +0800 +@@ -1902,7 +1902,8 @@ + UPDATE_STYLE_FIELD( font_style, css_fs_inherit ); + UPDATE_STYLE_FIELD( font_weight, css_fw_inherit ); + UPDATE_STYLE_FIELD( font_family, css_ff_inherit ); +- UPDATE_STYLE_FIELD( font_name, "" ); ++ //UPDATE_STYLE_FIELD( font_name, "" ); ++ pstyle->font_name = parent_font.get()->getTypeFace(); + UPDATE_LEN_FIELD( font_size ); + //UPDATE_LEN_FIELD( text_indent ); + spreadParent( pstyle->text_indent, parent_style->text_indent ); From eca9ec4877cacc7c09730c003615ad8dc2c641b9 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 24 Apr 2012 17:10:38 +0800 Subject: [PATCH 09/13] fix TOC entry page number counting, it was one page ahead. close #137 --- djvu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djvu.c b/djvu.c index 8632b4872..3156e149e 100644 --- a/djvu.c +++ b/djvu.c @@ -133,7 +133,7 @@ static int walkTableOfContent(lua_State *L, miniexp_t r, int *count, int depth) strcpy(page_number,miniexp_to_str(miniexp_car(miniexp_cdr(miniexp_nth(counter, lista))))); /* page numbers appear as #11, set # to 0 so strtol works */ page_number[0]= '0'; - lua_pushnumber(L, strtol(page_number, NULL, 10)+1); + lua_pushnumber(L, strtol(page_number, NULL, 10)); lua_settable(L, -3); lua_pushstring(L, "depth"); From ebc5f94f611a3644ff6d938bdd5ec4e964c413e8 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 24 Apr 2012 14:27:42 +0200 Subject: [PATCH 10/13] crengine patching shouldn't fail if already applied When patch is already applied, -N will skip applying it again, but it will also return error exit code which will break make fetchthirdparty --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0685ea60a..4c832fe83 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,7 @@ fetchthirdparty: # CREngine patch: change child nodes' type face # @TODO replace this dirty hack 24.04 2012 (houqp) cd kpvcrlib/crengine/crengine/src && \ - patch -N -p0 < ../../../lvrend_node_type_face.patch + patch -N -p0 < ../../../lvrend_node_type_face.patch || true unzip mupdf-thirdparty.zip -d mupdf # dirty patch in MuPDF's thirdparty liby for CREngine cd mupdf/thirdparty/jpeg-*/ && \ From dbb49505f1dd83a79edef678ceda60059a2c4857 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 24 Apr 2012 20:37:16 +0800 Subject: [PATCH 11/13] add doc format support Though I don't like doc at all. --- Makefile | 3 +-- filechooser.lua | 2 +- filesearcher.lua | 3 ++- kpvcrlib/CMakeLists.txt | 9 ++++----- reader.lua | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0685ea60a..d5e7ae2c1 100644 --- a/Makefile +++ b/Makefile @@ -71,8 +71,7 @@ DJVULIBS := $(DJVUDIR)/build/libdjvu/.libs/libdjvulibre.a CRENGINELIBS := $(CRENGINEDIR)/crengine/libcrengine.a \ $(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \ $(CRENGINEDIR)/thirdparty/libpng/libpng.a \ -# we don't support dictionary lookup corrently - #$(CRENGINEDIR)/thirdparty/antiword/libantiword.a + $(CRENGINEDIR)/thirdparty/antiword/libantiword.a THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \ $(MUPDFLIBDIR)/libopenjpeg.a \ $(MUPDFLIBDIR)/libjbig2dec.a \ diff --git a/filechooser.lua b/filechooser.lua index 6d7d2c88a..7d6f6738c 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -58,7 +58,7 @@ function FileChooser:readDir() or file_type == "pdf" or file_type == "xps" or file_type == "cbz" or file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "mobi" - or file_type == "fb2" or file_type == "chm" then + or file_type == "fb2" or file_type == "chm" or file_type == "doc" then table.insert(self.files, f) end end diff --git a/filesearcher.lua b/filesearcher.lua index e1228b09d..0d32ae873 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -39,7 +39,8 @@ function FileSearcher:readDir() or file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "mobi" - or file_type == "fb2" or file_type == "chm" then + or file_type == "fb2" or file_type == "chm" + or file_type == "doc" then file_entry = {dir=d, name=f,} table.insert(self.files, file_entry) --debug("file:"..d.."/"..f) diff --git a/kpvcrlib/CMakeLists.txt b/kpvcrlib/CMakeLists.txt index f148b2c1c..43dc7563a 100644 --- a/kpvcrlib/CMakeLists.txt +++ b/kpvcrlib/CMakeLists.txt @@ -43,11 +43,10 @@ ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/libpng) #message("Will build patched JPEGLIB library") #ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/libjpeg) -message("Will not build patched ANTIWORD library, because we haven't supported dictionary lookup yet.") -#message("Will build patched ANTIWORD library") -ADD_DEFINITIONS(-DENABLE_ANTIWORD=0) -#ADD_DEFINITIONS(-DCR3_ANTIWORD_PATCH=1) -#ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/antiword) +message("Will build patched ANTIWORD library") +ADD_DEFINITIONS(-DENABLE_ANTIWORD=1) +ADD_DEFINITIONS(-DCR3_ANTIWORD_PATCH=1) +ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/antiword) message("Will build crengine library") SET(GUI kpv) diff --git a/reader.lua b/reader.lua index 230e0eba5..75d7fcebf 100755 --- a/reader.lua +++ b/reader.lua @@ -44,7 +44,7 @@ function openFile(filename) reader = DJVUReader elseif file_type == "pdf" or file_type == "xps" or file_type == "cbz" then reader = PDFReader - elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" or file_type == "mobi" then + elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" or file_type == "mobi" or file_type == "doc" then reader = CREReader end if reader then From a89c88f40f9069ef8485ae217d362aeb3410daee Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 24 Apr 2012 20:44:59 +0800 Subject: [PATCH 12/13] add zip format support --- filechooser.lua | 3 ++- filesearcher.lua | 2 +- reader.lua | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/filechooser.lua b/filechooser.lua index 7d6f6738c..688160ddd 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -58,7 +58,8 @@ function FileChooser:readDir() or file_type == "pdf" or file_type == "xps" or file_type == "cbz" or file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "mobi" - or file_type == "fb2" or file_type == "chm" or file_type == "doc" then + or file_type == "fb2" or file_type == "chm" or file_type == "doc" + or file_type == "zip" then table.insert(self.files, f) end end diff --git a/filesearcher.lua b/filesearcher.lua index 0d32ae873..d3c7827f5 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -40,7 +40,7 @@ function FileSearcher:readDir() or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "mobi" or file_type == "fb2" or file_type == "chm" - or file_type == "doc" then + or file_type == "doc" or file_type == "zip" then file_entry = {dir=d, name=f,} table.insert(self.files, file_entry) --debug("file:"..d.."/"..f) diff --git a/reader.lua b/reader.lua index 75d7fcebf..b00fd5397 100755 --- a/reader.lua +++ b/reader.lua @@ -44,7 +44,7 @@ function openFile(filename) reader = DJVUReader elseif file_type == "pdf" or file_type == "xps" or file_type == "cbz" then reader = PDFReader - elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" or file_type == "mobi" or file_type == "doc" then + elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" or file_type == "mobi" or file_type == "doc" or file_type == "zip" then reader = CREReader end if reader then From 198a3fc4de41499039dc7ef748fa49dd8a3ebcb6 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 24 Apr 2012 23:41:37 +0800 Subject: [PATCH 13/13] add dummy span widgets & make clock count on seconds --- dialog.lua | 4 +--- widget.lua | 22 ++++++++++++++++++++++ wtest.lua | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/dialog.lua b/dialog.lua index fa35501d2..c168f0852 100644 --- a/dialog.lua +++ b/dialog.lua @@ -150,9 +150,7 @@ function ConfirmBox:init() ImageWidget:new{ file = "resources/info-i.png" }, - Widget:new{ - dimen = { w = 10, h = 0 } - }, + HorizontalSpan:new{ width = 10 }, VerticalGroup:new{ align = "left", TextWidget:new{ diff --git a/widget.lua b/widget.lua index 602688311..8d74abe8e 100644 --- a/widget.lua +++ b/widget.lua @@ -276,6 +276,17 @@ function HorizontalGroup:free() WidgetContainer.free(self) end +--[[ +Dummy Widget that reserves horizontal space +]] +HorizontalSpan = Widget:new{ + width = 0, +} + +function HorizontalSpan:getSize() + return {w = self.width, h = 0} +end + --[[ A Layout widget that puts objects under each other ]] @@ -324,6 +335,17 @@ function VerticalGroup:free() WidgetContainer.free(self) end +--[[ +Dummy Widget that reserves vertical space +]] +VerticalSpan = Widget:new{ + width = 0, +} + +function VerticalSpan:getSize() + return {w = 0, h = self.width} +end + --[[ an UnderlineContainer is a WidgetContainer that is able to paint a line under its child node diff --git a/wtest.lua b/wtest.lua index 13428d2e4..824cb5df4 100644 --- a/wtest.lua +++ b/wtest.lua @@ -53,7 +53,7 @@ function Clock:schedFunc() UIManager:setDirty(self) -- reschedule -- TODO: wait until next real minute shift - UIManager:scheduleIn(60, function() self:schedFunc() end) + UIManager:scheduleIn(1, function() self:schedFunc() end) end function Clock:onShow() @@ -65,7 +65,7 @@ function Clock:getTextWidget() return CenterContainer:new{ dimen = { w = 300, h = 25 }, TextWidget:new{ - text = os.date("%H:%M"), + text = os.date("%H:%M:%S"), face = Font:getFace("cfont", 12) } }