tui

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package tui contains reusable TUI components

Package tui contains diagnostic view models for TUI integration

Package tui contains help view components

Package tui contains help section adapters for scrollable help content

Package tui contains the terminal user interface components using Bubble Tea

Package tui contains navigation components for the TUI

Package tui contains pager component for scrollable content

MIGRATION GUIDE:

The Pager component has been enhanced to work with the new standardized scrolling system. Existing code using Pager will continue to work unchanged, but new code should consider using the StandardScrollPager or ScrollableView components for better consistency.

Migration options:

  1. Keep using Pager (no changes needed): pager := NewPager() pager.SetContent("your content")
  1. Use PagerScrollableAdapter for ScrollableList compatibility: pager := NewPager() adapter := NewPagerScrollableAdapter(pager) adapter.SetItems([]ScrollableItem{...})
  1. Migrate to StandardScrollPager (recommended for new code): scrollPager := NewStandardScrollPager() scrollPager.SetItems([]ScrollableItem{...})
  1. Use ScrollableView for viewport-based scrolling: view := NewScrollableView() view.SetItems([]ScrollableItem{...}) // New scrollable list mode // OR view.SetContent("string content") // Legacy string mode

Package tui contains animated progress components

Package tui contains result view models for displaying diagnostic results

Package tui contains core scrolling interfaces and types for standardized scroll behavior

Package tui contains scrollable view components

Package tui contains the StandardScrollPager implementation

Package tui contains test harness for TUI interaction testing

Package tui contains theme system for the TUI

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateTotalHelpHeight

func CalculateTotalHelpHeight(sections []ScrollableItem) int

CalculateTotalHelpHeight calculates the total height needed for all help sections

func MockTUITestComponent

func MockTUITestComponent() domain.TUIComponent

MockTUITestComponent creates a mock component for testing

Types

type AnimatedProgress

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

AnimatedProgress provides animated progress indicators

func NewAnimatedProgress

func NewAnimatedProgress() *AnimatedProgress

NewAnimatedProgress creates a new animated progress indicator

func (*AnimatedProgress) IsActive

func (p *AnimatedProgress) IsActive() bool

IsActive returns whether the progress indicator is active

func (*AnimatedProgress) SetMessage

func (p *AnimatedProgress) SetMessage(message string)

SetMessage updates the progress message

func (*AnimatedProgress) SetSize

func (p *AnimatedProgress) SetSize(width, height int)

SetSize sets the progress indicator dimensions

func (*AnimatedProgress) SetTheme

func (p *AnimatedProgress) SetTheme(theme domain.Theme)

SetTheme sets the progress indicator theme

func (*AnimatedProgress) Start

func (p *AnimatedProgress) Start(message string) tea.Cmd

Start starts the progress animation

func (*AnimatedProgress) Stop

func (p *AnimatedProgress) Stop()

Stop stops the progress animation

func (*AnimatedProgress) Update

func (p *AnimatedProgress) Update(msg tea.Msg) (*AnimatedProgress, tea.Cmd)

Update handles progress animation updates

func (*AnimatedProgress) View

func (p *AnimatedProgress) View() string

View renders the progress indicator

type AppState

type AppState int

AppState represents the current state of the application

const (
	StateMainMenu AppState = iota
	StateNavigation
	StateDiagnostic
	StateSettings
	StateHelp
	StateExit
)

type DarkTheme

type DarkTheme struct {
	*DefaultTheme
}

DarkTheme creates a dark theme variant

func NewDarkTheme

func NewDarkTheme() *DarkTheme

NewDarkTheme creates a new dark theme

type DefaultTheme

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

DefaultTheme implements the domain.Theme interface

func NewDefaultTheme

func NewDefaultTheme() *DefaultTheme

NewDefaultTheme creates a new default theme

func (*DefaultTheme) GetColor

func (t *DefaultTheme) GetColor(element string) string

GetColor implements domain.Theme

func (*DefaultTheme) GetLipglossStyle

func (t *DefaultTheme) GetLipglossStyle(element string) lipgloss.Style

GetLipglossStyle returns a lipgloss.Style for the given element

func (*DefaultTheme) GetStyle

func (t *DefaultTheme) GetStyle(element string) map[string]interface{}

GetStyle implements domain.Theme

func (*DefaultTheme) SetColor

func (t *DefaultTheme) SetColor(element, color string)

SetColor implements domain.Theme

type DiagnosticErrorMsg

type DiagnosticErrorMsg struct {
	Error error
}

type DiagnosticResultMsg

type DiagnosticResultMsg struct {
	Result domain.Result
}

type DiagnosticStartMsg

type DiagnosticStartMsg struct{}

Messages for diagnostic operations

type DiagnosticViewModel

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

DiagnosticViewModel wraps diagnostic tools for TUI integration

func NewDiagnosticViewModel

func NewDiagnosticViewModel(tool domain.DiagnosticTool) *DiagnosticViewModel

NewDiagnosticViewModel creates a new diagnostic view model

func (*DiagnosticViewModel) Blur

func (m *DiagnosticViewModel) Blur()

Blur implements domain.TUIComponent

func (*DiagnosticViewModel) Focus

func (m *DiagnosticViewModel) Focus()

Focus implements domain.TUIComponent

func (*DiagnosticViewModel) GetError

func (m *DiagnosticViewModel) GetError() error

GetError returns the current error

func (*DiagnosticViewModel) GetResult

func (m *DiagnosticViewModel) GetResult() domain.Result

GetResult returns the current result

func (*DiagnosticViewModel) GetState

GetState returns the current view state

func (*DiagnosticViewModel) GetTool

GetTool returns the underlying diagnostic tool

func (*DiagnosticViewModel) Init

func (m *DiagnosticViewModel) Init() tea.Cmd

Init implements tea.Model

func (*DiagnosticViewModel) IsLoading

func (m *DiagnosticViewModel) IsLoading() bool

IsLoading returns whether the view is in loading state

func (*DiagnosticViewModel) SetSize

func (m *DiagnosticViewModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*DiagnosticViewModel) SetTheme

func (m *DiagnosticViewModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*DiagnosticViewModel) Update

func (m *DiagnosticViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*DiagnosticViewModel) View

func (m *DiagnosticViewModel) View() string

View implements tea.Model

type DiagnosticViewState

type DiagnosticViewState int

DiagnosticViewState represents the current state of the diagnostic view

const (
	DiagnosticStateInput DiagnosticViewState = iota
	DiagnosticStateLoading
	DiagnosticStateResult
	DiagnosticStateError
)

type FormField

type FormField struct {
	Key       string
	Label     string
	Input     textinput.Model
	Required  bool
	Validator domain.Validator
	HelpText  string
	ErrorText string
}

FormField represents a single form field

type FormModel

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

FormModel provides input forms with validation

func NewFormModel

func NewFormModel(title string) *FormModel

NewFormModel creates a new form model

func (*FormModel) AddField

func (m *FormModel) AddField(key, label string, required bool)

AddField adds a field to the form

func (*FormModel) Blur

func (m *FormModel) Blur()

Blur implements domain.TUIComponent

func (*FormModel) Focus

func (m *FormModel) Focus()

Focus implements domain.TUIComponent

func (*FormModel) GetFieldValue

func (m *FormModel) GetFieldValue(key string) string

GetFieldValue gets the value of a field

func (*FormModel) GetValues

func (m *FormModel) GetValues() map[string]string

GetValues returns all form values as a map

func (*FormModel) Init

func (m *FormModel) Init() tea.Cmd

Init implements tea.Model

func (*FormModel) SetFieldValue

func (m *FormModel) SetFieldValue(key, value string)

SetFieldValue sets the value of a field

func (*FormModel) SetSize

func (m *FormModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*FormModel) SetTheme

func (m *FormModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*FormModel) Update

func (m *FormModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*FormModel) View

func (m *FormModel) View() string

View implements tea.Model

type FormSubmitMsg

type FormSubmitMsg struct {
	Values map[string]string
}

FormSubmitMsg represents a form submission message

type HelpItem

type HelpItem struct {
	// Key is the keyboard shortcut or command (e.g., "↑/↓ or j/k")
	Key string

	// Description explains what the key/command does
	Description string
}

HelpItem represents an individual help entry within a section

func NewHelpItem

func NewHelpItem(key, description string) HelpItem

NewHelpItem creates a new help item with key and description

type HelpModel

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

HelpModel displays help information and keyboard shortcuts using viewport for smooth scrolling

func NewHelpModel

func NewHelpModel() *HelpModel

NewHelpModel creates a new help model

func (*HelpModel) Blur

func (m *HelpModel) Blur()

Blur implements domain.TUIComponent

func (*HelpModel) Focus

func (m *HelpModel) Focus()

Focus implements domain.TUIComponent

func (*HelpModel) Init

func (m *HelpModel) Init() tea.Cmd

Init implements tea.Model

func (*HelpModel) SetSize

func (m *HelpModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*HelpModel) SetTheme

func (m *HelpModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*HelpModel) Update

func (m *HelpModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*HelpModel) View

func (m *HelpModel) View() string

View implements tea.Model

type HelpSection

type HelpSection struct {
	// Title is the section title (e.g., "Navigation & Scrolling")
	Title string

	// Items contains the help entries within this section
	Items []HelpItem

	// ID is a unique identifier for this section
	ID string
}

HelpSection represents a section of help content that implements ScrollableItem

func GetHelpSectionByID

func GetHelpSectionByID(sections []ScrollableItem, id string) *HelpSection

GetHelpSectionByID finds a help section by its ID

func NewHelpSection

func NewHelpSection(title string, items []HelpItem) *HelpSection

NewHelpSection creates a new help section with the given title and items

func (*HelpSection) GetHeight

func (hs *HelpSection) GetHeight() int

GetHeight implements ScrollableItem interface

func (*HelpSection) GetID

func (hs *HelpSection) GetID() string

GetID implements ScrollableItem interface

func (*HelpSection) IsSelectable

func (hs *HelpSection) IsSelectable() bool

IsSelectable implements ScrollableItem interface

func (*HelpSection) Render

func (hs *HelpSection) Render(width int, selected bool, theme domain.Theme) string

Render implements ScrollableItem interface

type KeyMap

type KeyMap struct {
	Up       key.Binding
	Down     key.Binding
	Left     key.Binding
	Right    key.Binding
	Enter    key.Binding
	Back     key.Binding
	Quit     key.Binding
	Help     key.Binding
	Tab      key.Binding
	PageUp   key.Binding
	PageDown key.Binding
	Home     key.Binding
	End      key.Binding
}

KeyMap defines keyboard shortcuts for the application

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings

type LightTheme

type LightTheme struct {
	*DefaultTheme
}

LightTheme creates a light theme variant

func NewLightTheme

func NewLightTheme() *LightTheme

NewLightTheme creates a new light theme

type MainModel

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

MainModel represents the root application model

func NewMainModel

func NewMainModel(plugins domain.PluginRegistry, config *domain.Config, configManager *configpkg.Manager, theme domain.Theme) *MainModel

NewMainModel creates a new main application model

func (*MainModel) Blur

func (m *MainModel) Blur()

Blur implements domain.TUIComponent

func (*MainModel) Focus

func (m *MainModel) Focus()

Focus implements domain.TUIComponent

func (*MainModel) Init

func (m *MainModel) Init() tea.Cmd

Init implements tea.Model

func (*MainModel) SetSize

func (m *MainModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*MainModel) SetTheme

func (m *MainModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*MainModel) Update

func (m *MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*MainModel) View

func (m *MainModel) View() string

View implements tea.Model

type NavigationAction int

NavigationAction represents different navigation actions

const (
	NavigationActionSelect NavigationAction = iota
	NavigationActionBack
	NavigationActionUp
	NavigationActionDown
)
type NavigationItem struct {
	ID          string
	Title       string
	Description string
	Icon        string
	Enabled     bool
}

NavigationItem represents a menu item

func (n NavigationItem) GetHeight() int

GetHeight implements ScrollableItem interface Returns the number of lines this item occupies when rendered

func (n NavigationItem) GetID() string

GetID implements ScrollableItem interface Returns a unique identifier for this item

func (n NavigationItem) IsSelectable() bool

IsSelectable implements ScrollableItem interface Returns true if this item can be selected by the user

func (n NavigationItem) Render(width int, selected bool, theme domain.Theme) string

Render implements ScrollableItem interface Renders the navigation item with proper selection styling and theme application

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

NavigationModel handles menu and navigation

func NewNavigationModel

func NewNavigationModel() *NavigationModel

NewNavigationModel creates a new navigation model

func (m *NavigationModel) AddBreadcrumb(crumb string)

AddBreadcrumb adds a breadcrumb to the navigation

func (m *NavigationModel) AddItem(item NavigationItem)

AddItem adds a new navigation item

func (m *NavigationModel) Blur()

Blur implements domain.TUIComponent

func (m *NavigationModel) DisableItem(id string)

DisableItem disables a menu item by ID

func (m *NavigationModel) EnableItem(id string)

EnableItem enables a menu item by ID

func (m *NavigationModel) Focus()

Focus implements domain.TUIComponent

func (m *NavigationModel) GetBreadcrumbs() []string

GetBreadcrumbs returns the current breadcrumbs

func (m *NavigationModel) GetSelected() *NavigationItem

GetSelected returns the currently selected item

func (m *NavigationModel) Init() tea.Cmd

Init implements tea.Model

func (m *NavigationModel) PopBreadcrumb() string

PopBreadcrumb removes the last breadcrumb

func (m *NavigationModel) RemoveItem(id string)

RemoveItem removes a navigation item by ID

func (m *NavigationModel) SetSelected(index int)

SetSelected sets the selected item by index

func (m *NavigationModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (m *NavigationModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (m *NavigationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (m *NavigationModel) View() string

View implements tea.Model

type NavigationMsg struct {
	Action NavigationAction
	Data   interface{}
}

NavigationMsg represents a navigation message

type Pager

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

Pager provides scrollable content functionality

func NewPager

func NewPager() *Pager

NewPager creates a new pager

func (*Pager) Blur

func (p *Pager) Blur()

Blur blurs the pager

func (*Pager) CanScrollDown

func (p *Pager) CanScrollDown() bool

CanScrollDown returns true if content can be scrolled down

func (*Pager) CanScrollUp

func (p *Pager) CanScrollUp() bool

CanScrollUp returns true if content can be scrolled up

func (*Pager) Focus

func (p *Pager) Focus()

Focus focuses the pager

func (*Pager) GetScrollPosition

func (p *Pager) GetScrollPosition() (int, int)

GetScrollPosition returns current scroll position and max scroll

func (*Pager) SetContent

func (p *Pager) SetContent(content string)

SetContent sets the content to be displayed in the pager

func (*Pager) SetContentLines

func (p *Pager) SetContentLines(lines []string)

SetContentLines sets the content as a slice of lines

func (*Pager) SetShowScrollIndicators

func (p *Pager) SetShowScrollIndicators(show bool)

SetShowScrollIndicators controls whether scroll indicators are shown

func (*Pager) SetSize

func (p *Pager) SetSize(width, height int)

SetSize sets the pager dimensions

func (*Pager) SetTheme

func (p *Pager) SetTheme(theme domain.Theme)

SetTheme sets the pager theme

func (*Pager) Update

func (p *Pager) Update(msg tea.Msg) (*Pager, tea.Cmd)

Update handles pager input

func (*Pager) View

func (p *Pager) View() string

View renders the pager content

type PagerScrollableAdapter

type PagerScrollableAdapter struct {
	*Pager
	// contains filtered or unexported fields
}

PagerScrollableAdapter provides backward compatibility by adapting the existing Pager to work with the new ScrollableList interface. This allows existing code using Pager to continue working while gradually migrating to the new scrolling system.

func NewPagerScrollableAdapter

func NewPagerScrollableAdapter(pager *Pager) *PagerScrollableAdapter

NewPagerScrollableAdapter creates a new adapter that wraps an existing Pager

func (*PagerScrollableAdapter) AddItem

func (p *PagerScrollableAdapter) AddItem(item ScrollableItem)

AddItem implements ScrollableList interface

func (*PagerScrollableAdapter) End

func (p *PagerScrollableAdapter) End() bool

End implements ScrollableList interface

func (*PagerScrollableAdapter) GetItems

func (p *PagerScrollableAdapter) GetItems() []ScrollableItem

GetItems implements ScrollableList interface

func (*PagerScrollableAdapter) GetScrollPosition

func (p *PagerScrollableAdapter) GetScrollPosition() ScrollPosition

GetScrollPosition implements ScrollableList interface

func (*PagerScrollableAdapter) GetSelected

func (p *PagerScrollableAdapter) GetSelected() int

GetSelected implements ScrollableList interface

func (*PagerScrollableAdapter) GetVisibleRange

func (p *PagerScrollableAdapter) GetVisibleRange() (start, end int)

GetVisibleRange implements ScrollableList interface

func (*PagerScrollableAdapter) Home

func (p *PagerScrollableAdapter) Home() bool

Home implements ScrollableList interface

func (*PagerScrollableAdapter) Init

func (p *PagerScrollableAdapter) Init() tea.Cmd

Init implements the TUIComponent interface (required by ScrollableList)

func (*PagerScrollableAdapter) IsItemVisible

func (p *PagerScrollableAdapter) IsItemVisible(index int) bool

IsItemVisible implements ScrollableList interface

func (*PagerScrollableAdapter) MoveDown

func (p *PagerScrollableAdapter) MoveDown() bool

MoveDown implements ScrollableList interface

func (*PagerScrollableAdapter) MoveUp

func (p *PagerScrollableAdapter) MoveUp() bool

MoveUp implements ScrollableList interface

func (*PagerScrollableAdapter) PageDown

func (p *PagerScrollableAdapter) PageDown() bool

PageDown implements ScrollableList interface

func (*PagerScrollableAdapter) PageUp

func (p *PagerScrollableAdapter) PageUp() bool

PageUp implements ScrollableList interface

func (*PagerScrollableAdapter) RemoveItem

func (p *PagerScrollableAdapter) RemoveItem(index int)

RemoveItem implements ScrollableList interface

func (*PagerScrollableAdapter) ScrollToItem

func (p *PagerScrollableAdapter) ScrollToItem(index int)

ScrollToItem implements ScrollableList interface

func (*PagerScrollableAdapter) SetItems

func (p *PagerScrollableAdapter) SetItems(items []ScrollableItem)

SetItems implements ScrollableList interface

func (*PagerScrollableAdapter) SetSelected

func (p *PagerScrollableAdapter) SetSelected(index int)

SetSelected implements ScrollableList interface

func (*PagerScrollableAdapter) Update

func (p *PagerScrollableAdapter) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements the TUIComponent interface (required by ScrollableList)

type ProgressBar

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

ProgressBar provides a determinate progress bar

func NewProgressBar

func NewProgressBar() *ProgressBar

NewProgressBar creates a new progress bar

func (*ProgressBar) IsComplete

func (p *ProgressBar) IsComplete() bool

IsComplete returns true if progress is complete

func (*ProgressBar) SetMessage

func (p *ProgressBar) SetMessage(message string)

SetMessage sets the progress message

func (*ProgressBar) SetProgress

func (p *ProgressBar) SetProgress(current, total int)

SetProgress sets the current progress

func (*ProgressBar) SetShowPercentage

func (p *ProgressBar) SetShowPercentage(show bool)

SetShowPercentage controls whether percentage is shown

func (*ProgressBar) SetSize

func (p *ProgressBar) SetSize(width, height int)

SetSize sets the progress bar dimensions

func (*ProgressBar) SetTheme

func (p *ProgressBar) SetTheme(theme domain.Theme)

SetTheme sets the progress bar theme

func (*ProgressBar) View

func (p *ProgressBar) View() string

View renders the progress bar

type ProgressModel

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

ProgressModel shows operation progress

func NewProgressModel

func NewProgressModel() *ProgressModel

NewProgressModel creates a new progress model

func (*ProgressModel) Blur

func (m *ProgressModel) Blur()

Blur implements domain.TUIComponent

func (*ProgressModel) Focus

func (m *ProgressModel) Focus()

Focus implements domain.TUIComponent

func (*ProgressModel) Init

func (m *ProgressModel) Init() tea.Cmd

Init implements tea.Model

func (*ProgressModel) IsComplete

func (m *ProgressModel) IsComplete() bool

IsComplete returns true if progress is complete

func (*ProgressModel) SetMessage

func (m *ProgressModel) SetMessage(message string)

SetMessage sets the progress message

func (*ProgressModel) SetProgress

func (m *ProgressModel) SetProgress(current, total int)

SetProgress sets the current progress

func (*ProgressModel) SetSize

func (m *ProgressModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*ProgressModel) SetTheme

func (m *ProgressModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*ProgressModel) Update

func (m *ProgressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*ProgressModel) View

func (m *ProgressModel) View() string

View implements tea.Model

type ProgressTickMsg

type ProgressTickMsg struct{}

ProgressTickMsg is sent to update the progress animation

type ResponsiveLayout

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

ResponsiveLayout handles responsive layout calculations

func NewResponsiveLayout

func NewResponsiveLayout() *ResponsiveLayout

NewResponsiveLayout creates a new responsive layout manager

func (*ResponsiveLayout) GetColumnCount

func (rl *ResponsiveLayout) GetColumnCount() int

GetColumnCount returns the recommended number of columns for the current screen size

func (*ResponsiveLayout) GetContentArea

func (rl *ResponsiveLayout) GetContentArea(headerHeight, footerHeight int) (int, int)

GetContentArea returns the available content area dimensions

func (*ResponsiveLayout) GetFormWidth

func (rl *ResponsiveLayout) GetFormWidth() int

GetFormWidth returns the recommended form width

func (*ResponsiveLayout) GetMaxTableWidth

func (rl *ResponsiveLayout) GetMaxTableWidth() int

GetMaxTableWidth returns the maximum recommended table width

func (*ResponsiveLayout) IsLargeScreen

func (rl *ResponsiveLayout) IsLargeScreen() bool

IsLargeScreen returns true if the screen is considered large

func (*ResponsiveLayout) IsMediumScreen

func (rl *ResponsiveLayout) IsMediumScreen() bool

IsMediumScreen returns true if the screen is considered medium

func (*ResponsiveLayout) IsSmallScreen

func (rl *ResponsiveLayout) IsSmallScreen() bool

IsSmallScreen returns true if the screen is considered small

func (*ResponsiveLayout) SetSize

func (rl *ResponsiveLayout) SetSize(width, height int)

SetSize updates the layout dimensions

type ResultViewMode

type ResultViewMode int

ResultViewMode represents different ways to display results

const (
	ResultViewModeFormatted ResultViewMode = iota
	ResultViewModeTable
	ResultViewModeRaw
)

type ResultViewModel

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

ResultViewModel handles display of diagnostic results

func NewResultViewModel

func NewResultViewModel() *ResultViewModel

NewResultViewModel creates a new result view model

func (*ResultViewModel) Blur

func (m *ResultViewModel) Blur()

Blur implements domain.TUIComponent

func (*ResultViewModel) Focus

func (m *ResultViewModel) Focus()

Focus implements domain.TUIComponent

func (*ResultViewModel) Init

func (m *ResultViewModel) Init() tea.Cmd

Init implements tea.Model

func (*ResultViewModel) SetResult

func (m *ResultViewModel) SetResult(result domain.Result)

SetResult sets the result to display

func (*ResultViewModel) SetSize

func (m *ResultViewModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*ResultViewModel) SetTheme

func (m *ResultViewModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*ResultViewModel) Update

func (m *ResultViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*ResultViewModel) View

func (m *ResultViewModel) View() string

View implements tea.Model

type SSLCheckCompleteMsg

type SSLCheckCompleteMsg struct {
	Result domain.SSLResult
}

SSL-specific messages

type SSLCheckErrorMsg

type SSLCheckErrorMsg struct {
	Error error
}

type ScrollPosition

type ScrollPosition struct {
	// SelectedIndex is the index of the currently selected item
	SelectedIndex int

	// TopVisible is the index of the first visible item in the viewport
	TopVisible int

	// ViewportHeight is the number of items that can fit in the viewport
	ViewportHeight int
}

ScrollPosition tracks the current scroll and selection state

func NewScrollPosition

func NewScrollPosition() ScrollPosition

NewScrollPosition creates a new ScrollPosition with default values

func (ScrollPosition) CanScrollDown

func (sp ScrollPosition) CanScrollDown(itemCount int) bool

CanScrollDown returns true if content can be scrolled down

func (ScrollPosition) CanScrollUp

func (sp ScrollPosition) CanScrollUp() bool

CanScrollUp returns true if content can be scrolled up

func (*ScrollPosition) EnsureSelectionVisible

func (sp *ScrollPosition) EnsureSelectionVisible(itemCount int)

EnsureSelectionVisible adjusts TopVisible to ensure the selected item is visible

func (ScrollPosition) GetVisibleRange

func (sp ScrollPosition) GetVisibleRange(itemCount int) (start, end int)

GetVisibleRange returns the start and end indices of visible items

func (ScrollPosition) IsItemVisible

func (sp ScrollPosition) IsItemVisible(index int) bool

IsItemVisible returns true if the item at the given index is visible

func (ScrollPosition) IsValid

func (sp ScrollPosition) IsValid(itemCount int) bool

IsValid returns true if the scroll position is valid for the given content

type ScrollableContent

type ScrollableContent struct {
	// Items contains all scrollable items
	Items []ScrollableItem

	// Position tracks current scroll and selection state
	Position ScrollPosition

	// ShowIndicators controls whether scroll indicators are displayed
	ShowIndicators bool

	// Theme for styling the content
	Theme domain.Theme

	// KeyMap for navigation key bindings
	KeyMap KeyMap
}

ScrollableContent represents scrollable content with metadata

func NewScrollableContent

func NewScrollableContent() *ScrollableContent

NewScrollableContent creates a new ScrollableContent with default settings

func (*ScrollableContent) AddItem

func (sc *ScrollableContent) AddItem(item ScrollableItem)

AddItem adds an item to the scrollable content

func (*ScrollableContent) GetSelectedItem

func (sc *ScrollableContent) GetSelectedItem() ScrollableItem

GetSelectedItem returns the currently selected item, or nil if none

func (*ScrollableContent) RemoveItem

func (sc *ScrollableContent) RemoveItem(index int)

RemoveItem removes an item at the specified index

func (*ScrollableContent) SetItems

func (sc *ScrollableContent) SetItems(items []ScrollableItem)

SetItems replaces all items in the scrollable content

func (*ScrollableContent) SetViewportHeight

func (sc *ScrollableContent) SetViewportHeight(height int)

SetViewportHeight updates the viewport height and adjusts scroll position

type ScrollableItem

type ScrollableItem interface {
	// Render returns the string representation of the item
	// width: available width for rendering
	// selected: whether this item is currently selected
	// theme: theme to apply for styling
	Render(width int, selected bool, theme domain.Theme) string

	// GetHeight returns the number of lines this item occupies when rendered
	GetHeight() int

	// IsSelectable returns true if this item can be selected by the user
	IsSelectable() bool

	// GetID returns a unique identifier for this item
	GetID() string
}

ScrollableItem defines the contract for items that can be rendered in a scrollable list

func CreateHelpSections

func CreateHelpSections() []ScrollableItem

CreateHelpSections creates all help sections for the application This function converts the existing help content structure to scrollable sections

type ScrollableList

type ScrollableList interface {
	domain.TUIComponent

	// Content management
	SetItems(items []ScrollableItem)
	GetItems() []ScrollableItem
	AddItem(item ScrollableItem)
	RemoveItem(index int)

	// Selection and scrolling
	GetSelected() int
	SetSelected(index int)
	GetScrollPosition() ScrollPosition
	ScrollToItem(index int)

	// Navigation
	MoveUp() bool
	MoveDown() bool
	PageUp() bool
	PageDown() bool
	Home() bool
	End() bool

	// Viewport management
	GetVisibleRange() (start, end int)
	IsItemVisible(index int) bool
}

ScrollableList defines the contract for scrollable content with selection This interface extends TUIComponent to provide unified scroll behavior

type ScrollableView

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

ScrollableView provides a standardized scrollable content view It can work with both string content (legacy mode) and ScrollableItem lists (new mode)

func NewScrollableView

func NewScrollableView() *ScrollableView

NewScrollableView creates a new scrollable view

func (*ScrollableView) AddItem

func (s *ScrollableView) AddItem(item ScrollableItem)

AddItem implements ScrollableList interface

func (*ScrollableView) Blur

func (s *ScrollableView) Blur()

Blur implements domain.TUIComponent

func (*ScrollableView) DisableScrollableList

func (s *ScrollableView) DisableScrollableList()

DisableScrollableList disables the new scrollable list mode and reverts to string content

func (*ScrollableView) EnableScrollableList

func (s *ScrollableView) EnableScrollableList()

EnableScrollableList enables the new scrollable list mode

func (*ScrollableView) End

func (s *ScrollableView) End() bool

End implements ScrollableList interface

func (*ScrollableView) Focus

func (s *ScrollableView) Focus()

Focus implements domain.TUIComponent

func (*ScrollableView) GetItems

func (s *ScrollableView) GetItems() []ScrollableItem

GetItems implements ScrollableList interface

func (*ScrollableView) GetScrollPercent

func (s *ScrollableView) GetScrollPercent() float64

GetScrollPercent returns the current scroll percentage

func (*ScrollableView) GetScrollPosition

func (s *ScrollableView) GetScrollPosition() ScrollPosition

GetScrollPosition implements ScrollableList interface

func (*ScrollableView) GetSelected

func (s *ScrollableView) GetSelected() int

GetSelected implements ScrollableList interface

func (*ScrollableView) GetVisibleRange

func (s *ScrollableView) GetVisibleRange() (start, end int)

GetVisibleRange implements ScrollableList interface

func (*ScrollableView) Home

func (s *ScrollableView) Home() bool

Home implements ScrollableList interface

func (*ScrollableView) Init

func (s *ScrollableView) Init() tea.Cmd

Init implements tea.Model

func (*ScrollableView) IsItemVisible

func (s *ScrollableView) IsItemVisible(index int) bool

IsItemVisible implements ScrollableList interface

func (*ScrollableView) MoveDown

func (s *ScrollableView) MoveDown() bool

MoveDown implements ScrollableList interface

func (*ScrollableView) MoveUp

func (s *ScrollableView) MoveUp() bool

MoveUp implements ScrollableList interface

func (*ScrollableView) PageDown

func (s *ScrollableView) PageDown() bool

PageDown implements ScrollableList interface

func (*ScrollableView) PageUp

func (s *ScrollableView) PageUp() bool

PageUp implements ScrollableList interface

func (*ScrollableView) RemoveItem

func (s *ScrollableView) RemoveItem(index int)

RemoveItem implements ScrollableList interface

func (*ScrollableView) ScrollToBottom

func (s *ScrollableView) ScrollToBottom()

ScrollToBottom scrolls to the bottom

func (*ScrollableView) ScrollToItem

func (s *ScrollableView) ScrollToItem(index int)

ScrollToItem implements ScrollableList interface

func (*ScrollableView) ScrollToTop

func (s *ScrollableView) ScrollToTop()

ScrollToTop scrolls to the top

func (*ScrollableView) SetContent

func (s *ScrollableView) SetContent(content string)

SetContent sets the main content to be displayed This method disables scrollable list mode and uses string content

func (*ScrollableView) SetFooter

func (s *ScrollableView) SetFooter(footer string)

SetFooter sets the footer text

func (*ScrollableView) SetHeader

func (s *ScrollableView) SetHeader(header string)

SetHeader sets the header text

func (*ScrollableView) SetItems

func (s *ScrollableView) SetItems(items []ScrollableItem)

SetItems implements ScrollableList interface

func (*ScrollableView) SetSelected

func (s *ScrollableView) SetSelected(index int)

SetSelected implements ScrollableList interface

func (*ScrollableView) SetSize

func (s *ScrollableView) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*ScrollableView) SetTheme

func (s *ScrollableView) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*ScrollableView) Update

func (s *ScrollableView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*ScrollableView) View

func (s *ScrollableView) View() string

View implements tea.Model

type StandardScrollPager

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

StandardScrollPager provides unified scrolling behavior for all TUI models

func NewStandardScrollPager

func NewStandardScrollPager() *StandardScrollPager

NewStandardScrollPager creates a new StandardScrollPager

func (*StandardScrollPager) AddItem

func (p *StandardScrollPager) AddItem(item ScrollableItem)

AddItem implements ScrollableList

func (*StandardScrollPager) Blur

func (p *StandardScrollPager) Blur()

Blur implements domain.TUIComponent

func (*StandardScrollPager) End

func (p *StandardScrollPager) End() bool

End implements ScrollableList

func (*StandardScrollPager) Focus

func (p *StandardScrollPager) Focus()

Focus implements domain.TUIComponent

func (*StandardScrollPager) GetItems

func (p *StandardScrollPager) GetItems() []ScrollableItem

GetItems implements ScrollableList

func (*StandardScrollPager) GetScrollPosition

func (p *StandardScrollPager) GetScrollPosition() ScrollPosition

GetScrollPosition implements ScrollableList

func (*StandardScrollPager) GetSelected

func (p *StandardScrollPager) GetSelected() int

GetSelected implements ScrollableList

func (*StandardScrollPager) GetVisibleRange

func (p *StandardScrollPager) GetVisibleRange() (start, end int)

GetVisibleRange implements ScrollableList

func (*StandardScrollPager) Home

func (p *StandardScrollPager) Home() bool

Home implements ScrollableList

func (*StandardScrollPager) Init

func (p *StandardScrollPager) Init() tea.Cmd

Init implements tea.Model

func (*StandardScrollPager) IsItemVisible

func (p *StandardScrollPager) IsItemVisible(index int) bool

IsItemVisible implements ScrollableList

func (*StandardScrollPager) MoveDown

func (p *StandardScrollPager) MoveDown() bool

MoveDown implements ScrollableList

func (*StandardScrollPager) MoveUp

func (p *StandardScrollPager) MoveUp() bool

MoveUp implements ScrollableList

func (*StandardScrollPager) PageDown

func (p *StandardScrollPager) PageDown() bool

PageDown implements ScrollableList

func (*StandardScrollPager) PageUp

func (p *StandardScrollPager) PageUp() bool

PageUp implements ScrollableList

func (*StandardScrollPager) RemoveItem

func (p *StandardScrollPager) RemoveItem(index int)

RemoveItem implements ScrollableList

func (*StandardScrollPager) ScrollToItem

func (p *StandardScrollPager) ScrollToItem(index int)

ScrollToItem implements ScrollableList

func (*StandardScrollPager) SetItems

func (p *StandardScrollPager) SetItems(items []ScrollableItem)

SetItems implements ScrollableList

func (*StandardScrollPager) SetSelected

func (p *StandardScrollPager) SetSelected(index int)

SetSelected implements ScrollableList

func (*StandardScrollPager) SetShowScrollIndicators

func (p *StandardScrollPager) SetShowScrollIndicators(show bool)

SetShowScrollIndicators controls whether scroll indicators are displayed

func (*StandardScrollPager) SetSize

func (p *StandardScrollPager) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*StandardScrollPager) SetTheme

func (p *StandardScrollPager) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*StandardScrollPager) Update

func (p *StandardScrollPager) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*StandardScrollPager) View

func (p *StandardScrollPager) View() string

View implements tea.Model

type StringScrollableItem

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

StringScrollableItem is a simple implementation of ScrollableItem for string content

func NewStringScrollableItem

func NewStringScrollableItem(content, id string) *StringScrollableItem

NewStringScrollableItem creates a new string-based scrollable item

func (*StringScrollableItem) GetHeight

func (s *StringScrollableItem) GetHeight() int

GetHeight implements ScrollableItem interface

func (*StringScrollableItem) GetID

func (s *StringScrollableItem) GetID() string

GetID implements ScrollableItem interface

func (*StringScrollableItem) IsSelectable

func (s *StringScrollableItem) IsSelectable() bool

IsSelectable implements ScrollableItem interface

func (*StringScrollableItem) Render

func (s *StringScrollableItem) Render(width int, selected bool, theme domain.Theme) string

Render implements ScrollableItem interface

type TUITestHarness

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

TUITestHarness enables TUI interaction testing

func NewTUITestHarness

func NewTUITestHarness(model tea.Model) *TUITestHarness

NewTUITestHarness creates a new test harness

func (*TUITestHarness) AssertOutput

func (h *TUITestHarness) AssertOutput(expected string) bool

AssertOutput checks if the current output contains the expected text

func (*TUITestHarness) AssertOutputNot

func (h *TUITestHarness) AssertOutputNot(notExpected string) bool

AssertOutputNot checks if the current output does not contain the text

func (*TUITestHarness) GetModel

func (h *TUITestHarness) GetModel() tea.Model

GetModel returns the current model (for inspection)

func (*TUITestHarness) GetOutput

func (h *TUITestHarness) GetOutput() string

GetOutput returns the current output

func (*TUITestHarness) GetOutputHistory

func (h *TUITestHarness) GetOutputHistory() []string

GetOutputHistory returns all output history

func (*TUITestHarness) IsRunning

func (h *TUITestHarness) IsRunning() bool

IsRunning returns whether the harness is currently running

func (*TUITestHarness) Read

func (h *TUITestHarness) Read(p []byte) (n int, err error)

Read implements io.Reader for tea.WithInput

func (*TUITestHarness) SendKey

func (h *TUITestHarness) SendKey(key tea.KeyType)

SendKey sends a key message to the program

func (*TUITestHarness) SendKeyRune

func (h *TUITestHarness) SendKeyRune(r rune)

SendKeyRune sends a key rune message to the program

func (*TUITestHarness) SendKeyString

func (h *TUITestHarness) SendKeyString(s string)

SendKeyString sends a string as individual key messages

func (*TUITestHarness) SendMessage

func (h *TUITestHarness) SendMessage(msg tea.Msg)

SendMessage sends a custom message to the program

func (*TUITestHarness) SendWindowSize

func (h *TUITestHarness) SendWindowSize(width, height int)

SendWindowSize sends a window size message

func (*TUITestHarness) Start

func (h *TUITestHarness) Start() error

Start starts the test harness

func (*TUITestHarness) Stop

func (h *TUITestHarness) Stop()

Stop stops the test harness

func (*TUITestHarness) WaitForOutput

func (h *TUITestHarness) WaitForOutput(text string, timeout time.Duration) bool

WaitForOutput waits for specific text to appear in the output

func (*TUITestHarness) WaitForOutputMatch

func (h *TUITestHarness) WaitForOutputMatch(predicate func(string) bool, timeout time.Duration) bool

WaitForOutputMatch waits for output that matches a predicate function

type TUITestSuite

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

TUITestSuite provides utilities for testing TUI components

func NewTUITestSuite

func NewTUITestSuite() *TUITestSuite

NewTUITestSuite creates a new test suite

func (*TUITestSuite) Cleanup

func (s *TUITestSuite) Cleanup()

Cleanup stops all harnesses and cleans up resources

func (*TUITestSuite) CreateHarness

func (s *TUITestSuite) CreateHarness(model tea.Model) *TUITestHarness

CreateHarness creates and registers a new test harness

func (*TUITestSuite) TestFormInteraction

func (s *TUITestSuite) TestFormInteraction(harness *TUITestHarness) error

TestFormInteraction tests form interaction flows

func (*TUITestSuite) TestKeyboardShortcuts

func (s *TUITestSuite) TestKeyboardShortcuts(harness *TUITestHarness) error

TestKeyboardShortcuts tests keyboard shortcuts

func (*TUITestSuite) TestNavigationFlow

func (s *TUITestSuite) TestNavigationFlow(harness *TUITestHarness) error

TestNavigationFlow tests basic navigation flows

func (*TUITestSuite) TestResponsiveLayout

func (s *TUITestSuite) TestResponsiveLayout(harness *TUITestHarness) error

TestResponsiveLayout tests responsive layout behavior

type TableModel

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

TableModel displays tabular data with sorting and filtering

func NewTableModel

func NewTableModel(headers []string) *TableModel

NewTableModel creates a new table model

func (*TableModel) AddRow

func (m *TableModel) AddRow(row []string)

AddRow adds a row to the table

func (*TableModel) Blur

func (m *TableModel) Blur()

Blur implements domain.TUIComponent

func (*TableModel) Focus

func (m *TableModel) Focus()

Focus implements domain.TUIComponent

func (*TableModel) Init

func (m *TableModel) Init() tea.Cmd

Init implements tea.Model

func (*TableModel) SetData

func (m *TableModel) SetData(rows [][]string)

SetData sets the table data

func (*TableModel) SetFilter

func (m *TableModel) SetFilter(filter string)

SetFilter sets the table filter

func (*TableModel) SetSize

func (m *TableModel) SetSize(width, height int)

SetSize implements domain.TUIComponent

func (*TableModel) SetTheme

func (m *TableModel) SetTheme(theme domain.Theme)

SetTheme implements domain.TUIComponent

func (*TableModel) SortBy

func (m *TableModel) SortBy(column int, descending bool)

SortBy sorts the table by the specified column

func (*TableModel) Update

func (m *TableModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*TableModel) View

func (m *TableModel) View() string

View implements tea.Model

type TableSelectMsg

type TableSelectMsg struct {
	Row  int
	Data []string
}

TableSelectMsg represents a table row selection message

type ThemeManager

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

ThemeManager manages theme switching and application

func NewThemeManager

func NewThemeManager() *ThemeManager

NewThemeManager creates a new theme manager

func (*ThemeManager) ApplyThemeToComponent

func (tm *ThemeManager) ApplyThemeToComponent(component domain.TUIComponent)

ApplyThemeToComponent applies the current theme to a TUI component

func (*ThemeManager) GetAvailableThemes

func (tm *ThemeManager) GetAvailableThemes() []string

GetAvailableThemes returns a list of available theme names

func (*ThemeManager) GetCurrentThemeName

func (tm *ThemeManager) GetCurrentThemeName() string

GetCurrentThemeName returns the name of the current theme

func (*ThemeManager) GetTheme

func (tm *ThemeManager) GetTheme() domain.Theme

GetTheme returns the current theme

func (*ThemeManager) RegisterTheme

func (tm *ThemeManager) RegisterTheme(name string, theme domain.Theme)

RegisterTheme registers a new theme

func (*ThemeManager) SetTheme

func (tm *ThemeManager) SetTheme(name string) bool

SetTheme sets the current theme by name

type ViewState

type ViewState int

ViewState represents the current state of a view

const (
	ViewStateInput ViewState = iota
	ViewStateLoading
	ViewStateResult
	ViewStateError
)

Jump to

Keyboard shortcuts

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