text

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: GPL-3.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WordToLeft

func WordToLeft(text []rune, position int) (length int)

WordToLeft returns how far away to the left the next word boundary is from a given position.

func WordToRight

func WordToRight(text []rune, position int) (length int)

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

func Backspace(text []rune, dot Dot, word bool) (result []rune, moved Dot)

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

func Delete(text []rune, dot Dot, word bool) (result []rune, moved Dot)

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 EmptyDot

func EmptyDot(position int) Dot

EmptyDot returns a zero-width dot at the specified position.

func Lift

func Lift(text []rune, dot Dot) (result []rune, moved Dot, lifted []rune)

Lift removes the section of text inside of the dot, and returns a copy of it.

func MoveLeft

func MoveLeft(text []rune, dot Dot, word bool) (moved Dot)

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

func MoveRight(text []rune, dot Dot, word bool) (moved Dot)

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

func SelectLeft(text []rune, dot Dot, word bool) (moved Dot)

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

func SelectRight(text []rune, dot Dot, word bool) (moved Dot)

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

func Type(text []rune, dot Dot, characters ...rune) (result []rune, moved Dot)

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

func WordAround(text []rune, position int) (around Dot)

WordAround returns a dot that surrounds the word at the specified position.

func (Dot) Add

func (dot Dot) Add(delta int) Dot

Add shifts the dot to the right by the specified amount.

func (Dot) Canon

func (dot Dot) Canon() Dot

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

func (dot Dot) Constrain(length int) Dot

Constrain constrains the dot's start and end from zero to length (inclusive).

func (Dot) Empty

func (dot Dot) Empty() bool

Empty returns whether or not the

func (Dot) Slice

func (dot Dot) Slice(text []rune) []rune

Slice returns the subset of text that the dot covers.

func (Dot) Sub

func (dot Dot) Sub(delta int) Dot

Sub shifts the dot to the left by the specified amount.

func (Dot) Width

func (dot Dot) Width() int

Width returns how many runes the dot spans.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL