Last active
December 20, 2025 19:39
-
-
Save sebdelsol/16ab741b44b75a46cbceb133163bbab5 to your computer and use it in GitHub Desktop.
Revisions
-
sebdelsol revised this gist
May 26, 2025 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ -- **MOVED to https://github.com/sebdelsol/KOReader.patches** local BD = require("ui/bidi") local Blitbuffer = require("ffi/blitbuffer") local Device = require("device") -
sebdelsol revised this gist
May 12, 2025 . 1 changed file with 85 additions and 60 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,8 @@ local BD = require("ui/bidi") local Blitbuffer = require("ffi/blitbuffer") local Device = require("device") local Geom = require("ui/geometry") local Math = require("optmath") local ProgressWidget = require("ui/widget/progresswidget") local ReaderFooter = require("apps/reader/modules/readerfooter") local ReaderToc = require("apps/reader/modules/readertoc") local T = require("ffi/util").template @@ -20,65 +20,74 @@ function ProgressWidget:paintTo(bb, x, y) -- same bar height if thin_ticks, need extra space for the taller markers local dy = self.thin_ticks and (Screen:scaleBySize(1) / 2) or 0 my_size.h = my_size.h + dy * 2 if not self.dimen then self.dimen = Geom:new { x = x, y = y, w = my_size.w, h = my_size.h, } else self.dimen.x = x self.dimen.y = y self.dimen.w = my_size.w self.dimen.h = my_size.h end if self.dimen.w == 0 or self.dimen.h == 0 then return end local _mirroredUI = BD.mirroredUILayout() -- We'll draw every bar element in order, bottom to top. local fill_width = my_size.w - 2 * (self.margin_h + self.bordersize) local fill_y = y + self.margin_v + self.bordersize local fill_height = my_size.h - 2 * (self.margin_v + self.bordersize) if self.radius == 0 then -- If we don't have rounded borders, we can start with a simple border colored rectangle. bb:paintRect(x, y + dy, my_size.w, my_size.h - dy * 2, self.bordercolor) -- And a full background bar inside (i.e., on top) of that. bb:paintRect( x + self.margin_h + self.bordersize, fill_y + dy, math.ceil(fill_width), math.ceil(fill_height) - dy * 2, self.bgcolor ) else -- Otherwise, we have to start with the background. bb:paintRoundedRect(x, y, my_size.w, my_size.h, self.bgcolor, self.radius) -- Then the border around that. bb:paintBorder( math.floor(x), math.floor(y), my_size.w, my_size.h, self.bordersize, self.bordercolor, self.radius ) end -- Then we can just paint the fill rectangle(s) and tick(s) on top of that. -- First the fill bar(s)... -- Fill bar for alternate pages (e.g. non-linear flows). if self.alt and self.alt[1] ~= nil then for i = 1, #self.alt do local tick_x = fill_width * ((self.alt[i][1] - 1) / self.last) local width = fill_width * (self.alt[i][2] / self.last) if _mirroredUI then tick_x = fill_width - tick_x - width end tick_x = math.floor(tick_x) width = math.ceil(width) bb:paintRect( x + self.margin_h + self.bordersize + tick_x, fill_y + dy, width, math.ceil(fill_height) - dy * 2, self.altcolor ) end end @@ -90,38 +99,48 @@ function ProgressWidget:paintTo(bb, x, y) fill_x = math.floor(fill_x) end bb:paintRect( fill_x, fill_y + dy, math.ceil(fill_width * self.percentage), math.ceil(fill_height) - dy * 2, self.fillcolor ) -- Overlay the initial position marker on top of that if self.initial_pos_marker and self.initial_percentage >= 0 then if self.height <= initial_marker_height_threshold then self.initial_pos_icon:paintTo( bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 4), y - Math.round(self.height / 6) ) else self.initial_pos_icon:paintTo( bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 2), y ) end end end -- ...then the tick(s). if self.ticks and self.last and self.last > 0 then local filled = math.floor(fill_width * self.percentage) for i, tick in ipairs(self.ticks) do local tick_x = fill_width * (tick / self.last) if _mirroredUI then tick_x = fill_width - tick_x end tick_x = math.floor(tick_x) -- color depend on the tick placment: white if it's read, black if after local color = (self.thin_ticks and (tick_x < filled)) and Blitbuffer.COLOR_WHITE or self.bordercolor bb:paintRect( x + self.margin_h + self.bordersize + tick_x, fill_y, self.tick_width, math.ceil(fill_height), color ) end end end @@ -157,7 +176,10 @@ local function patch_menu_item(attrib_name, replacement, menu, ...) local function find_sub_item(sub_items, text) local find_text if type(text) == "table" then local set = {} for _, t in ipairs(text) do set[t] = true end find_text = function(a_text) return set[a_text] end else find_text = function(a_text) return a_text == text end @@ -182,21 +204,24 @@ local function patch_menu_item(attrib_name, replacement, menu, ...) return item end local item = find_item_from_path(menu, { ... }) if item and item[attrib_name] then item[attrib_name] = replacement local path = { ... } for i, t in ipairs(path) do if type(t) == "table" then path[i] = table.concat(t, " | ") end end logger.info("Patch", attrib_name, "in '", table.concat(path, " > "), "'") end end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu ReaderFooter.addToMainMenu = function(self, menu_items) orig_ReaderFooter_addToMainMenu(self, menu_items) patch_menu_item( "callback", function() self.settings.progress_style_thin = true local bar_height = self.settings.progress_style_thin_height @@ -206,27 +231,27 @@ ReaderFooter.addToMainMenu = function(self, menu_items) end, menu_items.status_bar, _("Progress bar"), { _("Thickness and height: thin"), _("Thickness and height: thick") }, _("Thin") ) patch_menu_item( "enabled_func", function() return not self.settings.chapter_progress_bar and not self.settings.disable_progress_bar end, menu_items.status_bar, _("Progress bar"), _("Show chapter markers") ) patch_menu_item( "enabled_func", function() return not self.settings.chapter_progress_bar and self.settings.toc_markers and not self.settings.disable_progress_bar end, menu_items.status_bar, _("Progress bar"), T(_("Chapter marker width: %1"), self:genProgressBarChapterMarkerWidthMenuItems()) ) end -
sebdelsol revised this gist
May 5, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ local initial_marker_height_threshold = userpatch.getUpValue(ProgressWidget.pain local logger = require("logger") function ProgressWidget:paintTo(bb, x, y) local my_size = self:getSize() -- same bar height if thin_ticks, need extra space for the taller markers -
sebdelsol revised this gist
May 4, 2025 . 1 changed file with 6 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,13 +13,13 @@ local Screen = Device.screen local userpatch = require("userpatch") local initial_marker_height_threshold = userpatch.getUpValue(ProgressWidget.paintTo, "INITIAL_MARKER_HEIGHT_THRESHOLD") local logger = require("logger") ProgressWidget.paintTo = function(self, bb, x, y) local my_size = self:getSize() -- same bar height if thin_ticks, need extra space for the taller markers local dy = self.thin_ticks and (Screen:scaleBySize(1) / 2) or 0 my_size.h = my_size.h + dy * 2 if not self.dimen then @@ -146,15 +146,14 @@ ReaderFooter.setTocMarkers = function(self, reset) local save_thin_setting = self.settings.progress_style_thin self.settings.progress_style_thin = false -- prevent premature exit orig_ReaderFooter_setTocMarkers(self, reset or force_reset) self.settings.progress_style_thin = save_thin_setting ReaderToc.getTocTicks = orig_ReaderToc_getTocTicks end local function patch_menu_item(attrib_name, replacement, menu, ...) local function find_sub_item(sub_items, text) local find_text if type(text) == "table" then -
sebdelsol revised this gist
May 4, 2025 . 1 changed file with 21 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,7 @@ local Geom = require("ui/geometry") local ProgressWidget = require("ui/widget/progresswidget") local Math = require("optmath") local ReaderFooter = require("apps/reader/modules/readerfooter") local ReaderToc = require("apps/reader/modules/readertoc") local T = require("ffi/util").template local _ = require("gettext") @@ -18,7 +19,7 @@ ProgressWidget.paintTo = function(self, bb, x, y) local my_size = self:getSize() -- same bar height if special, need extra space for the taller markers local dy = self.thin_ticks and math.floor(Screen:scaleBySize(1) / 2) or 0 my_size.h = my_size.h + dy * 2 if not self.dimen then @@ -115,7 +116,7 @@ ProgressWidget.paintTo = function(self, bb, x, y) end tick_x = math.floor(tick_x) -- color depend on the tick placment: white if it's read, black if after local color = (self.thin_ticks and (tick_x < filled)) and Blitbuffer.COLOR_WHITE or self.bordercolor bb:paintRect(x + self.margin_h + self.bordersize + tick_x, fill_y, self.tick_width, @@ -126,18 +127,29 @@ ProgressWidget.paintTo = function(self, bb, x, y) end local orig_ReaderFooter_setTocMarkers = ReaderFooter.setTocMarkers local orig_ReaderToc_getTocTicks = ReaderToc.getTocTicks local was_thin_ticks ReaderFooter.setTocMarkers = function(self, reset) self.progress_bar.thin_ticks = self.settings.progress_style_thin and self.settings.toc_markers -- check ProgressWidget.paintTo local force_reset = false if self.progress_bar.thin_ticks ~= was_thin_ticks then self.ui.toc.ticks_flattened = nil force_reset = true end was_thin_ticks = self.progress_bar.thin_ticks if self.progress_bar.thin_ticks then -- force TOC to level 1 to avoid cluttering the status bar ReaderToc.getTocTicks = function(self, level) return { orig_ReaderToc_getTocTicks(self, 1) } end end local save_thin_setting = self.settings.progress_style_thin self.settings.progress_style_thin = false -- prevent premature exit orig_ReaderFooter_setTocMarkers(self, reset or force_reset) self.settings.progress_style_thin = save_thin_setting ReaderToc.getTocTicks = orig_ReaderToc_getTocTicks end local function patch_menu_item(attrib_name, replacement, menu, ...) -
sebdelsol revised this gist
May 4, 2025 . 1 changed file with 19 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,6 +30,8 @@ ProgressWidget.paintTo = function(self, bb, x, y) else self.dimen.x = x self.dimen.y = y self.dimen.w = my_size.w self.dimen.h = my_size.h end if self.dimen.w == 0 or self.dimen.h == 0 then return end @@ -39,25 +41,23 @@ ProgressWidget.paintTo = function(self, bb, x, y) local fill_y = y + self.margin_v + self.bordersize local fill_height = my_size.h - 2*(self.margin_v + self.bordersize) if self.radius == 0 then -- If we don't have rounded borders, we can start with a simple border colored rectangle. bb:paintRect(x, y + dy, my_size.w, my_size.h - dy * 2, self.bordercolor) -- And a full background bar inside (i.e., on top) of that. bb:paintRect(x + self.margin_h + self.bordersize, fill_y + dy, math.ceil(fill_width), math.ceil(fill_height) - dy * 2, self.bgcolor) else -- Otherwise, we have to start with the background. bb:paintRoundedRect(x, y, my_size.w, my_size.h, self.bgcolor, self.radius) -- Then the border around that. bb:paintBorder(math.floor(x), math.floor(y), my_size.w, my_size.h, self.bordersize, self.bordercolor, self.radius) end -- Then we can just paint the fill rectangle(s) and tick(s) on top of that. @@ -79,12 +79,6 @@ ProgressWidget.paintTo = function(self, bb, x, y) math.ceil(fill_height) - dy * 2, self.altcolor) end end -- Main fill bar for the specified percentage. @@ -224,4 +218,4 @@ ReaderFooter.addToMainMenu = function(self, menu_items) _("Progress bar"), T(_("Chapter marker width: %1"), self:genProgressBarChapterMarkerWidthMenuItems()) ) end -
sebdelsol revised this gist
Apr 25, 2025 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -146,12 +146,10 @@ ReaderFooter.setTocMarkers = function(self, reset) self.progress_bar.special_tick = self.settings.progress_style_thin and self.settings.toc_markers -- check ProgressWidget.paintTo end local function patch_menu_item(attrib_name, replacement, menu, ...) local logger = require("logger") local function find_sub_item(sub_items, text) local find_text if type(text) == "table" then local set = {} for _, t in ipairs(text) do set[t] = true end @@ -168,7 +166,7 @@ local patch_menu_item = function(attrib_name, replacement, menu, ...) end end local function find_item_from_path(menu, path) local sub_items, item for _, text in ipairs(path) do sub_items = (item or menu).sub_item_table @@ -187,6 +185,8 @@ local patch_menu_item = function(attrib_name, replacement, menu, ...) end end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu ReaderFooter.addToMainMenu = function(self, menu_items) orig_ReaderFooter_addToMainMenu(self, menu_items) -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,8 @@ local BD = require("ui/bidi") local Blitbuffer = require("ffi/blitbuffer") local Device = require("device") local Geom = require("ui/geometry") local ProgressWidget = require("ui/widget/progresswidget") local Math = require("optmath") local ReaderFooter = require("apps/reader/modules/readerfooter") local T = require("ffi/util").template -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 215 additions and 62 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,78 +1,231 @@ local BD = require("ui/bidi") local Blitbuffer = require("ffi/blitbuffer") local Device = require("device") local Font = require("ui/font") local Geom = require("ui/geometry") local ProgressWidget = require("ui/widget/progresswidget") local SpinWidget = require("ui/widget/spinwidget") local TextWidget = require("ui/widget/textwidget") local UIManager = require("ui/uimanager") local Math = require("optmath") local ReaderFooter = require("apps/reader/modules/readerfooter") local T = require("ffi/util").template local _ = require("gettext") local Screen = Device.screen local userpatch = require("userpatch") local initial_marker_height_threshold = userpatch.getUpValue(ProgressWidget.paintTo, "INITIAL_MARKER_HEIGHT_THRESHOLD") ProgressWidget.paintTo = function(self, bb, x, y) -- TODO Overlay the initial position marker on top of that local my_size = self:getSize() -- same bar height if special, need extra space for the taller markers local dy = self.special_tick and math.floor(Screen:scaleBySize(1) / 2) or 0 my_size.h = my_size.h + dy * 2 if not self.dimen then self.dimen = Geom:new{ x = x, y = y, w = my_size.w, h = my_size.h } else self.dimen.x = x self.dimen.y = y end if self.dimen.w == 0 or self.dimen.h == 0 then return end local _mirroredUI = BD.mirroredUILayout() -- We'll draw every bar element in order, bottom to top. local fill_width = my_size.w - 2*(self.margin_h + self.bordersize) local fill_y = y + self.margin_v + self.bordersize local fill_height = my_size.h - 2*(self.margin_v + self.bordersize) if not self.special_tick then -- special doesn't need a border if self.radius == 0 then -- If we don't have rounded borders, we can start with a simple border colored rectangle. bb:paintRect(x, y, my_size.w, my_size.h, self.bordercolor) -- And a full background bar inside (i.e., on top) of that. bb:paintRect(x + self.margin_h + self.bordersize, fill_y, math.ceil(fill_width), math.ceil(fill_height), self.bgcolor) else -- Otherwise, we have to start with the background. bb:paintRoundedRect(x, y, my_size.w, my_size.h, self.bgcolor, self.radius) -- Then the border around that. bb:paintBorder(math.floor(x), math.floor(y), my_size.w, my_size.h, self.bordersize, self.bordercolor, self.radius) end end -- Then we can just paint the fill rectangle(s) and tick(s) on top of that. -- First the fill bar(s)... -- Fill bar for alternate pages (e.g. non-linear flows). if self.alt and self.alt[1] ~= nil then for i=1, #self.alt do local tick_x = fill_width * ((self.alt[i][1] - 1) / self.last) local width = fill_width * (self.alt[i][2] / self.last) if _mirroredUI then tick_x = fill_width - tick_x - width end tick_x = math.floor(tick_x) width = math.ceil(width) bb:paintRect(x + self.margin_h + self.bordersize + tick_x, fill_y + dy, width, math.ceil(fill_height) - dy * 2, self.altcolor) end elseif self.special_tick then -- paint in case missing bb:paintRect(x + self.margin_h + self.bordersize, fill_y + dy, fill_width, math.ceil(fill_height) - dy * 2, self.altcolor) end -- Main fill bar for the specified percentage. if self.percentage >= 0 and self.percentage <= 1 then local fill_x = x + self.margin_h + self.bordersize if self.fill_from_right or (_mirroredUI and not self.fill_from_right) then fill_x = fill_x + (fill_width * (1 - self.percentage)) fill_x = math.floor(fill_x) end bb:paintRect(fill_x, fill_y + dy, math.ceil(fill_width * self.percentage), math.ceil(fill_height) - dy * 2, self.fillcolor) -- Overlay the initial position marker on top of that if self.initial_pos_marker and self.initial_percentage >= 0 then if self.height <= initial_marker_height_threshold then self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 4), y - Math.round(self.height / 6)) else self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 2), y) end end end -- ...then the tick(s). if self.ticks and self.last and self.last > 0 then local filled = math.floor(fill_width * self.percentage) for i, tick in ipairs(self.ticks) do local tick_x = fill_width * (tick / self.last) if _mirroredUI then tick_x = fill_width - tick_x end tick_x = math.floor(tick_x) -- color depend on the tick placment: white if it's read, black if after local color = (self.special_tick and (tick_x < filled)) and Blitbuffer.COLOR_WHITE or self.bordercolor bb:paintRect(x + self.margin_h + self.bordersize + tick_x, fill_y, self.tick_width, math.ceil(fill_height), color) end end end local orig_ReaderFooter_setTocMarkers = ReaderFooter.setTocMarkers ReaderFooter.setTocMarkers = function(self, reset) local save_thin_setting = self.settings.progress_style_thin local save_getTocTicksFlattened = self.ui.toc.getTocTicksFlattened self.settings.progress_style_thin = false -- prevent premature exit self.ui.toc.getTocTicksFlattened = function(self, for_chapter_navigation) return self.ui.toc.getTocTicks(self, 1) end -- TOC only at level 1 orig_ReaderFooter_setTocMarkers(self, reset) self.settings.progress_style_thin = save_thin_setting self.ui.toc.getTocTicksFlattened = save_getTocTicksFlattened self.progress_bar.special_tick = self.settings.progress_style_thin and self.settings.toc_markers -- check ProgressWidget.paintTo end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu local patch_menu_item = function(attrib_name, replacement, menu, ...) local logger = require("logger") local find_sub_item = function(sub_items, text) local find_text if type(text) == "table" then local set = {} for _, t in ipairs(text) do set[t] = true end find_text = function(a_text) return set[a_text] end else find_text = function(a_text) return a_text == text end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if item_text and find_text(item_text) then -- logger.info("Found item", item_text) return item end end end local find_item_from_path = function(menu, path) local sub_items, item for _, text in ipairs(path) do sub_items = (item or menu).sub_item_table if not sub_items then return end item = find_sub_item(sub_items, text) if not item then return end end return item end local item = find_item_from_path(menu, {...}) if item and item[attrib_name] then item[attrib_name] = replacement local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " | ") end end logger.info("Patch", attrib_name, "in '", table.concat(path," > "),"'") end end ReaderFooter.addToMainMenu = function(self, menu_items) orig_ReaderFooter_addToMainMenu(self, menu_items) patch_menu_item( "callback", function() self.settings.progress_style_thin = true local bar_height = self.settings.progress_style_thin_height self.progress_bar:updateStyle(false, bar_height) self:setTocMarkers() self:refreshFooter(true, true) end, menu_items.status_bar, _("Progress bar"), {_("Thickness and height: thin"), _("Thickness and height: thick")}, _("Thin") ) patch_menu_item( "enabled_func", function() return not self.settings.chapter_progress_bar and not self.settings.disable_progress_bar end, menu_items.status_bar, _("Progress bar"), _("Show chapter markers") ) patch_menu_item( "enabled_func", function() return not self.settings.chapter_progress_bar and self.settings.toc_markers and not self.settings.disable_progress_bar end, menu_items.status_bar, _("Progress bar"), T(_("Chapter marker width: %1"), self:genProgressBarChapterMarkerWidthMenuItems()) ) end -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 62 additions and 216 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,232 +1,78 @@ local InfoMessage = require("ui/widget/infomessage") local Math = require("optmath") local ReaderUI = require("apps/reader/readerui") local Screensaver = require("ui/screensaver") local UIManager = require("ui/uimanager") local _ = require("gettext") local expandSpecial_orig = Screensaver.expandSpecial Screensaver.expandSpecial = function(self, message) local chapter_title = "n/a" local chapter_percent = 0 local msg = expandSpecial_orig(self, message) local ui = ReaderUI.instance if ui then local current_page = ui.view.state.page or 1 chapter_title = ui.toc:getTocTitleByPage(current_page) if chapter_title and chapter_title ~= "" then chapter_title = chapter_title:gsub(" ", "\xC2\xA0") -- replace space with no-break-space end local ch_read = ui.toc:getChapterPagesDone(current_page) ch_read = ch_read + 1 local ch_count = ui.toc:getChapterPageCount(current_page) if ch_read == 1 then chapter_percent = 0 elseif ch_read == ch_count then chapter_percent = 100 else chapter_percent = Math.round(Math.clamp(((ch_read * 100) / ch_count), 1, 99)) end end local replace = { ["%C"] = chapter_title, ["%P"] = chapter_percent, } msg = msg:gsub("(%%%a)", replace) return msg end local info_text = ([[ %T title %A author(s) %S series %c current page number %t total page number %p percentage read %h time left in chapter %H time left in document %b battery level %B battery symbol %C chapter title %P chapter percent]]) local orig_Screensaver_setMessage = Screensaver.setMessage Screensaver.setMessage = function(self) -- local logger = require("logger") orig_Screensaver_setMessage(self) for widget in UIManager:topdown_widgets_iter() do if widget.title == _("Sleep screen message") then for _i, button in ipairs(widget.buttons[1]) do if button.text == _("Info") then button.callback = function() UIManager:show(InfoMessage:new{ text = _(info_text), monospace_font = true, }) end -- logger.info("Sleep screen messsage Info button patched") return end end end end end -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -185,7 +185,7 @@ local patch_menu_item = function(attrib_name, replacement, menu, ...) end local item = find_item_from_path(menu, {...}) if item and item[attrib_name] then item[attrib_name] = replacement local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " | ") end end logger.info("Patch", attrib_name, "in '", table.concat(path," > "),"'") -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,7 @@ local _ = require("gettext") local Screen = Device.screen -- Somewhat empirically chosen threshold to switch between the two designs ;o) -- TODO get from upvalues !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! local INITIAL_MARKER_HEIGHT_THRESHOLD = Screen:scaleBySize(12) ProgressWidget.paintTo = function(self, bb, x, y) @@ -152,7 +153,7 @@ end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu local patch_menu_item = function(attrib_name, replacement, menu, ...) local logger = require("logger") local find_sub_item = function(sub_items, text) @@ -194,7 +195,7 @@ end ReaderFooter.addToMainMenu = function(self, menu_items) orig_ReaderFooter_addToMainMenu(self, menu_items) patch_menu_item( "callback", function() self.settings.progress_style_thin = true @@ -209,7 +210,7 @@ ReaderFooter.addToMainMenu = function(self, menu_items) _("Thin") ) patch_menu_item( "enabled_func", function() return not self.settings.chapter_progress_bar and not self.settings.disable_progress_bar @@ -219,7 +220,7 @@ ReaderFooter.addToMainMenu = function(self, menu_items) _("Show chapter markers") ) patch_menu_item( "enabled_func", function() return not self.settings.chapter_progress_bar and self.settings.toc_markers and not self.settings.disable_progress_bar -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,6 @@ ProgressWidget.paintTo = function(self, bb, x, y) local fill_y = y + self.margin_v + self.bordersize local fill_height = my_size.h - 2*(self.margin_v + self.bordersize) if not self.special_tick then -- special doesn't need a border if self.radius == 0 then -- If we don't have rounded borders, we can start with a simple border colored rectangle. -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -157,16 +157,16 @@ local replace_item = function(attrib_name, replacement, menu, ...) local logger = require("logger") local find_sub_item = function(sub_items, text) local find_text if type(text) == "table" then local set = {} for _, t in ipairs(text) do set[t] = true end find_text = function(a_text) return set[a_text] end else find_text = function(a_text) return a_text == text end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if item_text and find_text(item_text) then -- logger.info("Found item", item_text) return item end -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -157,16 +157,16 @@ local replace_item = function(attrib_name, replacement, menu, ...) local logger = require("logger") local find_sub_item = function(sub_items, text) local found_text if type(text) == "table" then local set = {} for _, t in ipairs(text) do set[t] = true end found_text = function(a_text) return set[a_text] end else found_text = function(a_text) return a_text == text end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if item_text and found_text(item_text) then -- logger.info("Found item", item_text) return item end -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -156,13 +156,13 @@ local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu local replace_item = function(attrib_name, replacement, menu, ...) local logger = require("logger") local find_sub_item = function(sub_items, text) local is_text if type(text) == "table" then local set = {} for _, t in ipairs(text) do set[t] = true end is_text = function(a_text) return set[a_text] end else is_text = function(a_text) return a_text == text end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -167,12 +167,13 @@ local replace_item = function(attrib_name, replacement, menu, ...) for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if item_text and is_text(item_text) then -- logger.info("Found item", item_text) return item end end end local find_item_from_path = function(menu, path) local sub_items, item for _, text in ipairs(path) do sub_items = (item or menu).sub_item_table @@ -183,7 +184,7 @@ local replace_item = function(attrib_name, replacement, menu, ...) return item end local item = find_item_from_path(menu, {...}) if item then item[attrib_name] = replacement local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " | ") end end -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -167,7 +167,6 @@ local replace_item = function(attrib_name, replacement, menu, ...) for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if item_text and is_text(item_text) then return item end end -
sebdelsol revised this gist
Apr 24, 2025 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -154,7 +154,7 @@ end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu local replace_item = function(attrib_name, replacement, menu, ...) local logger = require("logger") local find_sub_item = function(sub_items, text_to_find) local is_text @@ -174,10 +174,9 @@ local replace_item = function(attrib_name, replacement, menu, ...) end local find_deep_item = function(menu, path) local sub_items, item for _, text in ipairs(path) do sub_items = (item or menu).sub_item_table if not sub_items then return end item = find_sub_item(sub_items, text) if not item then return end @@ -188,8 +187,8 @@ local replace_item = function(attrib_name, replacement, menu, ...) local item = find_deep_item(menu, {...}) if item then item[attrib_name] = replacement local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " | ") end end logger.info("Patch", attrib_name, "in '", table.concat(path," > "),"'") end end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -142,7 +142,7 @@ ReaderFooter.setTocMarkers = function(self, reset) local save_thin_setting = self.settings.progress_style_thin local save_getTocTicksFlattened = self.ui.toc.getTocTicksFlattened self.settings.progress_style_thin = false -- prevent premature exit self.ui.toc.getTocTicksFlattened = function(self, for_chapter_navigation) return self.ui.toc.getTocTicks(self, 1) end -- TOC only at level 1 orig_ReaderFooter_setTocMarkers(self, reset) -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -190,7 +190,6 @@ local replace_item = function(attrib_name, replacement, menu, ...) item[attrib_name] = replacement -- local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " | ") end end -- logger.info("Patch", attrib_name, "in '", table.concat(path," > "),"'") end end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -166,7 +166,7 @@ local replace_item = function(attrib_name, replacement, menu, ...) end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if item_text and is_text(item_text) then -- logger.info("Found item", item_text) return item end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -157,16 +157,16 @@ local replace_item = function(attrib_name, replacement, menu, ...) -- local logger = require("logger") local find_sub_item = function(sub_items, text_to_find) local is_text if type(text_to_find) == "table" then local set = {} for _, text in ipairs(text_to_find) do set[text] = true end is_text = function(text) return set[text] end else is_text = function(text) return text == text_to_find end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if is_text(item_text) then -- logger.info("Found item", item_text) return item end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ ProgressWidget.paintTo = function(self, bb, x, y) local my_size = self:getSize() -- same bar height if special, need extra space for the taller markers local dy = self.special_tick and math.floor(Screen:scaleBySize(1) / 2) or 0 my_size.h = my_size.h + dy * 2 @@ -44,7 +44,7 @@ ProgressWidget.paintTo = function(self, bb, x, y) local fill_height = my_size.h - 2*(self.margin_v + self.bordersize) if not self.special_tick then -- special doesn't need a border if self.radius == 0 then -- If we don't have rounded borders, we can start with a simple border colored rectangle. bb:paintRect(x, y, my_size.w, my_size.h, self.bordercolor) @@ -125,6 +125,7 @@ ProgressWidget.paintTo = function(self, bb, x, y) tick_x = fill_width - tick_x end tick_x = math.floor(tick_x) -- color depend on the tick placment: white if it's read, black if after local color = (self.special_tick and (tick_x < filled)) and Blitbuffer.COLOR_WHITE or self.bordercolor bb:paintRect(x + self.margin_h + self.bordersize + tick_x, fill_y, @@ -142,10 +143,12 @@ ReaderFooter.setTocMarkers = function(self, reset) local save_getTocTicksFlattened = self.ui.toc.getTocTicksFlattened self.settings.progress_style_thin = false -- prevent premature exit self.ui.toc.getTocTicksFlattened = function(self, reset) return self.ui.toc.getTocTicks(self, 1) end -- TOC only at level 1 orig_ReaderFooter_setTocMarkers(self, reset) self.settings.progress_style_thin = save_thin_setting self.ui.toc.getTocTicksFlattened = save_getTocTicksFlattened self.progress_bar.special_tick = self.settings.progress_style_thin and self.settings.toc_markers -- check ProgressWidget.paintTo end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -150,30 +150,30 @@ end local orig_ReaderFooter_addToMainMenu = ReaderFooter.addToMainMenu local replace_item = function(attrib_name, replacement, menu, ...) -- local logger = require("logger") local find_sub_item = function(sub_items, text_to_find) local check_text if type(text_to_find) == "table" then local set = {} for _, text in ipairs(text_to_find) do set[text] = true end check_text = function(text) return set[text] end else check_text = function(text) return text == text_to_find end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if check_text(item_text) then -- logger.info("Found item", item_text) return item end end end local find_deep_item = function(menu, path) local sub_items local item = menu for _, text in ipairs(path) do sub_items = item.sub_item_table if not sub_items then return end item = find_sub_item(sub_items, text) @@ -182,11 +182,11 @@ local replace_item = function(attrib, replacement, menu, ...) return item end local item = find_deep_item(menu, {...}) if item then item[attrib_name] = replacement -- local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " | ") end end -- logger.info("Patch", attrib_name, "in '", table.concat(path," > "),"'") return true end end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -154,17 +154,17 @@ local replace_item = function(attrib, replacement, menu, ...) -- local logger = require("logger") local find_sub_item = function(sub_items, text_to_find) local check if type(text_to_find) == "table" then local set = {} for _, text in ipairs(text_to_find) do set[text] = true end check = function(text) return set[text] end else check = function(text) return text == text_to_find end end for _, item in ipairs(sub_items) do local item_text = item.text or (item.text_func and item.text_func()) if check(item_text) then -- logger.info("Found item", item_text) return item end end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -138,15 +138,13 @@ end local orig_ReaderFooter_setTocMarkers = ReaderFooter.setTocMarkers ReaderFooter.setTocMarkers = function(self, reset) local save_thin_setting = self.settings.progress_style_thin local save_getTocTicksFlattened = self.ui.toc.getTocTicksFlattened self.settings.progress_style_thin = false -- prevent premature exit self.ui.toc.getTocTicksFlattened = function(self, reset) return self.ui.toc.getTocTicks(self, 1) end -- TOC only at level 1 orig_ReaderFooter_setTocMarkers(self, reset) self.settings.progress_style_thin = save_thin_setting self.ui.toc.getTocTicksFlattened = save_getTocTicksFlattened self.progress_bar.special_tick = self.settings.progress_style_thin and self.settings.toc_markers end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -140,8 +140,13 @@ local orig_ReaderFooter_setTocMarkers = ReaderFooter.setTocMarkers ReaderFooter.setTocMarkers = function(self, reset) local thin_save = self.settings.progress_style_thin self.settings.progress_style_thin = false local getTocTicksFlattened_save = self.ui.toc.getTocTicksFlattened self.ui.toc.getTocTicksFlattened = function(self, reset) -- TOC only at level 1 return self.ui.toc.getTocTicks(self, 1) end orig_ReaderFooter_setTocMarkers(self, reset) self.settings.progress_style_thin = thin_save self.ui.toc.getTocTicksFlattened = getTocTicksFlattened_save self.progress_bar.special_tick = self.settings.progress_style_thin and self.settings.toc_markers end -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -118,7 +118,7 @@ ProgressWidget.paintTo = function(self, bb, x, y) -- ...then the tick(s). if self.ticks and self.last and self.last > 0 then local filled = math.floor(fill_width * self.percentage) for i, tick in ipairs(self.ticks) do local tick_x = fill_width * (tick / self.last) if _mirroredUI then -
sebdelsol revised this gist
Apr 23, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -179,7 +179,7 @@ local replace_item = function(attrib, replacement, menu, ...) return item end local item = find_deep_item(menu, ...) if item then item[attrib] = replacement -- local path = {...} for i, t in ipairs(path) do if type(t)=="table" then path[i] = table.concat(t, " or ") end end
NewerOlder