Closed tfuxu closed 2 months ago
Does this not work for inline spoiler tags, e.g. hello ||world||
?
Does this not work for inline spoiler tags, e.g.
hello ||world||
?
Ah, I completely forgot about this 🤦♂️️ I'll think of another solution for this, since the overlay probably isn't as flexible to put only on a specific section of the message (at least not with the current implementation).
You can use a hover/tap EventController
combined with method.TextView.get_iter_at_position
and method.TextView.window_to_buffer_coords
to obtain the character mark at the hovering point, then check if it has a spoiler tag and set its opacity to 1 if there is any.
You'll also need to keep a last spoiler tag:
var lastSpoilerTag *gtk.TextTag
func(spoilerTag *gtk.TextTag) { // callback
if lastSpoilerTag == spoilerTag {
return
}
if lastSpoilerTag != nil {
lastSpoilerTag.SetProperty("opacity", 0)
}
spoilerTag.SetProperty("opacity", 1)
}
Partially implemented in https://github.com/diamondburned/dissent/commit/a52c614ea157324770a72333a61ede960365bafb.
Cool! Closing as there is a new solution implemented. I've also created a tracking issue for currently unsupported types of spoilers #282
This PR implements custom Spoiler widget used as a overlay on messages wrapped in
||
tags.Note: Putting this as a draft for now, as there are a couple
MarkdownViewer
bugs that needs to be fixed beforehand, and the current spoiler style definitely needs some polishing.Fixes #152
TODO:
Screenshots:
Simple message hidden:
Simple message visible:
Textblock/multi-line message hidden: