selection

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeNone = Mode(iota)
	ModeChar
	ModeLine
)

Variables

View Source
var EmptyRegion = Region{}

Functions

This section is empty.

Types

type Mode

type Mode int

Mode controls the selection behavior (charwise or linewise).

type Region

type Region struct {
	StartPos uint64 // Inclusive
	EndPos   uint64 // Exclusive
}

Region represents a selection within a document. The zero value represents an empty selection.

func (Region) Clip

func (r Region) Clip(n uint64) Region

Clip ensures that the region is within a document of length n.

func (Region) ContainsPosition

func (r Region) ContainsPosition(pos uint64) bool

ContainsPosition returns whether the position is within the region.

type Selector

type Selector struct {
	// contains filtered or unexported fields
}

Selector tracks the selected region of the document.

func (*Selector) Clear

func (s *Selector) Clear()

Clear clears the currently selected region, if any.

func (*Selector) Mode

func (s *Selector) Mode() Mode

Mode returns the current selection mode.

func (*Selector) Region

func (s *Selector) Region(tree *text.Tree, cursorPos uint64) Region

Region returns the currently selected region. If nothing is currently selected, the returned region will be empty.

func (*Selector) SetMode

func (s *Selector) SetMode(mode Mode)

SetMode sets the selection mode.

func (*Selector) Start

func (s *Selector) Start(mode Mode, cursorPos uint64)

Start begins a new selection from the current cursor position.

Jump to

Keyboard shortcuts

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