mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1328 from chrox/master
various fixes for the upcoming stable release
This commit is contained in:
4
.luacov
4
.luacov
@@ -2,6 +2,10 @@
|
||||
-- project folder as '.luacov' for project specific configuration
|
||||
-- @class module
|
||||
-- @name luacov.defaults
|
||||
|
||||
-- global flag to indicate coverage test
|
||||
LUACOV = true
|
||||
|
||||
return {
|
||||
|
||||
-- default filename to load for config options if not provided
|
||||
|
||||
@@ -58,6 +58,11 @@ DCREREADER_TWO_PAGE_THRESHOLD = 7
|
||||
-- page overlap pixels
|
||||
DOVERLAPPIXELS = 30
|
||||
|
||||
-- timeout to show link rectangle around links
|
||||
-- default to 0.5 second
|
||||
-- set to 0 to disable showing rectangle and follow link immediately
|
||||
FOLLOW_LINK_TIMEOUT = 0.5
|
||||
|
||||
-- customizable tap zones(rectangles)
|
||||
-- x: x coordinate of top left corner in proportion of screen width
|
||||
-- y: y coordinate of top left corner in proportion of screen height
|
||||
|
||||
@@ -85,7 +85,9 @@ function ReaderCropping:onPageCrop(mode)
|
||||
-- backup original zoom mode as cropping use "page" zoom mode
|
||||
self.orig_zoom_mode = self.view.zoom_mode
|
||||
if mode == "auto" then
|
||||
self:setCropZoomMode(true)
|
||||
if self.document.configurable.text_wrap ~= 1 then
|
||||
self:setCropZoomMode(true)
|
||||
end
|
||||
return
|
||||
end
|
||||
-- backup original view dimen
|
||||
|
||||
@@ -76,6 +76,7 @@ function ReaderDictionary:stardictLookup(word, box)
|
||||
--DEBUG("lookup result table:", word, results)
|
||||
self:showDict(word, tidy_markup(results), box)
|
||||
else
|
||||
DEBUG("JSON data cannot be decoded", results)
|
||||
-- dummy results
|
||||
results = {
|
||||
{
|
||||
|
||||
@@ -123,6 +123,7 @@ function ReaderHighlight:clear()
|
||||
if self.hold_pos then
|
||||
self.hold_pos = nil
|
||||
self.selected_text = nil
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -278,7 +279,7 @@ function ReaderHighlight:onHoldPan(arg, ges)
|
||||
self.selected_word = nil
|
||||
end
|
||||
end
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
UIManager:setDirty(self.dialog, "ui")
|
||||
end
|
||||
|
||||
function ReaderHighlight:lookup(selected_word)
|
||||
@@ -480,7 +481,7 @@ function ReaderHighlight:deleteHighlight(page, i)
|
||||
DEBUG("delete highlight")
|
||||
local removed = table.remove(self.view.highlight.saved[page], i)
|
||||
self.ui.bookmark:removeBookmark({
|
||||
page = self.ui.document.info.has_pages and removed.page or removed.pos0,
|
||||
page = self.ui.document.info.has_pages and page or removed.pos0,
|
||||
datetime = removed.datetime,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -90,7 +90,7 @@ function ReaderLink:onTap(arg, ges)
|
||||
if sbox then
|
||||
UIManager:show(LinkBox:new{
|
||||
box = sbox,
|
||||
timeout = 0.5,
|
||||
timeout = FOLLOW_LINK_TIMEOUT,
|
||||
callback = function() self:onGotoLink(link) end
|
||||
})
|
||||
return true
|
||||
|
||||
@@ -344,8 +344,8 @@ function ReaderPaging:onPanRelease(arg, ges)
|
||||
end
|
||||
else
|
||||
self.last_pan_relative_y = 0
|
||||
-- trigger partial refresh
|
||||
UIManager:setDirty(nil, "partial")
|
||||
-- trigger full refresh to clear ghosting generated by previous fast refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -295,6 +295,9 @@ function ReaderZooming:addToMainMenu(tab_item_table)
|
||||
if self.ui.document.info.has_pages then
|
||||
table.insert(tab_item_table.typeset, {
|
||||
text = _("Switch zoom mode"),
|
||||
enabled_func = function()
|
||||
return self.ui.document.configurable.text_wrap ~= 1
|
||||
end,
|
||||
sub_item_table = {
|
||||
{
|
||||
text = _("Zoom to fit content width"),
|
||||
|
||||
@@ -21,3 +21,25 @@ Input.dummy = true
|
||||
-- turn on debug
|
||||
local DEBUG = require("dbg")
|
||||
--DEBUG:turnOn()
|
||||
|
||||
-- remove debug hooks in wrapped function for better luacov performance
|
||||
if LUACOV then
|
||||
local function hook_free_call(callback)
|
||||
local hook, mask, count = debug.gethook()
|
||||
debug.sethook()
|
||||
local res = callback()
|
||||
debug.sethook(hook, mask)
|
||||
return res
|
||||
end
|
||||
|
||||
local UIManager = require("ui/uimanager")
|
||||
local uimanager_run = UIManager.run
|
||||
function UIManager:run()
|
||||
hook_free_call(function() return uimanager_run(UIManager) end)
|
||||
end
|
||||
|
||||
local screen_shot = Screen.shot
|
||||
function Screen:shot(filename)
|
||||
hook_free_call(function() return screen_shot(Screen, filename) end)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user