tui

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetStackInContext

func SetStackInContext(ctx context.Context, stack *StackModel) context.Context

Types

type BackMsg

type BackMsg struct {
	Handled bool
}

type CTXKey

type CTXKey struct{}

type CTXValue

type CTXValue struct {
	Stack *StackModel
}

type ClearScreenMsg

type ClearScreenMsg struct {
	NextMsg tea.Msg
}

ClearScreenMsg is a message that clears the screen before rendering the next message

type ConfigWrapper

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

func NewConfigWrapper

func NewConfigWrapper(next tea.Model, breadcrumb string, m tea.Model) *ConfigWrapper

func (*ConfigWrapper) Init

func (c *ConfigWrapper) Init() tea.Cmd

func (*ConfigWrapper) Update

func (c *ConfigWrapper) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ConfigWrapper) View

func (c *ConfigWrapper) View() string

type ConfirmModel

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

func NewConfirmModel

func NewConfirmModel(
	message string,
	onConfirm func() tea.Cmd,
	onCancel func() tea.Cmd,
) *ConfirmModel

func (*ConfirmModel) Init

func (m *ConfirmModel) Init() tea.Cmd

func (*ConfirmModel) Update

func (m *ConfirmModel) Update(msg tea.Msg) (*ConfirmModel, tea.Cmd)

func (*ConfirmModel) View

func (m *ConfirmModel) View() string

type CustomOption

type CustomOption struct {
	Key      string
	Title    string
	Function func(row table.Row) tea.Cmd
}

func (CustomOption) String

func (o CustomOption) String() string

type DimensionModel

type DimensionModel interface {
	tea.Model
	SetWidth(int)
	SetHeight(int)
}

DimensionModel is an extension of tea.Model that implements a SetWidth and SetHeight method. This allows for models to handle their own sizing. For models that contain child models, their implementation to SetWidth and SetHeight should also call SetWidth and SetHeight on the child models and subtract out any padding or margins that the parent model may have.

This allows for a more flexible and composable layout system, where each model is in charge of its own size and layout.

type DoneLoadingDataMsg

type DoneLoadingDataMsg struct{}

type DoneMsg

type DoneMsg struct {
	Message string
}

DoneMsg quits the program after displaying a message

type ErrorModel

type ErrorModel struct {
	Err error
	// contains filtered or unexported fields
}

func NewErrorModel

func NewErrorModel(
	err error,
) *ErrorModel

func (*ErrorModel) Init

func (m *ErrorModel) Init() tea.Cmd

func (*ErrorModel) Update

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

func (*ErrorModel) View

func (m *ErrorModel) View() string

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg quits the program after displaying an error message

type ExecDone

type ExecDone struct {
	Error error
}

type ExecModel

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

func NewExecModel

func NewExecModel(loadCmd TypedCmd[*exec.Cmd]) *ExecModel

func (*ExecModel) Init

func (m *ExecModel) Init() tea.Cmd

func (*ExecModel) Update

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

func (*ExecModel) View

func (m *ExecModel) View() string

type Form

type Form struct {
	*huh.Form
}

Form is a wrapper around a huh form that implements the layout.DimensionModel interface

func NewForm

func NewForm(huhForm *huh.Form) *Form

func (*Form) Init

func (f *Form) Init() tea.Cmd

func (*Form) SetHeight

func (f *Form) SetHeight(height int)

func (*Form) SetWidth

func (f *Form) SetWidth(width int)

func (*Form) Update

func (f *Form) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Form) View

func (f *Form) View() string

type FormAction

type FormAction[T any] struct {
	// contains filtered or unexported fields
}

func NewFormAction

func NewFormAction[T any](
	action func(T) tea.Cmd,
	onSubmit TypedCmd[T],
) FormAction[T]

func (*FormAction[T]) Init

func (fa *FormAction[T]) Init() tea.Cmd

func (*FormAction[T]) Update

func (fa *FormAction[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*FormAction[T]) View

func (fa *FormAction[T]) View() string

type FormWithAction

type FormWithAction[T any] struct {
	// contains filtered or unexported fields
}

func NewFormWithAction

func NewFormWithAction[T any](action FormAction[T], form tea.Model) *FormWithAction[T]

func (*FormWithAction[T]) Init

func (df *FormWithAction[T]) Init() tea.Cmd

func (*FormWithAction[T]) Update

func (df *FormWithAction[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*FormWithAction[T]) View

func (df *FormWithAction[T]) View() string

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

func NewList

func NewList[T any](
	title string,
	loadData TypedCmd[[]T],
	makeListItem func(T) ListItem,
	opts ...ListOption[T],
) *List[T]

func (*List[T]) Init

func (m *List[T]) Init() tea.Cmd

func (*List[T]) Update

func (m *List[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*List[T]) View

func (m *List[T]) View() string

type ListItem

type ListItem interface {
	Title() string
	Description() string
	FilterValue() string
	Height() int
}

type ListOption

type ListOption[T any] func(*List[T])

func WithOnSelect

func WithOnSelect[T any](onSelect func(ListItem) tea.Cmd) ListOption[T]

type LoadDataMsg

type LoadDataMsg[T any] struct {
	Data    T
	HasMore bool
}

type LoadFunc

type LoadFunc func() (*client.Logs200Response, <-chan *lclient.Log, error)

type LoadingDataMsg

type LoadingDataMsg struct {
	Cmd            tea.Cmd
	LoadingMsgTmpl string
}

type LogModel

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

func NewLogModel

func NewLogModel(loadFunc TypedCmd[*LogResult]) *LogModel

func (*LogModel) Init

func (m *LogModel) Init() tea.Cmd

func (*LogModel) KeyBinds

func (m *LogModel) KeyBinds() []key.Binding

func (*LogModel) SetHeight

func (m *LogModel) SetHeight(height int)

func (*LogModel) SetWidth

func (m *LogModel) SetWidth(width int)

func (*LogModel) Update

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

func (*LogModel) View

func (m *LogModel) View() string

type LogResult

type LogResult struct {
	Logs       *client.Logs200Response
	LogChannel <-chan *lclient.Log
}

type ModelWithCmd

type ModelWithCmd struct {
	Model      tea.Model
	Cmd        string
	Breadcrumb string
}

type ModelWithConfirm

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

func NewModelWithConfirm

func NewModelWithConfirm(model tea.Model) *ModelWithConfirm

func (*ModelWithConfirm) Init

func (m *ModelWithConfirm) Init() tea.Cmd

func (*ModelWithConfirm) Update

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

func (*ModelWithConfirm) View

func (m *ModelWithConfirm) View() string

type ScrollBarModel

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

func NewScrollBarModel

func NewScrollBarModel(
	height int,
	percent float64,
) *ScrollBarModel

func (*ScrollBarModel) Init

func (m *ScrollBarModel) Init() tea.Cmd

func (*ScrollBarModel) ScrollPercent

func (m *ScrollBarModel) ScrollPercent(percent float64)

func (*ScrollBarModel) SetHeight

func (m *ScrollBarModel) SetHeight(height int)

func (*ScrollBarModel) Update

func (m *ScrollBarModel) Update(_ tea.Msg) (*ScrollBarModel, tea.Cmd)

func (*ScrollBarModel) View

func (m *ScrollBarModel) View() string

type ShowConfirmMsg

type ShowConfirmMsg struct {
	Message   string
	OnConfirm func() tea.Cmd
}

type SimpleLoadedMsg

type SimpleLoadedMsg string

type SimpleModel

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

func NewSimpleModel

func NewSimpleModel(loadFunc TypedCmd[string]) *SimpleModel

func (*SimpleModel) Init

func (m *SimpleModel) Init() tea.Cmd

func (*SimpleModel) Update

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

func (*SimpleModel) View

func (m *SimpleModel) View() string

type StackModel

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

func GetStackFromContext

func GetStackFromContext(ctx context.Context) *StackModel

func NewStack

func NewStack() *StackModel

func (*StackModel) Init

func (m *StackModel) Init() tea.Cmd

func (*StackModel) Pop

func (m *StackModel) Pop() *ModelWithCmd

func (*StackModel) Push

func (m *StackModel) Push(model ModelWithCmd) tea.Cmd

func (*StackModel) PushError

func (m *StackModel) PushError(err error) tea.Cmd

func (*StackModel) StackSizeMsg

func (m *StackModel) StackSizeMsg() StackSizeMsg

func (*StackModel) Update

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

func (*StackModel) View

func (m *StackModel) View() string

func (*StackModel) WithDone

func (m *StackModel) WithDone(f func(tea.Msg) (tea.Model, tea.Cmd))

type StackSizeMsg

type StackSizeMsg struct {
	Width  int
	Height int
	Top    int
}

type Tab

type Tab struct {
	Name    string
	Content DimensionModel
}

type TabModel

type TabModel struct {
	Tabs []*Tab
	// contains filtered or unexported fields
}

Adapted from the tabs bubbletea example: https://github.com/charmbracelet/bubbletea/tree/main/examples/tabs

func NewTabModel

func NewTabModel(tabs []*Tab) *TabModel

func (*TabModel) CurrentTab

func (m *TabModel) CurrentTab() *Tab

func (*TabModel) Header

func (m *TabModel) Header() string

func (*TabModel) Init

func (m *TabModel) Init() tea.Cmd

func (*TabModel) KeyBinds

func (m *TabModel) KeyBinds() []key.Binding

func (*TabModel) SetHeight

func (m *TabModel) SetHeight(height int)

func (*TabModel) SetWidth

func (m *TabModel) SetWidth(width int)

func (*TabModel) Update

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

func (*TabModel) View

func (m *TabModel) View() string

type Table

type Table[T any] struct {
	Model table.Model
	// contains filtered or unexported fields
}

func NewTable

func NewTable[T any](
	columns []table.Column,
	loadData TypedCmd[[]T],
	createRow func(T) table.Row,
	onSelect func(rows []table.Row) tea.Cmd,
	tableOptions ...TableOption[T],
) *Table[T]

func (*Table[T]) Init

func (t *Table[T]) Init() tea.Cmd

func (*Table[T]) Update

func (t *Table[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Table[T]) View

func (t *Table[T]) View() string

type TableOption

type TableOption[T any] func(*Table[T])

func WithCustomOptions

func WithCustomOptions[T any](options []CustomOption) TableOption[T]

func WithHeader

func WithHeader[T any](message string) TableOption[T]

type TypedCmd

type TypedCmd[D any] tea.Cmd

TypedCmd is a wrapper around tea.Cmd that allows us to specify the type of data that the command will return. Since tea.Cmd is just a function that returns a message, it can be used to return any type of data. This wrapper allows us to have a more type-safe way of dealing with commands that return specific types of data.

Only the wrapper should be used to create a TypedCmd. And the function inside the type should never be executed directly. Instead, we should return the `tea.Cmd` from an Update or Init function on a `tea.Model`.

func (TypedCmd[D]) Unwrap

func (c TypedCmd[D]) Unwrap() tea.Cmd

type UserFacingError

type UserFacingError struct {
	Title   string
	Message string
	Err     error
}

func (UserFacingError) Error

func (u UserFacingError) Error() string

Directories

Path Synopsis
pkg/tui/views/jobcancelview.go
pkg/tui/views/jobcancelview.go

Jump to

Keyboard shortcuts

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