[ReaderHighlight] preserve highlight when using highlight dialogue#14437
Conversation
|
(You're not obliged to follow @Frenzie or myself's all suggestions.) You name it in the code |
if I don't do as he says, he follows me around teasing me with his Ryzen 7 with zillions of cores that builds emulators in seconds not minutes. ;) |
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
|
Isn't there another one for if you follow a link / location btw? |
|
I believe that's all of them... (don't quote me) |
|
@poire-z Is the little indicator for where a link points in there? |
|
It is in there and has a little world of his own: koreader/frontend/apps/reader/modules/readerrolling.lua Lines 786 to 796 in e84d63b I'd rather not send @Commodore64user on a journey into this world :) |
|
Alright. |
unsure if I should be grateful or offended... |
| callback = function() | ||
| this:lookupDict(index) | ||
| -- We don't call this:onClose(), same reason as above | ||
| this:lookupDict(index, this) |
| end | ||
| end | ||
| UIManager:scheduleIn(0.5, self.highlight_clear_and_redraw_action) | ||
| UIManager:scheduleIn(self.ui.DELAY_CLEAR_HIGHLIGHT_S, self.highlight_clear_and_redraw_action) |
There was a problem hiding this comment.
Are you sure the widget got proper ui?
| end | ||
|
|
||
| function ReaderUI:init() | ||
| self.DELAY_CLEAR_HIGHLIGHT_S = 0.5 |
There was a problem hiding this comment.
The constant, can be set once in the module, not in instances.
| local ReaderUI = require("apps/reader/readerui") | ||
| UIManager:scheduleIn(ReaderUI.DELAY_CLEAR_HIGHLIGHT_S, function() lookupCancelled() end) |
There was a problem hiding this comment.
That's quite ugly. All this to get a constant, because readerdict can be use in filemanager ?
I'd rather just see 0.5...
There was a problem hiding this comment.
all that because @hius07 prefers it declared in the module, not as instance variable, but it was working fine everywhere with self.ui.WHATEVER even in FM. ¯\_(ツ)_/¯
There was a problem hiding this comment.
I think he meant you could delare it in here:
koreader/frontend/apps/reader/readerui.lua
Lines 75 to 80 in e84d63b
and you could access it just like if declared in :init() as self.ui.DELAY_CLEAR_HIGHLIGHT_S.
There was a problem hiding this comment.
if that is what he meant, he should have said class variable. That is NOT what he said
|
I think this constant has really nothing to do in ReaderUI (except for broader access). |
| callback = function(dialog) | ||
| UIManager:close(dialog) | ||
| UIManager:scheduleIn(0.5, function() lookupCancelled() end) | ||
| UIManager:scheduleIn(self.ui.highlight.DELAY_CLEAR_HIGHLIGHT_S, function() lookupCancelled() end) |
There was a problem hiding this comment.
Can this codepath be taken if dict invoked from FileBrowser - there would be no self.ui.highlight ?
Same question for dictquicklookup ?
There was a problem hiding this comment.
good catch, this one is actually problematic, the one on dictquick is under a self.highlight so safe...
| local delay = self.ui.highlight and self.ui.highlight.DELAY_CLEAR_HIGHLIGHT_S or 0.5 | ||
| UIManager:scheduleIn(delay, function() lookupCancelled() end) |
There was a problem hiding this comment.
What happens if you start a new search in the interval? (Not a new problem, if it is one.)
There was a problem hiding this comment.
I tried with the current version, and nothing really. There are some factors, finger speed, by the time you start contact with the screen you are almost in the second half of the 0.5 and it clears just as normal and the next crengine selection begins.
As you said, not a new problem, which you can verify as well if you think you have faster fingering speed (FFS) 🫣
There was a problem hiding this comment.
I'm asking more what the problem would be if it did happen. If it's just a minor visual glitch it probably doesn't really matter, but if there's some kind of memory race condition it could be more serious.
|
I understand the thinking behind, so what should be done then? |
|
I'd say probably either add it to https://github.com/koreader/koreader/blob/87445034bd2ddadb524b2db3bfc7d05c657e8546/frontend/ui/size.lua (granted, it's a duration) or just use |
-- this should be self.ui.highlight.DELAY_CLEAR_HIGHLIGHT_S, but in FM we don't have access to self.ui
local delay = 0.5
UIManager:scheduleIn(delay, function() lookupCancelled() end) |
|
What's the question precisely? |
|
Is that better? A suitable alternative? Any other suggestions |
|
But I mean are you saying are happy with and prefer |
|
I am saying we keep the self.WHATEVER and use this as the exception for when self is not accessible, that way we get the grep and it sort of explains to anyone reading the code what's happening instead of the simple 0.5 |
|
Hold on, if there's no highlight to clear then why is there any delay at all? Shouldn't that be: if self.ui then
-- delay
else
-- immediate
end |
| local Screen = Device.screen | ||
|
|
||
| local ReaderHighlight = InputContainer:extend{ | ||
| DELAY_CLEAR_HIGHLIGHT_S = 0.5, |
There was a problem hiding this comment.
| DELAY_CLEAR_HIGHLIGHT_S = 0.5, |
|
That is only partially true in one case, searching from FM (or direct searches). In all other cases there are highlights, particular mention to meta-queries which also have highlights to clear |
|
Alright, just keep it as is then (besides the line that should be removed). |
|
On mobile, but wouldn't removing that line mean it never gets declared? Then we are trying to access something that doesn't exist |
|
Indeed, while on mobile I'd overlooked the comma. |
|
have a look @Frenzie, better now?, another thing would be to declare the class variable (constant) in FM as well... |
|
I think I'd prefer to just do that, but let's see what the others think. |
|
I think a Maybe we can put it in that file we have forgotten: https://github.com/koreader/koreader/blob/master/defaults.lua - just because it's used by many unrelated bits, so it can be considered global :) |
|
I was about to comment that the FM declaration is actually not very helpful and was a terrible idea. I take it back. in my opinion, the current form is the best compromise, it is still easily trackable with greps and doesn't bother the widgets with conundrums like "to ui or not to ui" |
I already stated my preferred solution in #14437 (comment) I regret bringing up the subject because I don't like this self.ui business at all. |
|
but you first proposed the self.ui though, are you sure adding it to the size file is better? like really? |
|
I'm also for UIManager:scheduleIn(G_defaults:readSetting("DELAY_CLEAR_HIGHLIGHT_S"), function()... |
|
One more koreader/frontend/apps/reader/modules/readerdictionary.lua Lines 1187 to 1192 in d97e177 |
Well yes, I like that better than sprinkling "we can't access self.ui here" all over the place. :-) But in any case let's go with |
This pull request introduces small improvements to the highlighting and clipboard features in the reader module, focusing on better user experience when copying text and performing dictionary lookups from the highlight dialogue. The changes ensure the dialogue is closed whilst preserving the highlighted text.
what's new
onClosemethod inReaderHighlightnow accepts akeep_highlightparameter, allowing the highlight to persist when needed.lookupDictfunction now receives the highlight as an argument for better context management.This change is