ui

package
v0.0.0-...-24f08a5 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ui implements a command-line user interface using tea.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	LogWriter *TeaLogWriter

	Initialized atomic.Bool
	Ready       atomic.Bool
	Failed      atomic.Bool
	// contains filtered or unexported fields
}

Handler is the principal implementation of a user interface Handler.

func NewHandler

func NewHandler(ctx context.Context, cancel context.CancelFunc, queueManager *queue.Manager) *Handler

NewHandler returns a pointer to a new user interface Handler.

func (*Handler) Launch

func (uiHandler *Handler) Launch() error

Launch starts the command-line user interface (the tea.Program).

type LogMsg

type LogMsg string

LogMsg is a regular string containing a log message. It is typed for identification as tea.Msg within a tea.Program.

type QueueProgressMsg

type QueueProgressMsg struct {
	// contains filtered or unexported fields
}

QueueProgressMsg is a tea.Msg containing queue.Progress information.

type TeaLogWriter

type TeaLogWriter struct {
	// contains filtered or unexported fields
}

TeaLogWriter is an implementation of an io.Writer, for use inside a [slog.Handler], that sends any logs to a tea.Program as tea.Msg.

func NewTeaLogWriter

func NewTeaLogWriter(program teaProgramProvider) *TeaLogWriter

NewTeaLogWriter returns a pointer to a new TeaLogWriter. It also starts the internal log processing function, which should eventually be stopped e.g. with a deferred TeaLogWriter.Stop call.

func (*TeaLogWriter) Stop

func (wr *TeaLogWriter) Stop()

Stop destroys the TeaLogWriter and stops any log message processing. This should be called when no more logs are actively being sent, as any in-flight or late logs will be discarded after calling this method.

func (*TeaLogWriter) Write

func (wr *TeaLogWriter) Write(p []byte) (int, error)

Write receives a byte slice containing a log message from e.g. a [slog.Handler]. It is interally sent into a buffered channel, received by [TeaLogWriter.processLogs].

type TeaModel

type TeaModel struct {
	// contains filtered or unexported fields
}

TeaModel is the principal tea.Model for the command-line user interface.

func NewTeaModel

func NewTeaModel(uiHandler *Handler, cancel context.CancelFunc) TeaModel

NewTeaModel returns an initial new TeaModel.

func (TeaModel) Init

func (m TeaModel) Init() tea.Cmd

Init initializes the model within a tea.Program.

func (TeaModel) Update

func (m TeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update is the principal message handling method of the model. It sets the internal state of the model, for later rendering.

func (TeaModel) View

func (m TeaModel) View() string

View is the principal rendering function of the model.

Jump to

Keyboard shortcuts

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