Documentation
¶
Overview ¶
Package tui provides a terminal user interface for managing EPOS environments.
Index ¶
- Constants
- Variables
- func ApplyButtonStyle(btn *tview.Button)
- func ApplyDropDownStyle(dd *tview.DropDown)
- func CenterPrimitive(p tview.Primitive, width, height int) tview.Primitive
- func CenterPrimitiveFixed(p tview.Primitive, width, height int) tview.Primitive
- func InitStyles()
- func NewStyledButton(label string, selected func()) *tview.Button
- func NewStyledForm() *tview.Form
- func NewStyledInactiveButton(label string, selected func()) *tview.Button
- func NewStyledInputField(label, value string) *tview.InputField
- func NewStyledList() *tview.List
- func NewStyledTextView() *tview.TextView
- func Run() error
- type App
- func (a *App) FlashMessage(message string, duration time.Duration)
- func (a *App) PopFocus() tview.Primitive
- func (a *App) PushFocus()
- func (a *App) Quit()
- func (a *App) ResetToHome(opts ResetOptions)
- func (a *App) RunBackgroundTask(opts TaskOptions)
- func (a *App) ShowConfirmation(opts ConfirmationOptions)
- func (a *App) ShowError(message string)
- func (a *App) ShowModalForm(opts ModalFormOptions)
- func (a *App) UpdateFooter(contextKey ScreenKey)
- func (a *App) UpdateFooterCustom(section string, keys []string)
- type ConfirmationOptions
- type DetailRow
- type DetailsPanel
- func (dp *DetailsPanel) Clear()
- func (dp *DetailsPanel) CycleFocus()
- func (dp *DetailsPanel) CycleFocusBackward()
- func (dp *DetailsPanel) GetCurrentDetailsName() string
- func (dp *DetailsPanel) GetCurrentDetailsType() string
- func (dp *DetailsPanel) GetFlex() *tview.Flex
- func (dp *DetailsPanel) IsShown() bool
- func (dp *DetailsPanel) RefreshFiles()
- func (dp *DetailsPanel) SetupInput()
- func (dp *DetailsPanel) Update(name, envType string, focus bool)
- type EnvList
- type FilePicker
- type FocusButton
- type FooterText
- type FormButton
- type FormField
- type KeyHint
- type ModalFormOptions
- type OperationProgress
- type OutputWriter
- type ResetOptions
- type ScreenKey
- type TaskOptions
- type Theme
- func (t *Theme) DestructiveTag(attrs string) string
- func (t *Theme) Hex(color tcell.Color) string
- func (t *Theme) MutedTag(attrs string) string
- func (t *Theme) PrimaryTag(attrs string) string
- func (t *Theme) SecondaryTag(attrs string) string
- func (t *Theme) Tag(color tcell.Color, attrs string) string
Constants ¶
const ( StateRunning = "running" StateSuccess = "success" StateError = "error" )
Variables ¶
var DefaultTheme = &Theme{ Primary: tcell.NewRGBColor(90, 180, 105), OnPrimary: tcell.NewRGBColor(0, 0, 0), Secondary: tcell.NewRGBColor(229, 161, 14), OnSecondary: tcell.NewRGBColor(0, 0, 0), Error: tcell.NewRGBColor(200, 60, 60), OnError: tcell.NewRGBColor(255, 255, 255), Destructive: tcell.NewRGBColor(200, 60, 60), OnDestructive: tcell.NewRGBColor(255, 255, 255), Success: tcell.NewRGBColor(90, 180, 105), OnSuccess: tcell.NewRGBColor(0, 0, 0), Background: tcell.NewRGBColor(20, 20, 20), OnBackground: tcell.NewRGBColor(20, 20, 20), Surface: tcell.NewRGBColor(60, 72, 65), OnSurface: tcell.NewRGBColor(255, 255, 255), Muted: tcell.NewRGBColor(60, 72, 65), OnMuted: tcell.NewRGBColor(20, 20, 20), HeaderBackground: tcell.NewRGBColor(40, 48, 43), }
DefaultTheme is the default color scheme.
DockerKey: DockerFooter, K8sKey: K8sFooter, DetailsDockerKey: DetailsFooter, DetailsK8sKey: DetailsFooter, FilePickerKey: FilePickerFooter, HomeKey: HomeFooter, PopulateFormKey: PopulateFooter, DeleteConfirmKey: DeleteFooter, CleanConfirmKey: CleanFooter, HelpKey: HelpFooter, UpdateFormKey: UpdateFooter, DeployFormKey: NewFooter, }
var KeyHints = map[ScreenKey][]KeyHint{ "docker": { {"tab: switch", "tab: switch between docker and k8s environments", true, "Navigation"}, {"↑↓: nav", "↑↓: navigate through docker environments", true, "Navigation"}, {"n: new", "n: create a new docker environment", true, "Environment"}, {"d: del", "d: delete the selected docker environment", true, "Environment"}, {"c: clean", "c: clean the selected docker environment", true, "Environment"}, {"u: update", "u: update the selected docker environment", true, "Environment"}, {"p: populate", "p: populate the selected docker environment", true, "Environment"}, {"enter: details", "enter: view details of the selected docker environment", true, "Navigation"}, {"?: help", "?: show help for current context", true, "Generic"}, {"q: quit", "q: quit the application", true, "Generic"}, }, "k8s": { {"tab: switch", "tab: switch between docker and k8s environments", true, "Navigation"}, {"↑↓: nav", "↑↓: navigate through k8s environments", true, "Navigation"}, {"n: new", "n: create a new k8s environment", true, "Environment"}, {"d: del", "d: delete the selected k8s environment", true, "Environment"}, {"c: clean", "c: clean the selected k8s environment", true, "Environment"}, {"u: update", "u: update the selected k8s environment", true, "Environment"}, {"p: populate", "p: populate the selected k8s environment", true, "Environment"}, {"enter: details", "enter: view details of the selected k8s environment", true, "Navigation"}, {"?: help", "?: show help for current context", true, "Generic"}, {"q: quit", "q: quit the application", true, "Generic"}, }, "details-docker": { {"esc: back", "esc: go back to docker environments list", true, "Navigation"}, {"tab: cycle", "tab: cycle through available actions", true, "Navigation"}, {"d: del", "d: delete this docker environment", true, "Environment"}, {"c: clean", "c: clean this docker environment", true, "Environment"}, {"u: update", "u: update this docker environment", true, "Environment"}, {"p: populate", "p: populate this docker environment", true, "Environment"}, {"g: gui", "g: open gui in browser", true, "Browser"}, {"G: copy gui", "G: copy gui url to clipboard", false, "Browser"}, {"b: backoffice", "b: open backoffice in browser", true, "Browser"}, {"B: copy backoffice", "B: copy backoffice url to clipboard", false, "Browser"}, {"a: api", "a: open api docs in browser", true, "Browser"}, {"A: copy api", "A: copy api url to clipboard", false, "Browser"}, {"e: directory", "e: open directory in browser", true, "Browser"}, {"E: copy directory", "E: copy directory url to clipboard", false, "Browser"}, {"enter: open file", "enter: open the selected ingested file/directory/url", false, "Browser"}, {"y: copy file", "y: copy the selected ingested file path to clipboard", false, "Browser"}, {"?: help", "?: show help for current context", true, "Generic"}, {"q: quit", "q: quit the application", false, "Generic"}, }, "details-k8s": { {"esc: back", "esc: go back to k8s environments list", true, "Navigation"}, {"tab: cycle", "tab: cycle through available actions", true, "Navigation"}, {"d: del", "d: delete this k8s environment", true, "Environment"}, {"c: clean", "c: clean this k8s environment", true, "Environment"}, {"u: update", "u: update this k8s environment", true, "Environment"}, {"p: populate", "p: populate this k8s environment", true, "Environment"}, {"g: gui", "g: open gui in browser", true, "Browser"}, {"G: copy gui", "G: copy gui url to clipboard", false, "Browser"}, {"b: backoffice", "b: open backoffice in browser", true, "Browser"}, {"B: copy backoffice", "B: copy backoffice url to clipboard", false, "Browser"}, {"a: api", "a: open api docs in browser", true, "Browser"}, {"A: copy api", "A: copy api url to clipboard", false, "Browser"}, {"e: directory", "e: open directory in browser", true, "Browser"}, {"E: copy directory", "E: copy directory url to clipboard", false, "Browser"}, {"enter: open file", "enter: open the selected ingested file/directory/url", false, "Browser"}, {"y: copy file", "y: copy the selected file path to clipboard", false, "Browser"}, {"?: help", "?: show help for current context", true, "Generic"}, {"q: quit", "q: quit the application", false, "Generic"}, }, "delete-confirm": { {"←→: switch", "", true, "Generic"}, {"enter: confirm", "", true, "Generic"}, {"esc: cancel", "", true, "Generic"}, }, "deleting": { {"please wait...", "", true, "Generic"}, }, "delete-complete": { {"esc/enter: back", "", true, "Generic"}, }, "clean-confirm": { {"←→: switch", "", true, "Generic"}, {"enter: confirm", "", true, "Generic"}, {"esc: cancel", "", true, "Generic"}, }, "cleaning": { {"please wait...", "", true, "Generic"}, }, "clean-complete": { {"esc/enter: back", "", true, "Generic"}, }, "update-form": { {"tab: next", "", true, "Generic"}, {"S-tab: prev", "", true, "Generic"}, {"enter: submit", "", true, "Generic"}, {"esc: cancel", "", true, "Generic"}, }, "updating": { {"please wait...", "", true, "Generic"}, }, "update-complete": { {"esc/enter: back", "", true, "Generic"}, }, "populate-confirm": { {"←→: switch", "", true, "Generic"}, {"enter: confirm", "", true, "Generic"}, {"esc: cancel", "", true, "Generic"}, }, "populating": { {"please wait...", "", true, "Generic"}, }, "populate-complete": { {"esc/enter: back", "", true, "Generic"}, }, "populate-form": { {"tab: next", "", true, "Generic"}, {"S-tab: prev", "", true, "Generic"}, {"enter: submit", "", true, "Generic"}, {"esc: cancel", "", true, "Generic"}, }, "file-picker": { {"↑↓←→: nav", "↑↓←→: navigate through files and directories", true, "Generic"}, {"/: search", "/: enter search mode for files", true, "Generic"}, {"space: mark", "space: mark/unmark files for selection", true, "Generic"}, {"n/N: next/prev match", "n/N: jump to next/previous search match", true, "Generic"}, {"enter: submit", "enter: submit selected files", true, "Generic"}, {"esc: cancel", "esc: cancel file selection", true, "Generic"}, }, "deploy-form": { {"tab: next", "", true, "Generic"}, {"S-tab: prev", "", true, "Generic"}, {"enter: submit", "", true, "Generic"}, {"esc: cancel", "", true, "Generic"}, }, "deploying": { {"esc: back (won't stop deployment)", "", true, "Generic"}, }, "deploy-complete": { {"esc/enter: back", "", true, "Generic"}, }, "help": { {"↑↓: nav", "↑↓: navigate through help content", true, "Generic"}, {"esc: close", "esc: close the help screen", true, "Generic"}, }, }
KeyHints maps screen names to their available keyboard shortcuts. Used by updateFooter() and help screen.
Functions ¶
func ApplyButtonStyle ¶
ApplyButtonStyle applies standard button styles.
func ApplyDropDownStyle ¶
ApplyDropDownStyle applies theme colors to a dropdown.
func CenterPrimitive ¶
CenterPrimitive wraps a primitive in a flex layout that centers it. Use width/height as proportions (1 = minimal, higher = more space).
func CenterPrimitiveFixed ¶
CenterPrimitiveFixed wraps a primitive in a flex layout that centers it with fixed dimensions.
func NewStyledButton ¶
NewStyledButton creates a button with theme colors.
func NewStyledForm ¶
NewStyledForm creates a form with theme colors.
func NewStyledInactiveButton ¶
NewStyledInactiveButton creates a button with surface colors (used for "Browse Files" etc).
func NewStyledInputField ¶
func NewStyledInputField(label, value string) *tview.InputField
NewStyledInputField creates an input field with theme colors.
func NewStyledList ¶
NewStyledList creates a list with theme colors.
func NewStyledTextView ¶
NewStyledTextView creates a text view with theme colors.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App manages the global TUI state, coordinator for components and navigation.
func (*App) FlashMessage ¶
FlashMessage shows a temporary message in the footer for the specified duration.
func (*App) PopFocus ¶
PopFocus restores the last saved focus from the stack. Returns the restored primitive or nil if stack was empty.
func (*App) ResetToHome ¶
func (a *App) ResetToHome(opts ResetOptions)
ResetToHome cleans up pages and returns to the home screen. Handles page removal, refreshing lists, and restoring focus.
func (*App) RunBackgroundTask ¶
func (a *App) RunBackgroundTask(opts TaskOptions)
RunBackgroundTask runs an operation with a standard progress UI. It starts a new OperationProgress screen and executes the provided task in a goroutine. Handles updating the UI upon completion (success or error).
func (*App) ShowConfirmation ¶
func (a *App) ShowConfirmation(opts ConfirmationOptions)
ShowConfirmation displays a standardized confirmation modal.
func (*App) ShowError ¶
ShowError displays an error modal with a message. Press OK or ESC to dismiss.
func (*App) ShowModalForm ¶
func (a *App) ShowModalForm(opts ModalFormOptions)
ShowModalForm displays a standardized modal form with fields and buttons.
func (*App) UpdateFooter ¶
UpdateFooter updates the footer section text and shortcut keys.
func (*App) UpdateFooterCustom ¶
UpdateFooterCustom updates the footer with custom keys (not from context).
type ConfirmationOptions ¶
type ConfirmationOptions struct {
PageName string
Title string
Message string
ConfirmLabel string
CancelLabel string
OnConfirm func()
OnCancel func()
Destructive bool // Use Red border
ConfirmDestructive bool // Use Red confirm button
Secondary bool // Use Yellow border (ignored if Destructive)
InputCapture func(leftBtn, rightBtn *tview.Button) func(*tcell.EventKey) *tcell.EventKey
}
ConfirmationOptions defines settings for the standardized confirmation modal.
type DetailsPanel ¶
type DetailsPanel struct {
// contains filtered or unexported fields
}
DetailsPanel manages the right-side information and action panel.
func NewDetailsPanel ¶
func NewDetailsPanel(app *App) *DetailsPanel
NewDetailsPanel creates a new DetailsPanel component.
func (*DetailsPanel) Clear ¶
func (dp *DetailsPanel) Clear()
Clear shows the placeholder text in the details panel.
func (*DetailsPanel) CycleFocus ¶
func (dp *DetailsPanel) CycleFocus()
CycleFocus cycles focus between buttons, grid, and list in the details view.
func (*DetailsPanel) CycleFocusBackward ¶
func (dp *DetailsPanel) CycleFocusBackward()
CycleFocusBackward cycles focus backward between buttons, grid, and list in the details view.
func (*DetailsPanel) GetCurrentDetailsName ¶
func (dp *DetailsPanel) GetCurrentDetailsName() string
GetCurrentDetailsName returns the current details environment name.
func (*DetailsPanel) GetCurrentDetailsType ¶
func (dp *DetailsPanel) GetCurrentDetailsType() string
GetCurrentDetailsType returns the current details environment type.
func (*DetailsPanel) GetFlex ¶
func (dp *DetailsPanel) GetFlex() *tview.Flex
GetFlex returns the main flex for this component.
func (*DetailsPanel) IsShown ¶
func (dp *DetailsPanel) IsShown() bool
IsShown returns true if the details panel is currently showing details.
func (*DetailsPanel) RefreshFiles ¶
func (dp *DetailsPanel) RefreshFiles()
RefreshFiles refreshes the ingested files list if details are currently shown.
func (*DetailsPanel) SetupInput ¶
func (dp *DetailsPanel) SetupInput()
SetupInput configures key handlers for the details panel.
func (*DetailsPanel) Update ¶
func (dp *DetailsPanel) Update(name, envType string, focus bool)
Update fetches and displays environment details in the panel.
type EnvList ¶
type EnvList struct {
// contains filtered or unexported fields
}
EnvList manages the left-side navigation for environment selection.
func (*EnvList) FocusActiveList ¶
func (el *EnvList) FocusActiveList()
FocusActiveList sets the focus to the currently active environment list (Docker or K8s). If the list is empty, it focuses the "Create New" button instead.
func (*EnvList) GetSelected ¶
GetSelected returns the currently selected environment name and whether it's Docker.
func (*EnvList) IsDockerActive ¶
IsDockerActive returns true if the Docker list is currently active.
func (*EnvList) Refresh ¶
func (el *EnvList) Refresh()
Refresh updates the lists from the database, preserving current focus/selection.
func (*EnvList) SetInitialFocus ¶
func (el *EnvList) SetInitialFocus()
SetInitialFocus sets the focus to the default list or button.
func (*EnvList) SetupInput ¶
func (el *EnvList) SetupInput()
SetupInput configures keyboard and focus handlers.
func (*EnvList) SwitchFocus ¶
func (el *EnvList) SwitchFocus()
SwitchFocus toggles focus between Docker and K8s lists.
type FilePicker ¶
type FilePicker struct {
// contains filtered or unexported fields
}
FilePicker is a component to select files or directories.
type FocusButton ¶
type FocusButton string
FocusButton represents the button to focus after UI rebuild.
const ( FocusButtonBrowse FocusButton = "browse" FocusButtonFiles FocusButton = "files" FocusButtonDirs FocusButton = "dirs" )
type FooterText ¶
type FooterText string
FooterText represents a footer text string.
const ( )
func GetFooterText ¶
func GetFooterText(key ScreenKey) FooterText
type FormButton ¶
type FormButton struct {
Label string
SelectedFunc func()
}
FormButton represents a button in a modal form.
type FormField ¶
type FormField struct {
Type string // "input", "checkbox", "dropdown"
Label string
Value string
Options []string // For dropdowns
InputChangedFunc func(string) // For inputs
CheckboxChangedFunc func(bool) // For checkboxes
SelectedFunc func(string, int) // For dropdowns
}
FormField represents a field in a modal form.
type ModalFormOptions ¶
type ModalFormOptions struct {
PageName string
Title string
Fields []FormField
Buttons []FormButton
Width int
Height int
OnCancel func()
}
ModalFormOptions defines settings for modal forms.
type OperationProgress ¶
type OperationProgress struct {
// contains filtered or unexported fields
}
OperationProgress manages the UI for operation progress screens.
func NewOperationProgress ¶
func NewOperationProgress(app *App, operation, envName string) *OperationProgress
NewOperationProgress creates a new OperationProgress instance.
func (*OperationProgress) Complete ¶
func (op *OperationProgress) Complete(success bool, errorMsg string)
Complete marks the operation as finished and shows the completion overlay.
func (*OperationProgress) Start ¶
func (op *OperationProgress) Start()
Start begins the progress display and ticker.
type OutputWriter ¶
type OutputWriter struct {
// contains filtered or unexported fields
}
OutputWriter captures command output and routes it to a TUI TextView.
func (*OutputWriter) ClearBuffer ¶
func (w *OutputWriter) ClearBuffer()
ClearBuffer clears the output buffer.
func (*OutputWriter) ClearView ¶
func (w *OutputWriter) ClearView()
ClearView disconnects the writer from the current view.
func (*OutputWriter) GetBuffer ¶
func (w *OutputWriter) GetBuffer() string
GetBuffer returns the current buffer content.
func (*OutputWriter) SetView ¶
func (w *OutputWriter) SetView(app *tview.Application, view *tview.TextView)
SetView connects the writer to a TextView for output display.
type ResetOptions ¶
type ResetOptions struct {
PageNames []string // Pages to remove
ClearDetails bool // Clear details panel (e.g., after delete)
RefreshFiles bool // Refresh files list (e.g., after populate)
RestoreFocus bool // Restore focus from stack
ForceEnvFocus bool // Explicitly focus environment list
}
ResetOptions configures the return to home screen.
type ScreenKey ¶
type ScreenKey string
ScreenKey represents a key for identifying UI screens.
const ( DetailsDockerKey ScreenKey = "details-docker" DetailsK8sKey ScreenKey = "details-k8s" DockerKey ScreenKey = "docker" K8sKey ScreenKey = "k8s" FilePickerKey ScreenKey = "file-picker" HomeKey ScreenKey = "home" PopulateFormKey ScreenKey = "populate-form" DeleteConfirmKey ScreenKey = "delete-confirm" CleanConfirmKey ScreenKey = "clean-confirm" HelpKey ScreenKey = "help" DeployFormKey ScreenKey = "deploy-form" UpdateFormKey ScreenKey = "update-form" )
type TaskOptions ¶
type TaskOptions struct {
Operation string
EnvName string
IsDocker bool
Task func() (string, error) // Returns success message or error
OnSuccess func()
ClearDetails bool
}
TaskOptions defines settings for background operations with progress UI.
type Theme ¶
type Theme struct {
Primary tcell.Color
OnPrimary tcell.Color
Secondary tcell.Color
OnSecondary tcell.Color
Error tcell.Color
OnError tcell.Color
Destructive tcell.Color
OnDestructive tcell.Color
Success tcell.Color
OnSuccess tcell.Color
Background tcell.Color
OnBackground tcell.Color
Surface tcell.Color
OnSurface tcell.Color
Muted tcell.Color
OnMuted tcell.Color
HeaderBackground tcell.Color
}
Theme defines the color scheme for the TUI.