textselect

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package textselect is what the Windows and Linux backends share of a selection across the texts of an area (driver.SelectionModel): the texts as the model reads them, hit-tested through their layouts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreaAt

func AreaAt[V any](under []V, taker func(V) Taker) (area V, ok bool)

AreaAt returns the selection area a press goes to among the views under it, innermost first, as Taker classifies them: the outermost area around the view hit, or the selectable text hit, unless a view inside keeps the press. ok is false when none takes it.

Types

type Selection

type Selection struct {
	Area     driver.NodeID
	Texts    []Text
	Model    driver.SelectionModel
	Dragging bool
	Told     driver.Bounds
	ToldText string
	// ToldRanges are the per-text ranges the area last reported: a
	// selection whose text and extent stay, such as the same words on
	// another text, still reports anew.
	ToldRanges []driver.SelectedRange
}

Selection is the selection of one area: the model over the area's texts, listed again before each use, and whether the pointer that started it is still down.

func (*Selection) Content

func (s *Selection) Content(i int) string

Content implements driver.SelectionTexts.

func (*Selection) Frame

func (s *Selection) Frame(i int) driver.Bounds

Frame implements driver.SelectionTexts.

func (*Selection) Key

func (s *Selection) Key(i int) uint64

Key implements driver.SelectionTexts.

func (*Selection) Len

func (s *Selection) Len() int

Len implements driver.SelectionTexts.

func (*Selection) OffsetAt

func (s *Selection) OffsetAt(i int, p driver.Point) int

OffsetAt implements driver.SelectionTexts.

func (*Selection) Ranges

func (s *Selection) Ranges() map[driver.NodeID]driver.SelectionRange

Ranges returns what each text, by its ID, has selected.

func (*Selection) Selected

func (s *Selection) Selected() []driver.SelectedRange

Selected returns what each text has selected, by its node, in document order: what EventSelectionChange's Ranges carries.

func (*Selection) Spans

func (s *Selection) Spans(i int) []driver.TextSpan

Spans implements driver.SelectionSpans.

func (*Selection) Tell

func (s *Selection) Tell(origin driver.Point, cleared bool) (driver.Event, bool)

Tell returns the event reporting the selection's text, per-text ranges and extent to its area, the extent at origin in the coordinates of its texts' boxes; false when none changed, as the extent stays while the selection moves within one text. A cleared selection reports none.

type Taker

type Taker uint8

Taker is what a view under a press is to a selection.

const (
	// Passes lets the press go on to the views around.
	Passes Taker = iota
	// Keeps takes the press itself: a field, a page, a pressable view or
	// one that follows pans.
	Keeps
	// Area is a selection area: a view with SelectionArea.
	Area
	// SelectableText is a text with SelectableOn outside any area.
	SelectableText
)

type Text

type Text struct {
	ID      driver.NodeID
	Content string
	Spans   []driver.TextSpan
	Box     driver.Bounds
	Layout  driver.TextHitTester
}

Text is one text of an area: its node, its content as ItemText gave it, its content box in the coordinates the selection is driven in, and its layout.

Jump to

Keyboard shortcuts

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