Documentation
¶
Index ¶
- type ColorPalette
- type DevTUI
- func (h *DevTUI) ContentView() string
- func (h *DevTUI) Init() tea.Cmd
- func (t *DevTUI) NewTabSection(title, description string) *tabSection
- func (t *DevTUI) ReturnFocus() error
- func (h *DevTUI) SetTestMode(enabled bool)
- func (h *DevTUI) Start(args ...any)
- func (h *DevTUI) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *DevTUI) View() string
- type HandlerDisplay
- type HandlerEdit
- type HandlerExecution
- type HandlerInteractive
- type HandlerWriter
- type MessageTracker
- type ShortcutEntry
- type ShortcutProvider
- type ShortcutRegistry
- type TuiConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColorPalette ¶ added in v0.0.168
type ColorPalette struct {
// Base (2 colores)
Foreground string // #F4F4F4
Background string // #000000
// Accent (2 colores)
Primary string // #FF6600 (tu actual Primary)
Secondary string // #666666 (tu actual Secondary)
// Semantic (4 colores)
Success string // #00FF00
Warning string // #FFFF00
Error string // #FF0000
Info string // #00FFFF
// UI (2-4 colores adicionales)
Border string // #444444
Muted string // #999999
Selected string // Derivado de Primary
Hover string // Derivado de Primary
}
func DefaultPalette ¶ added in v0.0.168
func DefaultPalette() *ColorPalette
type DevTUI ¶
type DevTUI struct {
*TuiConfig
// contains filtered or unexported fields
}
DevTUI mantiene el estado de la aplicación
func NewTUI ¶
NewTUI creates a new DevTUI instance and initializes it.
Usage Example:
config := &TuiConfig{
AppName: "MyApp",
ExitChan: make(chan bool),
Color: nil, // or your *ColorPalette
LogToFile: func(err any) { fmt.Println(err) },
}
tui := NewTUI(config)
func (*DevTUI) ContentView ¶
ContentView renderiza los mensajes para una sección de contenido
func (*DevTUI) NewTabSection ¶ added in v0.0.43
NewTabSection creates and initializes a new tabSection with the given title and footer NewTabSection creates a new tab section and automatically adds it to the TUI
Example:
tab := tui.NewTabSection("BUILD", "Compiler Section")
func (*DevTUI) ReturnFocus ¶
func (*DevTUI) SetTestMode ¶ added in v0.0.125
SetTestMode enables or disables test mode for synchronous behavior in tests. This should only be used in test files to make tests deterministic.
func (*DevTUI) Start ¶ added in v0.0.93
Start initializes and runs the terminal UI application.
It accepts optional variadic arguments of any type. If a *sync.WaitGroup is provided among these arguments, Start will call its Done() method before returning.
The method runs the UI using the internal tea engine, and handles any errors that may occur during execution. If an error occurs, it will be displayed on the console and the application will wait for user input before exiting.
Parameters:
- args ...any: Optional arguments. Can include a *sync.WaitGroup for synchronization.
type HandlerDisplay ¶ added in v0.0.117
type HandlerDisplay interface {
Name() string // Full text to display in footer (handler responsible for content) eg. "System Status Information Display"
Content() string // Display content (e.g., "help\n1-..\n2-...", "executing deploy wait...")
}
HandlerDisplay defines the interface for read-only information display handlers. These handlers show static or dynamic content without user interaction.
type HandlerEdit ¶ added in v0.0.117
type HandlerEdit interface {
Name() string // Identificador para logging: "ServerPort", "DatabaseURL"
Label() string // Field label (e.g., "Server Port", "Host Configuration")
Value() string // Current/initial value (e.g., "8080", "localhost")
Change(newValue string, progress func(msgs ...any)) // Nueva firma: sin error, sin variádico, string
}
HandlerEdit defines the interface for interactive fields that accept user input. These handlers allow users to modify values through text input.
type HandlerExecution ¶ added in v0.0.117
type HandlerExecution interface {
Name() string // Identificador para logging: "DeployProd", "BuildProject"
Label() string // Button label (e.g., "Deploy to Production", "Build Project")
Execute(progress func(msgs ...any)) // Nueva firma: sin error, sin variádico
}
HandlerExecution defines the interface for action buttons that execute operations. These handlers trigger business logic when activated by the user.
type HandlerInteractive ¶ added in v0.0.149
type HandlerInteractive interface {
Name() string // Identifier for logging: "ChatBot", "ConfigWizard"
Label() string // Field label (updates dynamically)
Value() string // Current input value
Change(newValue string, progress func(msgs ...any)) // Handle user input + content display via progress
WaitingForUser() bool // Should edit mode be auto-activated?
}
HandlerInteractive defines the interface for interactive content handlers. These handlers combine content display with user interaction capabilities. All content display is handled through progress() for consistency.
type HandlerWriter ¶ added in v0.0.103
type HandlerWriter interface {
Name() string // Writer identifier (e.g., "webBuilder", "ApplicationLog")
}
HandlerWriter defines the interface for basic writers that create new lines for each write. These writers are suitable for simple logging or output display.
type MessageTracker ¶ added in v0.0.116
MessageTracker provides optional interface for message tracking control. Handlers can implement this to control message updates and operation tracking.
type ShortcutEntry ¶ added in v0.0.161
type ShortcutEntry struct {
Key string // The shortcut key (e.g., "c", "d", "p")
Description string // Human-readable description (e.g., "coding mode", "debug mode")
TabIndex int // Index of the tab containing the handler
FieldIndex int // Index of the field within the tab
HandlerName string // Handler name for identification
Value string // Value to pass to Change()
}
ShortcutEntry represents a registered shortcut
type ShortcutProvider ¶ added in v0.0.161
type ShortcutProvider interface {
Shortcuts() map[string]string // Returns shortcut keys with descriptions (e.g., {"c": "coding mode", "d": "debug mode", "p": "production mode"})
}
ShortcutProvider defines the optional interface for handlers that provide global shortcuts. HandlerEdit implementations can implement this interface to enable global shortcut keys.
type ShortcutRegistry ¶ added in v0.0.161
type ShortcutRegistry struct {
// contains filtered or unexported fields
}
ShortcutRegistry manages global shortcut keys
func (*ShortcutRegistry) Get ¶ added in v0.0.161
func (sr *ShortcutRegistry) Get(key string) (*ShortcutEntry, bool)
func (*ShortcutRegistry) GetAll ¶ added in v0.0.161
func (sr *ShortcutRegistry) GetAll() map[string]*ShortcutEntry
GetAll returns all registered shortcuts for UI display
func (*ShortcutRegistry) List ¶ added in v0.0.161
func (sr *ShortcutRegistry) List() []string
func (*ShortcutRegistry) Register ¶ added in v0.0.161
func (sr *ShortcutRegistry) Register(key string, entry *ShortcutEntry)
func (*ShortcutRegistry) Unregister ¶ added in v0.0.161
func (sr *ShortcutRegistry) Unregister(key string)
type TuiConfig ¶
type TuiConfig struct {
AppName string // app name eg: "MyApp"
ExitChan chan bool // global chan to close app eg: make(chan bool)
/*// *ColorPalette style for the TUI
// if nil it will use default style:
type ColorPalette struct {
Foreground string // eg: #F4F4F4
Background string // eg: #000000
Primary string // eg: #FF6600
Secondary string // eg: #666666
}*/
Color *ColorPalette
LogToFile func(messages ...any) // function to write log error
}
