modalstack

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package modalstack manages a stack of overlay layers (confirm, input, filter, help) so more than one can be open at once and they dismiss in LIFO order. Only the top layer is rendered, centered over the background.

Layers are render functions, not pre-rendered strings: each is called with the current terminal size at render time, so an open modal reflows correctly when the terminal is resized without the caller re-pushing it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

type Layer func(width, height int) string

Layer renders a modal's content for the given viewport size.

type Model

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

Model is a LIFO stack of overlay layers.

func (*Model) Active

func (m *Model) Active() bool

Active reports whether any layer is open.

func (*Model) Clear

func (m *Model) Clear()

Clear removes all layers.

func (*Model) Len

func (m *Model) Len() int

Len returns the number of open layers.

func (*Model) Pop

func (m *Model) Pop() (Layer, bool)

Pop removes and returns the top layer, reporting false when empty.

func (*Model) Push

func (m *Model) Push(layer Layer)

Push adds a layer on top.

func (*Model) Render

func (m *Model) Render(background string, width, height int) string

Render centers the top layer (rendered at the current size) over the background. With no layers it returns the background unchanged, so callers can render unconditionally.

func (*Model) Top

func (m *Model) Top() (Layer, bool)

Top returns the top layer without removing it.

Jump to

Keyboard shortcuts

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