Documentation ¶
Index ¶
- func WordToLeft(text []rune, position int) (length int)
- func WordToRight(text []rune, position int) (length int)
- type Dot
- func Backspace(text []rune, dot Dot, word bool) (result []rune, moved Dot)
- func Delete(text []rune, dot Dot, word bool) (result []rune, moved Dot)
- func EmptyDot(position int) Dot
- func Lift(text []rune, dot Dot) (result []rune, moved Dot, lifted []rune)
- func MoveLeft(text []rune, dot Dot, word bool) (moved Dot)
- func MoveRight(text []rune, dot Dot, word bool) (moved Dot)
- func SelectLeft(text []rune, dot Dot, word bool) (moved Dot)
- func SelectRight(text []rune, dot Dot, word bool) (moved Dot)
- func Type(text []rune, dot Dot, characters ...rune) (result []rune, moved Dot)
- func WordAround(text []rune, position int) (around Dot)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WordToLeft ¶
WordToLeft returns how far away to the left the next word boundary is from a given position.
func WordToRight ¶
WordToRight returns how far away to the right the next word boundary is from a given position.
Types ¶
type Dot ¶
type Dot struct{ Start, End int }
Dot represents a cursor or text selection. It has a start and end position, referring to where the user began and ended the selection respectively.
func Backspace ¶
Backspace deletes the rune to the left of the dot. If word is true, it deletes up until the next word boundary on the left. If the dot is non-empty, it deletes the text inside of the dot.
func Delete ¶
Delete deletes the rune to the right of the dot. If word is true, it deletes up until the next word boundary on the right. If the dot is non-empty, it deletes the text inside of the dot.
func MoveLeft ¶
MoveLeft moves the dot left one rune. If word is true, it moves the dot to the next word boundary on the left.
func MoveRight ¶
MoveRight moves the dot right one rune. If word is true, it moves the dot to the next word boundary on the right.
func SelectLeft ¶
SelectLeft moves the end of the dot left one rune. If word is true, it moves the end of the dot to the next word boundary on the left.
func SelectRight ¶
SelectRight moves the end of the dot right one rune. If word is true, it moves the end of the dot to the next word boundary on the right.
func Type ¶
Type inserts one of more runes into the text at the dot position. If the dot is non-empty, it replaces the text inside of the dot with the new runes.
func WordAround ¶
WordAround returns a dot that surrounds the word at the specified position.
func (Dot) Canon ¶
Canon places the lesser value at the start, and the greater value at the end. Note that a canonized dot does not in all cases correspond directly to the original, because there is a semantic value to the start and end positions.
func (Dot) Constrain ¶
Constrain constrains the dot's start and end from zero to length (inclusive).