traits

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 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 added in v0.41.0

func (self *ListCursor) AreMultipleItemsSelected() bool

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

func (*ListCursor) CancelRangeSelect added in v0.41.0

func (self *ListCursor) CancelRangeSelect()

func (*ListCursor) ClampSelection added in v0.41.0

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 added in v0.41.0

func (self *ListCursor) ExpandNonStickyRange(change int)

func (*ListCursor) GetRangeStartIdx added in v0.41.0

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

func (*ListCursor) GetSelectedLineIdx

func (self *ListCursor) GetSelectedLineIdx() int

func (*ListCursor) GetSelectionRange added in v0.41.0

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

func (*ListCursor) GetSelectionRangeAndMode added in v0.41.0

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

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

func (*ListCursor) IsSelectingRange added in v0.41.0

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 added in v0.41.0

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 added in v0.41.0

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 added in v0.41.0

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

func (*ListCursor) ToggleStickyRange added in v0.41.0

func (self *ListCursor) ToggleStickyRange()

type RangeSelectMode added in v0.41.0

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