traits

package
v0.0.0-...-00ab8b8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListCursor

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

func NewListCursor

func NewListCursor(getLength func() int) *ListCursor

func (*ListCursor) AreMultipleItemsSelected

func (self *ListCursor) AreMultipleItemsSelected() bool

Returns true if we are in range select mode and selecting multiple items

func (*ListCursor) CancelRangeSelect

func (self *ListCursor) CancelRangeSelect()

func (*ListCursor) ClampSelection

func (self *ListCursor) ClampSelection()

To be called when the model might have shrunk so that our selection is not out of bounds

func (*ListCursor) ExpandNonStickyRange

func (self *ListCursor) ExpandNonStickyRange(change int)

func (*ListCursor) GetRangeStartIdx

func (self *ListCursor) GetRangeStartIdx() (int, bool)

func (*ListCursor) GetSelectedLineIdx

func (self *ListCursor) GetSelectedLineIdx() int

func (*ListCursor) GetSelectionRange

func (self *ListCursor) GetSelectionRange() (int, int)

func (*ListCursor) GetSelectionRangeAndMode

func (self *ListCursor) GetSelectionRangeAndMode() (int, int, RangeSelectMode)

Returns the selectedIdx, the rangeStartIdx, and the mode of the current selection.

func (*ListCursor) IsSelectingRange

func (self *ListCursor) IsSelectingRange() bool

Returns true if we are in range select mode. Note that we may be in range select mode and still only selecting a single item. See AreMultipleItemsSelected below.

func (*ListCursor) Len

func (self *ListCursor) Len() int

func (*ListCursor) MoveSelectedLine

func (self *ListCursor) MoveSelectedLine(change int)

Moves the cursor up or down by the given amount. If we are in non-sticky range select mode, this will cancel the range select

func (*ListCursor) MoveSelection

func (self *ListCursor) MoveSelection(delta int)

Moves the cursor up or down by the given amount, and also moves the range start index by the same amount

func (*ListCursor) SetSelectedLineIdx

func (self *ListCursor) SetSelectedLineIdx(value int)

Sets the selected line index. Note, you probably don't want to use this directly, because it doesn't affect the range select mode or range start index. You should only use this for navigation situations where e.g. the user wants to jump to the top of a list while in range select mode so that the selection ends up being between the top of the list and the previous selection

func (*ListCursor) SetSelection

func (self *ListCursor) SetSelection(value int)

Sets the selected index and cancels the range. You almost always want to use this instead of SetSelectedLineIdx. For example, if you want to jump the cursor to the top of a list after checking out a branch, you should use this method, or you may end up with a large range selection from the previous cursor position to the top of the list.

func (*ListCursor) SetSelectionRangeAndMode

func (self *ListCursor) SetSelectionRangeAndMode(selectedIdx, rangeStartIdx int, mode RangeSelectMode)

func (*ListCursor) ToggleStickyRange

func (self *ListCursor) ToggleStickyRange()

type RangeSelectMode

type RangeSelectMode int
const (
	// None means we are not selecting a range
	RangeSelectModeNone RangeSelectMode = iota
	// Sticky range select is started by pressing 'v', then the range is expanded
	// when you move up or down. It is cancelled by pressing 'v' again.
	RangeSelectModeSticky
	// Nonsticky range select is started by pressing shift+arrow and cancelled
	// when pressing up/down without shift, or by pressing 'v'
	RangeSelectModeNonSticky
)

Jump to

Keyboard shortcuts

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