widgets

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultButtonStlye         = tcell.StyleDefault.Foreground(tcell.ColorBlack).Background(tcell.ColorWhite)
	DefaultButtonActiveStyle   = tcell.StyleDefault.Foreground(tcell.ColorBlack).Background(tcell.ColorBlue).Underline(true)
	DefaultButtonDisabledStyle = tcell.StyleDefault.Foreground(tcell.ColorLightGray).Background(tcell.ColorDarkGray)
)

Functions

func DefaultStyleButton

func DefaultStyleButton(button *tview.Button)

Types

type FlexList

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

FlexList is a scrollable container for other primitives that behaves like a list, allowing selection and navigation of its child items.

func NewFlexList

func NewFlexList() *FlexList

NewFlexList creates a new FlexList.

func (*FlexList) AddItem

func (fl *FlexList) AddItem(item tview.Primitive, height int, proportion int, focus bool) *FlexList

AddItem adds a primitive to the list. Height is the fixed height of the item.

func (*FlexList) Clear

func (fl *FlexList) Clear()

Clear removes all items from the list.

func (*FlexList) Draw

func (fl *FlexList) Draw(screen tcell.Screen)

Draw implements tview.Primitive.

func (*FlexList) Focus

func (fl *FlexList) Focus(delegate func(p tview.Primitive))

Focus delegates focus to the currently selected child item.

func (*FlexList) GetCurrentItem

func (fl *FlexList) GetCurrentItem() int

GetCurrentItem returns the index of the currently selected item.

func (*FlexList) GetItemCount

func (fl *FlexList) GetItemCount() int

GetItemCount returns the number of items in the list.

func (*FlexList) HasFocus

func (fl *FlexList) HasFocus() bool

HasFocus returns whether this primitive has focus.

func (*FlexList) InputHandler

func (fl *FlexList) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles keyboard input for selection and scrolling.

func (*FlexList) SetChangedFunc

func (fl *FlexList) SetChangedFunc(handler func(index int)) *FlexList

SetChangedFunc sets a callback that is fired when the selection changes.

func (*FlexList) SetCurrentItem

func (fl *FlexList) SetCurrentItem(index int)

SetCurrentItem sets the currently selected item by its index.

func (*FlexList) SetSelectionColor

func (fl *FlexList) SetSelectionColor(color tcell.Color) *FlexList

SetSelectionColor sets the background color for the selected item.

type FocusWrapper

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

FocusWrapper is a lightweight struct that wraps a tview.Primitive to make it conform to our Focusable interface, using a delegate function to determine its focusable children.

func NewFocusWrapper

func NewFocusWrapper(p tview.Primitive, getFocusables func() []tview.Primitive) *FocusWrapper

NewFocusWrapper creates a new wrapper with a dynamic function to get focusable children.

func NewFocusWrapperWithStatic

func NewFocusWrapperWithStatic(p tview.Primitive, focusables ...tview.Primitive) *FocusWrapper

NewFocusWrapperWithStatic is a convenience constructor that takes a static slice of primitives.

func (*FocusWrapper) Blur

func (fw *FocusWrapper) Blur()

Blur is called when this primitive loses focus.

func (*FocusWrapper) Draw

func (fw *FocusWrapper) Draw(screen tcell.Screen)

Draw delegates the drawing to the wrapped primitive.

func (*FocusWrapper) Focus

func (fw *FocusWrapper) Focus(delegate func(p tview.Primitive))

Blur is called when this primitive loses focus.

func (*FocusWrapper) GetFocusablePrimitives

func (fw *FocusWrapper) GetFocusablePrimitives() []tview.Primitive

GetFocusablePrimitives implements the Focusable interface by calling the delegate function.

func (*FocusWrapper) GetRect

func (fw *FocusWrapper) GetRect() (int, int, int, int)

GetRect returns the rectangle of the wrapped primitive.

func (*FocusWrapper) HasFocus

func (fw *FocusWrapper) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*FocusWrapper) InputHandler

func (fw *FocusWrapper) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*FocusWrapper) MouseHandler

func (fw *FocusWrapper) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*FocusWrapper) SetRect

func (fw *FocusWrapper) SetRect(x, y, width, height int)

SetRect sets the rectangle of the wrapped primitive.

type HorizontalSeparator

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

HorizontalSeparator is a simple primitive that draws a horizontal line.

func NewHorizontalSeparator

func NewHorizontalSeparator(color tcell.Color) *HorizontalSeparator

NewHorizontalSeparator creates a new separator with a given color.

func (*HorizontalSeparator) Draw

func (s *HorizontalSeparator) Draw(screen tcell.Screen)

Draw draws the separator.

type OverviewWidget

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

OverviewWidget is a single-row visual representation of mod sets.

func NewOverviewWidget

func NewOverviewWidget(allMods []string) *OverviewWidget

NewOverviewWidget creates a new widget. allMods should be a sorted list.

func (*OverviewWidget) Draw

func (w *OverviewWidget) Draw(screen tcell.Screen)

Draw implements tview.Primitive.

func (*OverviewWidget) SetAllMods

func (w *OverviewWidget) SetAllMods(allMods []string)

SetAllMods sets or updates the universe of all mods for the widget.

func (*OverviewWidget) UpdateState

func (w *OverviewWidget) UpdateState(problemMods, clearedMods, candidateMods, effectiveMods sets.Set)

UpdateState provides the widget with the current sets to display.

type RichModal

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

RichModal is a centered message window that offers control over width and supports separately-aligned text sections using a Flex layout.

func NewRichModal

func NewRichModal() *RichModal

NewRichModal returns a new RichModal message window.

func (*RichModal) AddButtons

func (m *RichModal) AddButtons(labels []string) *RichModal

AddButtons adds buttons to the window.

func (*RichModal) ClearButtons

func (m *RichModal) ClearButtons() *RichModal

ClearButtons removes all buttons from the window.

func (*RichModal) Draw

func (m *RichModal) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*RichModal) Focus

func (m *RichModal) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*RichModal) HasFocus

func (m *RichModal) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*RichModal) InputHandler

func (m *RichModal) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler delegates input events to the flex layout.

func (*RichModal) MouseHandler

func (m *RichModal) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler delegates mouse events to the flex layout.

func (*RichModal) SetBackgroundColor

func (m *RichModal) SetBackgroundColor(color tcell.Color) *RichModal

SetBackgroundColor sets the background color of the modal and its contents.

func (*RichModal) SetButtonActivatedStyle

func (m *RichModal) SetButtonActivatedStyle(style tcell.Style) *RichModal

SetButtonActivatedStyle sets the style of the buttons when they are focused.

func (*RichModal) SetButtonBackgroundColor

func (m *RichModal) SetButtonBackgroundColor(color tcell.Color) *RichModal

SetButtonBackgroundColor sets the background color of the buttons.

func (*RichModal) SetButtonStyle

func (m *RichModal) SetButtonStyle(style tcell.Style) *RichModal

SetButtonStyle sets the style of the buttons when they are not focused.

func (*RichModal) SetButtonTextColor

func (m *RichModal) SetButtonTextColor(color tcell.Color) *RichModal

SetButtonTextColor sets the color of the button texts.

func (*RichModal) SetCenteredText

func (m *RichModal) SetCenteredText(text string) *RichModal

SetCenteredText sets the main, centered message text of the window.

func (*RichModal) SetDetailsText

func (m *RichModal) SetDetailsText(text string) *RichModal

SetDetailsText sets the optional, left-aligned details text of the window.

func (*RichModal) SetDetailsTextColor

func (m *RichModal) SetDetailsTextColor(color tcell.Color) *RichModal

SetDetailsTextColor sets the color of the left-aligned details text.

func (*RichModal) SetDoneFunc

func (m *RichModal) SetDoneFunc(handler func(buttonIndex int, buttonLabel string)) *RichModal

SetDoneFunc sets a handler which is called when one of the buttons was pressed.

func (*RichModal) SetFocus

func (m *RichModal) SetFocus(index int) *RichModal

SetFocus shifts the focus to the button with the given index.

func (*RichModal) SetMaxWidth

func (m *RichModal) SetMaxWidth(max int) *RichModal

SetMaxWidth sets the maximum width of the modal's content area.

func (*RichModal) SetMinWidth

func (m *RichModal) SetMinWidth(min int) *RichModal

SetMinWidth sets the minimum width of the modal's content area.

func (*RichModal) SetTextColor

func (m *RichModal) SetTextColor(color tcell.Color) *RichModal

SetTextColor sets the color of the main centered text.

type SearchableList

type SearchableList struct {
	*tview.Flex
	// contains filtered or unexported fields
}

SearchableList is a custom widget that combines an input field for searching with a list that displays filtered results. It implements Focusable.

func NewSearchableList

func NewSearchableList() *SearchableList

NewSearchableList creates a new SearchableList.

func (*SearchableList) Blur

func (s *SearchableList) Blur()

func (*SearchableList) Focus

func (s *SearchableList) Focus(delegate func(p tview.Primitive))

Focus delegates focus to the search field by default.

func (*SearchableList) GetFocusablePrimitives

func (s *SearchableList) GetFocusablePrimitives() []tview.Primitive

GetFocusablePrimitives implements the Focusable interface.

func (*SearchableList) SetItems

func (s *SearchableList) SetItems(items []string)

SetItems clears the list and sets new items.

type SearchableTable

type SearchableTable struct {
	*tview.Flex
	Table  *tview.Table
	Search *tview.InputField
	// contains filtered or unexported fields
}

SearchableTable combines a search input field with a tview.Table.

func NewSearchableTable

func NewSearchableTable(headers []string, searchColumns ...int) *SearchableTable

NewSearchableTable creates a new SearchableTable.

func (*SearchableTable) Blur

func (st *SearchableTable) Blur()

Blur is called when this primitive loses focus.

func (*SearchableTable) Clear

func (st *SearchableTable) Clear()

Clear implements a custom Clear method that targets the inner table, preventing the Flex layout from being destroyed.

func (*SearchableTable) Filter

func (st *SearchableTable) Filter(query string)

Filter re-populates the table based on the search query. Replace the Filter method to use pre-calculated widths

func (*SearchableTable) Focus

func (st *SearchableTable) Focus(delegate func(p tview.Primitive))

Focus delegates focus to the search field by default.

func (*SearchableTable) GetCell

func (st *SearchableTable) GetCell(row, column int) *tview.TableCell

GetCell returns the cell at the specified row and column.

func (*SearchableTable) GetFocusablePrimitives

func (st *SearchableTable) GetFocusablePrimitives() []tview.Primitive

GetFocusablePrimitives implements the Focusable interface.

func (*SearchableTable) GetRowCount

func (st *SearchableTable) GetRowCount() int

GetRowCount returns the number of rows in the table, including headers.

func (*SearchableTable) GetSelection

func (st *SearchableTable) GetSelection() (row, column int)

GetSelection returns the currently selected row and column.

func (*SearchableTable) Select

func (st *SearchableTable) Select(row, column int)

Select sets the currently selected cell by row and column.

func (*SearchableTable) SetData

func (st *SearchableTable) SetData(data [][]string)

Replace the SetData method

type TabBar

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

TabBar is a primitive that draws a bar of selectable tabs.

func NewTabBar

func NewTabBar() *TabBar

NewTabBar creates a new TabBar.

func (*TabBar) Draw

func (tb *TabBar) Draw(screen tcell.Screen)

Draw renders the tab bar.

func (*TabBar) InputHandler

func (tb *TabBar) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles keyboard navigation for the tab bar.

func (*TabBar) MouseHandler

func (tb *TabBar) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler handles mouse clicks on the tab bar.

func (*TabBar) SetTabs

func (tb *TabBar) SetTabs(tabs []string, activeTab int)

SetTabs updates the tab labels and active tab index.

type TabbedPanes

type TabbedPanes struct {
	*tview.Flex
	// contains filtered or unexported fields
}

TabbedPanes is a custom widget that provides a tabbed view.

func NewTabbedPanes

func NewTabbedPanes() *TabbedPanes

NewTabbedPanes creates a new TabbedPanes widget.

func (*TabbedPanes) AddTab

func (t *TabbedPanes) AddTab(label string, content tview.Primitive)

AddTab adds a new tab with a given label and content primitive.

func (*TabbedPanes) Focus

func (t *TabbedPanes) Focus(delegate func(p tview.Primitive))

func (*TabbedPanes) GetActiveContent

func (t *TabbedPanes) GetActiveContent() tview.Primitive

GetActiveContent returns the primitive of the currently active tab.

func (*TabbedPanes) GetActiveTab

func (t *TabbedPanes) GetActiveTab() int

GetActiveTab returns the index of the currently active tab.

func (*TabbedPanes) GetFocusablePrimitives

func (t *TabbedPanes) GetFocusablePrimitives() []tview.Primitive

GetFocusablePrimitives implements the Focusable interface.

func (*TabbedPanes) SelectNext

func (t *TabbedPanes) SelectNext()

SelectNext selects the next tab in the sequence.

func (*TabbedPanes) SelectPrevious

func (t *TabbedPanes) SelectPrevious()

SelectPrevious selects the previous tab in the sequence.

func (*TabbedPanes) SetActiveTab

func (t *TabbedPanes) SetActiveTab(index int)

SetActiveTab sets the currently active tab by its index.

func (*TabbedPanes) SetOnTabChange

func (t *TabbedPanes) SetOnTabChange(handler func(index int, label string))

SetOnTabChange sets a callback function to be executed when the active tab changes.

type TitleFrame

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

TitleFrame is a primitive that wraps another primitive, adding a horizontal rule at the top with an optional title.

func NewTitleFrame

func NewTitleFrame(content tview.Primitive, title string) *TitleFrame

NewTitleFrame creates a new TitleFrame.

func (*TitleFrame) Draw

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

Draw draws the TitleFrame.

func (*TitleFrame) Focus

func (f *TitleFrame) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*TitleFrame) HasFocus

func (f *TitleFrame) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*TitleFrame) InputHandler

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

InputHandler returns the handler for this primitive.

func (*TitleFrame) MouseHandler

func (f *TitleFrame) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*TitleFrame) PasteHandler

func (f *TitleFrame) PasteHandler() func(pastedText string, setFocus func(p tview.Primitive))

PasteHandler returns the handler for this primitive.

func (*TitleFrame) SetTitle

func (f *TitleFrame) SetTitle(title string)

Focus is called when this primitive receives focus.

type VerticalSeparator

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

VerticalSeparator is a simple primitive that draws a vertical line.

func NewVerticalSeparator

func NewVerticalSeparator(color tcell.Color) *VerticalSeparator

NewVerticalSeparator creates a new separator with a given color.

func (*VerticalSeparator) Draw

func (s *VerticalSeparator) Draw(screen tcell.Screen)

Draw draws the separator.

Jump to

Keyboard shortcuts

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