Documentation
¶
Index ¶
- Constants
- Variables
- func CloneContext(ctx context.Context) context.Context
- func CloneStateAndPushPage[S CloneableState[S]](ctx context.Context, page tea.Model) context.Context
- func GetCurrentModel(ctx context.Context) tea.Model
- func GetCurrentState[S any](ctx context.Context) S
- func GetInitiaConfigDirectory(ctx context.Context) (string, error)
- func GetInitiaDataDirectory(ctx context.Context) (string, error)
- func GetInitiaHome(ctx context.Context) (string, error)
- func GetMinitiaArtifactsConfigJson(ctx context.Context) (string, error)
- func GetMinitiaArtifactsJson(ctx context.Context) (string, error)
- func GetMinitiaHome(ctx context.Context) (string, error)
- func GetOPInitHome(ctx context.Context) (string, error)
- func GetOPInitKeyFileJson(ctx context.Context) (string, error)
- func GetTooltip(ctx context.Context) bool
- func GetWindowWidth(ctx context.Context) int
- func HandleCommonCommands[S CloneableState[S]](model BaseModelInterface, msg tea.Msg) (tea.Model, tea.Cmd, bool)
- func NewAppContext[S CloneableState[S]](initialState S) context.Context
- func PushPageAndGetState[S CloneableState[S]](baseModel BaseModelInterface) S
- func PushPageState[S CloneableState[S]](ctx context.Context, page tea.Model, state S) context.Context
- func SetCurrentModel(ctx context.Context, currentModel tea.Model) context.Context
- func SetCurrentState[S any](ctx context.Context, state S) context.Context
- func SetInitiaHome(ctx context.Context, initiaHome string) context.Context
- func SetMinitiaHome(ctx context.Context, minitiaHome string) context.Context
- func SetOPInitHome(ctx context.Context, opInitHome string) context.Context
- func SetTooltip(ctx context.Context, showTooltip bool) context.Context
- func SetWindowWidth(ctx context.Context, windowWidth int) context.Context
- func ToggleTooltip(ctx context.Context, msg tea.Msg) (context.Context, bool)
- func ToggleTooltipInContext(ctx context.Context) context.Context
- func Undo[S CloneableState[S]](ctx context.Context, msg tea.Msg) (context.Context, tea.Model, tea.Cmd, bool)
- type BaseModel
- type BaseModelInterface
- type CloneableState
- type Key
- type PageStatePair
Constants ¶
const (
DefaultPadding int = 2
)
Variables ¶
var ( ExistingContextKey = []Key{ PageKey, StateKey, PageStackKey, TooltipToggleKey, InitiaHomeKey, MinitiaHomeKey, OPInitHomeKey, WindowWidth, } )
Functions ¶
func CloneContext ¶
CloneContext creates a shallow copy of the existing context while preserving all keys and values
func CloneStateAndPushPage ¶
func CloneStateAndPushPage[S CloneableState[S]](ctx context.Context, page tea.Model) context.Context
CloneStateAndPushPage clones the current state and pushes the current page-state pair onto the context (non-pointer version)
func GetCurrentModel ¶
GetCurrentModel retrieves the current model from the context
func GetCurrentState ¶
GetCurrentState retrieves the current state from the context and panics if not found (a non-pointer version)
func GetOPInitKeyFileJson ¶ added in v0.1.2
func GetTooltip ¶
GetTooltip retrieves the boolean value for showing or hiding tooltip information from the context
func GetWindowWidth ¶
func HandleCommonCommands ¶
func HandleCommonCommands[S CloneableState[S]](model BaseModelInterface, msg tea.Msg) (tea.Model, tea.Cmd, bool)
func NewAppContext ¶
func NewAppContext[S CloneableState[S]](initialState S) context.Context
NewAppContext initializes a new context with a generic state.
func PushPageAndGetState ¶
func PushPageAndGetState[S CloneableState[S]](baseModel BaseModelInterface) S
func PushPageState ¶
func PushPageState[S CloneableState[S]](ctx context.Context, page tea.Model, state S) context.Context
PushPageState pushes the current page and state onto the stack in the context
func SetCurrentModel ¶
SetCurrentModel updates the current model in the context
func SetCurrentState ¶
SetCurrentState stores the current state in the context using StateKey (non-pointer version)
func SetTooltip ¶
SetTooltip sets the boolean value for showing or hiding tooltip information in the context
func ToggleTooltip ¶
ToggleTooltip toggles the "tooltip" flag in the context for showing tooltips.
Types ¶
type BaseModel ¶
BaseModel provides common functionality for all context-aware models
func (*BaseModel) CanGoPreviousPage ¶
func (*BaseModel) GetContext ¶
GetContext retrieves the context from BaseModel
func (*BaseModel) SetContext ¶
SetContext set the context from BaseModel
type BaseModelInterface ¶
type BaseModelInterface interface {
tea.Model
SetContext(ctx context.Context)
GetContext() context.Context
CanGoPreviousPage() bool
WrapView(content string) string
HandlePanic(err error) tea.Cmd
}
BaseModelInterface is an interface for base models
func AdjustWindowSize ¶
func AdjustWindowSize(model BaseModelInterface, msg tea.Msg) BaseModelInterface
type CloneableState ¶
type CloneableState[S any] interface { Clone() S }
CloneableState is an interface that requires the Clone method
type PageStatePair ¶
type PageStatePair[S CloneableState[S]] struct { Page tea.Model State S }
PageStatePair is a generic struct that holds a pair of page (model) and its associated state.
func GetPageStack ¶
func GetPageStack[S CloneableState[S]](ctx context.Context) []PageStatePair[S]
GetPageStack retrieves the page-state stack from the context
func PopPageState ¶
func PopPageState[S CloneableState[S]](ctx context.Context) (context.Context, *PageStatePair[S])
PopPageState pops the last page-state pair from the stack