From c57c3196563a3821991b9180c61068b4789803ac Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Wed, 19 Sep 2012 12:25:15 +0100 Subject: [PATCH 1/5] When user presses BACK in the filemanager it should NOT exit the program, only HOME should do so. Otherwise too many times one accidentally exits from KPV. --- filechooser.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filechooser.lua b/filechooser.lua index 9ae9aa97d..bb7f26d4f 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -532,7 +532,7 @@ function FileChooser:addAllCommands() self.pagedirty = true end ) - self.commands:add({KEY_BACK, KEY_HOME}, nil, "Back", + self.commands:add(KEY_HOME, nil, "Back", "exit", function(self) return "break" From d2b2d8b18f58ae2f3ffbd1f910051075ba41a375 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Wed, 19 Sep 2012 12:26:32 +0100 Subject: [PATCH 2/5] Make the info messages about highlight short enough to be visible. Also, shorten the delay from 2s to 1s. --- unireader.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unireader.lua b/unireader.lua index 97e019a64..ff8581df9 100644 --- a/unireader.lua +++ b/unireader.lua @@ -386,7 +386,7 @@ end function UniReader:startHighLightMode() local t = self:getText(self.pageno) if not t or #t == 0 then - showInfoMsgWithDelay("No text available for highlight", 2000, 1); + showInfoMsgWithDelay("No text available", 1000, 1); return nil end @@ -397,7 +397,7 @@ function UniReader:startHighLightMode() end end - showInfoMsgWithDelay("No visible text for highlight", 2000, 1); + showInfoMsgWithDelay("No visible text", 1000, 1); Debug("_findFirstWordInView none found in", t) return nil From f5f5040f201f949bf96c8524535572d30be849d5 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Wed, 19 Sep 2012 12:29:45 +0100 Subject: [PATCH 3/5] Change "Updating HighLight data..." message to Debug() as this operation cannot possibly hang and it conveys no useful info to the end user. --- unireader.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unireader.lua b/unireader.lua index ff8581df9..df91da636 100644 --- a/unireader.lua +++ b/unireader.lua @@ -970,7 +970,7 @@ function UniReader:loadSettings(filename) if self.highlight.to_fix ~= nil then for _,fix_item in ipairs(self.highlight.to_fix) do if fix_item == "djvu invert y axle" then - InfoMessage:show("Updating HighLight data...", 1) + Debug("Updating HighLight data...") for pageno,text_table in pairs(self.highlight) do if type(pageno) == "number" then text_table = self:invertTextYAxel(pageno, text_table) From eb002540a205697d07ad0d972fcd632cca84a9b9 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Wed, 19 Sep 2012 17:49:20 +0100 Subject: [PATCH 4/5] Don't crash on user pressing ENTER in empty history --- just display an appropriate message. --- filehistory.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/filehistory.lua b/filehistory.lua index e5cffdcc8..d95d94959 100644 --- a/filehistory.lua +++ b/filehistory.lua @@ -199,6 +199,10 @@ function FileHistory:addAllCommands() self.commands:add({KEY_ENTER, KEY_FW_PRESS}, nil, "Enter", "open selected item", function(self) + if #self.result == 0 then + showInfoMsgWithDelay("No files to open", 1500, 1) + return + end file_entry = self.result[self.perpage*(self.page-1)+self.current] file_full_path = file_entry.dir .. "/" .. file_entry.name From f11a0067750b46222985258c8ca974a995d22f0a Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Wed, 19 Sep 2012 18:25:26 +0100 Subject: [PATCH 5/5] 1. Fix deleting highlights when there is more than one (previously it would delete not only the current highlight but some or all of the later ones) 2. Support deleting highlights from within "show all highlights" function (Shift-N). It is much easier to delete multiple highlights than having to position the cursor on them and press Del. 3. Fix the bug whereby the first press of Menu would overlay the info on top of the book's text. 4. Show the number of bookmarks and highlights in their respective lists. 5. Fix the incorrect section title shown in Menu when the file contains TOC with external links. 6. Rename "start highlight mode" -> "enter highlight mode". 7. Rename "display all highlights" -> "show all highlights". --- unireader.lua | 61 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/unireader.lua b/unireader.lua index df91da636..844e38825 100644 --- a/unireader.lua +++ b/unireader.lua @@ -699,10 +699,10 @@ function UniReader:startHighLightMode() and t[l.cur][w.cur].y1 <= line_item.y1 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 + table.remove(self.highlight[self.pageno],k) -- remove page entry if empty if #self.highlight[self.pageno] == 0 then - self.highlight[self.pageno] = nil + table.remove(self.highlight, self.pageno) end return end @@ -1440,6 +1440,7 @@ function UniReader:addJump(pageno) end table.insert(self.jump_history, jump_item) self.jump_history.cur = #self.jump_history + 1 + self:redrawCurrentPage() return true end @@ -1477,6 +1478,7 @@ function UniReader:addBookmark(pageno) table.sort(self.bookmarks, function(a,b) return self:isBookmarkInSequence(a, b) end) + self:redrawCurrentPage() return true end @@ -1670,7 +1672,6 @@ function UniReader:_getTocTitleByPage(pageno) if not self.toc then -- build toc when needed. self:fillToc() - self:redrawCurrentPage() end -- no table of content @@ -1679,11 +1680,12 @@ function UniReader:_getTocTitleByPage(pageno) end local pre_entry = self.toc[1] - for _k,_v in ipairs(self.toc) do - if _v.page > pageno then + local numpages = self.doc:getPages() + for k,v in ipairs(self.toc) do + if v.page >= 1 and v.page <= numpages and v.page > pageno then break end - pre_entry = _v + pre_entry = v end return self:cleanUpTocTitle(pre_entry.title) end @@ -1878,7 +1880,7 @@ function UniReader:showBookMarks() end while true do bm_menu = SelectMenu:new{ - menu_title = "Bookmarks", + menu_title = "Bookmarks ("..tostring(#menu_items).." items)", item_array = menu_items, deletable = true, } @@ -1922,30 +1924,47 @@ function UniReader:prevBookMarkedPage() end function UniReader:showHighLight() - local menu_items = {} - local highlight_dict = {} + local menu_items, highlight_page, highlight_num = {}, {}, {} + local ret_code, item_no = -1, -1 + -- build menu items for k,v in pairs(self.highlight) do if type(k) == "number" then for k1,v1 in ipairs(v) do table.insert(menu_items, v1.text) - table.insert(highlight_dict, {page=k, start=v1[1]}) + table.insert(highlight_page, k) + table.insert(highlight_num, k1) end end end + if #menu_items == 0 then - showInfoMsgWithDelay( - "No HighLights found.", 2000, 1) - else - toc_menu = SelectMenu:new{ - menu_title = "HighLights", + return showInfoMsgWithDelay("No HighLights found", 1000, 1) + end + + while true do + hl_menu = SelectMenu:new{ + menu_title = "HighLights ("..tostring(#menu_items).." items)", item_array = menu_items, + deletable = true, } - item_no = toc_menu:choose(0, fb.bb:getHeight()) - if item_no then - self:goto(highlight_dict[item_no].page) + ret_code, item_no = hl_menu:choose(0, fb.bb:getHeight()) + if ret_code then + return self:goto(highlight_page[ret_code]) + elseif item_no then -- delete item + local hpage = highlight_page[item_no] + local hnum = highlight_num[item_no] + table.remove(self.highlight[hpage], hnum) + if #self.highlight[hpage] == 0 then + table.remove(self.highlight, hpage) + end + table.remove(highlight_page, item_no) + table.remove(menu_items, item_no) + if #menu_items == 0 then + return self:redrawCurrentPage() + end else - self:redrawCurrentPage() + return self:redrawCurrentPage() end end end @@ -2808,14 +2827,14 @@ function UniReader:addAllCommands() -- highlight mode self.commands:add(KEY_N, nil, "N", - "start highlight mode", + "enter highlight mode", function(unireader) unireader:startHighLightMode() unireader:goto(unireader.pageno) end ) self.commands:add(KEY_N, MOD_SHIFT, "N", - "display all highlights", + "show all highlights", function(unireader) unireader:showHighLight() unireader:goto(unireader.pageno)