From 28ba1c7e3792872d1ab9292fb957d41ea51d037a Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Fri, 14 Sep 2012 23:22:19 +0100 Subject: [PATCH 1/6] 1. It is customary to call DjVu context by the name of the program. 2. When changing DjVu page rendering mode there is no need to clear DjVu cache, only our own tile cache. --- djvu.c | 8 ++++---- djvureader.lua | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/djvu.c b/djvu.c index 8be9bc694..7ea55a829 100644 --- a/djvu.c +++ b/djvu.c @@ -79,9 +79,9 @@ static int openDocument(lua_State *L) { luaL_getmetatable(L, "djvudocument"); lua_setmetatable(L, -2); - doc->context = ddjvu_context_create("DJVUReader"); + doc->context = ddjvu_context_create("kindlepdfviewer"); if (! doc->context) { - return luaL_error(L, "cannot create context."); + return luaL_error(L, "cannot create context"); } printf("## cache_size = %d\n", cache_size); @@ -91,12 +91,12 @@ static int openDocument(lua_State *L) { while (! ddjvu_document_decoding_done(doc->doc_ref)) handle(L, doc->context, True); if (! doc->doc_ref) { - return luaL_error(L, "cannot open DJVU file <%s>", filename); + return luaL_error(L, "cannot open DjVu file <%s>", filename); } doc->pixelformat = ddjvu_format_create(DDJVU_FORMAT_GREY8, 0, NULL); if (! doc->pixelformat) { - return luaL_error(L, "cannot create DJVU pixelformat for <%s>", filename); + return luaL_error(L, "cannot create DjVu pixelformat for <%s>", filename); } ddjvu_format_set_row_order(doc->pixelformat, 1); ddjvu_format_set_y_direction(doc->pixelformat, 1); diff --git a/djvureader.lua b/djvureader.lua index 0edb4bca3..012c0ccc2 100644 --- a/djvureader.lua +++ b/djvureader.lua @@ -47,9 +47,7 @@ function DJVUReader:select_render_mode() local mode = mode_menu:choose(0, fb.bb:getHeight()) if mode then self.render_mode = mode - 1 - Debug("select_render_mode(), render_mode=", self.render_mode) self:clearCache() - self.doc:cleanCache() end self:redrawCurrentPage() end From 284ab49db4f0031c01e5df4440fdb992b2f1e1c2 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sat, 15 Sep 2012 21:01:29 +0100 Subject: [PATCH 2/6] Shorten the message to make it visible. --- filesearcher.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesearcher.lua b/filesearcher.lua index 7d6810e1e..0fd5005ff 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -219,7 +219,7 @@ function FileSearcher:addAllCommands() function(self) file_entry = self.result[self.perpage*(self.page-1)+self.current] local file_to_del = file_entry.dir .. "/" .. file_entry.name - InfoMessage:show("Press \'Y\' to confirm deleting... ",0) + InfoMessage:show("Press \'Y\' to confirm... ",0) while true do ev = input.saveWaitForEvent() ev.code = adjustKeyEvents(ev) From 3048311dd5bddad91cb6b38d280999a20d331f51 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sat, 15 Sep 2012 21:28:47 +0100 Subject: [PATCH 3/6] Show the number of hits in Search Results. --- filesearcher.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesearcher.lua b/filesearcher.lua index 0fd5005ff..96abd60c8 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -275,7 +275,7 @@ function FileSearcher:choose(keywords) fb.bb:paintRect(0, 0, G_width, G_height, 0) -- draw menu title - DrawTitle("Search Results for \'"..string.upper(self.keywords).."\'",self.margin_H,0,self.title_H,3,tface) + DrawTitle("Search Results for \'"..string.upper(self.keywords).."\'".." ("..tostring(self.items).." hits)",self.margin_H,0,self.title_H,3,tface) -- draw results local c if self.items == 0 then -- nothing found From 527421eb86efdd240004c213b6e33462dc71be4d Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sat, 15 Sep 2012 21:31:00 +0100 Subject: [PATCH 4/6] Make file search function completely case-insensitive. --- filesearcher.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesearcher.lua b/filesearcher.lua index 96abd60c8..85840ed45 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -64,7 +64,7 @@ function FileSearcher:setSearchResult(keywords) self.result = self.files else for __,f in pairs(self.files) do - if string.find(string.lower(f.name), keywords) then + if string.find(string.lower(f.name), string.lower(keywords)) then table.insert(self.result, f) end end From 42d95833197b43f19db803092d0b63fb340bae2b Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sat, 15 Sep 2012 21:32:00 +0100 Subject: [PATCH 5/6] In the Search Results show the actual pattern entered, not the uppercased version thereof. --- filesearcher.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesearcher.lua b/filesearcher.lua index 85840ed45..0c114e95d 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -275,7 +275,7 @@ function FileSearcher:choose(keywords) fb.bb:paintRect(0, 0, G_width, G_height, 0) -- draw menu title - DrawTitle("Search Results for \'"..string.upper(self.keywords).."\'".." ("..tostring(self.items).." hits)",self.margin_H,0,self.title_H,3,tface) + DrawTitle("Search Results for \'"..self.keywords.."\'".." ("..tostring(self.items).." hits)",self.margin_H,0,self.title_H,3,tface) -- draw results local c if self.items == 0 then -- nothing found From dac88587bf4bfd99fbcea08c340f970db35d6531 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sat, 15 Sep 2012 22:00:59 +0100 Subject: [PATCH 6/6] Fix for the case when TOC contains a link to external file: we should redraw the current page and not just quietly return from UniReader:goto(). --- unireader.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unireader.lua b/unireader.lua index 3caa70d1c..31b15959e 100644 --- a/unireader.lua +++ b/unireader.lua @@ -1483,6 +1483,8 @@ end -- change current page and cache next page after rendering function UniReader:goto(no, is_ignore_jump) if no < 1 or no > self.doc:getPages() then + -- may be reached by following TOC entry pointing to external file. + self:redrawCurrentPage() return end