tui

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PageMain                  = "main"
	PageSettingsMain          = "settings_main"
	PageSettingsBasic         = "settings_basic"
	PageSettingsAdvanced      = "settings_advanced"
	PageSettingsReaderList    = "settings_reader_list"
	PageSettingsReaderEdit    = "settings_reader_edit"
	PageSettingsIgnoreSystems = "settings_ignore_systems"
	PageSettingsTagsWrite     = "settings_tags_write"
	PageSettingsAudio         = "settings_audio"
	PageSettingsReaders       = "settings_readers"
	PageSettingsScanMode      = "settings_readers_scanMode"
	PageSettingsAudioMenu     = "settings_audio_menu"
	PageSettingsReadersMenu   = "settings_readers_menu"
	PageSettingsTUI           = "settings_tui"
	PageSettingsAbout         = "settings_about"
	PageSearchMedia           = "search_media"
	PageExportLog             = "export_log"
	PageGenerateDB            = "generate_db"
)
View Source
const DefaultMaxHeight = 30

DefaultMaxHeight is the default maximum height for the TUI in non-CRT mode.

View Source
const DefaultMaxWidth = 100

DefaultMaxWidth is the default maximum width for the TUI in non-CRT mode.

View Source
const TUIRequestTimeout = 5 * time.Second

TUIRequestTimeout is the timeout for API requests from the TUI. This is shorter than the default API timeout since TUI calls are to localhost.

View Source
const TagReadTimeout = 30 * time.Second

TagReadTimeout is the timeout for tag read operations. This is longer than TUIRequestTimeout to give users time to physically tap a tag.

Variables

View Source
var AvailableThemes = map[string]*Theme{
	"default":       &ThemeDefault,
	"high_contrast": &ThemeHighContrast,
	"dracula":       &ThemeDracula,
	"nord":          &ThemeNord,
	"gruvbox":       &ThemeGruvbox,
	"monogreen":     &ThemeMonogreen,
}

AvailableThemes maps theme names to theme definitions.

View Source
var ExitDelayOptions = []ExitDelayOption{
	{Label: "0 seconds", Value: 0},
	{Label: "1 second", Value: 1},
	{Label: "2 seconds", Value: 2},
	{Label: "3 seconds", Value: 3},
	{Label: "5 seconds", Value: 5},
	{Label: "10 seconds", Value: 10},
	{Label: "15 seconds", Value: 15},
	{Label: "20 seconds", Value: 20},
	{Label: "30 seconds", Value: 30},
}

ExitDelayOptions provides structured exit delay choices.

View Source
var ThemeDefault = Theme{
	Name:        "default",
	DisplayName: "Default (Dark Blue)",

	PrimitiveBackgroundColor: tcell.ColorDarkBlue,
	ContrastBackgroundColor:  tcell.ColorBlue,
	BorderColor:              tcell.ColorLightYellow,
	PrimaryTextColor:         tcell.ColorWhite,
	SecondaryTextColor:       tcell.ColorGray,
	InverseTextColor:         tcell.ColorDarkBlue,

	BgColorName:     "darkblue",
	AccentColorName: "yellow",
	TextColorName:   "white",
	HighlightBgName: "yellow",
	HighlightFgName: "black",
	SecondaryColor:  "gray",

	FieldFocusedBg:     tcell.ColorBlue,
	FieldUnfocusedBg:   tcell.ColorDarkBlue,
	ProgressFillColor:  tcell.ColorGreen,
	ProgressEmptyColor: tcell.ColorGray,

	ErrorColor:       tcell.ColorRed,
	ErrorColorName:   "red",
	WarningColor:     tcell.ColorYellow,
	WarningColorName: "yellow",
	SuccessColor:     tcell.ColorGreen,
	SuccessColorName: "green",

	LabelColor:     tcell.ColorGray,
	LabelColorName: "gray",
}

ThemeDefault is the original dark blue/yellow theme.

View Source
var ThemeDracula = Theme{
	Name:        "dracula",
	DisplayName: "Dracula",

	PrimitiveBackgroundColor: tcell.NewHexColor(0x282A36),
	ContrastBackgroundColor:  tcell.NewHexColor(0x44475A),
	BorderColor:              tcell.NewHexColor(0xBD93F9),
	PrimaryTextColor:         tcell.NewHexColor(0xF8F8F2),
	SecondaryTextColor:       tcell.NewHexColor(0x6272A4),
	InverseTextColor:         tcell.NewHexColor(0x282A36),

	BgColorName:     "#282a36",
	AccentColorName: "#bd93f9",
	TextColorName:   "#f8f8f2",
	HighlightBgName: "#bd93f9",
	HighlightFgName: "#282a36",
	SecondaryColor:  "#6272a4",

	FieldFocusedBg:     tcell.NewHexColor(0x44475A),
	FieldUnfocusedBg:   tcell.NewHexColor(0x282A36),
	ProgressFillColor:  tcell.NewHexColor(0x50FA7B),
	ProgressEmptyColor: tcell.NewHexColor(0x44475A),

	ErrorColor:       tcell.NewHexColor(0xFF5555),
	ErrorColorName:   "#ff5555",
	WarningColor:     tcell.NewHexColor(0xF1FA8C),
	WarningColorName: "#f1fa8c",
	SuccessColor:     tcell.NewHexColor(0x50FA7B),
	SuccessColorName: "#50fa7b",

	LabelColor:     tcell.NewHexColor(0x6272A4),
	LabelColorName: "#6272a4",
}

ThemeDracula uses the Dracula color scheme with purple accents.

View Source
var ThemeGruvbox = Theme{
	Name:        "gruvbox",
	DisplayName: "Gruvbox",

	PrimitiveBackgroundColor: tcell.NewHexColor(0x282828),
	ContrastBackgroundColor:  tcell.NewHexColor(0x3C3836),
	BorderColor:              tcell.NewHexColor(0xFABD2F),
	PrimaryTextColor:         tcell.NewHexColor(0xEBDBB2),
	SecondaryTextColor:       tcell.NewHexColor(0xA89984),
	InverseTextColor:         tcell.NewHexColor(0x282828),

	BgColorName:     "#282828",
	AccentColorName: "#fabd2f",
	TextColorName:   "#ebdbb2",
	HighlightBgName: "#fabd2f",
	HighlightFgName: "#282828",
	SecondaryColor:  "#a89984",

	FieldFocusedBg:     tcell.NewHexColor(0x504945),
	FieldUnfocusedBg:   tcell.NewHexColor(0x282828),
	ProgressFillColor:  tcell.NewHexColor(0xB8BB26),
	ProgressEmptyColor: tcell.NewHexColor(0x504945),

	ErrorColor:       tcell.NewHexColor(0xFB4934),
	ErrorColorName:   "#fb4934",
	WarningColor:     tcell.NewHexColor(0xFABD2F),
	WarningColorName: "#fabd2f",
	SuccessColor:     tcell.NewHexColor(0xB8BB26),
	SuccessColorName: "#b8bb26",

	LabelColor:     tcell.NewHexColor(0xA89984),
	LabelColorName: "#a89984",
}

ThemeGruvbox uses the Gruvbox retro groove color scheme with warm, earthy tones.

View Source
var ThemeHighContrast = Theme{
	Name:        "high_contrast",
	DisplayName: "High Contrast",

	PrimitiveBackgroundColor: tcell.NewHexColor(0x000000),
	ContrastBackgroundColor:  tcell.NewHexColor(0x000000),
	BorderColor:              tcell.ColorYellow,
	PrimaryTextColor:         tcell.ColorWhite,
	SecondaryTextColor:       tcell.ColorWhite,
	InverseTextColor:         tcell.NewHexColor(0x000000),

	BgColorName:     "#000000",
	AccentColorName: "yellow",
	TextColorName:   "white",
	HighlightBgName: "yellow",
	HighlightFgName: "#000000",
	SecondaryColor:  "white",

	FieldFocusedBg:     tcell.ColorYellow,
	FieldUnfocusedBg:   tcell.NewHexColor(0x000000),
	ProgressFillColor:  tcell.ColorYellow,
	ProgressEmptyColor: tcell.ColorWhite,

	ErrorColor:       tcell.ColorRed,
	ErrorColorName:   "red",
	WarningColor:     tcell.ColorYellow,
	WarningColorName: "yellow",
	SuccessColor:     tcell.ColorLime,
	SuccessColorName: "lime",

	LabelColor:     tcell.ColorWhite,
	LabelColorName: "white",
}

ThemeHighContrast uses true black background with bright yellow for accessibility.

View Source
var ThemeMonogreen = Theme{
	Name:        "monogreen",
	DisplayName: "Mono Green (Retro)",

	PrimitiveBackgroundColor: tcell.ColorBlack,
	ContrastBackgroundColor:  tcell.NewHexColor(0x0A1A0A),
	BorderColor:              tcell.ColorGreen,
	PrimaryTextColor:         tcell.ColorGreen,
	SecondaryTextColor:       tcell.ColorDarkGreen,
	InverseTextColor:         tcell.ColorBlack,

	BgColorName:     "black",
	AccentColorName: "green",
	TextColorName:   "green",
	HighlightBgName: "green",
	HighlightFgName: "black",
	SecondaryColor:  "darkgreen",

	FieldFocusedBg:     tcell.ColorDarkGreen,
	FieldUnfocusedBg:   tcell.ColorBlack,
	ProgressFillColor:  tcell.ColorLime,
	ProgressEmptyColor: tcell.ColorDarkGreen,

	ErrorColor:       tcell.ColorRed,
	ErrorColorName:   "red",
	WarningColor:     tcell.ColorYellow,
	WarningColorName: "yellow",
	SuccessColor:     tcell.ColorLime,
	SuccessColorName: "lime",

	LabelColor:     tcell.ColorDarkGreen,
	LabelColorName: "darkgreen",
}

ThemeMonogreen is a retro green-on-black theme inspired by classic CRT monitors.

View Source
var ThemeNames = []string{
	"default",
	"high_contrast",
	"dracula",
	"nord",
	"gruvbox",
	"monogreen",
}

ThemeNames returns the list of available theme names in display order.

View Source
var ThemeNord = Theme{
	Name:        "nord",
	DisplayName: "Nord",

	PrimitiveBackgroundColor: tcell.NewHexColor(0x2E3440),
	ContrastBackgroundColor:  tcell.NewHexColor(0x3B4252),
	BorderColor:              tcell.NewHexColor(0x88C0D0),
	PrimaryTextColor:         tcell.NewHexColor(0xECEFF4),
	SecondaryTextColor:       tcell.NewHexColor(0xD8DEE9),
	InverseTextColor:         tcell.NewHexColor(0x2E3440),

	BgColorName:     "#2e3440",
	AccentColorName: "#88c0d0",
	TextColorName:   "#eceff4",
	HighlightBgName: "#88c0d0",
	HighlightFgName: "#2e3440",
	SecondaryColor:  "#d8dee9",

	FieldFocusedBg:     tcell.NewHexColor(0x3B4252),
	FieldUnfocusedBg:   tcell.NewHexColor(0x2E3440),
	ProgressFillColor:  tcell.NewHexColor(0xA3BE8C),
	ProgressEmptyColor: tcell.NewHexColor(0x4C566A),

	ErrorColor:       tcell.NewHexColor(0xBF616A),
	ErrorColorName:   "#bf616a",
	WarningColor:     tcell.NewHexColor(0xEBCB8B),
	WarningColorName: "#ebcb8b",
	SuccessColor:     tcell.NewHexColor(0xA3BE8C),
	SuccessColorName: "#a3be8c",

	LabelColor:     tcell.NewHexColor(0x4C566A),
	LabelColorName: "#4c566a",
}

ThemeNord uses the Nord arctic color palette with cool blue tones.

Functions

func ApplyTheme added in v2.9.0

func ApplyTheme(theme *Theme)

ApplyTheme applies the given theme to tview's global styles.

func BuildAndRetry

func BuildAndRetry(
	cfg *config.Instance,
	builder func() (*tview.Application, error),
) error

BuildAndRetry attempts to build and display a TUI dialog, retrying with alternate settings on error. It's used to work around issues on MiSTer, which has an unusual setup for showing TUI applications. When cfg is non-nil, ZapScript execution is disabled while the TUI is open.

func BuildExportLogModal

func BuildExportLogModal(
	pages *tview.Pages,
	app *tview.Application,
	pl platforms.Platform,
	logDestPath string,
	logDestName string,
)

BuildExportLogModal creates the log export page with PageFrame.

func BuildGenerateDBPage

func BuildGenerateDBPage(
	cfg *config.Instance,
	pages *tview.Pages,
	app *tview.Application,
)

BuildGenerateDBPage creates the media database update page with PageFrame.

func BuildMain

func BuildMain(
	cfg *config.Instance,
	pl platforms.Platform,
	isRunning func() bool,
	logDestPath string,
	logDestName string,
) (*tview.Application, error)

func BuildMainPage

func BuildMainPage(
	cfg *config.Instance,
	pages *tview.Pages,
	app *tview.Application,
	pl platforms.Platform,
	isRunning func() bool,
	logDestPath string,
	logDestName string,
	session *Session,
) tview.Primitive

func BuildSearchMedia

func BuildSearchMedia(svc SettingsService, pages *tview.Pages, app *tview.Application, session *Session)

BuildSearchMedia creates the search media page. If session is nil, the default session is used.

func BuildSettingsMainMenu

func BuildSettingsMainMenu(
	cfg *config.Instance,
	pages *tview.Pages,
	app *tview.Application,
	pl platforms.Platform,
	rebuildMainPage func(),
	logDestPath string,
	logDestName string,
)

BuildSettingsMainMenu creates the top-level settings menu with Audio, Readers, and Advanced options.

func BuildSettingsMainMenuWithService added in v2.9.0

func BuildSettingsMainMenuWithService(
	cfg *config.Instance,
	svc SettingsService,
	pages *tview.Pages,
	app *tview.Application,
	pl platforms.Platform,
	rebuildMainPage func(),
	logDestPath string,
	logDestName string,
)

BuildSettingsMainMenuWithService creates the settings menu using the given SettingsService.

func BuildTagsWriteMenu

func BuildTagsWriteMenu(svc SettingsService, pages *tview.Pages, app *tview.Application, session *Session)

BuildTagsWriteMenu creates the tag write menu. If session is nil, the default session is used.

func CenterWidget

func CenterWidget(width, height int, p tview.Primitive) tview.Primitive

CenterWidget creates a fixed-size centered layout for CRT displays.

func FormatLabel added in v2.9.0

func FormatLabel(text string) string

FormatLabel returns a tview color markup string for a label. Use this for inline labels in dynamic text (e.g., status displays).

func NewLabel added in v2.9.0

func NewLabel(text string) *tview.TextView

NewLabel creates a consistently styled label TextView. Labels use LabelColor, are bold, and have a colon suffix.

func ResponsiveMaxWidget added in v2.9.0

func ResponsiveMaxWidget(maxWidth, maxHeight int, p tview.Primitive) tview.Primitive

ResponsiveMaxWidget creates a centered layout that respects max width/height but clamps to terminal size when smaller. This prevents clipping on small terminals.

func SetBoxTitle added in v2.9.0

func SetBoxTitle(box interface{ SetTitle(string) *tview.Box }, title string)

SetBoxTitle sets a box title with consistent padding.

func SetCurrentTheme added in v2.9.0

func SetCurrentTheme(name string) bool

SetCurrentTheme sets the current theme by name. Returns false if the theme name is not found.

func SetInputLabel added in v2.9.0

func SetInputLabel(input *tview.InputField, text string) *tview.InputField

SetInputLabel configures an InputField's label with consistent styling. Labels use LabelColor, are bold, and have a colon suffix with trailing space.

func SetupOSKInputField added in v2.9.0

func SetupOSKInputField(
	field *tview.InputField,
	pages *tview.Pages,
	app *tview.Application,
	onUpdate func(string),
) *tview.InputField

SetupOSKInputField configures an InputField to open the on-screen keyboard when Enter is pressed (if OSK is enabled in settings). The onUpdate callback is called when the text changes via OSK, allowing the caller to update state.

func ShowConfirmModal added in v2.9.0

func ShowConfirmModal(pages *tview.Pages, app *tview.Application, message string, onYes, onNo func())

ShowConfirmModal displays a confirmation dialog with Yes/No buttons. onYes is called when the user clicks "Yes", onNo is called for "No" or Escape.

func ShowErrorModal added in v2.9.0

func ShowErrorModal(pages *tview.Pages, app *tview.Application, message string, onDismiss func())

ShowErrorModal displays an error message modal to the user. onDismiss is called when the modal is closed and should restore focus.

func ShowInfoModal added in v2.9.0

func ShowInfoModal(pages *tview.Pages, app *tview.Application, title, message string)

ShowInfoModal displays an informational modal with a title and OK button.

func ShowOSKModal added in v2.9.0

func ShowOSKModal(
	pages *tview.Pages,
	app *tview.Application,
	initialValue string,
	onSubmit func(string),
	onCancel func(),
)

ShowOSKModal displays an on-screen keyboard modal for text input. The keyboard is sized to fit within CRT mode constraints (75x15). onSubmit is called with the final text when the user confirms. onCancel is called when the user cancels (Escape or Cancel button).

func ShowWaitingModal added in v2.9.0

func ShowWaitingModal(pages *tview.Pages, app *tview.Application, message string, onCancel func()) func()

ShowWaitingModal displays a modal while waiting for user action (like placing a tag). Returns a cleanup function that removes the modal.

func WriteTagWithModal added in v2.9.0

func WriteTagWithModal(
	pages *tview.Pages,
	app *tview.Application,
	svc SettingsService,
	text string,
	onComplete func(success bool),
)

WriteTagWithModal displays a waiting modal while writing to a tag. It handles the full flow: show waiting modal -> call API -> show result. onComplete is called after the operation completes (success or failure) with the focus target.

Types

type ButtonBar added in v2.9.0

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

ButtonBar creates a horizontal bar of buttons with arrow key navigation.

func NewButtonBar added in v2.9.0

func NewButtonBar(app *tview.Application) *ButtonBar

NewButtonBar creates a new button bar.

func (*ButtonBar) AddButton added in v2.9.0

func (bb *ButtonBar) AddButton(label string, action func()) *ButtonBar

AddButton adds a button to the bar.

func (*ButtonBar) AddButtonWithHelp added in v2.9.0

func (bb *ButtonBar) AddButtonWithHelp(label, helpText string, action func()) *ButtonBar

AddButtonWithHelp adds a button with associated help text.

func (*ButtonBar) Draw added in v2.9.0

func (bb *ButtonBar) Draw(screen tcell.Screen)

Draw renders the button bar.

func (*ButtonBar) Focus added in v2.9.0

func (bb *ButtonBar) Focus(delegate func(p tview.Primitive))

Focus is called when the button bar receives focus.

func (*ButtonBar) GetFirstButton added in v2.9.0

func (bb *ButtonBar) GetFirstButton() *tview.Button

GetFirstButton returns the first button for focus purposes.

func (*ButtonBar) HasFocus added in v2.9.0

func (bb *ButtonBar) HasFocus() bool

HasFocus returns whether the button bar has focus.

func (*ButtonBar) InputHandler added in v2.9.0

func (bb *ButtonBar) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles keyboard input for the button bar.

func (*ButtonBar) MouseHandler added in v2.9.0

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

MouseHandler handles mouse input for the button bar.

func (*ButtonBar) SetHelpCallback added in v2.9.0

func (bb *ButtonBar) SetHelpCallback(fn func(string)) *ButtonBar

SetHelpCallback sets the callback for when button focus changes.

func (*ButtonBar) SetOnDown added in v2.9.0

func (bb *ButtonBar) SetOnDown(fn func()) *ButtonBar

SetOnDown sets the callback for when Down is pressed (to wrap to top of content).

func (*ButtonBar) SetOnLeft added in v2.9.0

func (bb *ButtonBar) SetOnLeft(fn func()) *ButtonBar

SetOnLeft sets the callback for when Left is pressed on the first button.

func (*ButtonBar) SetOnRight added in v2.9.0

func (bb *ButtonBar) SetOnRight(fn func()) *ButtonBar

SetOnRight sets the callback for when Right is pressed on the last button.

func (*ButtonBar) SetOnUp added in v2.9.0

func (bb *ButtonBar) SetOnUp(fn func()) *ButtonBar

SetOnUp sets the callback for when Up is pressed (to navigate back to content).

func (*ButtonBar) SetOnWrap added in v2.9.0

func (bb *ButtonBar) SetOnWrap(fn func()) *ButtonBar

SetOnWrap sets the callback for when Tab is pressed on the last button (to wrap to top).

func (*ButtonBar) SetupNavigation added in v2.9.0

func (bb *ButtonBar) SetupNavigation(onEscape func()) *ButtonBar

SetupNavigation sets up the escape callback.

func (*ButtonBar) UpdateButtonLabel added in v2.9.0

func (bb *ButtonBar) UpdateButtonLabel(index int, label string)

UpdateButtonLabel updates the label of a button at the given index.

type ButtonGrid added in v2.9.0

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

ButtonGrid is a 2-row button grid for the main menu.

func NewButtonGrid added in v2.9.0

func NewButtonGrid(app *tview.Application, cols int) *ButtonGrid

NewButtonGrid creates a new 2-row button grid.

func (*ButtonGrid) AddRow added in v2.9.0

func (bg *ButtonGrid) AddRow(items ...*ButtonGridItem) *ButtonGrid

AddRow adds a row of buttons to the grid.

func (*ButtonGrid) Draw added in v2.9.0

func (bg *ButtonGrid) Draw(screen tcell.Screen)

Draw renders the button grid.

func (*ButtonGrid) Focus added in v2.9.0

func (bg *ButtonGrid) Focus(delegate func(p tview.Primitive))

Focus implements tview.Primitive.

func (*ButtonGrid) FocusFirst added in v2.9.0

func (bg *ButtonGrid) FocusFirst()

FocusFirst sets focus to first enabled button.

func (*ButtonGrid) GetFocus added in v2.9.0

func (bg *ButtonGrid) GetFocus() (row, col int)

GetFocus returns the current focused button position.

func (*ButtonGrid) InputHandler added in v2.9.0

func (bg *ButtonGrid) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles keyboard input.

func (*ButtonGrid) MouseHandler added in v2.9.0

func (bg *ButtonGrid) MouseHandler() func(
	action tview.MouseAction,
	event *tcell.EventMouse,
	setFocus func(p tview.Primitive),
) (bool, tview.Primitive)

MouseHandler handles mouse input.

func (*ButtonGrid) SetFocus added in v2.9.0

func (bg *ButtonGrid) SetFocus(row, col int)

SetFocus sets focus to a specific button position.

func (*ButtonGrid) SetOnEscape added in v2.9.0

func (bg *ButtonGrid) SetOnEscape(fn func()) *ButtonGrid

SetOnEscape sets the callback for escape key.

func (*ButtonGrid) SetOnHelp added in v2.9.0

func (bg *ButtonGrid) SetOnHelp(fn func(string)) *ButtonGrid

SetOnHelp sets the callback for help text changes.

type ButtonGridItem added in v2.9.0

type ButtonGridItem struct {
	Button   *tview.Button
	HelpText string
	Disabled bool
}

ButtonGridItem represents a button in the grid with its help text.

type CheckList added in v2.9.0

type CheckList struct {
	*tview.List
	// contains filtered or unexported fields
}

CheckList is a list with toggleable checkbox items for multi-select.

func NewCheckList added in v2.9.0

func NewCheckList(items, initiallySelected []string, onChange func(selected []string)) *CheckList

NewCheckList creates a new multi-select checkbox list.

func NewCheckListWithValues added in v2.9.0

func NewCheckListWithValues(
	items []CheckListItem,
	initiallySelected []string,
	onChange func(selected []string),
) *CheckList

NewCheckListWithValues creates a checklist with separate labels and values.

func (*CheckList) GetSelected added in v2.9.0

func (cl *CheckList) GetSelected() []string

GetSelected returns the list of selected item values.

func (*CheckList) GetSelectedCount added in v2.9.0

func (cl *CheckList) GetSelectedCount() int

GetSelectedCount returns the number of selected items.

func (*CheckList) SetSelectionSyncFunc added in v2.9.0

func (cl *CheckList) SetSelectionSyncFunc(fn func(count int))

SetSelectionSyncFunc sets a callback that fires when selection changes.

func (*CheckList) SetupNavigation added in v2.9.0

func (cl *CheckList) SetupNavigation(pages *tview.Pages, previousPage string) *CheckList

SetupNavigation adds escape key handling.

type CheckListItem added in v2.9.0

type CheckListItem struct {
	Label string
	Value string
}

CheckListItem represents an item with separate display label and value.

type DefaultSettingsService added in v2.9.0

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

DefaultSettingsService implements SettingsService using an APIClient.

func NewSettingsService added in v2.9.0

func NewSettingsService(apiClient client.APIClient) *DefaultSettingsService

NewSettingsService creates a SettingsService that uses the given APIClient.

func (*DefaultSettingsService) CancelWriteTag added in v2.9.0

func (s *DefaultSettingsService) CancelWriteTag(ctx context.Context) error

CancelWriteTag cancels a pending write operation.

func (*DefaultSettingsService) GetReaders added in v2.9.0

GetReaders fetches connected readers from the API.

func (*DefaultSettingsService) GetSettings added in v2.9.0

GetSettings fetches current settings from the API.

func (*DefaultSettingsService) GetSystems added in v2.9.0

func (s *DefaultSettingsService) GetSystems(ctx context.Context) ([]models.System, error)

GetSystems fetches available systems from the API.

func (*DefaultSettingsService) GetTokens added in v2.9.0

GetTokens fetches currently active tokens from the API.

func (*DefaultSettingsService) SearchMedia added in v2.9.0

SearchMedia searches for media matching the given parameters.

func (*DefaultSettingsService) UpdateSettings added in v2.9.0

func (s *DefaultSettingsService) UpdateSettings(ctx context.Context, params models.UpdateSettingsParams) error

UpdateSettings sends a settings update to the API.

func (*DefaultSettingsService) WriteTag added in v2.9.0

func (s *DefaultSettingsService) WriteTag(ctx context.Context, text string) error

WriteTag writes text to a tag via the reader.

type ExitDelayOption added in v2.9.0

type ExitDelayOption struct {
	Label string
	Value float32
}

ExitDelayOption pairs a display label with its numeric value.

type LogEntry added in v2.7.0

type LogEntry struct {
	Level   string `json:"level"`
	Time    string `json:"time"`
	Message string `json:"message"`
}

LogEntry represents a parsed JSON log line

type MainFrame added in v2.9.0

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

MainFrame wraps the main page content and adds keyboard hints to the bottom border.

func NewMainFrame added in v2.9.0

func NewMainFrame(content tview.Primitive) *MainFrame

NewMainFrame creates a wrapper that adds hints to the main page.

func (*MainFrame) Draw added in v2.9.0

func (mf *MainFrame) Draw(screen tcell.Screen)

Draw renders the wrapped content and adds hints to the bottom border.

func (*MainFrame) Focus added in v2.9.0

func (mf *MainFrame) Focus(delegate func(p tview.Primitive))

Focus delegates to the wrapped content.

func (*MainFrame) HasFocus added in v2.9.0

func (mf *MainFrame) HasFocus() bool

HasFocus returns whether the wrapped content has focus.

func (*MainFrame) InputHandler added in v2.9.0

func (mf *MainFrame) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler delegates to the wrapped content.

func (*MainFrame) MouseHandler added in v2.9.0

func (mf *MainFrame) MouseHandler() func(
	action tview.MouseAction,
	event *tcell.EventMouse,
	setFocus func(p tview.Primitive),
) (bool, tview.Primitive)

MouseHandler delegates to the wrapped content.

type OnScreenKeyboard added in v2.9.0

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

OnScreenKeyboard provides a virtual keyboard for controller input.

func NewOnScreenKeyboard added in v2.9.0

func NewOnScreenKeyboard(initialText string, onSubmit func(string), onCancel func()) *OnScreenKeyboard

NewOnScreenKeyboard creates a new on-screen keyboard widget.

func (*OnScreenKeyboard) Draw added in v2.9.0

func (o *OnScreenKeyboard) Draw(screen tcell.Screen)

Draw renders the keyboard to the screen.

func (*OnScreenKeyboard) Focus added in v2.9.0

func (o *OnScreenKeyboard) Focus(delegate func(p tview.Primitive))

Focus is called when the keyboard receives focus.

func (*OnScreenKeyboard) GetText added in v2.9.0

func (o *OnScreenKeyboard) GetText() string

GetText returns the current input text.

func (*OnScreenKeyboard) HasFocus added in v2.9.0

func (o *OnScreenKeyboard) HasFocus() bool

HasFocus returns whether the keyboard has focus.

func (*OnScreenKeyboard) InputHandler added in v2.9.0

func (o *OnScreenKeyboard) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles keyboard input for navigation and selection.

func (*OnScreenKeyboard) SetText added in v2.9.0

func (o *OnScreenKeyboard) SetText(text string) *OnScreenKeyboard

SetText sets the current input text.

type PageFrame added in v2.9.0

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

PageFrame provides a consistent page structure with: - Breadcrumb title in top border - Main content area - Optional info text line (above help text) - Dynamic help text line - ButtonBar footer - Keyboard hints in bottom border

func NewPageFrame added in v2.9.0

func NewPageFrame(app *tview.Application) *PageFrame

NewPageFrame creates a new page frame with the given application reference.

func (*PageFrame) Draw added in v2.9.0

func (pf *PageFrame) Draw(screen tcell.Screen)

Draw renders the page frame with bottom border hints.

func (*PageFrame) Focus added in v2.9.0

func (pf *PageFrame) Focus(delegate func(p tview.Primitive))

Focus implements tview.Primitive.

func (*PageFrame) FocusButtonBar added in v2.9.0

func (pf *PageFrame) FocusButtonBar()

FocusButtonBar sets focus to the button bar.

func (*PageFrame) FocusContent added in v2.9.0

func (pf *PageFrame) FocusContent()

FocusContent sets focus to the content primitive.

func (*PageFrame) FocusContentFirst added in v2.9.0

func (pf *PageFrame) FocusContentFirst()

FocusContentFirst sets focus to the content and selects the first item (for wrap from bottom).

func (*PageFrame) FocusContentLast added in v2.9.0

func (pf *PageFrame) FocusContentLast()

FocusContentLast sets focus to the content and selects the last item (for wrap from top).

func (*PageFrame) GetButtonBar added in v2.9.0

func (pf *PageFrame) GetButtonBar() *ButtonBar

GetButtonBar returns the button bar.

func (*PageFrame) GetContent added in v2.9.0

func (pf *PageFrame) GetContent() tview.Primitive

GetContent returns the content primitive.

func (*PageFrame) HasFocus added in v2.9.0

func (pf *PageFrame) HasFocus() bool

HasFocus implements tview.Primitive.

func (*PageFrame) InputHandler added in v2.9.0

func (pf *PageFrame) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler implements tview.Primitive.

func (*PageFrame) MouseHandler added in v2.9.0

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

MouseHandler implements tview.Primitive.

func (*PageFrame) SetButtonBar added in v2.9.0

func (pf *PageFrame) SetButtonBar(bar *ButtonBar) *PageFrame

SetButtonBar sets the button bar at the bottom of the frame. Call SetupContentToButtonNavigation after this for list content navigation.

func (*PageFrame) SetContent added in v2.9.0

func (pf *PageFrame) SetContent(content tview.Primitive) *PageFrame

SetContent sets the main content primitive.

func (*PageFrame) SetHelpText added in v2.9.0

func (pf *PageFrame) SetHelpText(text string) *PageFrame

SetHelpText sets the dynamic help text displayed above the button bar.

func (*PageFrame) SetInfoText added in v2.9.0

func (pf *PageFrame) SetInfoText(text string) *PageFrame

SetInfoText sets the optional info text displayed above the help text. If text is empty, the info line is hidden. If the text is longer than the available width, it is truncated from the left with "...".

func (*PageFrame) SetOnEscape added in v2.9.0

func (pf *PageFrame) SetOnEscape(fn func()) *PageFrame

SetOnEscape sets the callback when ESC is pressed.

func (*PageFrame) SetTitle added in v2.9.0

func (pf *PageFrame) SetTitle(path ...string) *PageFrame

SetTitle sets the page title using breadcrumb-style path segments. Example: SetTitle("Settings", "Readers", "Manage") displays " Settings > Readers > Manage "

func (*PageFrame) SetupContentToButtonNavigation added in v2.9.0

func (pf *PageFrame) SetupContentToButtonNavigation()

SetupContentToButtonNavigation sets up full wrap navigation between content and button bar. This should be called after setting content and button bar.

type PrimitiveWithSetBorder

type PrimitiveWithSetBorder interface {
	tview.Primitive
	SetBorder(arg bool) *tview.Box
}

type ProgressBar

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

func NewProgressBar

func NewProgressBar() *ProgressBar

func (*ProgressBar) Draw

func (p *ProgressBar) Draw(screen tcell.Screen)

func (*ProgressBar) GetProgress

func (p *ProgressBar) GetProgress() float64

func (*ProgressBar) SetProgress

func (p *ProgressBar) SetProgress(progress float64) *ProgressBar

type ReaderInfo added in v2.9.0

type ReaderInfo struct {
	Driver string
	Count  int
}

ReaderInfo holds the details of connected readers.

type ScanState added in v2.9.0

type ScanState int

ScanState represents the current state of the scanning area.

const (
	ScanStateNoReader ScanState = iota
	ScanStateWaiting
	ScanStateScanned
)

type ScanningArea added in v2.9.0

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

ScanningArea is a custom widget that displays NFC scanning status.

func NewScanningArea added in v2.9.0

func NewScanningArea(app *tview.Application) *ScanningArea

NewScanningArea creates a new scanning area widget.

func (*ScanningArea) ClearToken added in v2.9.0

func (sa *ScanningArea) ClearToken() *ScanningArea

ClearToken clears token info and returns to waiting state if reader connected.

func (*ScanningArea) Draw added in v2.9.0

func (sa *ScanningArea) Draw(screen tcell.Screen)

Draw renders the scanning area based on current state.

func (*ScanningArea) SetReaderInfo added in v2.9.0

func (sa *ScanningArea) SetReaderInfo(count int, driver string) *ScanningArea

SetReaderInfo updates the reader info and adjusts state accordingly.

func (*ScanningArea) SetState added in v2.9.0

func (sa *ScanningArea) SetState(state ScanState) *ScanningArea

SetState changes the current state.

func (*ScanningArea) SetTokenInfo added in v2.9.0

func (sa *ScanningArea) SetTokenInfo(scanTime, uid, value string) *ScanningArea

SetTokenInfo sets the scanned token details and changes to scanned state.

type ScrollIndicatorList added in v2.9.0

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

ScrollIndicatorList wraps a tview.List and draws scroll indicators.

func NewScrollIndicatorList added in v2.9.0

func NewScrollIndicatorList() *ScrollIndicatorList

NewScrollIndicatorList creates a new list with scroll indicators.

func (*ScrollIndicatorList) Draw added in v2.9.0

func (sil *ScrollIndicatorList) Draw(screen tcell.Screen)

Draw renders the list with scroll indicators.

func (*ScrollIndicatorList) Focus added in v2.9.0

func (sil *ScrollIndicatorList) Focus(delegate func(p tview.Primitive))

Focus delegates focus to the underlying list.

func (*ScrollIndicatorList) GetList added in v2.9.0

func (sil *ScrollIndicatorList) GetList() *tview.List

GetList returns the underlying tview.List for configuration.

func (*ScrollIndicatorList) HasFocus added in v2.9.0

func (sil *ScrollIndicatorList) HasFocus() bool

HasFocus returns whether the list has focus.

func (*ScrollIndicatorList) InputHandler added in v2.9.0

func (sil *ScrollIndicatorList) InputHandler() func(*tcell.EventKey, func(tview.Primitive))

InputHandler returns the list's input handler.

func (*ScrollIndicatorList) MouseHandler added in v2.9.0

func (sil *ScrollIndicatorList) MouseHandler() func(
	tview.MouseAction, *tcell.EventMouse, func(tview.Primitive),
) (bool, tview.Primitive)

MouseHandler returns the list's mouse handler.

type Session added in v2.9.0

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

Session holds TUI session state that persists across page navigations. It is thread-safe and can be created per-test for parallel test execution.

func DefaultSession added in v2.9.0

func DefaultSession() *Session

DefaultSession returns the default session instance for production use.

func NewSession added in v2.9.0

func NewSession() *Session

NewSession creates a new TUI session with default values.

func (*Session) ClearSearchMedia added in v2.9.0

func (s *Session) ClearSearchMedia()

ClearSearchMedia resets all search media state to defaults.

func (*Session) GetMainMenuFocus added in v2.9.0

func (s *Session) GetMainMenuFocus() (row, col int)

GetMainMenuFocus returns the current main menu focus position.

func (*Session) GetSearchMediaName added in v2.9.0

func (s *Session) GetSearchMediaName() string

GetSearchMediaName returns the search media name query.

func (*Session) GetSearchMediaSystem added in v2.9.0

func (s *Session) GetSearchMediaSystem() string

GetSearchMediaSystem returns the search media system filter.

func (*Session) GetSearchMediaSystemName added in v2.9.0

func (s *Session) GetSearchMediaSystemName() string

GetSearchMediaSystemName returns the search media system display name.

func (*Session) GetWriteTagZapScript added in v2.9.0

func (s *Session) GetWriteTagZapScript() string

GetWriteTagZapScript returns the current ZapScript for the write tag form.

func (*Session) SetMainMenuFocus added in v2.9.0

func (s *Session) SetMainMenuFocus(row, col int)

SetMainMenuFocus sets the main menu focus position.

func (*Session) SetSearchMediaName added in v2.9.0

func (s *Session) SetSearchMediaName(v string)

SetSearchMediaName sets the search media name query.

func (*Session) SetSearchMediaSystem added in v2.9.0

func (s *Session) SetSearchMediaSystem(v string)

SetSearchMediaSystem sets the search media system filter.

func (*Session) SetSearchMediaSystemName added in v2.9.0

func (s *Session) SetSearchMediaSystemName(v string)

SetSearchMediaSystemName sets the search media system display name.

func (*Session) SetWriteTagZapScript added in v2.9.0

func (s *Session) SetWriteTagZapScript(v string)

SetWriteTagZapScript sets the ZapScript for the write tag form.

type SettingsList added in v2.9.0

type SettingsList struct {
	*tview.List
	// contains filtered or unexported fields
}

SettingsList wraps a tview.List with consistent navigation and manual highlight management.

func NewSettingsList added in v2.9.0

func NewSettingsList(pages *tview.Pages, previousPage string) *SettingsList

NewSettingsList creates a new settings list with arrow key navigation.

func (*SettingsList) AddAction added in v2.9.0

func (sl *SettingsList) AddAction(
	label string,
	description string,
	action func(),
) *SettingsList

AddAction adds a simple action item (like a submenu link or button).

func (*SettingsList) AddBack added in v2.9.0

func (sl *SettingsList) AddBack() *SettingsList

AddBack adds a "Back" action item with default description.

func (*SettingsList) AddBackWithDesc added in v2.9.0

func (sl *SettingsList) AddBackWithDesc(description string) *SettingsList

AddBackWithDesc adds a "Back" action item with custom description.

func (*SettingsList) AddCycle added in v2.9.0

func (sl *SettingsList) AddCycle(
	label string,
	description string,
	options []string,
	currentIndex *int,
	onChange func(string, int),
) *SettingsList

AddCycle adds an inline cycle selector to the list.

func (*SettingsList) AddNavAction added in v2.9.0

func (sl *SettingsList) AddNavAction(
	label string,
	description string,
	action func(),
) *SettingsList

AddNavAction adds a navigation action that opens a submenu or new page. Displays with a ">" prefix to indicate navigation.

func (*SettingsList) AddToggle added in v2.9.0

func (sl *SettingsList) AddToggle(
	label string,
	description string,
	value *bool,
	onChange func(bool),
) *SettingsList

AddToggle adds a boolean toggle item to the list.

func (*SettingsList) GetCurrentDescription added in v2.9.0

func (sl *SettingsList) GetCurrentDescription() string

GetCurrentDescription returns the description of the currently selected item.

func (*SettingsList) SetDynamicHelpMode added in v2.9.0

func (sl *SettingsList) SetDynamicHelpMode(enabled bool) *SettingsList

SetDynamicHelpMode enables or disables dynamic help mode. When enabled, inline descriptions are hidden and the help callback is used instead.

func (*SettingsList) SetHelpCallback added in v2.9.0

func (sl *SettingsList) SetHelpCallback(fn func(string)) *SettingsList

SetHelpCallback sets a callback that fires when selection changes. The callback receives the description of the currently selected item. Use this with PageFrame's SetHelpText for dynamic help.

func (*SettingsList) SetRebuildPrevious added in v2.9.0

func (sl *SettingsList) SetRebuildPrevious(fn func()) *SettingsList

SetRebuildPrevious sets a callback to rebuild the previous page on Back navigation. When set, going back will call this function instead of just switching to the cached page.

func (*SettingsList) SetupCycleKeys added in v2.9.0

func (sl *SettingsList) SetupCycleKeys(
	cycleIndices map[int]func(delta int),
) *SettingsList

SetupCycleKeys adds Left/Right key handling for cycle items.

func (*SettingsList) TriggerInitialHelp added in v2.9.0

func (sl *SettingsList) TriggerInitialHelp() *SettingsList

TriggerInitialHelp calls the help callback with the first item's description. Call this after adding all items to set the initial help text.

type SettingsService added in v2.9.0

type SettingsService interface {
	// GetSettings fetches current settings from the API.
	GetSettings(ctx context.Context) (*models.SettingsResponse, error)

	// UpdateSettings sends a settings update to the API.
	UpdateSettings(ctx context.Context, params models.UpdateSettingsParams) error

	// GetSystems fetches available systems from the API.
	GetSystems(ctx context.Context) ([]models.System, error)

	// GetTokens fetches currently active tokens from the API.
	GetTokens(ctx context.Context) (*models.TokensResponse, error)

	// GetReaders fetches connected readers from the API.
	GetReaders(ctx context.Context) (*models.ReadersResponse, error)

	// WriteTag writes text to a tag via the reader.
	WriteTag(ctx context.Context, text string) error

	// CancelWriteTag cancels a pending write operation.
	CancelWriteTag(ctx context.Context) error

	// SearchMedia searches for media matching the given parameters.
	SearchMedia(ctx context.Context, params models.SearchParams) (*models.SearchResults, error)
}

SettingsService handles settings API operations.

type SystemItem added in v2.9.0

type SystemItem struct {
	ID   string
	Name string
}

SystemItem represents a system with ID and display name.

type SystemSelector added in v2.9.0

type SystemSelector struct {
	*ScrollIndicatorList
	// contains filtered or unexported fields
}

SystemSelector is a reusable system selection component. It can operate in single-select or multi-select mode.

func NewSystemSelector added in v2.9.0

func NewSystemSelector(cfg *SystemSelectorConfig) *SystemSelector

NewSystemSelector creates a new system selector with the given configuration.

func (*SystemSelector) GetCurrentItem added in v2.9.0

func (ss *SystemSelector) GetCurrentItem() int

GetCurrentItem returns the index of the currently selected list item.

func (*SystemSelector) GetItemCount added in v2.9.0

func (ss *SystemSelector) GetItemCount() int

GetItemCount returns the number of items in the list.

func (*SystemSelector) GetSelected added in v2.9.0

func (ss *SystemSelector) GetSelected() []string

GetSelected returns the list of selected system IDs.

func (*SystemSelector) GetSelectedCount added in v2.9.0

func (ss *SystemSelector) GetSelectedCount() int

GetSelectedCount returns the number of selected items.

func (*SystemSelector) GetSelectedSingle added in v2.9.0

func (ss *SystemSelector) GetSelectedSingle() string

GetSelectedSingle returns the currently selected system ID (single-select mode). Returns empty string if "All" is selected or in multi-select mode.

func (*SystemSelector) SetCurrentItem added in v2.9.0

func (ss *SystemSelector) SetCurrentItem(index int)

SetCurrentItem sets the currently selected list item.

func (*SystemSelector) SetInputCapture added in v2.9.0

func (ss *SystemSelector) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKey)

SetInputCapture sets the input capture function on the underlying list.

type SystemSelectorConfig added in v2.9.0

type SystemSelectorConfig struct {
	OnMulti     func(selected []string)
	OnSingle    func(systemID string)
	Systems     []SystemItem
	Selected    []string
	Mode        SystemSelectorMode
	IncludeAll  bool
	AutoConfirm bool // Single-select only: auto-close on selection
}

SystemSelectorConfig configures a new SystemSelector.

type SystemSelectorMode added in v2.9.0

type SystemSelectorMode int

SystemSelectorMode defines whether the selector allows single or multiple selections.

const (
	// SystemSelectorSingle allows selecting one system (with optional "All" option).
	SystemSelectorSingle SystemSelectorMode = iota
	// SystemSelectorMulti allows selecting multiple systems (checkbox style).
	SystemSelectorMulti
)

type Theme added in v2.9.0

type Theme struct {
	HighlightFgName          string
	SecondaryColor           string
	BgColorName              string
	Name                     string
	HighlightBgName          string
	AccentColorName          string
	TextColorName            string
	DisplayName              string
	SuccessColorName         string
	WarningColorName         string
	ErrorColorName           string
	LabelColorName           string
	ContrastBackgroundColor  tcell.Color
	BorderColor              tcell.Color
	PrimitiveBackgroundColor tcell.Color
	FieldFocusedBg           tcell.Color
	FieldUnfocusedBg         tcell.Color
	ProgressFillColor        tcell.Color
	ProgressEmptyColor       tcell.Color
	ErrorColor               tcell.Color
	PrimaryTextColor         tcell.Color
	WarningColor             tcell.Color
	SecondaryTextColor       tcell.Color
	SuccessColor             tcell.Color
	InverseTextColor         tcell.Color
	LabelColor               tcell.Color
}

Theme defines all colors used in the TUI.

func CurrentTheme added in v2.9.0

func CurrentTheme() *Theme

CurrentTheme returns the currently active theme.

type TokenInfo added in v2.9.0

type TokenInfo struct {
	Time  string
	UID   string
	Value string
}

TokenInfo holds the details of a scanned token.

type VerticalDivider added in v2.9.0

type VerticalDivider struct {
	*tview.Box
}

VerticalDivider draws a vertical line for separating columns.

func NewVerticalDivider added in v2.9.0

func NewVerticalDivider() *VerticalDivider

NewVerticalDivider creates a new vertical divider.

func (*VerticalDivider) Draw added in v2.9.0

func (vd *VerticalDivider) Draw(screen tcell.Screen)

Draw renders the vertical divider.

Jump to

Keyboard shortcuts

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