Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface {
URL2Reader(url string) (io.ReadCloser, error)
}
Config configures HTML rendering.
type ConfigLogger ¶
ConfigLogger may be optionally implemented by a Config instance. It provides a mechanism to report back errors etc.
type ConfigNavigator ¶
type ConfigNavigator interface {
}ConfigNavigator may be optionally implemented by a Config instance. It provides a mechanism to handle link clicks.
type ConfigQuirks ¶
ConfigQuirks may be optionally implemented by a Config instance. It provides a mechanism to enforce quirks mode or non-quirks mode. Returning other than the suggested mode may have unpredictable results.
type ConfigUserAgentStyleSheet ¶
ConfigUserAgentStyleSheet may be optionally implemented by a Config instance. It provides a mechanism to use other than the default user agent style sheet. Setting a non-standard user agent style sheet may have unpredictable results.
type DisplayList ¶
type DisplayList struct { ID int // contains filtered or unexported fields }
DisplayList collects items to display in a HTML widget. The ID field reflects the value returned from [SetWindowLocation].
func (*DisplayList) Draw ¶
func (dl *DisplayList) Draw(budget time.Duration) (completed bool)
Draw draws 'l' until complete or until 'budget' is exhausted.
This function allows to incrementally update a HTML widget while keeping the GUI responsive.
As any other GUI updates, this method can be executed only on the GUI thread. Example code running draw on the GUI thread:
v := html.NewPreview(nil, cfg) ch := make(chan *html.DisplayList, 20) var dl *html.DisplayList tk.NewTicker(100*time.Millisecond, func() { if dl == nil { out: for { select { case dl = <-ch: // Drain. default: break out } } } if dl != nil && dl.Draw(80*time.Millisecond) { dl = nil } }) v.SetWindowLocation("index.html", ch)
The above code demonstrates only a basic approach. It does not handle, for instance, the situation when a a particular display list is not yet fully drawn but a newer one becomes available, making drawing the rest of the previous list a waste of time.
type Preview ¶
type Preview struct { *TextWidget // contains filtered or unexported fields }
Preview provides a TextWidget based, preview quality rendering of simple HTML documents.
Only a limited subset of HTML/CSS is recognized and only the flow layout is supported, approximately. Everything else is ignored.
The intended use is for presenting small and simple markdown-only documents rendered to HTML by the gomarkdown package. There are no plans at the moment to extend the capabilities of Preview beyond that — the text widget is not compatible with most modern HTML/CSS features.
func NewPreview ¶
NewPreview returns a new Preview.
func (*Preview) SeeID ¶
SeeID attempts to make HTML node 'id' visible and returns true if the node was found.
func (*Preview) SetWindowLocation ¶
func (p *Preview) SetWindowLocation(href string, listChan chan *DisplayList, seeTop bool) (id int, err error)
SetWindowLocation computes the display list for 'href'. It does so in a separate non-GUI goroutine. If the 'listChan' is non-nil, the result will be sent to the channel.
If the channel is nil, SetWindowLocation becomes blocking and does not return until the display list is fully shown in the widget.
It is recommended to pass a non-nil 'listChan' to keep the GUI interactive.