base

package
v0.0.0-...-674ef51 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DotSpinner = spinner.Spinner{
	Frames: []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"},
	FPS:    time.Second / 10,
}

Functions

func Back

func Back() tea.Msg

Back goes back to the previous state if available.

func BackN

func BackN(steps int) tea.Cmd

BackN goes back N states back or up to the initial State (home).

func BackToHome

func BackToHome() tea.Msg

BackToHome goes back to the initial State (home).

func CombinedKeyMap

func CombinedKeyMap(first, second help.KeyMap) combinedKeyMap

CombinedKeyMap is a convenience function to create a combined KeyMap that implements help.KeyMap, useful for concatenating them.

The resulting keybind is not ment to be be modified in-place.

func Loaded

func Loaded() tea.Msg

Loaded will stop the loading message.

func Loading

func Loading(message string) tea.Cmd

Loading will display a loading message with a spinner.

func New

func New(state State) *model

func Notify

func Notify(message string) tea.Cmd

Notify sends a notification with the default time.Duration.

func NotifyWithDuration

func NotifyWithDuration(message string, duration time.Duration) tea.Cmd

NotifyWithDuration sends a notification with the given time.Duration.

func Viewport

func Viewport(title, content string, color lipgloss.Color) tea.Cmd

Types

type BackMsg

type BackMsg struct {
	Steps int
}

type BackToHomeMsg

type BackToHomeMsg struct{}

type LoadingMsg

type LoadingMsg struct {
	Message string
}

type NoKeyMap

type NoKeyMap struct{}

NoKeyMap implements help.keyMap.

func (NoKeyMap) FullHelp

func (k NoKeyMap) FullHelp() [][]key.Binding

FullHelp implements help.keyMap.

func (NoKeyMap) ShortHelp

func (k NoKeyMap) ShortHelp() []key.Binding

ShortHelp implements help.keyMap.

type NotificationMsg

type NotificationMsg struct {
	Message string
}

type NotificationTimeoutMsg

type NotificationTimeoutMsg struct{}

type NotificationWithDurationMsg

type NotificationWithDurationMsg struct {
	NotificationMsg
	Duration time.Duration
}

type RestoredMsg

type RestoredMsg struct{}

RestoredMsg is sent when going back to the state.

type ShowViewportMsg

type ShowViewportMsg struct {
	Title,
	Content string
	Color lipgloss.Color
}

type Size

type Size struct {
	Width,
	Height int
}

Size holds width and Height information.

type State

type State interface {
	// Intermediate if the State should be saved to history.
	//
	// For example when loading states.
	Intermediate() bool

	// Backable if can back out of the State to previous states.
	//
	// For example when filtering a list, this can avoid to go back
	// to previous state and instead cancel the filtering.
	Backable() bool

	// KeyMap returns the State specific KeyMap.
	KeyMap() help.KeyMap

	// Title of the State, with optional Background and Foreground.
	Title() Title

	// Subtitle of the Sate, shown below the Title.
	Subtitle() string

	// Status of the State, shown to the right of the Title.
	Status() string

	// Resize the State's usable viewport.
	//
	// Gets called at least once after Init, as well as each time the State
	// is popped out of the history before Update.
	Resize(size Size) tea.Cmd

	// Init is the first function that will be called. It returns an optional
	// initial command. To not perform an initial command return nil.
	Init(ctx context.Context) tea.Cmd

	// Update is called when a message is received. Use it to inspect messages
	// and, in response, update the model and/or send a command.
	Update(ctx context.Context, msg tea.Msg) tea.Cmd

	// View renders the program's UI, which is just a string. The view is
	// rendered after every Update.
	View() string
}

State is kind of an indirect wrapper interface of Model (wrapper of tea.Model).

State could be thought of as a "Window".

type Title

type Title struct {
	Text string

	Background,
	Foreground lipgloss.Color
}

Jump to

Keyboard shortcuts

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