41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package atspi
|
|
|
|
import "unicode/utf8"
|
|
|
|
// DocumentCaretUnit selects the AT-SPI text granularity for virtual browsing.
|
|
type DocumentCaretUnit uint8
|
|
|
|
const (
|
|
DocumentCaretCharacter DocumentCaretUnit = iota + 1
|
|
DocumentCaretWord
|
|
DocumentCaretLine
|
|
DocumentCaretLineRemainder
|
|
// DocumentCaretBrailleLine preserves native spacing for display offsets.
|
|
DocumentCaretBrailleLine
|
|
)
|
|
|
|
func (unit DocumentCaretUnit) Valid() bool {
|
|
return unit >= DocumentCaretCharacter && unit <= DocumentCaretBrailleLine
|
|
}
|
|
|
|
type DocumentCaretText struct {
|
|
TextAttributeRuns []TextAttributeRun
|
|
Start int
|
|
End int
|
|
Text string
|
|
RawText string
|
|
Misspelled bool
|
|
CharacterCount int
|
|
SelectionStart, SelectionEnd int
|
|
// Bounds describe this native line, including offscreen document text.
|
|
Bounds Rectangle
|
|
}
|
|
|
|
func documentCaretCharacter(value string) string {
|
|
if value == "" {
|
|
return ""
|
|
}
|
|
character, _ := utf8.DecodeRuneInString(value)
|
|
return string(character)
|
|
}
|