Documentation ¶
Index ¶
- type ContextState
- func (self *ContextState[T]) GetCurrentContextKey(item T) string
- func (self *ContextState[T]) GetCurrentMainTab() MainTab[T]
- func (self *ContextState[T]) GetMainTabTitles() []string
- func (self *ContextState[T]) HandleNextMainTab()
- func (self *ContextState[T]) HandlePrevMainTab()
- func (self *ContextState[T]) SetMainTabIndex(index int)
- type FilteredList
- func (self *FilteredList[T]) Filter(filter func(T, int) bool)
- func (self *FilteredList[T]) Get(index int) T
- func (self *FilteredList[T]) GetAllItems() []T
- func (self *FilteredList[T]) GetIndex(item T) int
- func (self *FilteredList[T]) GetItems() []T
- func (self *FilteredList[T]) Len() int
- func (self *FilteredList[T]) SetItems(items []T)
- func (self *FilteredList[T]) Sort(less func(T, T) bool)
- func (self *FilteredList[T]) TryGet(index int) (T, bool)
- type IGui
- type ISideListPanel
- type ListPanel
- type MainTab
- type SideListPanel
- func (self *SideListPanel[T]) FilterAndSort()
- func (self *SideListPanel[T]) GetSelectedItem() (T, error)
- func (self *SideListPanel[T]) GetView() *gocui.View
- func (self *SideListPanel[T]) HandleClick() error
- func (self *SideListPanel[T]) HandleNextLine() error
- func (self *SideListPanel[T]) HandleNextMainTab() error
- func (self *SideListPanel[T]) HandlePrevLine() error
- func (self *SideListPanel[T]) HandlePrevMainTab() error
- func (self *SideListPanel[T]) HandleSelect() error
- func (self *SideListPanel[T]) IsFilterDisabled() bool
- func (self *SideListPanel[T]) IsHidden() bool
- func (self *SideListPanel[T]) Refocus()
- func (self *SideListPanel[T]) RerenderList() error
- func (self *SideListPanel[T]) SetItems(items []T)
- func (self *SideListPanel[T]) SetMainTabIndex(index int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextState ¶
type ContextState[T any] struct { // this function returns the tabs that we can display for an item (the tabs // are shown on the main view) GetMainTabs func() []MainTab[T] // This tells us whether we need to re-render to the main panel for a given item. // This should include the item's ID and if you want to invalidate the cache for // some other reason, you can add that to the key as well (e.g. the container's state). GetItemContextCacheKey func(item T) string // contains filtered or unexported fields }
A 'context' generally corresponds to an item and the tab in the main panel that we're displaying. So if we switch to a new item, or change the tab in the panel panel for the current item, we end up with a new context. When we have a new context, we render new content to the main panel.
func (*ContextState[T]) GetCurrentContextKey ¶
func (self *ContextState[T]) GetCurrentContextKey(item T) string
func (*ContextState[T]) GetCurrentMainTab ¶
func (self *ContextState[T]) GetCurrentMainTab() MainTab[T]
func (*ContextState[T]) GetMainTabTitles ¶
func (self *ContextState[T]) GetMainTabTitles() []string
func (*ContextState[T]) HandleNextMainTab ¶
func (self *ContextState[T]) HandleNextMainTab()
func (*ContextState[T]) HandlePrevMainTab ¶
func (self *ContextState[T]) HandlePrevMainTab()
func (*ContextState[T]) SetMainTabIndex ¶
func (self *ContextState[T]) SetMainTabIndex(index int)
type FilteredList ¶
type FilteredList[T comparable] struct { // contains filtered or unexported fields }
func NewFilteredList ¶
func NewFilteredList[T comparable]() *FilteredList[T]
func (*FilteredList[T]) Filter ¶
func (self *FilteredList[T]) Filter(filter func(T, int) bool)
func (*FilteredList[T]) Get ¶
func (self *FilteredList[T]) Get(index int) T
func (*FilteredList[T]) GetAllItems ¶
func (self *FilteredList[T]) GetAllItems() []T
func (*FilteredList[T]) GetIndex ¶
func (self *FilteredList[T]) GetIndex(item T) int
func (*FilteredList[T]) GetItems ¶
func (self *FilteredList[T]) GetItems() []T
func (*FilteredList[T]) Len ¶
func (self *FilteredList[T]) Len() int
returns the length of the filtered list
func (*FilteredList[T]) SetItems ¶
func (self *FilteredList[T]) SetItems(items []T)
func (*FilteredList[T]) Sort ¶
func (self *FilteredList[T]) Sort(less func(T, T) bool)
func (*FilteredList[T]) TryGet ¶
func (self *FilteredList[T]) TryGet(index int) (T, bool)
type IGui ¶
type IGui interface { HandleClick(v *gocui.View, itemCount int, selectedLine *int, handleSelect func() error) error NewSimpleRenderStringTask(getContent func() string) tasks.TaskFunc FocusY(selectedLine int, itemCount int, view *gocui.View) ShouldRefresh(contextKey string) bool GetMainView() *gocui.View IsCurrentView(*gocui.View) bool FilterString(view *gocui.View) string IgnoreStrings() []string Update(func() error) QueueTask(f func(ctx context.Context)) error }
type ISideListPanel ¶
type ListPanel ¶
type ListPanel[T comparable] struct { SelectedIdx int List *FilteredList[T] View *gocui.View }
func (*ListPanel[T]) SelectNextLine ¶
func (self *ListPanel[T]) SelectNextLine()
func (*ListPanel[T]) SelectPrevLine ¶
func (self *ListPanel[T]) SelectPrevLine()
func (*ListPanel[T]) SetSelectedLineIdx ¶
type SideListPanel ¶
type SideListPanel[T comparable] struct { ContextState *ContextState[T] ListPanel[T] // message to render in the main view if there are no items in the panel // and it has focus. Leave empty if you don't want to render anything NoItemsMessage string // a representation of the gui Gui IGui // this Filter is applied on top of additional default filters Filter func(T) bool Sort func(a, b T) bool // a callback to invoke when the item is clicked OnClick func(T) error // returns the cells that we render to the view in a table format. The cells will // be rendered with padding. GetTableCells func(T) []string // function to be called after re-rendering list. Can be nil OnRerender func() error // set this to true if you don't want to allow manual filtering via '/' DisableFilter bool // This can be nil if you want to always show the panel Hide func() bool }
list panel at the side of the screen that renders content to the main panel
func (*SideListPanel[T]) FilterAndSort ¶
func (self *SideListPanel[T]) FilterAndSort()
func (*SideListPanel[T]) GetSelectedItem ¶
func (self *SideListPanel[T]) GetSelectedItem() (T, error)
func (*SideListPanel[T]) GetView ¶
func (self *SideListPanel[T]) GetView() *gocui.View
func (*SideListPanel[T]) HandleClick ¶
func (self *SideListPanel[T]) HandleClick() error
func (*SideListPanel[T]) HandleNextLine ¶
func (self *SideListPanel[T]) HandleNextLine() error
func (*SideListPanel[T]) HandleNextMainTab ¶
func (self *SideListPanel[T]) HandleNextMainTab() error
func (*SideListPanel[T]) HandlePrevLine ¶
func (self *SideListPanel[T]) HandlePrevLine() error
func (*SideListPanel[T]) HandlePrevMainTab ¶
func (self *SideListPanel[T]) HandlePrevMainTab() error
func (*SideListPanel[T]) HandleSelect ¶
func (self *SideListPanel[T]) HandleSelect() error
func (*SideListPanel[T]) IsFilterDisabled ¶
func (self *SideListPanel[T]) IsFilterDisabled() bool
func (*SideListPanel[T]) IsHidden ¶
func (self *SideListPanel[T]) IsHidden() bool
func (*SideListPanel[T]) Refocus ¶
func (self *SideListPanel[T]) Refocus()
func (*SideListPanel[T]) RerenderList ¶
func (self *SideListPanel[T]) RerenderList() error
func (*SideListPanel[T]) SetItems ¶
func (self *SideListPanel[T]) SetItems(items []T)
func (*SideListPanel[T]) SetMainTabIndex ¶
func (self *SideListPanel[T]) SetMainTabIndex(index int)
Click to show internal directories.
Click to hide internal directories.