Skip to content

Latest commit

 

History

History
73 lines (55 loc) · 2.98 KB

File metadata and controls

73 lines (55 loc) · 2.98 KB
type Package Documentation
title CoreCLI frame — opt-in TUI sub-module
description The Frame live TUI AppShell — an isolated sub-module wrapping bubbletea and lipgloss behind the HLCRF region model, with focus navigation and ready-made components
repo core/cli
module dappco.re/go/cli/frame

Frame — opt-in TUI sub-module

Frame is a live compositional AppShell for TUIs. It lives in its own Go module (dappco.re/go/cli/frame, own go.mod) so its dependencies — charmbracelet/bubbletea, charmbracelet/lipgloss, charmbracelet/x/ansi — never reach consumers that need only output and command registration. Source: go/pkg/cli/frame/.

Model

Components implement one interface; the frame allocates width and height per region:

type Model interface {
    View(width, height int) string
}

type ModelFunc func(width, height int) string // func adapter

Building a frame

NewFrame(variant) takes an HLCRF variant string (the same Header/Left/Content/Right/Footer region model as the lib's Layout); region methods slot models in:

f := frame.NewFrame("HCF").
    Header(frame.StatusLine("app", "env", "dev")).
    Content(myModel).
    Footer(frame.KeyHints("q quit", "tab focus"))
f.Run()               // live bubbletea programme (TTY)
f.RunFor(5 * time.Second)
s := f.String()       // one-shot render, no programme

Navigation and focus

  • Navigate(m) pushes a model into Content and records history; Back() pops it.
  • Focus(region), Focused() — explicit focus; WithKeyMap(km) rebinds keys.
  • KeyMap fields: FocusNext, FocusPrev, FocusUp, FocusDown, FocusLeft, FocusRight, Back, Quit (all tea.KeyType). Focus cycles a ring of populated regions; arrow-style keys move spatially.
  • Send(msg) injects a tea.Msg; Stop() ends the programme. Frame itself implements tea.Model (Init/Update/View).

Components

Ready-made single-line models in frame_components.go:

Component Renders
StatusLine(title, pairs...) Title plus key/value pairs
KeyHints(hints...) Key-binding hints row
Breadcrumb(parts...) Navigation trail
StaticModel(text) Fixed text block

Notes

  • Output defaults to stderr; WithOutput(w) redirects (used by tests and String()).
  • Non-TTY environments get the one-shot render path rather than a live programme.
  • The sub-module pins its own dappco.re/go version independently of the parent lib.

File map

File Contents
go/pkg/cli/frame/frame.go Frame, Model, navigation, focus ring, bubbletea integration
go/pkg/cli/frame/frame_components.go StatusLine, KeyHints, Breadcrumb, StaticModel
go/pkg/cli/frame/frame_model.go Internal model plumbing
go/pkg/cli/frame/layout.go Region geometry for the frame
go/pkg/cli/frame/style.go lipgloss styles
go/pkg/cli/frame/io.go Writer plumbing
go/pkg/cli/frame/go.mod Module boundary — bubbletea/lipgloss stay here