类型 MarkdownSelection

API 文档由 Go 源码生成,内容为英文。

type MarkdownSelection struct {
	Anchor, Focus int
}

MarkdownSelection is a range of the rendered text of a MarkdownView, in byte offsets. Anchor is where the user began and Focus is where the pointer is now; either may be ahead of the other. Range clamps and orders them against the view's text, so a selection that was made before a message changed still copies the part that is there.

方法

Range#

func (s MarkdownSelection) Range(text []byte) (start, end int)

Range returns the selected bytes, ordered and clamped to text. Clamping snaps both ends back to the start of the rune they point into, because a selection kept while a streaming message shortened can land inside a multi-byte character; without the snap SelectedText would return invalid UTF-8.