finder

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finder

type Finder struct {
	*tview.Box
	// contains filtered or unexported fields
}

func NewFinder

func NewFinder() *Finder

NewFinder returns a new finder.

func (*Finder) Draw

func (f *Finder) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*Finder) GetCurrentItem

func (f *Finder) GetCurrentItem() int

GetCurrentItem returns the index of the currently selected finder item, starting at 0 for the first item. Returns -1 if no item is selected (this only occurs when the list is empty).

func (*Finder) InputHandler

func (f *Finder) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*Finder) SetChangedFunc

func (f *Finder) SetChangedFunc(handler func(index int)) *Finder

SetChangedFunc sets the function which is called when the user navigates to an item. The function receives the item's index in the list of items (starting with 0, -1 when no item is selected).

func (*Finder) SetCounterStyle

func (f *Finder) SetCounterStyle(style tcell.Style) *Finder

SetCounterStyle sets the style of the counter.

func (*Finder) SetCurrentItem

func (f *Finder) SetCurrentItem(index int) *Finder

SetCurrentItem sets the currently selected item by its index, starting at 0 for the first item. If a negative index is provided, items are referred to from the back (-1 = last item, -2 = second-to-last item, and so on). Out of range indices are clamped to the beginning/end.

Calling this function triggers a "changed" event if the selection changes.

func (*Finder) SetDoneFunc

func (f *Finder) SetDoneFunc(handler func(index int)) *Finder

SetDoneFunc sets a handler which is called when the user is done entering text. The callback function is provided with the index of the most recently selected item. The index is -1 when no item was selected.

func (*Finder) SetFieldStyle

func (f *Finder) SetFieldStyle(style tcell.Style) *Finder

SetFieldStyle sets the style of the input area (when no placeholder is shown).

func (*Finder) SetHighlightFullLine

func (f *Finder) SetHighlightFullLine(highlight bool) *Finder

SetHighlightFullLine sets a flag which determines whether the colored background of selected items spans the entire width of the view. If set to true, the highlight spans the entire view. If set to false, only the text of the selected item from beginning to end is highlighted.

func (*Finder) SetHighlightMatchMaintainBackgroundColor

func (f *Finder) SetHighlightMatchMaintainBackgroundColor(maintainBackgroundColor bool) *Finder

SetHighlightMatchMaintainBackgroundColor defines whether the background color of highlightMatchStyle will be applied. If set to true, the background color of itemStyle or selectedItemStyle will be maintained. If false, the background color of highlightMatchStyle will be applied.

func (*Finder) SetHighlightMatchStyle

func (f *Finder) SetHighlightMatchStyle(style tcell.Style) *Finder

SetHighlightMatchStyle sets the style used to highlight matches between items and the filter text.

func (*Finder) SetInputLabel

func (f *Finder) SetInputLabel(inputLabel string) *Finder

SetInputLabel sets the text to be displayed before the input area.

func (*Finder) SetInputLabelStyle

func (f *Finder) SetInputLabelStyle(style tcell.Style) *Finder

SetInputLabelStyle sets the style of the input label.

func (*Finder) SetInputPadding

func (f *Finder) SetInputPadding(padding int) *Finder

SetInputPadding sets the right padding of the inputLabel (space between label and input field).

func (*Finder) SetItemLabel

func (f *Finder) SetItemLabel(label string) *Finder

SetItemLabel sets the text to be displayed before an item which is not selected.

func (*Finder) SetItemLabelPadding

func (f *Finder) SetItemLabelPadding(itemLabelPadding int) *Finder

SetItemLabelPadding sets the right padding of the itemLabel (space between label and item text).

func (*Finder) SetItemLabelStyle

func (f *Finder) SetItemLabelStyle(style tcell.Style) *Finder

SetItemLabelStyle sets the style of the label to be displayed before a (not selected) item.

func (*Finder) SetItemStyle

func (f *Finder) SetItemStyle(style tcell.Style) *Finder

SetItemStyle sets the style of a list item when not selected.

func (*Finder) SetItems

func (f *Finder) SetItems(itemCount int, provider ItemNameProviderFunction) *Finder

SetItems sets the available number of items and a function to provide a name of a specific item by index.

func (*Finder) SetMatcherFunc

func (f *Finder) SetMatcherFunc(matcher MatcherFunction) *Finder

SetMatcherFunc sets the function which is called in order to match the filter string with all available items.

func (*Finder) SetPlaceholder

func (f *Finder) SetPlaceholder(placeholder string) *Finder

SetPlaceholder sets the text to be displayed when the input text is empty.

func (*Finder) SetPlaceholderStyle

func (f *Finder) SetPlaceholderStyle(style tcell.Style) *Finder

SetPlaceholderStyle sets the style of the input area (when a placeholder is shown).

func (*Finder) SetSelectedFocusOnly

func (f *Finder) SetSelectedFocusOnly(focusOnly bool) *Finder

SetSelectedFocusOnly sets a flag which determines when the currently selected finder item is highlighted. If set to true, selected items are only highlighted when the finder has focus. If set to false, they are always highlighted.

func (*Finder) SetSelectedItemLabel

func (f *Finder) SetSelectedItemLabel(label string) *Finder

SetSelectedItemLabel sets the text to be displayed before the currently selected item.

func (*Finder) SetSelectedItemLabelPadding

func (f *Finder) SetSelectedItemLabelPadding(padding int) *Finder

SetSelectedItemLabelPadding sets the right padding of the selectedItemLabel (space between label and item text).

func (*Finder) SetSelectedItemLabelStyle

func (f *Finder) SetSelectedItemLabelStyle(style tcell.Style) *Finder

SetSelectedItemLabelStyle sets the style of the label to be displayed before a selected item.

func (*Finder) SetSelectedItemStyle

func (f *Finder) SetSelectedItemStyle(style tcell.Style) *Finder

SetSelectedItemStyle sets the style of a list item when selected.

func (*Finder) SetWrapAround

func (f *Finder) SetWrapAround(wrapAround bool) *Finder

SetWrapAround sets the flag that determines whether navigating the finder list will wrap around. That is, navigating downwards on the last item will move the selection to the first item (similarly in the other direction). If set to false, the selection won't change when navigating downwards on the last item or navigating upwards on the first item.

type ItemNameProviderFunction

type ItemNameProviderFunction func(index int) string

ItemNameProviderFunction is called in order to retrieve the name of the item at the passed index. The string value returned from this function will be displayed in the finder list.

type MatcherFunction

type MatcherFunction func(item string, filter string) ([][2]int, int, bool)

MatcherFunction is called in order to check if parts of an item cam be matched to the passed filter string. It returns a slice of all successive matches, the sore to sort items according to their similarity and a boolean value indicating if there was a match at all. [2]int represents the start position (inclusive) and end position (exclusive) within the item string.

Jump to

Keyboard shortcuts

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