mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
minor: a lot of luacheck fixes
This commit is contained in:
@@ -6,6 +6,9 @@ globals = {
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
"ANDROID_FONT_DIR",
|
||||
"KOBO_TOUCH_MIRRORED",
|
||||
"KOBO_SYNC_BRIGHTNESS_WITH_NICKEL",
|
||||
"DRCOUNTMAX",
|
||||
"DHINTCOUNT",
|
||||
"DFULL_SCREEN",
|
||||
|
||||
@@ -71,7 +71,7 @@ script:
|
||||
- make all
|
||||
- travis_retry make testfront
|
||||
- luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out
|
||||
- test $(grep Total ./luacheck.out | awk '{print $2}') -le 140
|
||||
- test $(grep Total ./luacheck.out | awk '{print $2}') -le 65
|
||||
|
||||
after_success:
|
||||
- make coverage
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||
local FileManagerMenu = require("apps/filemanager/filemanagermenu")
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local VerticalGroup = require("ui/widget/verticalgroup")
|
||||
local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local VerticalSpan = require("ui/widget/verticalspan")
|
||||
local OPDSBrowser = require("ui/widget/opdsbrowser")
|
||||
local TextWidget = require("ui/widget/textwidget")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Font = require("ui/font")
|
||||
local Screen = require("device").screen
|
||||
local Geom = require("ui/geometry")
|
||||
local Event = require("ui/event")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
local util = require("ffi/util")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
|
||||
local OPDSCatalog = InputContainer:extend{
|
||||
|
||||
@@ -92,7 +92,7 @@ function ReaderBookmark:importSavedHighlight(config)
|
||||
if not config:readSetting("highlights_imported") then
|
||||
for page, marks in pairs(textmarks) do
|
||||
for _, mark in ipairs(marks) do
|
||||
local page = self.ui.document.info.has_pages and page or mark.pos0
|
||||
page = self.ui.document.info.has_pages and page or mark.pos0
|
||||
-- highlights saved by some old versions don't have pos0 field
|
||||
-- we just ignore those highlights
|
||||
if page then
|
||||
@@ -125,7 +125,7 @@ function ReaderBookmark:onSaveSettings()
|
||||
end
|
||||
|
||||
function ReaderBookmark:onToggleBookmark()
|
||||
local pn_or_xp = nil
|
||||
local pn_or_xp
|
||||
if self.ui.document.info.has_pages then
|
||||
pn_or_xp = self.view.state.page
|
||||
else
|
||||
@@ -295,16 +295,16 @@ end
|
||||
|
||||
-- binary search of sorted bookmarks
|
||||
function ReaderBookmark:isBookmarkAdded(item)
|
||||
local _start, _middle, _end, direction = 1, 1, #self.bookmarks, 0
|
||||
local _start, _middle, _end = 1, 1, #self.bookmarks
|
||||
while _start <= _end do
|
||||
_middle = math.floor((_start + _end)/2)
|
||||
if self:isBookmarkSame(item, self.bookmarks[_middle]) then
|
||||
return true
|
||||
end
|
||||
if self:isBookmarkInPageOrder(item, self.bookmarks[_middle]) then
|
||||
_end, direction = _middle - 1, 0
|
||||
_end = _middle - 1
|
||||
else
|
||||
_start, direction = _middle + 1, 1
|
||||
_start = _middle + 1
|
||||
end
|
||||
end
|
||||
return false
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Screen = require("device").screen
|
||||
local Geom = require("ui/geometry")
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderRotation = InputContainer:new{
|
||||
@@ -26,7 +23,7 @@ function ReaderRotation:init()
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: reset rotation on new document, maybe on new page?
|
||||
-- @TODO: reset rotation on new document, maybe on new page?
|
||||
|
||||
function ReaderRotation:onRotate(rotate_by)
|
||||
self.current_rotation = (self.current_rotation + rotate_by) % 360
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("ui/screen")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -69,7 +67,7 @@ function ReaderSearch:onShowSearchDialog(text)
|
||||
self.ui.highlight:clear()
|
||||
end,
|
||||
}
|
||||
local res = do_search(self.searchFromCurrent, text, 0)()
|
||||
do_search(self.searchFromCurrent, text, 0)()
|
||||
UIManager:show(self.search_dialog)
|
||||
-- TODO: regional
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local Generic = require("device/generic/device")
|
||||
local isAndroid, android = pcall(require, "android")
|
||||
local _, android = pcall(require, "android")
|
||||
local ffi = require("ffi")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ local Device = {
|
||||
}
|
||||
|
||||
function Device:new(o)
|
||||
local o = o or {}
|
||||
o = o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
||||
@@ -10,7 +10,7 @@ local BasePowerD = {
|
||||
}
|
||||
|
||||
function BasePowerD:new(o)
|
||||
local o = o or {}
|
||||
o = o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
if o.init then o:init() end
|
||||
|
||||
@@ -73,7 +73,7 @@ local GestureDetector = {
|
||||
}
|
||||
|
||||
function GestureDetector:new(o)
|
||||
local o = o or {}
|
||||
o = o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
if o.init then o:init() end
|
||||
|
||||
@@ -6,6 +6,8 @@ local _ = require("gettext")
|
||||
local Key = require("device/key")
|
||||
local GestureDetector = require("device/gesturedetector")
|
||||
|
||||
-- luacheck: push
|
||||
-- luacheck: ignore
|
||||
-- constants from <linux/input.h>
|
||||
local EV_SYN = 0
|
||||
local EV_KEY = 1
|
||||
@@ -36,6 +38,7 @@ local ABS_MT_POSITION_X = 53
|
||||
local ABS_MT_POSITION_Y = 54
|
||||
local ABS_MT_TRACKING_ID = 57
|
||||
local ABS_MT_PRESSURE = 58
|
||||
-- luacheck: pop
|
||||
|
||||
--[[
|
||||
an interface to get input events
|
||||
@@ -105,7 +108,7 @@ local Input = {
|
||||
}
|
||||
|
||||
function Input:new(o)
|
||||
local o = o or {}
|
||||
o = o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
if o.init then o:init() end
|
||||
|
||||
@@ -147,8 +147,11 @@ function Kindle4:init()
|
||||
Kindle.init(self)
|
||||
end
|
||||
|
||||
-- luacheck: push
|
||||
-- luacheck: ignore
|
||||
local ABS_MT_POSITION_X = 53
|
||||
local ABS_MT_POSITION_Y = 54
|
||||
-- luacheck: pop
|
||||
function KindleTouch:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.powerd = require("device/kindle/powerd"):new{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local Generic = require("device/generic/device") -- <= look at this file!
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
-- luacheck: push
|
||||
-- luacheck: ignore
|
||||
local EVT_INIT = 21
|
||||
local EVT_EXIT = 22
|
||||
local EVT_SHOW = 23
|
||||
@@ -32,6 +34,7 @@ local KEY_PREV2 = 0x1c
|
||||
local KEY_NEXT2 = 0x1d
|
||||
local KEY_COVEROPEN = 0x02
|
||||
local KEY_COVERCLOSE = 0x03
|
||||
-- luacheck: pop
|
||||
|
||||
local function yes() return true end
|
||||
|
||||
@@ -49,12 +52,12 @@ function PocketBook:init()
|
||||
ev.value = ev.type == EVT_KEYDOWN and 1 or 0
|
||||
ev.type = 1 -- EV_KEY
|
||||
elseif ev.type == EVT_BACKGROUND then
|
||||
isInBackGround = true
|
||||
self.isInBackGround = true
|
||||
self:onPowerEvent("Power")
|
||||
elseif isInBackGround and ev.type == EVT_FOREGROUND then
|
||||
isInBackGround = false
|
||||
elseif self.isInBackGround and ev.type == EVT_FOREGROUND then
|
||||
self.isInBackGround = false
|
||||
self:onPowerEvent("Power")
|
||||
elseif not isInBackGround and ev.type == EVT_FOREGROUND then
|
||||
elseif not self.isInBackGround and ev.type == EVT_FOREGROUND then
|
||||
self.screen:refreshPartial()
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -594,7 +594,7 @@ function KoptInterface:getReflewOCRWord(doc, pageno, rect)
|
||||
local cached = Cache:check(kctx_hash)
|
||||
if cached then
|
||||
local kc = self:waitForContext(cached.kctx)
|
||||
local ok, word = pcall(
|
||||
local _, word = pcall(
|
||||
kc.getTOCRWord, kc, "dst",
|
||||
rect.x, rect.y, rect.w, rect.h,
|
||||
self.tessocr_data, self.ocr_lang, self.ocr_type, 0, 1)
|
||||
@@ -628,7 +628,7 @@ function KoptInterface:getNativeOCRWord(doc, pageno, rect)
|
||||
--kc:exportSrcPNGFile({rect}, nil, "ocr-word.png")
|
||||
local word_w, word_h = kc:getPageDim()
|
||||
--DEBUG(word_w, word_h)
|
||||
local ok, word = pcall(
|
||||
local _, word = pcall(
|
||||
kc.getTOCRWord, kc, "src",
|
||||
0, 0, word_w, word_h,
|
||||
self.tessocr_data, self.ocr_lang, self.ocr_type, 0, 1)
|
||||
@@ -655,7 +655,7 @@ end
|
||||
function KoptInterface:getClipPageContext(doc, pos0, pos1, pboxes, drawer)
|
||||
assert(pos0.page == pos1.page)
|
||||
assert(pos0.zoom == pos1.zoom)
|
||||
local rect = nil
|
||||
local rect
|
||||
if pboxes and #pboxes > 0 then
|
||||
local box = pboxes[1]
|
||||
rect = Geom:new{
|
||||
@@ -1060,7 +1060,7 @@ function KoptInterface:nativeToPageRectTransform(doc, pageno, rect)
|
||||
y = rect.y + rect.h - 5
|
||||
}
|
||||
local boxes = self:getPageBoxesFromPositions(doc, pageno, pos0, pos1)
|
||||
res_rect = nil
|
||||
local res_rect = nil
|
||||
if #boxes > 0 then
|
||||
res_rect = boxes[1]
|
||||
for _, box in pairs(boxes) do
|
||||
|
||||
@@ -422,7 +422,7 @@ function UIManager:_refresh(mode, region)
|
||||
-- combine both refreshes' regions
|
||||
local combined = region:combine(self._refresh_stack[i].region)
|
||||
-- update the mode, if needed
|
||||
local mode = update_mode(mode, self._refresh_stack[i].mode)
|
||||
mode = update_mode(mode, self._refresh_stack[i].mode)
|
||||
-- remove colliding update
|
||||
table.remove(self._refresh_stack, i)
|
||||
-- and try again with combined data
|
||||
|
||||
Reference in New Issue
Block a user