window

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App bridges an MTUI Window to Bubble Tea's Model interface.

func NewApp

func NewApp(win *MainWindow) *App

NewApp creates a Bubble Tea Model that manages the given Window.

func (*App) Init

func (a *App) Init() tea.Cmd

Init implements tea.Model.

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (*App) View

func (a *App) View() string

View implements tea.Model.

type BaseWindow

type BaseWindow struct {
	widget.BaseContainer
	// contains filtered or unexported fields
}

BaseWindow is the shared base for Window and PopupWindow. It provides:

  • Container behavior (embeds widget.BaseContainer)
  • A borderless content Panel with configurable layout (default TCB)
  • Keyboard event routing: Tab/Shift-Tab focus cycling, key binding resolution, focused leaf dispatch, OnKeyPress fallthrough
  • Mouse event routing: hit testing, focus change on press, MouseClickEvent dispatch
  • ShowPopup method (delegates to stack.push)
  • OnKeyPress callback setter

BaseWindow is NOT instantiated directly by users. It's embedded by Window and PopupWindow.

func (*BaseWindow) ActiveKeyBindings

func (bw *BaseWindow) ActiveKeyBindings() []key.Binding

ActiveKeyBindings returns all registered key bindings from visible, active components in the current window's component tree. Useful for building status bars or help overlays.

func (*BaseWindow) Add

func (bw *BaseWindow) Add(child widget.Component, position widget.Position)

Add places a child component at the given position in the content panel.

func (*BaseWindow) OnKeyPress

func (bw *BaseWindow) OnKeyPress(fn func(tea.KeyMsg) tea.Cmd)

OnKeyPress sets a handler called when a key is not consumed by focus cycling, key binding resolution, or the focused leaf's Update.

func (*BaseWindow) OnUpdate

func (bw *BaseWindow) OnUpdate(fn func() tea.Cmd)

OnUpdate sets a handler called after every event that changes state (focus, key bindings, etc.). Use this to update status bars or other reactive UI.

func (*BaseWindow) ShowPopup

func (bw *BaseWindow) ShowPopup(popup *PopupWindow) tea.Cmd

ShowPopup pushes a popup window onto the stack. Returns nil if no stack is set.

func (*BaseWindow) View

func (bw *BaseWindow) View() string

View renders the content panel, setting its size and position from the window.

type MainWindow

type MainWindow struct {
	BaseWindow
}

MainWindow is the main application window. It embeds BaseWindow for container behavior and event routing. Use NewApp(win) to start the application.

func NewWindow

func NewWindow(id string, layout ...widget.Layout) *MainWindow

NewWindow creates a new main window with the given ID. Optional layout parameter defaults to TCB.

type OverlayOffset

type OverlayOffset struct {
	X, Y int // content start position (inside the border)
}

OverlayOffset stores the screen offset where the popup content is rendered. Used by the Stack to adjust mouse coordinates for popup hit testing.

func RenderOverlay

func RenderOverlay(content, title string, width, height int) (string, OverlayOffset)

RenderOverlay renders a popup centered on a dimmed background. Returns the rendered string and the content offset for mouse coordinate adjustment.

type PopupStyles

type PopupStyles struct {
	Border lipgloss.Style
}

PopupStyles defines the visual appearance of a popup window.

func DefaultPopupStyles

func DefaultPopupStyles() PopupStyles

DefaultPopupStyles returns sensible defaults for popup windows.

type PopupWindow struct {
	BaseWindow
	// contains filtered or unexported fields
}

PopupWindow is a container rendered as a centered overlay. It embeds BaseWindow for event routing and adds Close/OnResult/Escape.

func NewPopupWindow

func NewPopupWindow(id, title string, styles PopupStyles, layout ...widget.Layout) *PopupWindow

NewPopupWindow creates a PopupWindow with the given ID, title, and styles. Optional layout parameter defaults to TCB.

func (*PopupWindow) Close

func (p *PopupWindow) Close(result any) tea.Cmd

Close returns a command that closes this popup and delivers the result. The Stack processes this: pops the popup, then calls OnResult.

func (*PopupWindow) OnResult

func (p *PopupWindow) OnResult(fn func(value any) tea.Cmd)

OnResult sets a handler called when the popup is closed. Called for both confirmed (non-nil result) and cancelled (nil result). Fires AFTER the popup is popped from the stack.

func (*PopupWindow) Title

func (p *PopupWindow) Title() string

Title returns the popup's title.

type Stack

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

Stack manages a MainWindow and its popup overlays. Internal to the framework.

Jump to

Keyboard shortcuts

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