stacker

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 1 Imported by: 0

README

Stacker

Scene stacking for the BubbleTea.

I already know BubbleTea. What is this?

A way to stack scenes on top of one another and interact with only the top one. For example:

Here is a "main menu" scene:

Choose a game:
 > Snake
   TicTacToe
   Tetris

And imagine there is a scene for each game listed.
When a user selects a game, they would expect to play the game. Then when they're done, they should be brought back to the main menu. For the sake of example, imagine the Snake game also has an "Options" menu which users would again expect to be able to enter and exit (back into their Snake game). This could be conceptually thought of as a stack of scenes!

The "stack" grows rightwards

- Program starts
| Main menu |
- User selects Snake
| Main menu | Snake |
- User plays Snake for a while...
| Main menu | Snake |
- User check options for Snake
| Main menu | Snake | Options |
- User saves their options (and returns to Snake)
| Main menu | Snake |
- User finishes playing snake
| Main menu |
- User selects TicTacToe
| Main menu | TicTacToe |
... and so on ...

Stacker is a framework to place "scenes" on top of each other. The "stacker" manages the stack of scenes. Only the top scene is shown and receives updates. The top-most scene can "push" a new scene on top or "pop" itself off of the stack.

API

TODO
This API is not even close to functioning yet. I think it can be used, but I also wouldn't be surprised if I've neglected to export a useful/necessary function.

Todo

  • Return the model when the scene is popped
  • Push a scene which, when popped, will not alert the pusher; or perhaps popping can be silent... That sounds easier
  • Put stackers on stackers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddScene

func AddScene(m tea.Model) tea.Cmd

func NewStacker

func NewStacker(m tea.Model) tea.Model

func PopScene

func PopScene() tea.Cmd

func PopSceneSilent

func PopSceneSilent() tea.Cmd

Types

type Stacker

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

func (*Stacker) Init

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

func (*Stacker) Update

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

func (*Stacker) View

func (m *Stacker) View() string

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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