fix some luacheck warnings

pull/2111/head
chrox 8 years ago
parent 03fda94562
commit 551857ce6e

@ -8,4 +8,4 @@ make all
retry_cmd 2 make testfront retry_cmd 2 make testfront
set +o pipefail set +o pipefail
luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out
test $(grep Total ./luacheck.out | awk '{print $2}') -le 53 test $(grep Total ./luacheck.out | awk '{print $2}') -le 25

@ -605,7 +605,7 @@ function ReaderPaging:genPageStatesFromTop(top_page_state, blank_area, offset)
if self.current_page == self.number_of_pages then break end if self.current_page == self.number_of_pages then break end
self:_gotoPage(current_page + 1, "scrolling") self:_gotoPage(current_page + 1, "scrolling")
current_page = current_page + 1 current_page = current_page + 1
local state = self:getNextPageState(blank_area, Geom:new{}) state = self:getNextPageState(blank_area, Geom:new{})
table.insert(page_states, state) table.insert(page_states, state)
end end
end end
@ -627,7 +627,7 @@ function ReaderPaging:genPageStatesFromBottom(bottom_page_state, blank_area, off
if self.current_page == 1 then break end if self.current_page == 1 then break end
self:_gotoPage(current_page - 1, "scrolling") self:_gotoPage(current_page - 1, "scrolling")
current_page = current_page - 1 current_page = current_page - 1
local state = self:getPrevPageState(blank_area, Geom:new{}) state = self:getPrevPageState(blank_area, Geom:new{})
table.insert(page_states, 1, state) table.insert(page_states, 1, state)
end end
end end

@ -27,9 +27,9 @@ function ReaderSearch:addToMainMenu(tab_item_table)
end end
function ReaderSearch:onShowSearchDialog(text) function ReaderSearch:onShowSearchDialog(text)
local do_search = function(search_func, text, param) local do_search = function(search_func, _text, param)
return function() return function()
local res = search_func(self, text, param) local res = search_func(self, _text, param)
if res then if res then
if self.ui.document.info.has_pages then if self.ui.document.info.has_pages then
self.ui.link:onGotoLink({page = res.page - 1}) self.ui.link:onGotoLink({page = res.page - 1})

@ -452,7 +452,7 @@ function ReaderView:drawXPointerSavedHighlight(bb, x, y)
end -- end for all saved highlight end -- end for all saved highlight
end end
function ReaderView:drawHighlightRect(bb, x, y, rect, drawer) function ReaderView:drawHighlightRect(bb, _x, _y, rect, drawer)
local x, y, w, h = rect.x, rect.y, rect.w, rect.h local x, y, w, h = rect.x, rect.y, rect.w, rect.h
if drawer == "underscore" then if drawer == "underscore" then

@ -322,12 +322,12 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, re
local cached = Cache:check(renderpg_hash, TileCacheItem) local cached = Cache:check(renderpg_hash, TileCacheItem)
if not cached then if not cached then
local page_size = Document.getNativePageDimensions(doc, pageno) local page_size = Document.getNativePageDimensions(doc, pageno)
local bbox = { local full_page_bbox = {
x0 = 0, y0 = 0, x0 = 0, y0 = 0,
x1 = page_size.w, x1 = page_size.w,
y1 = page_size.h, y1 = page_size.h,
} }
local kc = self:createContext(doc, pageno, bbox) local kc = self:createContext(doc, pageno, full_page_bbox)
local page = doc._document:openPage(pageno) local page = doc._document:openPage(pageno)
kc:setZoom(zoom) kc:setZoom(zoom)
page:getPagePix(kc) page:getPagePix(kc)
@ -444,7 +444,7 @@ function KoptInterface:getReflowedTextBoxes(doc, pageno)
local cached = Cache:check(hash) local cached = Cache:check(hash)
if not cached then if not cached then
local kctx_hash = "kctx|"..context_hash local kctx_hash = "kctx|"..context_hash
local cached = Cache:check(kctx_hash) cached = Cache:check(kctx_hash)
if cached then if cached then
local kc = self:waitForContext(cached.kctx) local kc = self:waitForContext(cached.kctx)
--kc:setDebug() --kc:setDebug()
@ -468,7 +468,7 @@ function KoptInterface:getNativeTextBoxes(doc, pageno)
local cached = Cache:check(hash) local cached = Cache:check(hash)
if not cached then if not cached then
local kctx_hash = "kctx|"..context_hash local kctx_hash = "kctx|"..context_hash
local cached = Cache:check(kctx_hash) cached = Cache:check(kctx_hash)
if cached then if cached then
local kc = self:waitForContext(cached.kctx) local kc = self:waitForContext(cached.kctx)
--kc:setDebug() --kc:setDebug()
@ -493,7 +493,7 @@ function KoptInterface:getReflowedTextBoxesFromScratch(doc, pageno)
local cached = Cache:check(hash) local cached = Cache:check(hash)
if not cached then if not cached then
local kctx_hash = "kctx|"..context_hash local kctx_hash = "kctx|"..context_hash
local cached = Cache:check(kctx_hash) cached = Cache:check(kctx_hash)
if cached then if cached then
local reflowed_kc = self:waitForContext(cached.kctx) local reflowed_kc = self:waitForContext(cached.kctx)
local fullwidth, fullheight = reflowed_kc:getPageDim() local fullwidth, fullheight = reflowed_kc:getPageDim()
@ -541,19 +541,19 @@ end
get page regions in native page via optical method, get page regions in native page via optical method,
--]] --]]
function KoptInterface:getPageBlock(doc, pageno, x, y) function KoptInterface:getPageBlock(doc, pageno, x, y)
local kctx = nil local kctx
local bbox = doc:getPageBBox(pageno) local bbox = doc:getPageBBox(pageno)
local context_hash = self:getContextHash(doc, pageno, bbox) local context_hash = self:getContextHash(doc, pageno, bbox)
local hash = "pageblocks|"..context_hash local hash = "pageblocks|"..context_hash
local cached = Cache:check(hash) local cached = Cache:check(hash)
if not cached then if not cached then
local page_size = Document.getNativePageDimensions(doc, pageno) local page_size = Document.getNativePageDimensions(doc, pageno)
local bbox = { local full_page_bbox = {
x0 = 0, y0 = 0, x0 = 0, y0 = 0,
x1 = page_size.w, x1 = page_size.w,
y1 = page_size.h, y1 = page_size.h,
} }
local kc = self:createContext(doc, pageno, bbox) local kc = self:createContext(doc, pageno, full_page_bbox)
local screen_size = Screen:getSize() local screen_size = Screen:getSize()
-- leptonica needs a source image of at least 300dpi -- leptonica needs a source image of at least 300dpi
kc:setZoom(screen_size.w / page_size.w * 300 / self.screen_dpi) kc:setZoom(screen_size.w / page_size.w * 300 / self.screen_dpi)
@ -594,7 +594,7 @@ function KoptInterface:getReflewOCRWord(doc, pageno, rect)
local cached = Cache:check(hash) local cached = Cache:check(hash)
if not cached then if not cached then
local kctx_hash = "kctx|"..context_hash local kctx_hash = "kctx|"..context_hash
local cached = Cache:check(kctx_hash) cached = Cache:check(kctx_hash)
if cached then if cached then
local kc = self:waitForContext(cached.kctx) local kc = self:waitForContext(cached.kctx)
local _, word = pcall( local _, word = pcall(
@ -665,8 +665,8 @@ function KoptInterface:getClipPageContext(doc, pos0, pos1, pboxes, drawer)
x = box.x, y = box.y, x = box.x, y = box.y,
w = box.w, h = box.h, w = box.w, h = box.h,
} }
for _, box in ipairs(pboxes) do for _, _box in ipairs(pboxes) do
rect = rect:combine(Geom:new(box)) rect = rect:combine(Geom:new(_box))
end end
else else
local zoom = pos0.zoom or 1 local zoom = pos0.zoom or 1
@ -910,9 +910,9 @@ end
get link from position in screen page get link from position in screen page
]]-- ]]--
function KoptInterface:getLinkFromPosition(doc, pageno, pos) function KoptInterface:getLinkFromPosition(doc, pageno, pos)
local function inside_box(pos, box) local function _inside_box(_pos, box)
if pos then if _pos then
local x, y = pos.x, pos.y local x, y = _pos.x, _pos.y
if box.x <= x and box.y <= y if box.x <= x and box.y <= y
and box.x + box.w >= x and box.x + box.w >= x
and box.y + box.h >= y then and box.y + box.h >= y then
@ -934,7 +934,7 @@ function KoptInterface:getLinkFromPosition(doc, pageno, pos)
w = link.x1 - link.x0 + Screen:scaleBySize(10), w = link.x1 - link.x0 + Screen:scaleBySize(10),
h = link.y1 - link.y0 + Screen:scaleBySize(10) h = link.y1 - link.y0 + Screen:scaleBySize(10)
} }
if inside_box(pos, lbox) and link.page then if _inside_box(pos, lbox) and link.page then
return link, lbox return link, lbox
end end
end end

@ -6,14 +6,6 @@ local function enable_if_equals(configurable, option, value)
return configurable[option] == value return configurable[option] == value
end end
local function enable_if_greater_than(configurable, option, value)
return configurable[option] > value
end
local function enable_if_less_than(configurable, option, value)
return configurable[option] < value
end
local KoptOptions = { local KoptOptions = {
prefix = 'kopt', prefix = 'kopt',
{ {

@ -8,7 +8,7 @@ return {
return G_reader_settings:readSetting("disable_double_tap") ~= false return G_reader_settings:readSetting("disable_double_tap") ~= false
end, end,
callback = function() callback = function()
disabled = G_reader_settings:readSetting("disable_double_tap") ~= false local disabled = G_reader_settings:readSetting("disable_double_tap") ~= false
G_reader_settings:saveSetting("disable_double_tap", not disabled) G_reader_settings:saveSetting("disable_double_tap", not disabled)
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _("This will take effect on next restart."), text = _("This will take effect on next restart."),

@ -6,13 +6,13 @@ local function dpi() return G_reader_settings:readSetting("screen_dpi") end
local function custom() return G_reader_settings:readSetting("custom_screen_dpi") end local function custom() return G_reader_settings:readSetting("custom_screen_dpi") end
local function setDPI(dpi) local function setDPI(_dpi)
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _("This will take effect on next restart."), text = _("This will take effect on next restart."),
}) })
Screen:setDPI(dpi) Screen:setDPI(_dpi)
end end
@ -29,32 +29,32 @@ return {
{ {
text = _("Small"), text = _("Small"),
checked_func = function() checked_func = function()
local dpi, custom = dpi(), custom() local _dpi, _custom = dpi(), custom()
return dpi and dpi <= 140 and dpi ~= custom return _dpi and _dpi <= 140 and _dpi ~= _custom
end, end,
callback = function() setDPI(120) end callback = function() setDPI(120) end
}, },
{ {
text = _("Medium"), text = _("Medium"),
checked_func = function() checked_func = function()
local dpi, custom = dpi(), custom() local _dpi, _custom = dpi(), custom()
return dpi and dpi > 140 and dpi <= 200 and dpi ~= custom return _dpi and _dpi > 140 and _dpi <= 200 and _dpi ~= _custom
end, end,
callback = function() setDPI(160) end callback = function() setDPI(160) end
}, },
{ {
text = _("Large"), text = _("Large"),
checked_func = function() checked_func = function()
local dpi, custom = dpi(), custom() local _dpi, _custom = dpi(), custom()
return dpi and dpi > 200 and dpi ~= custom return _dpi and _dpi > 200 and _dpi ~= _custom
end, end,
callback = function() setDPI(240) end callback = function() setDPI(240) end
}, },
{ {
text = _("Custom DPI") .. ": " .. (custom() or 160), text = _("Custom DPI") .. ": " .. (custom() or 160),
checked_func = function() checked_func = function()
local dpi, custom = dpi(), custom() local _dpi, _custom = dpi(), custom()
return custom and dpi == custom return _custom and _dpi == _custom
end, end,
callback = function() setDPI(custom() or 160) end, callback = function() setDPI(custom() or 160) end,
hold_input = { hold_input = {
@ -62,11 +62,11 @@ return {
type = "number", type = "number",
hint = "(90 - 330)", hint = "(90 - 330)",
callback = function(input) callback = function(input)
local dpi = tonumber(input) local _dpi = tonumber(input)
dpi = dpi < 90 and 90 or dpi _dpi = _dpi < 90 and 90 or _dpi
dpi = dpi > 330 and 330 or dpi _dpi = _dpi > 330 and 330 or _dpi
G_reader_settings:saveSetting("custom_screen_dpi", dpi) G_reader_settings:saveSetting("custom_screen_dpi", _dpi)
setDPI(dpi) setDPI(_dpi)
end, end,
}, },
}, },

@ -420,14 +420,14 @@ function UIManager:broadcastEvent(event)
-- the widget's event handler might close widgets in which case -- the widget's event handler might close widgets in which case
-- a simple iterator like ipairs would skip over some entries -- a simple iterator like ipairs would skip over some entries
local i = 1 local i = 1
while (i <= #self._window_stack) do while i <= #self._window_stack do
local prev_widget = self._window_stack[i].widget local prev_widget = self._window_stack[i].widget
self._window_stack[i].widget:handleEvent(event) self._window_stack[i].widget:handleEvent(event)
local top_widget = self._window_stack[i] local top_widget = self._window_stack[i]
if top_widget == nil then if top_widget == nil then
-- top widget closed itself -- top widget closed itself
break break
elseif (top_window.widget == prev_widget) then elseif top_widget.widget == prev_widget then
i = i + 1 i = i + 1
end end
end end

Loading…
Cancel
Save