Documentation
¶
Index ¶
- type ColorStyle
- type DevTUI
- func (t *DevTUI) AddTabSections(sections ...*tabSection) *DevTUI
- func (h *DevTUI) ContentView() string
- func (t *DevTUI) GetTotalTabSections() int
- func (h *DevTUI) HandleKeyboard(msg tea.KeyMsg) (bool, tea.Cmd)
- func (h *DevTUI) Init() tea.Cmd
- func (t *DevTUI) NewTabSection(title, footer string) *tabSection
- func (h *DevTUI) Print(messages ...any)
- func (t *DevTUI) ReturnFocus() error
- func (h *DevTUI) Start(args ...any)
- func (h *DevTUI) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *DevTUI) View() string
- type TuiConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColorStyle ¶
type DevTUI ¶
type DevTUI struct {
*TuiConfig
// contains filtered or unexported fields
}
DevTUI mantiene el estado de la aplicación
func DefaultTUIForTest ¶ added in v0.0.10
NewDefaultTUI creates a DevTUI instance with basic default configuration useful for unit tests and for quick initialization in real applications
func NewTUI ¶
NewTUI creates a new DevTUI instance and initializes it.
Usage Example:
config := &TuiConfig{
AppName: "MyApp",
TabIndexStart: 0,
ExitChan: make(chan bool),
Color: nil, // or your *ColorStyle
LogToFile: func(err any) { fmt.Println(err) },
}
tui := NewTUI(config)
// Configure your sections and fields:
tui.NewTabSection("My Section", "Description").
NewField("Field1", "value", true, nil)
// Start the TUI:
var wg sync.WaitGroup
wg.Add(1)
go tui.Run(&wg)
wg.Wait()
func (*DevTUI) AddTabSections ¶ added in v0.0.9
AddTabSections adds one or more tabSections to the DevTUI If a tab with title "DEFAULT" exists, it will be replaced by the first tab section Deprecated: Use NewTabSection and append to tabSections directly
func (*DevTUI) ContentView ¶
ContentView renderiza los mensajes para una sección de contenido
func (*DevTUI) GetTotalTabSections ¶ added in v0.0.9
GetTotalTabSections returns the total number of tab sections
func (*DevTUI) HandleKeyboard ¶ added in v0.0.10
HandleKeyboard processes keyboard input and updates the model state returns whether the update function should continue processing or return early
func (*DevTUI) NewTabSection ¶ added in v0.0.43
NewTabSection creates and initializes a new tabSection with the given title and footer Example:
tab := tui.NewTabSection("BUILD", "Press enter to compile")
func (*DevTUI) ReturnFocus ¶
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 TuiConfig ¶
type TuiConfig struct {
AppName string // app name eg: "MyApp"
TabIndexStart int // is the index of the tab section to start default 0
ExitChan chan bool // global chan to close app eg: make(chan bool)
/* *ColorStyle style for the TUI
eg:
type ColorStyle struct {
Foreground string // eg: #F4F4F4
Background string // eg: #000000
Highlight string // eg: #FF6600
Lowlight string // eg: #666666
}*/
Color *ColorStyle
LogToFile func(messages ...any) // function to write log error
}
