Documentation
¶
Index ¶
- Constants
- Variables
- func AlignObject(alignment fyne.TextAlign, object fyne.CanvasObject) (*fyne.Container, int)
- func CloneRichTextSegment(seg widget.RichTextSegment) widget.RichTextSegment
- func CloneRichTextSegments(segs []widget.RichTextSegment) []widget.RichTextSegment
- func CountMarkdownImageSegments(segments []widget.RichTextSegment) int
- func ExtractMarkdownImageAltTexts(markdown string) map[string]string
- func HideTooltipWidgets(objects []fyne.CanvasObject)
- func LoadMarkdownImageObject(source fyne.URI) (fyne.CanvasObject, error)
- func LoadMarkdownImageResource(source fyne.URI) (fyne.Resource, []byte, error)
- func MarkdownImageDisplaySize(content []byte) fyne.Size
- func MarkdownImageSource(source fyne.URI) string
- func NewLazyMarkdownRichText(markdown string) *widget.RichText
- func NewMarkdownImagePlaceholder(title, status string) fyne.CanvasObject
- func NewTooltipBubble(content fyne.CanvasObject) *fyne.Container
- func ReadLimitedBytes(reader io.Reader, source fyne.URI) ([]byte, error)
- func ReadMarkdownImageBytes(source fyne.URI) ([]byte, error)
- func RemoteMarkdownImageTooLarge(rawURL string) (bool, error)
- func RewriteMarkdownImageSegments(segments []widget.RichTextSegment, altTexts map[string]string) []widget.RichTextSegment
- func RichTextSegmentsPlainText(segs []widget.RichTextSegment) string
- type HoverTooltipManager
- type IconNavButton
- func (b *IconNavButton) CreateRenderer() fyne.WidgetRenderer
- func (b *IconNavButton) Icon() fyne.Resource
- func (b *IconNavButton) MinSize() fyne.Size
- func (b *IconNavButton) MouseIn(_ *desktop.MouseEvent)
- func (b *IconNavButton) MouseMoved(_ *desktop.MouseEvent)
- func (b *IconNavButton) MouseOut()
- func (b *IconNavButton) SetIcon(icon fyne.Resource)
- func (b *IconNavButton) SetSelected(selected bool)
- func (b *IconNavButton) SetText(text string)
- func (b *IconNavButton) Tapped(_ *fyne.PointEvent)
- func (b *IconNavButton) TappedSecondary(_ *fyne.PointEvent)
- func (b *IconNavButton) Text() string
- type LazyMarkdownImageSegment
- func (s *LazyMarkdownImageSegment) Inline() bool
- func (s *LazyMarkdownImageSegment) Select(_, _ fyne.Position)
- func (s *LazyMarkdownImageSegment) SelectedText() string
- func (s *LazyMarkdownImageSegment) Textual() string
- func (s *LazyMarkdownImageSegment) Unselect()
- func (s *LazyMarkdownImageSegment) Update(fyne.CanvasObject)
- func (s *LazyMarkdownImageSegment) Visual() fyne.CanvasObject
- type TooltipWidget
- func (w *TooltipWidget) CreateRenderer() fyne.WidgetRenderer
- func (w *TooltipWidget) MouseIn(*desktop.MouseEvent)
- func (w *TooltipWidget) MouseMoved(*desktop.MouseEvent)
- func (w *TooltipWidget) MouseOut()
- func (w *TooltipWidget) SetBadge(text, tooltip string)
- func (w *TooltipWidget) SetBadgeWithContent(text string, tooltip fyne.CanvasObject)
Constants ¶
const ( // MarkdownImageLoadTimeout is the maximum time allowed for loading a markdown image. MarkdownImageLoadTimeout = 12 * time.Second // MaxMarkdownImageBytes is the maximum allowed size for markdown images (1MB). MaxMarkdownImageBytes = 1 << 20 // MaxMarkdownImageWidth is the maximum display width for markdown images. MaxMarkdownImageWidth = 560 // MaxMarkdownImageHeight is the maximum display height for markdown images. MaxMarkdownImageHeight = 320 // MarkdownPlaceholderHeight is the height of the image loading placeholder. MarkdownPlaceholderHeight = 72 // MarkdownPlaceholderBorderWidth is the border width of the image loading placeholder. MarkdownPlaceholderBorderWidth = 1 )
const TooltipHideDelay = 200 * time.Millisecond
TooltipHideDelay is the delay before hiding a tooltip after the mouse leaves the widget.
Variables ¶
var ErrMarkdownImageTooLarge = bytes.ErrTooLarge
ErrMarkdownImageTooLarge is returned when a markdown image exceeds size limits.
var LazyMarkdownLogger = slog.With("component", "ui.lazy_markdown")
LazyMarkdownLogger is the structured logger for lazy markdown operations.
var MarkdownImageHTTPClient = &http.Client{Timeout: MarkdownImageLoadTimeout}
MarkdownImageHTTPClient is the HTTP client used for downloading markdown images.
var MarkdownImagePattern = regexp.MustCompile(`!\[([^]]*)]\(([^)]+)\)`)
MarkdownImagePattern matches markdown image syntax to extract alt text and URLs.
Functions ¶
func AlignObject ¶
AlignObject aligns an object according to the specified text alignment and returns the container and content index.
func CloneRichTextSegment ¶
func CloneRichTextSegment(seg widget.RichTextSegment) widget.RichTextSegment
CloneRichTextSegment creates a deep copy of a single rich text segment.
func CloneRichTextSegments ¶
func CloneRichTextSegments(segs []widget.RichTextSegment) []widget.RichTextSegment
CloneRichTextSegments creates a deep copy of rich text segments.
func CountMarkdownImageSegments ¶
func CountMarkdownImageSegments(segments []widget.RichTextSegment) int
CountMarkdownImageSegments counts the number of image segments in rich text segments.
func ExtractMarkdownImageAltTexts ¶
ExtractMarkdownImageAltTexts extracts alt text for each image URL from markdown content.
func HideTooltipWidgets ¶
func HideTooltipWidgets(objects []fyne.CanvasObject)
HideTooltipWidgets hides all tooltip widgets within the given canvas objects.
func LoadMarkdownImageObject ¶
func LoadMarkdownImageObject(source fyne.URI) (fyne.CanvasObject, error)
LoadMarkdownImageObject loads an image from the source URI and returns it as a canvas object.
func LoadMarkdownImageResource ¶
LoadMarkdownImageResource loads image bytes from the source URI and returns them as a fyne resource.
func MarkdownImageDisplaySize ¶
MarkdownImageDisplaySize calculates the display size for a markdown image based on its content.
func MarkdownImageSource ¶
MarkdownImageSource returns the string representation of the image source URI.
func NewLazyMarkdownRichText ¶
NewLazyMarkdownRichText creates a RichText widget from markdown with lazy image loading.
func NewMarkdownImagePlaceholder ¶
func NewMarkdownImagePlaceholder(title, status string) fyne.CanvasObject
NewMarkdownImagePlaceholder creates a placeholder widget shown while markdown images are loading.
func NewTooltipBubble ¶
func NewTooltipBubble(content fyne.CanvasObject) *fyne.Container
NewTooltipBubble creates a tooltip bubble container with styled background for the given content.
func ReadLimitedBytes ¶
ReadLimitedBytes reads from a reader up to MaxMarkdownImageBytes to prevent excessive memory usage.
func ReadMarkdownImageBytes ¶
ReadMarkdownImageBytes reads image bytes from the source URI, supporting both local and remote sources.
func RemoteMarkdownImageTooLarge ¶
RemoteMarkdownImageTooLarge checks if a remote image exceeds size limits via HTTP HEAD request.
func RewriteMarkdownImageSegments ¶
func RewriteMarkdownImageSegments(segments []widget.RichTextSegment, altTexts map[string]string) []widget.RichTextSegment
RewriteMarkdownImageSegments replaces ImageSegment with LazyMarkdownImageSegment for lazy loading.
func RichTextSegmentsPlainText ¶
func RichTextSegmentsPlainText(segs []widget.RichTextSegment) string
RichTextSegmentsPlainText extracts plain text from rich text segments.
Types ¶
type HoverTooltipManager ¶
type HoverTooltipManager struct {
// contains filtered or unexported fields
}
HoverTooltipManager manages the display and positioning of hover tooltips.
func NewHoverTooltipManager ¶
func NewHoverTooltipManager(layer *fyne.Container) *HoverTooltipManager
NewHoverTooltipManager creates a new HoverTooltipManager with the specified overlay layer.
func (*HoverTooltipManager) Hide ¶
func (m *HoverTooltipManager) Hide(owner fyne.CanvasObject)
func (*HoverTooltipManager) Show ¶
func (m *HoverTooltipManager) Show(owner fyne.CanvasObject, content fyne.CanvasObject)
type IconNavButton ¶
type IconNavButton struct {
// contains filtered or unexported fields
}
IconNavButton is a navigation button with an icon and optional text label.
func NewIconNavButton ¶
func NewIconNavButton(icon fyne.Resource, onTap func()) *IconNavButton
func (*IconNavButton) CreateRenderer ¶
func (b *IconNavButton) CreateRenderer() fyne.WidgetRenderer
func (*IconNavButton) Icon ¶
func (b *IconNavButton) Icon() fyne.Resource
func (*IconNavButton) MinSize ¶
func (b *IconNavButton) MinSize() fyne.Size
func (*IconNavButton) MouseIn ¶
func (b *IconNavButton) MouseIn(_ *desktop.MouseEvent)
func (*IconNavButton) MouseMoved ¶
func (b *IconNavButton) MouseMoved(_ *desktop.MouseEvent)
func (*IconNavButton) MouseOut ¶
func (b *IconNavButton) MouseOut()
func (*IconNavButton) SetIcon ¶
func (b *IconNavButton) SetIcon(icon fyne.Resource)
func (*IconNavButton) SetSelected ¶
func (b *IconNavButton) SetSelected(selected bool)
func (*IconNavButton) SetText ¶
func (b *IconNavButton) SetText(text string)
func (*IconNavButton) Tapped ¶
func (b *IconNavButton) Tapped(_ *fyne.PointEvent)
func (*IconNavButton) TappedSecondary ¶
func (b *IconNavButton) TappedSecondary(_ *fyne.PointEvent)
func (*IconNavButton) Text ¶
func (b *IconNavButton) Text() string
type LazyMarkdownImageSegment ¶
LazyMarkdownImageSegment is a rich text segment that loads images asynchronously.
func (*LazyMarkdownImageSegment) Inline ¶
func (s *LazyMarkdownImageSegment) Inline() bool
func (*LazyMarkdownImageSegment) Select ¶
func (s *LazyMarkdownImageSegment) Select(_, _ fyne.Position)
func (*LazyMarkdownImageSegment) SelectedText ¶
func (s *LazyMarkdownImageSegment) SelectedText() string
func (*LazyMarkdownImageSegment) Textual ¶
func (s *LazyMarkdownImageSegment) Textual() string
func (*LazyMarkdownImageSegment) Unselect ¶
func (s *LazyMarkdownImageSegment) Unselect()
func (*LazyMarkdownImageSegment) Update ¶
func (s *LazyMarkdownImageSegment) Update(fyne.CanvasObject)
func (*LazyMarkdownImageSegment) Visual ¶
func (s *LazyMarkdownImageSegment) Visual() fyne.CanvasObject
type TooltipWidget ¶
type TooltipWidget struct {
widget.BaseWidget
// contains filtered or unexported fields
}
TooltipWidget is a widget that displays a tooltip on hover.
func NewTooltipLabel ¶
func NewTooltipLabel(text, tooltip string, manager *HoverTooltipManager) *TooltipWidget
NewTooltipLabel creates a new TooltipWidget with a label and tooltip text.
func NewTooltipRichText ¶
func NewTooltipRichText(segments []widget.RichTextSegment, tooltip []widget.RichTextSegment, manager *HoverTooltipManager) *TooltipWidget
NewTooltipRichText creates a new TooltipWidget with rich text content and tooltip segments.
func (*TooltipWidget) CreateRenderer ¶
func (w *TooltipWidget) CreateRenderer() fyne.WidgetRenderer
func (*TooltipWidget) MouseIn ¶
func (w *TooltipWidget) MouseIn(*desktop.MouseEvent)
func (*TooltipWidget) MouseMoved ¶
func (w *TooltipWidget) MouseMoved(*desktop.MouseEvent)
func (*TooltipWidget) MouseOut ¶
func (w *TooltipWidget) MouseOut()
func (*TooltipWidget) SetBadge ¶
func (w *TooltipWidget) SetBadge(text, tooltip string)
func (*TooltipWidget) SetBadgeWithContent ¶
func (w *TooltipWidget) SetBadgeWithContent(text string, tooltip fyne.CanvasObject)