selection

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package selection is the multi-select model behind the grid overview's batch actions: which files are picked, and the anchor a range extension measures from.

It is deliberately just integers. What an index means - a position in the app's file set, not a position in the grid - and which gesture calls which method are internal/ui/grid's business; this package draws nothing and imports no fyne at all, which is why it sits here beside internal/filesort rather than under internal/ui.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Range

func Range(a, b int) []int

Range is the inclusive span between a and b, always ascending however the two are ordered - a Shift+click can name a cell either side of the anchor.

Types

type Set

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

Set is a set of file indices plus the anchor a range extension measures from. The zero value is not usable - see New.

func New

func New() *Set

New builds an empty set.

func (*Set) Add

func (s *Set) Add(i int)

Add puts i in the set without moving the anchor - what a range extension walks with, since the anchor is the one end of that range that must not move. A no-op when i is already in.

func (*Set) Anchor

func (s *Set) Anchor() (int, bool)

Anchor is the index a range extension measures from, ok=false when no Toggle has happened since the last Clear.

func (*Set) Clear

func (s *Set) Clear()

Clear empties the set and drops the anchor with it: there is nothing left for a range to extend from.

func (*Set) Contains

func (s *Set) Contains(i int) bool

Contains reports whether i is in the set.

func (*Set) Indices

func (s *Set) Indices() []int

Indices is the set in ascending order, as a slice the caller owns: the batch actions hold their target list across a background trash move, so it must not alias state a later keystroke can mutate.

func (*Set) Len

func (s *Set) Len() int

Len is how many indices are in the set.

func (*Set) Replace

func (s *Set) Replace(is []int)

Replace swaps the membership for is, leaving the anchor alone - so a select-all followed by a Shift+click still extends from wherever the user last clicked.

func (*Set) Toggle

func (s *Set) Toggle(i int) bool

Toggle flips whether i is in the set, and makes i the anchor either way. Reports whether i is in the set afterwards.

Jump to

Keyboard shortcuts

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