Another set of fixes (#4083)

* Make findcalibre actually useful

By setting SEARCH_LIBRARY_PATH when a Calibre tree is found, so that
book paths can properly be constructed.

Users should still very much set it themselves, but at least everything
works as intended when not, instead of mysteriously half-breaking later.

Drop the SetDefaults bits, it appeared to have been added to fix no-ops
detected by Luacheck, and it's actually non-functional, because
SetDefaults doesn't handle saving variables it did not itself assign.
So this was just causing the "Do you want to save new defaults" popup to
show up on exit, but it couldn't actually do anything useful (like, say,
save the new SEARCH_LIBRARY_PATH value).

fix #4082

* Better comments about the state of NaturalLight on the Clara, and how this might translate to the H2O²r2.

re #4015

* Make ScrolltextWidget refresh as "partial" only on actual Scroll events

Moving the cursor should stay "ui", or things gets annoying really fast
;).

re #4084

* Bump base to pickup ZMQ fixes (fix #4086)
pull/4096/head
NiLuJe 6 years ago committed by GitHub
parent d4ebcd26c9
commit fea0d8dbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 3b2706a0db4133a90027e49bd994bec74919882c Subproject commit 3d160a41b81433135fcbcf0971a4e51c571419bf

@ -6,7 +6,6 @@ local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer") local InputContainer = require("ui/widget/container/inputcontainer")
local Menu = require("ui/widget/menu") local Menu = require("ui/widget/menu")
local Screen = require("device").screen local Screen = require("device").screen
local SetDefaults = require("apps/filemanager/filemanagersetdefaults")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local lfs = require("libs/libkoreader-lfs") local lfs = require("libs/libkoreader-lfs")
local logger = require("logger") local logger = require("logger")
@ -52,10 +51,16 @@ local function findcalibre(root)
else else
if entity ~= "." and entity ~= ".." then if entity ~= "." and entity ~= ".." then
local fullPath=root .. "/" .. entity local fullPath=root .. "/" .. entity
local mode = lfs.attributes(fullPath,"mode") local mode = lfs.attributes(fullPath, "mode")
if mode == "file" then if mode == "file" then
if entity == calibre or entity == "." .. calibre then if entity == calibre or entity == "." .. calibre then
t = root .. "/" .. entity t = root .. "/" .. entity
-- If we got so far, SEARCH_LIBRARY_PATH is either empty or bogus, so, re-set it,
-- so that we actually can convert a book's relative path to its absolute path.
-- NOTE: No-one should actually rely on that, as the value is *NEVER* saved to the defaults.
-- (SetDefaults can only do that with values modified from within its own advanced menu).
_G['SEARCH_LIBRARY_PATH'] = root .. "/"
logger.info("FMSearch: Found a SEARCH_LIBRARY_PATH @", SEARCH_LIBRARY_PATH)
end end
elseif mode == "directory" then elseif mode == "directory" then
t = findcalibre(fullPath) t = findcalibre(fullPath)
@ -75,15 +80,13 @@ function Search:getCalibre()
self.metafile_1 = findcalibre("/mnt") self.metafile_1 = findcalibre("/mnt")
if not self.metafile_1 then if not self.metafile_1 then
self.error = _("SEARCH_LIBRARY_PATH should be defined in DEFAULTS.LUA.") self.error = _("SEARCH_LIBRARY_PATH should be defined in DEFAULTS.LUA.")
else
SetDefaults.settings_changed = true
end end
else else
if string.sub(SEARCH_LIBRARY_PATH,string.len(SEARCH_LIBRARY_PATH)) ~= "/" then if string.sub(SEARCH_LIBRARY_PATH, string.len(SEARCH_LIBRARY_PATH)) ~= "/" then
SEARCH_LIBRARY_PATH = SEARCH_LIBRARY_PATH .. "/" -- luacheck: ignore _G['SEARCH_LIBRARY_PATH'] = SEARCH_LIBRARY_PATH .. "/"
end end
if io.open(SEARCH_LIBRARY_PATH .. calibre,"r") == nil then if io.open(SEARCH_LIBRARY_PATH .. calibre, "r") == nil then
if io.open(SEARCH_LIBRARY_PATH .. "." .. calibre,"r") == nil then if io.open(SEARCH_LIBRARY_PATH .. "." .. calibre, "r") == nil then
self.error = SEARCH_LIBRARY_PATH .. calibre .. " " .. _("not found.") self.error = SEARCH_LIBRARY_PATH .. calibre .. " " .. _("not found.")
logger.err(self.error) logger.err(self.error)
else else
@ -98,19 +101,16 @@ function Search:getCalibre()
UIManager:show(InfoMessage:new{text = _("You must specify at least one field to search at! (SEARCH_XXX = true in defaults.lua)")}) UIManager:show(InfoMessage:new{text = _("You must specify at least one field to search at! (SEARCH_XXX = true in defaults.lua)")})
elseif self.metafile_1 == nil then elseif self.metafile_1 == nil then
self.metafile_1 = findcalibre("/mnt") self.metafile_1 = findcalibre("/mnt")
if self.metafile_1 then
SetDefaults.settings_changed = true
end
end end
end end
-- check 2nd file -- check 2nd file
local dummy local dummy
if string.sub(SEARCH_LIBRARY_PATH2,string.len(SEARCH_LIBRARY_PATH2)) ~= "/" then if string.sub(SEARCH_LIBRARY_PATH2, string.len(SEARCH_LIBRARY_PATH2)) ~= "/" then
SEARCH_LIBRARY_PATH2 = SEARCH_LIBRARY_PATH2 .. "/" -- luacheck: ignore _G['SEARCH_LIBRARY_PATH2'] = SEARCH_LIBRARY_PATH2 .. "/"
end end
if io.open(SEARCH_LIBRARY_PATH2 .. calibre,"r") == nil then if io.open(SEARCH_LIBRARY_PATH2 .. calibre, "r") == nil then
if io.open(SEARCH_LIBRARY_PATH2 .. "." .. calibre,"r") ~= nil then if io.open(SEARCH_LIBRARY_PATH2 .. "." .. calibre, "r") ~= nil then
dummy = SEARCH_LIBRARY_PATH2 .. "." .. calibre dummy = SEARCH_LIBRARY_PATH2 .. "." .. calibre
end end
else else
@ -122,18 +122,20 @@ function Search:getCalibre()
self.metafile_2 = nil self.metafile_2 = nil
end end
-- check if they are newer than our own file -- check if they are newer than our own file
self.use_own_metadata_file = false self.use_own_metadata_file = false
if self.metafile_1 then if self.metafile_1 then
pcall(lfs.mkdir("temp")) pcall(lfs.mkdir("temp"))
if io.open(koreaderfile, "r") then if io.open(koreaderfile, "r") then
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_1).modification then if lfs.attributes(koreaderfile, "modification") > lfs.attributes(self.metafile_1, "modification") then
if self.metafile_2 then if self.metafile_2 then
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_2).modification then if lfs.attributes(koreaderfile, "modification") > lfs.attributes(self.metafile_2, "modification") then
self.use_own_metadata_file = true self.use_own_metadata_file = true
logger.info("FMSearch: Using our own simplified metadata file as it's newer than", self.metafile_2)
end end
else else
self.use_own_metadata_file = true self.use_own_metadata_file = true
logger.info("FMSearch: Using our own simplified metadata file as it's newer than", self.metafile_1)
end end
end end
end end
@ -153,7 +155,7 @@ function Search:ShowSearch()
enabled = true, enabled = true,
callback = function() callback = function()
self.search_value = self.search_dialog:getInputText() self.search_value = self.search_dialog:getInputText()
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "series" then if self.search_value == dummy and self.lastsearch == "series" then
self.use_previous_search_results = true self.use_previous_search_results = true
else else
self.use_previous_search_results = false self.use_previous_search_results = false
@ -167,7 +169,7 @@ function Search:ShowSearch()
enabled = true, enabled = true,
callback = function() callback = function()
self.search_value = self.search_dialog:getInputText() self.search_value = self.search_dialog:getInputText()
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "tags" then if self.search_value == dummy and self.lastsearch == "tags" then
self.use_previous_search_results = true self.use_previous_search_results = true
else else
self.use_previous_search_results = false self.use_previous_search_results = false
@ -191,7 +193,7 @@ function Search:ShowSearch()
enabled = true, enabled = true,
callback = function() callback = function()
self.search_value = self.search_dialog:getInputText() self.search_value = self.search_dialog:getInputText()
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "find" then if self.search_value == dummy and self.lastsearch == "find" then
self.use_previous_search_results = true self.use_previous_search_results = true
else else
self.use_previous_search_results = false self.use_previous_search_results = false
@ -243,16 +245,16 @@ function Search:find(option)
local firstrun local firstrun
-- removes leading and closing characters and converts hex-unicodes -- removes leading and closing characters and converts hex-unicodes
local ReplaceHexChars = function(s,n,j) local ReplaceHexChars = function(s, n, j)
local l=string.len(s) local l=string.len(s)
if string.sub(s,l,l) == "\"" then if string.sub(s, l, l) == "\"" then
s=string.sub(s,n,string.len(s)-1) s=string.sub(s, n, string.len(s)-1)
else else
s=string.sub(s,n,string.len(s)-j) s=string.sub(s, n, string.len(s)-j)
end end
s=string.gsub(s,"\\u([a-f0-9][a-f0-9][a-f0-9][a-f0-9])",function(w) return util.unichar(tonumber(w, 16)) end) s=string.gsub(s, "\\u([a-f0-9][a-f0-9][a-f0-9][a-f0-9])", function(w) return util.unichar(tonumber(w, 16)) end)
return s return s
end end
@ -269,22 +271,22 @@ function Search:find(option)
while line ~= " ], " and line ~= " ]" do while line ~= " ], " and line ~= " ]" do
line = f:read() line = f:read()
if line ~= " ], " and line ~= " ]" then if line ~= " ], " and line ~= " ]" then
self.data[i][s] = self.data[i][s] .. "," .. ReplaceHexChars(line,8,3) self.data[i][s] = self.data[i][s] .. "," .. ReplaceHexChars(line, 8, 3)
if s == self.authors then if s == self.authors then
self.data[i][self.authors2] = self.data[i][self.authors2] .. " & " .. ReplaceHexChars(line,8,3) self.data[i][self.authors2] = self.data[i][self.authors2] .. " & " .. ReplaceHexChars(line, 8, 3)
elseif s == self.tags then elseif s == self.tags then
local tags_line = ReplaceHexChars(line,8,3) local tags_line = ReplaceHexChars(line, 8, 3)
self.data[i][self.tags2] = self.data[i][self.tags2] .. " & " .. tags_line self.data[i][self.tags2] = self.data[i][self.tags2] .. " & " .. tags_line
self.data[i][self.tags3] = self.data[i][self.tags3] .. "\t" .. tags_line self.data[i][self.tags3] = self.data[i][self.tags3] .. "\t" .. tags_line
self.browse_tags[tags_line] = (self.browse_tags[tags_line] or 0) + 1 self.browse_tags[tags_line] = (self.browse_tags[tags_line] or 0) + 1
end end
end end
end end
self.data[i][s] = string.sub(self.data[i][s],2) self.data[i][s] = string.sub(self.data[i][s], 2)
if s == self.authors then if s == self.authors then
self.data[i][self.authors2] = string.sub(self.data[i][self.authors2],4) self.data[i][self.authors2] = string.sub(self.data[i][self.authors2], 4)
elseif s == self.tags then elseif s == self.tags then
self.data[i][self.tags2] = string.sub(self.data[i][self.tags2],4) self.data[i][self.tags2] = string.sub(self.data[i][self.tags2], 4)
self.data[i][self.tags3] = self.data[i][self.tags3] .. "\t" self.data[i][self.tags3] = self.data[i][self.tags3] .. "\t"
end end
end end
@ -309,7 +311,7 @@ function Search:find(option)
local g = io.open(koreaderfile, "r") local g = io.open(koreaderfile, "r")
line = g:read() line = g:read()
if line ~= "#metadata.Koreader Version 1.1" and line ~= "#metadata.koreader Version 1.1" then if line ~= "#metadata.Koreader Version 1.1" and line ~= "#metadata.koreader Version 1.1" then
self.use_own_metadata_file = false self.use_own_metadata_file = false
g:close() g:close()
else else
line = g:read() line = g:read()
@ -343,12 +345,14 @@ function Search:find(option)
for j in string.gmatch(self.data[i][self.tags3],"\t[^\t]+") do for j in string.gmatch(self.data[i][self.tags3],"\t[^\t]+") do
if j~="\t" then if j~="\t" then
self.browse_tags[string.sub(j,2)] = (self.browse_tags[string.sub(j,2)] or 0) + 1 self.browse_tags[string.sub(j, 2)] = (self.browse_tags[string.sub(j, 2)] or 0) + 1
end end
end end
-- NOTE: This skips kePubs downloaded by nickel, because they don't have a file extension,
-- they're stored as .kobo/kepub/<UUID>
if DocumentRegistry:hasProvider(self.data[i][self.path]) then if DocumentRegistry:hasProvider(self.data[i][self.path]) then
if upsearch ~= "" then if upsearch ~= "" then
if string.find(search_content,upsearch,nil,true) then if string.find(search_content, upsearch, nil, true) then
i = i + 1 i = i + 1
end end
else else
@ -359,7 +363,7 @@ function Search:find(option)
elseif option == "tags" then elseif option == "tags" then
local found = false local found = false
for j in string.gmatch(self.data[i][self.tags3],"\t[^\t]+") do for j in string.gmatch(self.data[i][self.tags3],"\t[^\t]+") do
if j~="\t" and self.browse_tags[string.sub(j,2)] then if j~="\t" and self.browse_tags[string.sub(j, 2)] then
found = true found = true
end end
end end
@ -375,10 +379,11 @@ function Search:find(option)
end end
end end
if not self.use_own_metadata_file then if not self.use_own_metadata_file then
logger.info("FMSearch: Writing our own simplified metadata file . . .")
local g = io.open(koreaderfile, "w") local g = io.open(koreaderfile, "w")
g:write("#metadata.koreader Version 1.1\n") g:write("#metadata.koreader Version 1.1\n")
f = io.open(self.metafile_1) f = io.open(self.metafile_1, "r")
line = f:read() line = f:read()
while line do while line do
if line == " }, " or line == " }" then if line == " }, " or line == " }" then
@ -400,7 +405,7 @@ function Search:find(option)
end end
if upsearch ~= "" then if upsearch ~= "" then
if string.find(search_content,upsearch,nil,true) then if string.find(search_content, upsearch, nil, true) then
i = i + 1 i = i + 1
end end
else else
@ -410,8 +415,8 @@ function Search:find(option)
end end
elseif option == "tags" then elseif option == "tags" then
local found = false local found = false
for j in string.gmatch(self.data[i][self.tags3],"\t[^\t]+") do for j in string.gmatch(self.data[i][self.tags3], "\t[^\t]+") do
if j~="\t" and self.browse_tags[string.sub(j,2)] then if j~="\t" and self.browse_tags[string.sub(j, 2)] then
found = true found = true
end end
end end
@ -427,19 +432,19 @@ function Search:find(option)
ReadMultipleLines(self.authors) ReadMultipleLines(self.authors)
elseif line == " \"tags\": [" then -- TAGS elseif line == " \"tags\": [" then -- TAGS
ReadMultipleLines(self.tags) ReadMultipleLines(self.tags)
elseif string.sub(line,1,11) == " \"title\"" then -- TITLE elseif string.sub(line, 1, 11) == " \"title\"" then -- TITLE
self.data[i][self.title] = ReplaceHexChars(line,15,3) self.data[i][self.title] = ReplaceHexChars(line, 15, 3)
elseif string.sub(line,1,11) == " \"lpath\"" then -- LPATH elseif string.sub(line, 1, 11) == " \"lpath\"" then -- LPATH
self.data[i][self.path] = ReplaceHexChars(line,15,3) self.data[i][self.path] = ReplaceHexChars(line, 15, 3)
if firstrun then if firstrun then
self.data[i][self.path] = SEARCH_LIBRARY_PATH .. self.data[i][self.path] self.data[i][self.path] = SEARCH_LIBRARY_PATH .. self.data[i][self.path]
else else
self.data[i][self.path] = SEARCH_LIBRARY_PATH2 .. self.data[i][self.path] self.data[i][self.path] = SEARCH_LIBRARY_PATH2 .. self.data[i][self.path]
end end
elseif string.sub(line,1,12) == " \"series\"" and line ~= " \"series\": null, " then -- SERIES elseif string.sub(line, 1, 12) == " \"series\"" and line ~= " \"series\": null, " then -- SERIES
self.data[i][self.series] = ReplaceHexChars(line,16,3) self.data[i][self.series] = ReplaceHexChars(line, 16, 3)
elseif string.sub(line,1,18) == " \"series_index\"" and line ~= " \"series_index\": null, " then -- SERIES_INDEX elseif string.sub(line, 1, 18) == " \"series_index\"" and line ~= " \"series_index\": null, " then -- SERIES_INDEX
self.data[i][self.series_index] = ReplaceHexChars(line,21,2) self.data[i][self.series_index] = ReplaceHexChars(line, 21, 2)
end end
line = f:read() line = f:read()
@ -448,20 +453,20 @@ function Search:find(option)
firstrun = false firstrun = false
if self.metafile_2 then if self.metafile_2 then
f = io.open(self.metafile_2) f = io.open(self.metafile_2, "r")
line = f:read() line = f:read()
end end
end end
end end
g.close() g.close()
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_1).modification then if lfs.attributes(koreaderfile, "modification") < lfs.attributes(self.metafile_1, "modification") then
lfs.touch(koreaderfile, lfs.touch(koreaderfile,
lfs.attributes(self.metafile_1).modification + 1, lfs.attributes(self.metafile_1, "modification") + 1,
lfs.attributes(self.metafile_1).modification + 1) lfs.attributes(self.metafile_1, "modification") + 1)
end end
if self.metafile_2 then if self.metafile_2 then
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_2).modification then if lfs.attributes(koreaderfile, "modification") < lfs.attributes(self.metafile_2, "modification") then
lfs.touch(koreaderfile, lfs.attributes(self.metafile_2).modification + 1, lfs.attributes(self.metafile_2).modification + 1) lfs.touch(koreaderfile, lfs.attributes(self.metafile_2, "modification") + 1, lfs.attributes(self.metafile_2, "modification") + 1)
end end
end end
end end
@ -487,11 +492,11 @@ function Search:onMenuHold(item)
if item.notchecked then if item.notchecked then
item.info = item.info .. item.path item.info = item.info .. item.path
local f = io.open(item.path) local f = io.open(item.path, "r")
if f == nil then if f == nil then
item.info = item.info .. "\n" .. _("File not found!") item.info = item.info .. "\n" .. _("File not found!")
else else
item.info = item.info .. "\n" .. _("Size:") .. " " .. string.format("%4.1fM",lfs.attributes(item.path, "size")/1024/1024) item.info = item.info .. "\n" .. _("Size:") .. " " .. string.format("%4.1fM", lfs.attributes(item.path, "size")/1024/1024)
f:close() f:close()
end end
item.notchecked = false item.notchecked = false
@ -599,7 +604,7 @@ function Search:browse(option, run, chosen)
for v,n in util.orderedPairs(self.browse_series) do for v,n in util.orderedPairs(self.browse_series) do
dummy = v dummy = v
if not SEARCH_CASESENSITIVE then dummy = string.upper(dummy) end if not SEARCH_CASESENSITIVE then dummy = string.upper(dummy) end
if string.find(dummy,upsearch,nil,true) then if string.find(dummy, upsearch, nil, true) then
table.insert(self.results, { table.insert(self.results, {
text = v .. " (" .. tostring(self.browse_series[v]) .. ")", text = v .. " (" .. tostring(self.browse_series[v]) .. ")",
callback = function() callback = function()
@ -612,7 +617,7 @@ function Search:browse(option, run, chosen)
for v,n in util.orderedPairs(self.browse_tags) do for v,n in util.orderedPairs(self.browse_tags) do
dummy = v dummy = v
if not SEARCH_CASESENSITIVE then dummy = string.upper(dummy) end if not SEARCH_CASESENSITIVE then dummy = string.upper(dummy) end
if string.find(dummy,upsearch,nil,true) then if string.find(dummy, upsearch, nil, true) then
table.insert(self.results, { table.insert(self.results, {
text = v .. " (" .. tostring(self.browse_tags[v]) .. ")", text = v .. " (" .. tostring(self.browse_tags[v]) .. ")",
callback = function() callback = function()
@ -642,7 +647,7 @@ function Search:browse(option, run, chosen)
if self.data[i][self.series_index] == "0.0" then if self.data[i][self.series_index] == "0.0" then
text = self.data[i][self.title] .. " (" .. self.data[i][self.authors] .. ")" text = self.data[i][self.title] .. " (" .. self.data[i][self.authors] .. ")"
else else
text = string.format("%6.1f",self.data[i][self.series_index]:gsub(".0$","")) .. ": " .. self.data[i][self.title] .. " (" .. self.data[i][self.authors] .. ")" text = string.format("%6.1f", self.data[i][self.series_index]:gsub(".0$","")) .. ": " .. self.data[i][self.title] .. " (" .. self.data[i][self.authors] .. ")"
end end
else else
text = self.data[i][self.authors] .. ": " .. self.data[i][self.title] text = self.data[i][self.authors] .. ": " .. self.data[i][self.title]

@ -123,7 +123,7 @@ local KoboSnow = Kobo:new{
} }
-- Kobo Aura H2O2, Rev2: -- Kobo Aura H2O2, Rev2:
-- FIXME: Shares FL/NaturalLight issues with the Clara (#4015) -- FIXME: Check if the Clara fix actually helps here... (#4015)
local KoboSnowRev2 = Kobo:new{ local KoboSnowRev2 = Kobo:new{
model = "Kobo_snow", model = "Kobo_snow",
hasFrontlight = yes, hasFrontlight = yes,
@ -134,8 +134,8 @@ local KoboSnowRev2 = Kobo:new{
hasNaturalLight = yes, hasNaturalLight = yes,
frontlight_settings = { frontlight_settings = {
frontlight_white = "/sys/class/backlight/lm3630a_ledb", frontlight_white = "/sys/class/backlight/lm3630a_ledb",
frontlight_red = "/sys/class/backlight/lm3630a_led", frontlight_red = "/sys/class/backlight/lm3630a_leda",
frontlight_green = "/sys/class/backlight/lm3630a_leda", frontlight_green = "/dev/null",
}, },
} }
@ -179,7 +179,6 @@ local KoboPika = Kobo:new{
} }
-- Kobo Clara HD: -- Kobo Clara HD:
-- FIXME: Check that NaturalLight behaves properly (c.f., #4015)
local KoboNova = Kobo:new{ local KoboNova = Kobo:new{
model = "Kobo_nova", model = "Kobo_nova",
hasFrontlight = yes, hasFrontlight = yes,
@ -189,7 +188,11 @@ local KoboNova = Kobo:new{
frontlight_settings = { frontlight_settings = {
frontlight_white = "/sys/class/backlight/lm3630a_ledb", frontlight_white = "/sys/class/backlight/lm3630a_ledb",
frontlight_red = "/sys/class/backlight/lm3630a_leda", frontlight_red = "/sys/class/backlight/lm3630a_leda",
frontlight_green = "/sys/class/backlight/lm3630a_led1b", -- NOTE: There doesn't appear to be a dedicated "green" LED, instead,
-- there's a knob that mixes the white & red ones together (/sys/class/backlight/lm3630a_led).
-- c.f., https://www.mobileread.com/forums/showpost.php?p=3728236&postcount=2947
-- Because I'm not familiar with sysfs_light.lua, just throw green into the void, and hope for the best...
frontlight_green = "/dev/null",
}, },
} }

@ -108,14 +108,18 @@ function ScrollTextWidget:getCharPos()
return self.text_widget:getCharPos() return self.text_widget:getCharPos()
end end
function ScrollTextWidget:updateScrollBar() function ScrollTextWidget:updateScrollBar(is_partial)
local low, high = self.text_widget:getVisibleHeightRatios() local low, high = self.text_widget:getVisibleHeightRatios()
if low ~= self.prev_low or high ~= self.prev_high then if low ~= self.prev_low or high ~= self.prev_high then
self.prev_low = low self.prev_low = low
self.prev_high = high self.prev_high = high
self.v_scroll_bar:set(low, high) self.v_scroll_bar:set(low, high)
local refreshfunc = "ui"
if is_partial then
refreshfunc = "partial"
end
UIManager:setDirty(self.dialog, function() UIManager:setDirty(self.dialog, function()
return "partial", self.dimen return refreshfunc, self.dimen
end) end)
end end
end end
@ -152,22 +156,22 @@ end
function ScrollTextWidget:scrollDown() function ScrollTextWidget:scrollDown()
self.text_widget:scrollDown(); self.text_widget:scrollDown();
self:updateScrollBar() self:updateScrollBar(true)
end end
function ScrollTextWidget:scrollUp() function ScrollTextWidget:scrollUp()
self.text_widget:scrollUp(); self.text_widget:scrollUp();
self:updateScrollBar() self:updateScrollBar(true)
end end
function ScrollTextWidget:scrollToTop() function ScrollTextWidget:scrollToTop()
self.text_widget:scrollToTop(); self.text_widget:scrollToTop();
self:updateScrollBar() self:updateScrollBar(true)
end end
function ScrollTextWidget:scrollToBottom() function ScrollTextWidget:scrollToBottom()
self.text_widget:scrollToBottom(); self.text_widget:scrollToBottom();
self:updateScrollBar() self:updateScrollBar(true)
end end
function ScrollTextWidget:scrollText(direction) function ScrollTextWidget:scrollText(direction)
@ -177,12 +181,12 @@ function ScrollTextWidget:scrollText(direction)
else else
self.text_widget:scrollUp() self.text_widget:scrollUp()
end end
self:updateScrollBar() self:updateScrollBar(true)
end end
function ScrollTextWidget:scrollToRatio(ratio) function ScrollTextWidget:scrollToRatio(ratio)
self.text_widget:scrollToRatio(ratio) self.text_widget:scrollToRatio(ratio)
self:updateScrollBar() self:updateScrollBar(true)
end end
function ScrollTextWidget:onScrollText(arg, ges) function ScrollTextWidget:onScrollText(arg, ges)

Loading…
Cancel
Save