Documentation
¶
Index ¶
- Constants
- Variables
- func NewSpinner(color bool) spinner.Model
- type PreviewModel
- type SelectModel
- func (m SelectModel) Done() bool
- func (m SelectModel) Init() tea.Cmd
- func (m SelectModel) Selected() int
- func (m SelectModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m SelectModel) View() tea.View
- func (m SelectModel) WithCursor(i int) SelectModel
- func (m SelectModel) WithHint(hint string) SelectModel
- type TokenModel
Constants ¶
const ( KeyCtrlC = "ctrl+c" KeyEnter = "enter" KeyEsc = "esc" KeyBackspace = "backspace" KeyHome = "home" KeyEnd = "end" KeySlash = "/" // Letter keys. The value is the literal bubbletea reports; uppercase // variants are the shifted key (e.g. "N" for shift+n). KeyQ = "q" KeyN = "n" KeyShiftN = "N" KeyG = "g" KeyShiftG = "G" )
Key constants map bubbletea key-press string representations to named values.
const ( // PreviewFrameWidth is how many columns the frame steals from the box's // outer width before content. Callers subtract it from the pane width to get // the column count content must wrap to (e.g. glamour word-wrap width). PreviewFrameWidth = previewBorderSize + previewPaddingX // PreviewFrameHeight is the rows the frame consumes, so callers can size the // box to leave room for surrounding chrome. PreviewFrameHeight = previewBorderSize // top+bottom border )
previewFramePadding is the columns/rows lipgloss border + horizontal padding add around the content. The border costs 1 cell on each side (2 cols, 2 rows) and the padding adds 1 col on each side (2 cols).
Variables ¶
Functions ¶
func NewSpinner ¶
Types ¶
type PreviewModel ¶
type PreviewModel struct {
// contains filtered or unexported fields
}
PreviewModel is a display-only pane that frames pre-rendered content inside a bordered box. It does no rendering of its own — callers supply already-styled content (e.g. glamour-rendered markdown) and the box size, and PreviewModel only draws the frame. It is used as the right-hand pane of the theme picker to show sample markdown rendered in the highlighted theme.
PreviewModel is not a standalone bubbletea program: it has no Update loop and View returns a plain string so a parent model can compose it horizontally with other panes.
func NewPreviewModel ¶
func NewPreviewModel() PreviewModel
NewPreviewModel returns an empty preview pane.
func (PreviewModel) ContentHeight ¶
func (m PreviewModel) ContentHeight() int
ContentHeight is the row count available for content inside the frame. Callers use it to vertically place content (e.g. to center a loading placeholder).
func (PreviewModel) ContentWidth ¶
func (m PreviewModel) ContentWidth() int
ContentWidth is the column count available for content inside the frame. Callers wrap their content (e.g. via glamour) to this width.
func (PreviewModel) View ¶
func (m PreviewModel) View() string
View renders the bordered content box as a plain string for a parent model to place. Returns "" until a size has been set.
func (PreviewModel) WithContent ¶
func (m PreviewModel) WithContent(content string) PreviewModel
WithContent returns a copy of the pane displaying content. Content is assumed to be pre-wrapped to ContentWidth(); anything wider is clipped by the box.
func (PreviewModel) WithSize ¶
func (m PreviewModel) WithSize(width, height int) PreviewModel
WithSize returns a copy of the pane sized to the given outer width and height (in terminal cells), border and padding included.
type SelectModel ¶
type SelectModel struct {
// contains filtered or unexported fields
}
SelectModel is a single-choice picker rendered as a vertical list with a cursor (›) marking the focused option. ↑/↓ or k/j move; Enter confirms; Esc/Ctrl+C cancels.
func NewSelectModel ¶
func NewSelectModel(prompt string, options []string) SelectModel
func (SelectModel) Done ¶
func (m SelectModel) Done() bool
Done reports whether the user has confirmed a selection.
func (SelectModel) Init ¶
func (m SelectModel) Init() tea.Cmd
func (SelectModel) Selected ¶
func (m SelectModel) Selected() int
Selected returns the index chosen by the user. Only valid when Done().
func (SelectModel) View ¶
func (m SelectModel) View() tea.View
func (SelectModel) WithCursor ¶
func (m SelectModel) WithCursor(i int) SelectModel
WithCursor returns a copy of the model with the initial cursor positioned at index i, clamped to the available options. Use this to pre-select a default choice.
func (SelectModel) WithHint ¶
func (m SelectModel) WithHint(hint string) SelectModel
WithHint returns a copy of the model with a custom footer hint line.
type TokenModel ¶
type TokenModel struct {
// contains filtered or unexported fields
}
func NewTokenModel ¶
func NewTokenModel() TokenModel
func (TokenModel) Init ¶
func (m TokenModel) Init() tea.Cmd
func (TokenModel) Token ¶
func (m TokenModel) Token() string
func (TokenModel) View ¶
func (m TokenModel) View() tea.View