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 (h *DevTUI) InitTUI(args ...any)
- func (t *DevTUI) NewTabSection(title, footer string) *TabSection
- func (h *DevTUI) Print(messages ...any)
- func (t *DevTUI) ReturnFocus() error
- func (h *DevTUI) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *DevTUI) View() string
- type Field
- type TabSection
- func (ts *TabSection) AddFields(fields ...Field)
- func (ts *TabSection) FieldHandlers() []Field
- func (ts *TabSection) Footer() string
- func (ts *TabSection) SetFieldHandlers(handlers []Field)
- func (ts *TabSection) SetFooter(footer string)
- func (ts *TabSection) SetTitle(title string)
- func (ts *TabSection) Title() string
- func (ts *TabSection) Write(p []byte) (n int, err error)
- 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 (*DevTUI) AddTabSections ¶ added in v0.0.9
func (t *DevTUI) AddTabSections(sections ...*TabSection) *DevTUI
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) InitTUI ¶ added in v0.0.5
InitTUI initializes and runs the terminal UI application.
It accepts optional variadic arguments of any type. If a *sync.WaitGroup is provided among these arguments, InitTUI 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.
func (*DevTUI) NewTabSection ¶ added in v0.0.43
func (t *DevTUI) NewTabSection(title, footer string) *TabSection
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 ¶
type Field ¶ added in v0.0.44
type Field struct {
// contains filtered or unexported fields
}
use NewField to create a new field in the tab section Field represents a field in the TUI with a name, value, and editable state.
func NewField ¶ added in v0.0.44
func NewField(name, value string, editable bool, changeFunc func(newValue string) (string, error)) *Field
NewField creates and returns a new Field instance.
Parameters:
- name: The name of the field.
- value: The initial value of the field.
- editable: A boolean indicating whether the field is editable.
- changeFunc: A callback function that is invoked when the field's value changes. It receives the new value as a parameter and returns the updated value and an error, if any.
Returns: - A pointer to the newly created Field instance.
Example usage:
field := NewField("username", "defaultUser", true, func(newValue string) (string, error) {
if len(newValue) == 0 {
return "", errors.New("value cannot be empty")
}
return newValue, nil
})
func (*Field) SetCursorAtEnd ¶ added in v0.0.44
func (f *Field) SetCursorAtEnd()
func (*Field) SetEditable ¶ added in v0.0.44
type TabSection ¶
type TabSection struct {
// contains filtered or unexported fields
}
TabSection represents a tab section in the TUI with configurable fields and content
func (*TabSection) AddFields ¶ added in v0.0.44
func (ts *TabSection) AddFields(fields ...Field)
AddFields adds one or more Field handlers to the section This is the preferred method for adding fields in normal usage
func (*TabSection) FieldHandlers ¶ added in v0.0.7
func (ts *TabSection) FieldHandlers() []Field
FieldHandlers returns the field handlers slice
func (*TabSection) Footer ¶ added in v0.0.44
func (ts *TabSection) Footer() string
Footer returns the tab section footer text
func (*TabSection) SetFieldHandlers ¶ added in v0.0.44
func (ts *TabSection) SetFieldHandlers(handlers []Field)
SetFieldHandlers sets the field handlers slice (mainly for testing)
func (*TabSection) SetFooter ¶ added in v0.0.44
func (ts *TabSection) SetFooter(footer string)
SetFooter sets the tab section footer text
func (*TabSection) SetTitle ¶ added in v0.0.44
func (ts *TabSection) SetTitle(title string)
SetTitle sets the tab section title
