modelmanager

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationNone = iota
	OperationPush
	OperationPop
	OperationReplace
)

Operations

Variables

This section is empty.

Functions

This section is empty.

Types

type ModelManager

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

Model manager

func New

func New(rootScreen Screen) ModelManager

Initializes a new instance of the model manager

func (*ModelManager) PopScreen

func (manager *ModelManager) PopScreen()

Pops the top screen from the stack

func (*ModelManager) PushScreen

func (manager *ModelManager) PushScreen(screen Screen) tea.Cmd

Adds a new screen on the stack

func (*ModelManager) ReplaceScreen

func (manager *ModelManager) ReplaceScreen(screen Screen) tea.Cmd

Replaces the current screen with a new screen on the stack

func (*ModelManager) ResolveOperation

func (manager *ModelManager) ResolveOperation()

Resolves the operation

func (*ModelManager) Update

func (manager *ModelManager) Update(msg tea.Msg) tea.Cmd

Calls the update method on the current screen

func (ModelManager) View

func (manager ModelManager) View() string

Calls the View() function on the current screen with center aligned to the screen

type Operation

type Operation struct {
	// Action
	Action int

	// Related screen
	Screen *Screen
}

Type of operation

func NoneOperation

func NoneOperation() Operation

None operation

type Screen

type Screen interface {
	Init() tea.Cmd
	Update(tea.Msg, *ModelManager) (Screen, tea.Cmd)
	View() string
}

A tea.Model-ish interface but for model manager

type ScreenRefocusedMsg

type ScreenRefocusedMsg struct{}

Message represeting that the screenw as refocused after popping

Jump to

Keyboard shortcuts

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