Documentation
¶
Index ¶
- type App
- type BaseWindow
- func (bw *BaseWindow) ActiveKeyBindings() []key.Binding
- func (bw *BaseWindow) Add(child widget.Component, position widget.Position)
- func (bw *BaseWindow) OnKeyPress(fn func(tea.KeyMsg) tea.Cmd)
- func (bw *BaseWindow) OnUpdate(fn func() tea.Cmd)
- func (bw *BaseWindow) ShowPopup(popup *PopupWindow) tea.Cmd
- func (bw *BaseWindow) View() string
- type MainWindow
- type OverlayOffset
- type PopupStyles
- type PopupWindow
- type Stack
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.
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.
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 ¶
PopupStyles defines the visual appearance of a popup window.
func DefaultPopupStyles ¶
func DefaultPopupStyles() PopupStyles
DefaultPopupStyles returns sensible defaults for popup windows.
type PopupWindow ¶
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.