<NME> readerhinting.lua
<BEF> local EventListener = require("ui/widget/eventlistener")

local DHINTCOUNT = G_defaults:readSetting("DHINTCOUNT")

local ReaderHinting = EventListener:extend{
    hinting_states = nil, -- array
function ReaderHinting:onHintPage()
    if not self.view.hinting then return true end
    for i=1, DHINTCOUNT do
        if self.view.state.page + i <= self.ui.document.info.number_of_pages then
            self.ui.document:hintPage(
                self.view.state.page + i,
                self.zoom:getZoom(self.view.state.page + i),
                self.view.state.rotation,
    for i=1, DHINTCOUNT do
        if self.view.state.page + i <= self.document.info.number_of_pages then
            self.document:hintPage(
                self.view.state.page + i,
                self.zoom:getZoom(self.view.state.page + i),
                self.view.state.rotation,
                self.view.state.gamma,
                self.view.render_mode)
        end
    end
    return true
end

function ReaderHinting:onSetHinting(hinting)
    self.view.hinting = hinting
end

function ReaderHinting:onDisableHinting()
    table.insert(self.hinting_states, self.view.hinting)
    self.view.hinting = false
    return true
end

function ReaderHinting:onRestoreHinting()
    self.view.hinting = table.remove(self.hinting_states)
    return true
end

return ReaderHinting

<MSG> minor(readerhinting): access document directly instead of from ui

<DFF> @@ -7,8 +7,8 @@ local ReaderHinting = EventListener:new{
 function ReaderHinting:onHintPage()
     if not self.view.hinting then return true end
     for i=1, DHINTCOUNT do
-        if self.view.state.page + i <= self.ui.document.info.number_of_pages then
-            self.ui.document:hintPage(
+        if self.view.state.page + i <= self.document.info.number_of_pages then
+            self.document:hintPage(
                 self.view.state.page + i,
                 self.zoom:getZoom(self.view.state.page + i),
                 self.view.state.rotation,

{'addition_count': 2, 'commit_subject': 'minor(readerhinting): access document directly instead of from ui', 'deletion_count': 2, 'file_extension': '.lua', 'lang': 'lua', 'license': 'agpl-3.0', 'repo_name': 'koreader/koreader'}