devtui

package module
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: MIT Imports: 16 Imported by: 0

README

devtui

interactive terminal user interface focused on developing applications

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockAsyncProcessor added in v0.0.38

func MockAsyncProcessor(steps int, delay time.Duration) func(string, chan<- Message)

MockAsyncProcessor creates a mock async processor function for testing

func VerifyAsyncMessages added in v0.0.38

func VerifyAsyncMessages(t *testing.T, messages []Message, expectedCount int)

VerifyAsyncMessages checks that messages follow the expected pattern

Types

type AsyncMessageMsg added in v0.0.38

type AsyncMessageMsg Message

AsyncMessageMsg is a message from an async field handler

type ColorStyle

type ColorStyle struct {
	ForeGround string // eg: #F4F4F4
	Background string // eg: #000000
	Highlight  string // eg: #FF6600
	Lowlight   string // eg: #666666
}

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

func DefaultTUIForTest(LogToFile func(messageErr any)) *DevTUI

NewDefaultTUI creates a DevTUI instance with basic default configuration useful for unit tests and for quick initialization in real applications

func NewTUI

func NewTUI(c *TuiConfig) *DevTUI

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

func (*DevTUI) ContentView

func (h *DevTUI) ContentView() string

ContentView renderiza los mensajes para una sección de contenido

func (*DevTUI) GetTabSections added in v0.0.38

func (h *DevTUI) GetTabSections() []TabSection

GetTabSections returns a copy of the tab sections for testing purposes

func (*DevTUI) GetTotalTabSections added in v0.0.9

func (t *DevTUI) GetTotalTabSections() int

GetTotalTabSections returns the total number of tab sections

func (*DevTUI) HandleKeyboard added in v0.0.10

func (h *DevTUI) HandleKeyboard(msg tea.KeyMsg) (bool, tea.Cmd)

HandleKeyboard processes keyboard input and updates the model state returns whether the update function should continue processing or return early

func (*DevTUI) Init

func (h *DevTUI) Init() tea.Cmd

Init initializes the terminal UI application.

func (*DevTUI) InitTUI added in v0.0.5

func (h *DevTUI) InitTUI(args ...any)

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) Print

func (h *DevTUI) Print(messages ...any)

Print sends a normal Label or error to the tui in current tab

func (*DevTUI) ProcessFieldValueChange added in v0.0.38

func (h *DevTUI) ProcessFieldValueChange(field *FieldHandler, newValue string)

ProcessFieldValueChange handles both synchronous and asynchronous field value changes

func (*DevTUI) ReturnFocus

func (t *DevTUI) ReturnFocus() error

func (*DevTUI) SetAsyncMessageChannel added in v0.0.38

func (h *DevTUI) SetAsyncMessageChannel(channel chan Message)

SetAsyncMessageChannel sets the async message channel for testing purposes

func (*DevTUI) Update

func (h *DevTUI) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update maneja las actualizaciones del estado

func (*DevTUI) View

func (h *DevTUI) View() string

type FieldHandler added in v0.0.7

type FieldHandler struct {
	Name  string // eg: "port", "Server Port", "8080"
	Label string // eg: "Server Port"
	Value string // eg: "8080"

	Editable    bool                                                  // if no editable eject the action ChangeValue directly
	ChangeValue func(newValue string) (execMessage string, err error) //eg: "8080" -> "9090" execMessage: "Port changed from 8080 to 9090"
	// Async handler that can send multiple messages over time
	AsyncFieldValueChange func(newValue string, messageChan chan<- Message)
	IsAsync               bool // Flag indicating if this handler uses async processing
	// contains filtered or unexported fields
}

Interface for handling tab field sectionFields

func (*FieldHandler) SetCursorAtEnd added in v0.0.7

func (cf *FieldHandler) SetCursorAtEnd()

type Message added in v0.0.38

type Message struct {
	Content    string
	Type       messagetype.Type
	TabSection *TabSection
	// contains filtered or unexported fields
}

Message represents a message sent asynchronously or synchronously in the TUI

func CollectAsyncMessages added in v0.0.38

func CollectAsyncMessages(t *testing.T, triggerFn func(), timeout time.Duration) []Message

CollectAsyncMessages runs a function that triggers async messages and collects them with a timeout

func RunAsyncFieldTest added in v0.0.38

func RunAsyncFieldTest(t *testing.T, tui *DevTUI, tabIndex, fieldIndex int, testValue string) []Message

RunAsyncFieldTest is a helper function for testing async field functionality

type TabSection

type TabSection struct {
	Title         string         // eg: "BUILD", "TEST"
	FieldHandlers []FieldHandler // Field actions configured for the section
	// contains filtered or unexported fields
}

represent the tab section in the tui

func (*TabSection) Write added in v0.0.4

func (ts *TabSection) Write(p []byte) (n int, err error)

Write implementa io.Writer para capturar la salida de otros procesos

type TuiConfig

type TuiConfig struct {
	AppName       string    // app name eg: "MyApp"
	TabIndexStart int       // is the index of the tab section to start
	ExitChan      chan bool //  global chan to close app
	Color         *ColorStyle

	LogToFile func(messageErr any) // function to write log error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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