Last active
September 2, 2024 15:52
-
-
Save uroybd/1f9af11fdf0bba6c6c7e728eaded4833 to your computer and use it in GitHub Desktop.
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 characters
local UIManager = require("ui/uimanager") | |
local ReaderHighlight = require("apps/reader/modules/readerhighlight") | |
local _ = require("gettext") | |
local util = require("util") | |
local ButtonDialog = require("ui/widget/buttondialog") | |
local BD = require("ui/bidi") | |
local C_ = _.pgettext | |
ReaderHighlight.onShowHighlightDialog = function(self, index) | |
local item = self.ui.annotation.annotations[index] | |
local buttons = { | |
{ | |
{ | |
text = _("Delete"), | |
callback = function() | |
self:deleteHighlight(index) | |
UIManager:close(self.edit_highlight_dialog) | |
self.edit_highlight_dialog = nil | |
end, | |
}, | |
{ | |
text = C_("Highlight", "Style"), | |
callback = function() | |
self:editHighlightStyle(index) | |
UIManager:close(self.edit_highlight_dialog) | |
self.edit_highlight_dialog = nil | |
end, | |
}, | |
{ | |
text = _("Color"), | |
callback = function () | |
self:editHighlightColor(index) | |
UIManager:close(self.edit_highlight_dialog) | |
self.edit_highlight_dialog = nil | |
end | |
}, | |
{ | |
text = item.note and _("Edit note") or _("Add note"), | |
callback = function() | |
self:editHighlight(index) | |
UIManager:close(self.edit_highlight_dialog) | |
self.edit_highlight_dialog = nil | |
end, | |
}, | |
{ | |
text = "…", | |
callback = function() | |
self.selected_text = util.tableDeepCopy(item) | |
self:onShowHighlightMenu(index) | |
UIManager:close(self.edit_highlight_dialog) | |
self.edit_highlight_dialog = nil | |
end, | |
}, | |
}, | |
} | |
if self.ui.rolling then | |
local enabled = not item.text_edited | |
local start_prev = "◁▒▒" | |
local start_next = "▷▒▒" | |
local end_prev = "▒▒◁" | |
local end_next = "▒▒▷" | |
if BD.mirroredUILayout() then | |
-- BiDi will mirror the arrows, and this just works | |
start_prev, start_next = start_next, start_prev | |
end_prev, end_next = end_next, end_prev | |
end | |
table.insert(buttons, { | |
{ | |
text = start_prev, | |
enabled = enabled, | |
callback = function() | |
self:updateHighlight(index, 0, -1, false) | |
end, | |
hold_callback = function() | |
self:updateHighlight(index, 0, -1, true) | |
return true | |
end | |
}, | |
{ | |
text = start_next, | |
enabled = enabled, | |
callback = function() | |
self:updateHighlight(index, 0, 1, false) | |
end, | |
hold_callback = function() | |
self:updateHighlight(index, 0, 1, true) | |
return true | |
end | |
}, | |
{ | |
text = end_prev, | |
enabled = enabled, | |
callback = function() | |
self:updateHighlight(index, 1, -1, false) | |
end, | |
hold_callback = function() | |
self:updateHighlight(index, 1, -1, true) | |
end | |
}, | |
{ | |
text = end_next, | |
enabled = enabled, | |
callback = function() | |
self:updateHighlight(index, 1, 1, false) | |
end, | |
hold_callback = function() | |
self:updateHighlight(index, 1, 1, true) | |
end | |
} | |
}) | |
end | |
self.edit_highlight_dialog = ButtonDialog:new{ | |
buttons = buttons, | |
} | |
UIManager:show(self.edit_highlight_dialog) | |
return true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment