CaretBounds#
func (v *MarkdownView) CaretBounds() (ui.Rect, bool)CaretBounds reports no caret: a MarkdownView paints text, not an input field.
API 文档由 Go 源码生成,内容为英文。
type MarkdownView struct {
// code lines with their tabs spread into blanks
// where each byte of a spread code line came from
// the rendered text, for selection and copying
// where each span of the current inline block starts in plain
// where the last Paint put the document
}MarkdownView lays out and paints a markdown.Document. It keeps the arrays it builds, so laying out the next version of a message that is still being typed allocates nothing once the view is warm. The zero value is ready; a view is used by one goroutine, and one view serves one document.
doc.Parse(message)
height := view.Layout(canvas, components.MarkdownStyle{Size: 13}, &doc, width)
...
view.Paint(canvas, components.MarkdownPaint{Look: components.MarkdownLookFor(theme), X: x, Y: y, Links: links})Layout measures text and is the expensive half: do it when the text or the width changed, and call Paint every frame. Proportional text has no italic face yet, so emphasis is drawn a weight heavier than the text around it.
CaretBounds#func (v *MarkdownView) CaretBounds() (ui.Rect, bool)CaretBounds reports no caret: a MarkdownView paints text, not an input field.
Codes#func (v *MarkdownView) Codes() []MarkdownCodeCodes lists the fenced code blocks, in reading order.
Height#func (v *MarkdownView) Height() float32Height is the height of the laid-out document.
Layout#func (v *MarkdownView) Layout(canvas *ui.Canvas, style MarkdownStyle, doc *markdown.Document, width float32) float32Layout positions the blocks of doc in a column width wide and returns its height. Positions are relative to the point the document is painted at.
Link#func (v *MarkdownView) Link(i int) stringLink returns the destination of link fragment i, as numbered by MarkdownPaint.Links (less Base), and "" for a number that is not one.
LinkCount#func (v *MarkdownView) LinkCount() intLinkCount is how many link fragments the document has: a link that wraps onto two lines is two fragments.
OffsetAt#func (v *MarkdownView) OffsetAt(point ui.Point) (offset int, ok bool)OffsetAt is the text offset nearest a window point, for a pointer that selects answer text. It uses the origin and measurements of the last Paint, so it is valid from that paint until the next Layout or Paint. Decoration such as list markers is skipped; a point in the margin snaps to the nearest character.
Paint#func (v *MarkdownView) Paint(canvas *ui.Canvas, p MarkdownPaint)Paint draws the laid-out document.
SelectedText#func (v *MarkdownView) SelectedText(sel MarkdownSelection) stringSelectedText returns the rendered text of sel: what a copy of the selection puts on the clipboard. Offsets are clamped to the laid-out text, so an empty view or a selection outside it returns "".
TextLen#func (v *MarkdownView) TextLen() intTextLen is the length in bytes of the rendered text that can be selected.