Documentation
¶
Index ¶
- func ContextPicker(width, height int, contexts []string, selected int, errMsg string) string
- func Help(width, height int, viewTitle string, specs []KeySpec) string
- func HelpBody(viewTitle string, specs []KeySpec) string
- func LongestCommonPrefix(cmds []Command) string
- func NSChip(ns string) string
- func NSChipBold(ns string) string
- func Overlay(base, top string, col, row int) string
- func Sparkline(samples []float64, width int, color lipgloss.Color) string
- func StatusDot(phase string) string
- func StatusPill(phase string) string
- type Align
- type Column
- type Command
- type Form
- func (f Form) AddRow(k, v string) Form
- func (f Form) Data() map[string][]byte
- func (f Form) DeleteSelected() Form
- func (f Form) IsDirty() bool
- func (f Form) IsHidden(i int) bool
- func (f Form) Mode() FormMode
- func (f Form) RowCount() int
- func (f Form) SetWidth(w int) Form
- func (f Form) Update(msg tea.Msg) (Form, tea.Cmd)
- func (f Form) View() string
- func (f Form) WithName(name string) Form
- func (f Form) WithOriginal(data map[string][]byte) Form
- type FormMode
- type FormQuitRequestedMsg
- type FormSaveRequestedMsg
- type KeySpec
- type Palette
- func (p Palette) Filtered() []Command
- func (p Palette) MoveDown() (Palette, tea.Cmd)
- func (p Palette) MoveUp() (Palette, tea.Cmd)
- func (p Palette) Selected() *Command
- func (p Palette) SetInput(s string) Palette
- func (p Palette) Update(msg tea.Msg) (Palette, tea.Cmd)
- func (p Palette) View(width int) string
- type PaletteCmd
- type Row
- type Table
- func (t Table) MoveBottom() Table
- func (t Table) MoveDown() Table
- func (t Table) MoveTop() Table
- func (t Table) MoveUp() Table
- func (t Table) RowCount() int
- func (t Table) SelectedIndex() int
- func (t Table) SelectedRow() Row
- func (t Table) SetHeight(h int) Table
- func (t Table) SetRows(rows []Row) Table
- func (t Table) SetWidth(w int) Table
- func (t Table) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextPicker ¶ added in v0.3.0
ContextPicker renders a centered modal listing available kubeconfig contexts. Used at startup when no current-context is set (or `klens` was pointed at a kubeconfig with multiple contexts and no default), so the user gets a list-pick UX instead of a cryptic "no current-context" error.
The component is purely a renderer — it doesn't own its own selection state because the shell already knows how to wire arrow-key + enter routing against a numeric index. Pass `selected` from the model.
func Help ¶ added in v0.3.0
Help renders the help modal centered on a blank canvas (legacy form, kept for the existing test). Prefer `HelpBody` + Overlay for live use.
func HelpBody ¶ added in v0.3.0
HelpBody renders the bordered help modal as an opaque block. The shell then overlays it over the live frame so the user keeps context while reading the keymap. Use `Help` for the legacy place-on-blank-canvas form.
`help.go` lives in `components` (not `layout`) because the views package already depends on both, while `layout` itself depends on `components` — putting the overlay here is the only direction that avoids an import cycle.
func LongestCommonPrefix ¶ added in v0.3.0
LongestCommonPrefix returns the longest case-insensitive prefix shared by every command's Name in cmds. Used by Tab-complete in inline ex-mode: if the user types `dep` and only `deployments` matches, Tab fills in the rest. If multiple candidates match, Tab fills in only the shared prefix so the user sees the disambiguation point.
func NSChip ¶ added in v0.3.0
NSChip renders a small colored square + namespace name, like the design's namespace dot. The square is "▆" (U+2586). Color comes from theme.NSColorFor.
func NSChipBold ¶ added in v0.3.0
NSChipBold renders a more prominent variant of NSChip — both square and name in the namespace's color, with the name bolded. Used in the top bar where the namespace is the visual anchor of the screen.
func Overlay ¶ added in v0.3.0
Overlay paints `top` over `base` at visual position (col, row), preserving ANSI escape codes on both. `base` and `top` are multi-line strings; rows are line indices (0-based) and cols are visible cells via lipgloss.Width.
Lipgloss has no native cell-coordinate overlay — `Place` blanks the background. We need an actual overlay so the palette / help modal can float above the live table without losing context. This implementation walks each base line, slicing it by visible-cell width via ansi.Truncate and ansi.TruncateLeft so escape sequences carry through correctly.
func Sparkline ¶ added in v0.3.0
Sparkline renders samples as a Unicode-block sparkline of the given character width, colored with `color`. Returns "" for empty samples.
func StatusDot ¶ added in v0.3.0
StatusDot returns just the colored ● glyph (no trailing name) for compact rows.
func StatusPill ¶ added in v0.3.0
StatusPill renders a colored dot ● + the phase name, both colored from theme.StatusStyleFor (Dot for the bullet, Text for the name).
Types ¶
type Column ¶
type Column struct {
Header string
Width int
Align Align // default Left
Flex bool // when true, the column grows to absorb leftover width
}
Column defines a table column's header and display width. Width is the minimum/baseline; Flex columns absorb any extra horizontal slack the table gets so the content stretches to the table's full assigned width instead of leaving an empty band on the right.
type Command ¶ added in v0.3.0
type Command struct {
Name string // e.g. "deployments"
Desc string // e.g. "list deployments"
Alias string // e.g. ":dp"
}
Command is one entry in the shell's command vocabulary. Used by both the modal palette (ctrl+p) and the inline ex-mode prompt (`:`), so the two surfaces share a single source of truth for what's runnable.
Name is the canonical spelling typed in the modal palette; Alias is the short form (vim-style `:dp`). Either matches in FilterCommands.
func DefaultCommands ¶ added in v0.3.0
func DefaultCommands() []Command
DefaultCommands is the built-in command list — resource jumps, the runtime context switcher, and quit. Adding a new command here makes it reachable from both ctrl+p (modal) and `:` (inline) automatically.
func ExactCommand ¶ added in v0.3.0
ExactCommand returns the command whose Name or Alias matches q exactly, or nil. Used by the inline ex-mode to short-circuit Enter when the user typed an unambiguous key like `q` or `dp`, even if the substring match would have surfaced multiple candidates.
func FilterCommands ¶ added in v0.3.0
FilterCommands returns commands matching q (case-insensitive substring on Name or Alias). Empty q returns the full slice in declaration order so the modal palette has a stable rendering when first opened.
Alias matching is prefix-anchored *after* the leading `:` is stripped — so `dp` finds `:dp` but `p` doesn't match every command whose alias starts with `:p…`. Substring on Name still applies, so typing `de` still surfaces `deployments`.
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form is an immutable key/value editor for secrets and configmaps. All mutation methods return a new Form — safe for Bubble Tea models.
func NewForm ¶
NewForm creates a Form pre-populated from a decoded secret/configmap Data map. The same map is also stashed as the diff baseline.
func (Form) AddRow ¶
AddRow appends a new row with the given key/value and lands on it in edit mode so the user can fill it in immediately.
func (Form) DeleteSelected ¶
DeleteSelected removes the currently selected row.
func (Form) IsDirty ¶
IsDirty reports whether the in-memory data differs from the baseline captured by NewForm/WithOriginal. Computed (not flagged) so reverting a typo back to its original value correctly reports clean.
func (Form) SetWidth ¶ added in v0.3.0
SetWidth sets the form's content width. Hosts call this from their Table() method so the form fills the focus frame's full width instead of the legacy 72-col default.
func (Form) Update ¶
Update routes input by mode. Non-key messages reach the active textinput so cursor blinks keep flowing.
type FormMode ¶ added in v0.3.0
type FormMode int
FormMode is the editor's input state. Three modes — that's the whole state machine.
ModeNav — j/k navigate, ↵ to edit a row, esc to exit (or
open ModeConfirmExit when the form is dirty).
ModeEdit — the selected row's value field is a textinput; the
form captures every keystroke until esc commits and
drops back to ModeNav. The value lands in the form's
in-memory data; the API write happens on confirm.
ModeConfirmExit — single inline bar at the bottom: `s` save & exit,
`d` discard & exit, `esc` cancel back to ModeNav.
const ( ModeEdit ModeConfirmExit )
Mode values for FormMode.
type FormQuitRequestedMsg ¶ added in v0.3.0
type FormQuitRequestedMsg struct{}
FormQuitRequestedMsg is emitted when the user picks `d` in ModeConfirmExit (or hits esc on a clean form). The host view drops the form without saving.
type FormSaveRequestedMsg ¶ added in v0.3.0
type FormSaveRequestedMsg struct{}
FormSaveRequestedMsg is emitted when the user picks `s` in ModeConfirmExit. The host view persists via its service then closes the form on the SecretSavedMsg / ConfigMapSavedMsg success path.
type KeySpec ¶ added in v0.3.0
KeySpec is one row in the help overlay: a key, what it does, and whether it's wired today. `Soon` keys render dimmed.
type Palette ¶
type Palette struct {
// contains filtered or unexported fields
}
Palette is an immutable command palette component (the modal surface). The inline ex-mode (`:`) doesn't use this — it renders its own one-line suggestion strip and shares only the underlying command list helpers.
func NewPalette ¶
NewPalette creates a Palette. Pass nil for cmds to use DefaultCommands.
func (Palette) Selected ¶
Selected returns the currently highlighted command, or nil if the list is empty.
func (Palette) SetInput ¶
SetInput sets the filter text directly (used in tests and keyboard shortcuts).
type PaletteCmd ¶
type PaletteCmd = Command
PaletteCmd is preserved as a name alias for backwards-compatibility with callers/tests that constructed palette entries directly. New code should use components.Command + DefaultCommands / FilterCommands from commands.go.
type Row ¶
type Row []string
Row is a slice of string cells, one per column. Cells may contain pre-rendered ANSI styling (chips, pills, sparklines) — the table preserves it.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is an immutable, value-type table component. All mutation methods return a new Table — safe to embed in Bubble Tea models.
func (Table) MoveBottom ¶
MoveBottom moves the selection to the last row.
func (Table) SelectedIndex ¶
SelectedIndex returns the zero-based index of the focused row.
func (Table) SelectedRow ¶
SelectedRow returns the currently focused Row, or nil if the table is empty.
func (Table) SetHeight ¶ added in v0.3.0
SetHeight sets the number of terminal rows allocated to the table.