components

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeEditor

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

CodeEditor provides a multi-input form for creating/editing code snippets.

func NewCodeEditor

func NewCodeEditor(width, height int) CodeEditor

NewCodeEditor creates a new code editor form.

func (CodeEditor) GetCategory

func (ce CodeEditor) GetCategory() int

GetCategory returns the category ID.

func (CodeEditor) GetFocusedField

func (ce CodeEditor) GetFocusedField() int

GetFocusedField returns the currently focused field index.

func (CodeEditor) GetTags

func (ce CodeEditor) GetTags() []int

GetTags returns the tag IDs.

func (CodeEditor) GetValues

func (ce CodeEditor) GetValues() (title, language, description, code string)

GetValues returns all field values.

func (CodeEditor) IsCancelFocused

func (ce CodeEditor) IsCancelFocused() bool

IsCancelFocused returns true if Cancel button is focused.

func (CodeEditor) IsOnTextInput

func (ce CodeEditor) IsOnTextInput() bool

IsOnTextInput returns true if focus is on a text input field (not buttons).

func (CodeEditor) IsSaveFocused

func (ce CodeEditor) IsSaveFocused() bool

IsSaveFocused returns true if Save button is focused.

func (*CodeEditor) NextField

func (ce *CodeEditor) NextField() tea.Cmd

NextField moves focus to the next input field.

func (*CodeEditor) PrevField

func (ce *CodeEditor) PrevField() tea.Cmd

PrevField moves focus to the previous input field.

func (*CodeEditor) SetCategory

func (ce *CodeEditor) SetCategory(id int, name string)

SetCategory sets the category for the snippet.

func (*CodeEditor) SetTags

func (ce *CodeEditor) SetTags(ids []int, names []string)

SetTags sets the tags for the snippet.

func (*CodeEditor) SetValues

func (ce *CodeEditor) SetValues(title, language, description, code string)

SetValues populates the editor with existing snippet data.

func (*CodeEditor) Update

func (ce *CodeEditor) Update(msg tea.Msg) (CodeEditor, tea.Cmd)

Update handles input for the code editor.

func (CodeEditor) View

func (ce CodeEditor) View() string

View renders the code editor.

type CodeViewer

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

CodeViewer displays a snippet's code with syntax highlighting and line numbers.

func NewCodeViewer

func NewCodeViewer(title, language, description, code string, width int) CodeViewer

NewCodeViewer creates a new code viewer.

func (CodeViewer) View

func (cv CodeViewer) View() string

View renders the code viewer.

type ConfirmDialog

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

func NewConfirmDialog

func NewConfirmDialog(title, message, warning string) ConfirmDialog

func (ConfirmDialog) IsYes

func (c ConfirmDialog) IsYes() bool

func (*ConfirmDialog) SelectNo

func (c *ConfirmDialog) SelectNo()

func (*ConfirmDialog) SelectYes

func (c *ConfirmDialog) SelectYes()

func (ConfirmDialog) View

func (c ConfirmDialog) View() string

type FocusChangedMsg

type FocusChangedMsg struct {
	FocusedField int
	FieldLine    int // Approximate line number of the field
}

FocusChangedMsg is sent when focus changes to request viewport scroll.

type FormView

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

func NewFormView

func NewFormView(title, subtitle, placeholder string) FormView

func (FormView) Focus

func (f FormView) Focus() tea.Cmd

func (*FormView) SetValue

func (f *FormView) SetValue(value string)

func (*FormView) Update

func (f *FormView) Update(msg tea.Msg) (FormView, tea.Cmd)

func (FormView) Value

func (f FormView) Value() string

func (FormView) View

func (f FormView) View() string

type HelpItem

type HelpItem struct {
	Action string
	Key    string
}

type HelpSection

type HelpSection struct {
	Title string
	Items []HelpItem
}

type HelpView

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

func NewHelpView

func NewHelpView(title string, sections []HelpSection) HelpView

func (HelpView) View

func (h HelpView) View() string
type MenuItem struct {
	Label    string
	Shortcut string
	Action   func() tea.Cmd
}
type MenuView struct {
	// contains filtered or unexported fields
}

func NewMenuView

func NewMenuView(title, subtitle string, items []MenuItem) MenuView
func (m MenuView) GetSelection() int
func (m MenuView) IsCancel() bool
func (m *MenuView) MoveDown()
func (m *MenuView) MoveUp()
func (m MenuView) View() string

type SearchableTableView

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

SearchableTableView is a table component with integrated search functionality. It provides real-time filtering as the user types.

func NewSearchableTableView

func NewSearchableTableView(columns []table.Column, title, emptyMsg, actionHint string, height int) SearchableTableView

NewSearchableTableView creates a new searchable table view.

func (SearchableTableView) GetSearchQuery

func (stv SearchableTableView) GetSearchQuery() string

GetSearchQuery returns the current search query.

func (SearchableTableView) IsSearchActive

func (stv SearchableTableView) IsSearchActive() bool

IsSearchActive returns whether search mode is active.

func (SearchableTableView) SelectedRow

func (stv SearchableTableView) SelectedRow() table.Row

SelectedRow returns the currently selected row.

func (*SearchableTableView) SetRows

func (stv *SearchableTableView) SetRows(rows []table.Row)

SetRows sets all rows and resets search filter.

func (*SearchableTableView) ToggleSearch

func (stv *SearchableTableView) ToggleSearch()

ToggleSearch enables/disables search mode.

func (*SearchableTableView) Update

func (stv *SearchableTableView) Update(msg tea.Msg) (SearchableTableView, tea.Cmd)

Update handles messages and updates state.

func (SearchableTableView) View

func (stv SearchableTableView) View() string

View renders the searchable table.

type SelectorView

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

SelectorView provides a searchable selection interface for categories or tags. Can be used for single selection (category) or multi-selection (tags).

func NewSelectorView

func NewSelectorView(title, subtitle string, multiSelect bool, width, height int) SelectorView

NewSelectorView creates a new selector view. multiSelect: true for tags (can select multiple), false for category (single selection)

func (SelectorView) GetSelectedID

func (sv SelectorView) GetSelectedID() int

GetSelectedID returns the currently focused ID (single-select only)

func (SelectorView) GetSelectedIDs

func (sv SelectorView) GetSelectedIDs() []int

GetSelectedIDs returns all selected IDs (multi-select only)

func (SelectorView) IsSelected

func (sv SelectorView) IsSelected(id int) bool

IsSelected checks if an ID is selected

func (*SelectorView) SetRows

func (sv *SelectorView) SetRows(rows []table.Row)

SetRows sets the data rows for the selector.

func (*SelectorView) SetSelected

func (sv *SelectorView) SetSelected(ids []int)

SetSelected pre-selects items (for editing existing snippet)

func (*SelectorView) ToggleSelection

func (sv *SelectorView) ToggleSelection(id int)

ToggleSelection toggles the selection state of the current row (multi-select only)

func (*SelectorView) Update

func (sv *SelectorView) Update(msg tea.Msg) (SelectorView, tea.Cmd)

Update handles input for the selector.

func (*SelectorView) UpdateCheckboxDisplay

func (sv *SelectorView) UpdateCheckboxDisplay()

UpdateCheckboxDisplay updates the checkbox column for all rows

func (SelectorView) View

func (sv SelectorView) View() string

View renders the selector.

type TabModel

type TabModel interface {
	tea.Model
}

TabModel represents content that can be displayed in a tab.

type TabStyles

type TabStyles struct {
	InactiveTabBorder lipgloss.Border
	ActiveTabBorder   lipgloss.Border
	Doc               lipgloss.Style
	HighlightColor    lipgloss.AdaptiveColor
	InactiveTab       lipgloss.Style
	ActiveTab         lipgloss.Style
	Window            lipgloss.Style
	ContentPadding    lipgloss.Style
	ModeIndicator     lipgloss.Style
	InteractiveMode   lipgloss.Style
	NavigationMode    lipgloss.Style
}

TabStyles contains all styling configuration for the tabs component.

func DefaultTabStyles

func DefaultTabStyles() *TabStyles

DefaultTabStyles creates the default styling configuration.

type TableView

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

TableView represents a reusable table component with actions

func NewTableView

func NewTableView(columns []table.Column, title, emptyMsg, actionHint string, height int) TableView

NewTableView creates a new table view

func (*TableView) SelectedRow

func (tv *TableView) SelectedRow() table.Row

func (*TableView) SetRows

func (tv *TableView) SetRows(rows []table.Row)

func (*TableView) Update

func (tv *TableView) Update(msg tea.Msg) (TableView, tea.Cmd)

func (TableView) View

func (tv TableView) View() string

type Tabs

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

Tabs represents the main tabbed interface component.

func NewTabs

func NewTabs(labels []string, contents []TabModel) (Tabs, error)

NewTabs creates a new tabbed interface.

func (*Tabs) EnableDebug

func (t *Tabs) EnableDebug(enabled bool)

func (Tabs) Init

func (t Tabs) Init() tea.Cmd

func (*Tabs) SetLabelWidth

func (t *Tabs) SetLabelWidth(width int)

func (*Tabs) SetStyles

func (t *Tabs) SetStyles(styles *TabStyles)

func (Tabs) Update

func (t Tabs) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Tabs) View

func (t Tabs) View() string

type ViewportResizeMsg

type ViewportResizeMsg struct {
	Width  int
	Height int
}

ViewportResizeMsg is sent to tabs when viewport dimensions change

type ViewportTab

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

ViewportTab provides viewport management and message handling for tabs. Embed this in your tab structs to get scrolling and message functionality.

func NewViewportTab

func NewViewportTab() ViewportTab

NewViewportTab creates a new viewport tab.

func (*ViewportTab) ClearMessages

func (v *ViewportTab) ClearMessages()

ClearMessages clears both error and success messages.

func (*ViewportTab) GotoBottom

func (v *ViewportTab) GotoBottom()

GotoBottom scrolls to the bottom of the viewport.

func (*ViewportTab) GotoTop

func (v *ViewportTab) GotoTop()

GotoTop scrolls to the top of the viewport.

func (ViewportTab) HandleResize

func (v ViewportTab) HandleResize(msg ViewportResizeMsg) (ViewportTab, tea.Cmd)

HandleResize handles viewport resize messages. Call this at the start of your Update method.

func (ViewportTab) Height

func (v ViewportTab) Height() int

Height returns the viewport height.

func (ViewportTab) Init

func (v ViewportTab) Init() tea.Cmd

Init initializes the viewport.

func (ViewportTab) IsReady

func (v ViewportTab) IsReady() bool

IsReady returns true if viewport is initialized.

func (ViewportTab) RenderMessages

func (v ViewportTab) RenderMessages() string

RenderMessages returns formatted error/success messages.

func (ViewportTab) ScrollPercent

func (v ViewportTab) ScrollPercent() float64

ScrollPercent returns the current scroll percentage (0-1).

func (*ViewportTab) SetContent

func (v *ViewportTab) SetContent(content string)

SetContent sets the viewport content.

func (*ViewportTab) SetError

func (v *ViewportTab) SetError(msg string)

SetError sets an error message to display.

func (*ViewportTab) SetSuccess

func (v *ViewportTab) SetSuccess(msg string)

SetSuccess sets a success message to display.

func (*ViewportTab) SetYOffset

func (v *ViewportTab) SetYOffset(offset int)

SetYOffset sets the vertical scroll offset.

func (ViewportTab) TotalLines

func (v ViewportTab) TotalLines() int

TotalLines returns the total number of lines in the content. Note: This is an approximation based on scroll percent.

func (ViewportTab) UpdateViewport

func (v ViewportTab) UpdateViewport(msg tea.Msg) (ViewportTab, tea.Cmd)

UpdateViewport updates the viewport for scrolling. Call this at the end of your Update method to handle scroll keys.

func (ViewportTab) View

func (v ViewportTab) View() string

View returns the viewport view or loading message.

func (ViewportTab) Width

func (v ViewportTab) Width() int

Width returns the viewport width.

func (ViewportTab) YOffset

func (v ViewportTab) YOffset() int

YOffset returns the current vertical scroll offset.

Jump to

Keyboard shortcuts

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