component

package
v0.2.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

Breadcrumb renders the navigation path as the panel title.

func NewBreadcrumb

func NewBreadcrumb(t theme.Theme) Breadcrumb

NewBreadcrumb creates a new breadcrumb component.

func (b *Breadcrumb) SetCount(n int)

SetCount sets the item count shown next to the title.

func (b *Breadcrumb) SetSearchAnnotation(s string)

SetSearchAnnotation sets the search badge shown after the breadcrumb.

func (b *Breadcrumb) SetSegment(s *BreadcrumbSegment)

SetSegment sets the k9s-style breadcrumb segment.

func (b *Breadcrumb) SetSegments(segments []string)

SetSegments updates the breadcrumb path (legacy).

func (b *Breadcrumb) SetTail(tail bool)

SetTail enables [tail] badge instead of [count].

func (b *Breadcrumb) SetTheme(t theme.Theme)

SetTheme updates the theme used for rendering.

func (b Breadcrumb) View() string

View renders the breadcrumb as a title string (used inside bordered content panel).

type BreadcrumbPart struct {
	Text       string
	IsBuildNum bool
	Separator  string // ":" instead of "/" before this part; empty = default "/"
}

BreadcrumbPart is one piece of the context portion of a breadcrumb segment.

type BreadcrumbSegment struct {
	ViewType      string
	Context       []BreadcrumbPart
	Running       bool             // filter active — rendered as "running " prefix
	Mine          bool             // filter active — rendered as "my " prefix
	ResolvedParts []BreadcrumbPart // resolved #last info, shown after " → " arrow
}

BreadcrumbSegment mirrors view.BreadcrumbSegment so the component package doesn't import the view package.

type Column

type Column struct {
	Title string
	Width int
}

Column defines a table column.

type Field

type Field struct {
	Key         string
	Label       string
	Kind        FieldKind
	Description string
	Required    bool
	Choices     []string
	Default     string
	Validator   func(string) error
}

Field describes one input in a PopupForm.

type FieldKind

type FieldKind int

FieldKind identifies the input shape of a PopupForm field.

const (
	FieldText FieldKind = iota
	FieldPassword
	FieldBool
	FieldChoice
)
type Header struct {
	// contains filtered or unexported fields
}

Header renders the top panel with connection info and shortcuts.

func NewHeader

func NewHeader(t theme.Theme, url, user, jenkinsVersion string, debug bool) Header

NewHeader creates a new header component.

func (*Header) SetConnected

func (h *Header) SetConnected(connected bool)

SetConnected updates the connection status.

func (*Header) SetDebugCounters

func (h *Header) SetDebugCounters(renderMs, updateMs int64, cacheTotal int, updateCount int64, viewType string)

SetDebugCounters updates the debug overlay values shown in the header.

func (*Header) SetMineFilter

func (h *Header) SetMineFilter(mine bool)

SetMineFilter updates whether the mine filter is active (shown inline with username).

func (*Header) SetRunningBuilds

func (h *Header) SetRunningBuilds(count int, key string)

SetRunningBuilds updates the running builds count and the key hint shown when > 0.

func (*Header) SetTheme

func (h *Header) SetTheme(t theme.Theme)

SetTheme updates the theme used for rendering.

func (*Header) SetURL

func (h *Header) SetURL(url string)

SetURL updates the server URL shown in the header.

func (*Header) SetUser

func (h *Header) SetUser(user string)

SetUser updates the user shown in the header.

func (*Header) SetViewShortcuts

func (h *Header) SetViewShortcuts(shortcuts []Shortcut)

SetViewShortcuts updates the context-sensitive shortcuts from the active view. Called on every render to reflect the current view state.

func (*Header) SetWidth

func (h *Header) SetWidth(w int)

SetWidth updates the header width.

func (Header) View

func (h Header) View() string

View renders the header panel.

type InputMode

type InputMode int

InputMode represents the current input mode.

const (
	ModeNormal InputMode = iota
	ModeCommand
	ModeSearch
)
type NavTags struct {
	// contains filtered or unexported fields
}

NavTags renders k9s-style navigation tags at the bottom of the TUI.

func NewNavTags

func NewNavTags(t theme.Theme) NavTags

NewNavTags creates a new NavTags component.

func (n *NavTags) SetRooted(r bool)

SetRooted marks whether the current view is root-scoped (e.g. builds(*)). Root-scoped views show only the active tag, no ancestors.

func (n *NavTags) SetTheme(t theme.Theme)

SetTheme updates the theme used for rendering.

func (n *NavTags) SetViewType(vt string)

SetViewType sets the current view's ViewType (e.g. "builds+running").

func (n NavTags) View() string

View renders the navigation tag line.

type ParamForm

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

ParamForm is a self-contained form component for entering Jenkins build parameters. It is a thin adapter on top of PopupForm.

func NewParamForm

func NewParamForm(t theme.Theme, params []jenkins.ParameterDefinition) ParamForm

NewParamForm creates a form from parameter definitions.

func (*ParamForm) SetSize

func (pf *ParamForm) SetSize(termW, termH int)

SetSize updates both the popup content width and visible row count from the host's terminal dimensions.

func (*ParamForm) SetTheme

func (pf *ParamForm) SetTheme(t theme.Theme)

SetTheme updates the theme used for rendering.

func (*ParamForm) Update

func (pf *ParamForm) Update(msg tea.KeyMsg) ParamFormResult

Update processes a key message and returns the form result.

func (ParamForm) View

func (pf ParamForm) View() string

View renders the form.

type ParamFormResult

type ParamFormResult struct {
	Status ParamFormStatus
	Values map[string]string
}

ParamFormResult is returned by Update after each key press.

type ParamFormStatus

type ParamFormStatus int

ParamFormStatus represents the outcome of a form interaction.

const (
	ParamFormActive ParamFormStatus = iota
	ParamFormDone
	ParamFormCancelled
)

type PopupForm

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

PopupForm is a reusable modal form with shared key bindings, validation and rendering. Hosts wrap it to expose domain-specific APIs.

func NewPopupForm

func NewPopupForm(t theme.Theme, title string, defs []Field) PopupForm

NewPopupForm constructs a popup form with the given fields and a default content width of 60 columns. Hosts should call SetSize once they know the terminal dimensions.

func (PopupForm) ContentWidth

func (pf PopupForm) ContentWidth() int

ContentWidth reports the current inner width (before border + padding).

func (PopupForm) Cursor

func (pf PopupForm) Cursor() int

Cursor returns the active field index.

func (*PopupForm) FocusKey

func (pf *PopupForm) FocusKey(key string)

FocusKey moves the cursor to the field with the given Key, if any.

func (*PopupForm) RegisterCustomKey

func (pf *PopupForm) RegisterCustomKey(key, id, hint string)

RegisterCustomKey associates a key binding with an id surfaced via PopupResult.Custom and a footer hint.

func (*PopupForm) ReserveStatusLines

func (pf *PopupForm) ReserveStatusLines(n int)

ReserveStatusLines reserves a fixed number of rows for the status section so the popup's overall height does not change when status text appears or disappears. n=0 disables reservation (status renders only when set).

func (*PopupForm) SetSize

func (pf *PopupForm) SetSize(termW, termH int)

SetSize updates content width (clamped 50..80) from the terminal dimensions. Width snaps once and remains stable until called again, so typing into a field cannot grow the popup. termH is accepted for future use but currently ignored — all fields are rendered without scrolling.

func (*PopupForm) SetStatus

func (pf *PopupForm) SetStatus(kind StatusKind, text string)

SetStatus sets the optional status line. Pass StatusNone to clear.

func (*PopupForm) SetTheme

func (pf *PopupForm) SetTheme(t theme.Theme)

SetTheme refreshes the theme used for rendering.

func (*PopupForm) Update

func (pf *PopupForm) Update(msg tea.KeyMsg) PopupResult

Update processes a key event and returns the resulting popup state.

func (PopupForm) Values

func (pf PopupForm) Values() map[string]string

Values returns the current value for each field as a string map keyed by Field.Key.

func (PopupForm) View

func (pf PopupForm) View() string

View renders the popup as a styled box. Callers overlay it on a background using their preferred mechanism (e.g. view.overlayCenter).

type PopupResult

type PopupResult struct {
	Status PopupStatus
	Custom string // populated when Status == PopupCustom
}

PopupResult is returned by PopupForm.Update.

type PopupStatus

type PopupStatus int

PopupStatus is the outcome of a PopupForm.Update call.

const (
	PopupActive PopupStatus = iota
	PopupSubmitted
	PopupCancelled
	PopupCustom
)

type ProgressBar

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

ProgressBar renders a styled progress bar string of exact visible width.

func NewProgressBar

func NewProgressBar(t theme.Theme) ProgressBar

NewProgressBar creates a new progress bar with the given theme.

func (ProgressBar) DualRenderWithText

func (pb ProgressBar) DualRenderWithText(width int, elapsed, estimated time.Duration) string

DualRenderWithText returns both normal and selected renderings of an inline progress bar, joined by \x1f. The table uses this to pick the right variant.

func (ProgressBar) Render

func (pb ProgressBar) Render(width int, elapsed, estimated time.Duration) string

Render returns a styled progress bar string of exactly `width` visible characters. When estimated is 0, returns a "● Running" fallback.

func (ProgressBar) RenderComplete

func (pb ProgressBar) RenderComplete(width int, text string, style lipgloss.Style) string

RenderComplete renders a fully filled bar with centered text in the given style.

func (ProgressBar) RenderCompleteTall

func (pb ProgressBar) RenderCompleteTall(width int, text string, style lipgloss.Style) string

RenderCompleteTall renders a 3-line tall fully filled bar with centered text on the middle line.

func (ProgressBar) RenderPendingTall

func (pb ProgressBar) RenderPendingTall(width int, text string) string

RenderPendingTall renders a 3-line tall bar filled with a uniform shade character, with centered text on the middle line. Uses the same colors as the unfilled progress bar portion for a subtle "waiting" appearance.

func (ProgressBar) RenderWithText

func (pb ProgressBar) RenderWithText(width int, elapsed, estimated time.Duration) string

RenderWithText returns a styled progress bar with time-remaining text centered inside.

func (ProgressBar) RenderWithTextTall

func (pb ProgressBar) RenderWithTextTall(width int, elapsed, estimated time.Duration) string

RenderWithTextTall returns a 3-line tall progress bar with text centered on the middle line. Top and bottom lines show a solid filled/empty bar without text.

func (*ProgressBar) SetTheme

func (pb *ProgressBar) SetTheme(t theme.Theme)

SetTheme updates the theme used for rendering.

type Row

type Row []string

Row is a slice of cell values.

type Shortcut

type Shortcut struct {
	Key    string
	Action string
	Active bool // when true, action text is highlighted with the search match style
}

Shortcut is a key/action pair.

type StatusBar

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

StatusBar manages command/search input and error display.

func NewStatusBar

func NewStatusBar(t theme.Theme) StatusBar

NewStatusBar creates a new status bar.

func (*StatusBar) ClearError

func (s *StatusBar) ClearError()

ClearError clears the error message.

func (StatusBar) CommandView

func (s StatusBar) CommandView() string

CommandView renders the command input panel (shown at top when active).

func (*StatusBar) HasError

func (s *StatusBar) HasError() bool

HasError returns whether an error is currently displayed.

func (*StatusBar) Mode

func (s *StatusBar) Mode() InputMode

Mode returns the current input mode.

func (*StatusBar) SetError

func (s *StatusBar) SetError(err string)

SetError sets an error message to display.

func (*StatusBar) SetInput

func (s *StatusBar) SetInput(input string)

SetInput updates the command/search input text.

func (*StatusBar) SetMode

func (s *StatusBar) SetMode(mode InputMode)

SetMode updates the input mode.

func (*StatusBar) SetSuggestion

func (s *StatusBar) SetSuggestion(suggestion string)

SetSuggestion updates the inline autocomplete suggestion.

func (*StatusBar) SetTheme

func (s *StatusBar) SetTheme(t theme.Theme)

SetTheme updates the theme used for rendering.

func (*StatusBar) SetWidth

func (s *StatusBar) SetWidth(w int)

SetWidth updates the status bar width.

type StatusKind

type StatusKind int

StatusKind selects the styling of the optional status line.

const (
	StatusNone StatusKind = iota
	StatusInfo
	StatusOK
	StatusError
)

type Table

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

Table renders a selectable, scrollable table.

func NewTable

func NewTable(t theme.Theme, columns []Column) Table

NewTable creates a new table component.

func (*Table) ContentHeight

func (t *Table) ContentHeight() int

ContentHeight returns the number of visible content rows (excluding header).

func (*Table) Cursor

func (t *Table) Cursor() int

Cursor returns the current cursor index.

func (*Table) End

func (t *Table) End()

End moves the cursor to the last non-disabled row.

func (*Table) Home

func (t *Table) Home()

Home moves the cursor to the first non-disabled row.

func (*Table) IsDisabled

func (t *Table) IsDisabled(idx int) bool

IsDisabled returns true if the row at idx is disabled.

func (*Table) MoveDown

func (t *Table) MoveDown()

MoveDown moves the cursor down, skipping disabled rows.

func (*Table) MoveUp

func (t *Table) MoveUp()

MoveUp moves the cursor up, skipping disabled rows.

func (*Table) PageDown

func (t *Table) PageDown()

PageDown moves the cursor down by one page, snapping to a non-disabled row.

func (*Table) PageUp

func (t *Table) PageUp()

PageUp moves the cursor up by one page, snapping to a non-disabled row.

func (*Table) ScrollOffset

func (t *Table) ScrollOffset() int

ScrollOffset returns the index of the first visible row.

func (*Table) SelectedRow

func (t *Table) SelectedRow() Row

SelectedRow returns the currently selected row, or nil if empty.

func (*Table) SetColumnWidth

func (t *Table) SetColumnWidth(i, w int)

SetColumnWidth updates the width of the column at index i.

func (*Table) SetCursor

func (t *Table) SetCursor(idx int)

SetCursor moves the cursor to the given index, adjusting scroll offset. If the target row is disabled, it snaps to the nearest non-disabled row (preferring forward, then backward).

func (*Table) SetDisabled

func (t *Table) SetDisabled(indices map[int]bool)

SetDisabled stores the set of disabled row indices. Pass nil to clear.

func (*Table) SetRows

func (t *Table) SetRows(rows []Row)

SetRows replaces the table data.

func (*Table) SetSize

func (t *Table) SetSize(w, h int)

SetSize updates the table dimensions and clamps the scroll offset so that rows aren't needlessly scrolled out of view (e.g. after a height increase).

func (*Table) SetTheme

func (t *Table) SetTheme(th theme.Theme)

SetTheme updates the theme used for rendering.

func (*Table) TotalRows

func (t *Table) TotalRows() int

TotalRows returns the total number of rows in the table.

func (Table) View

func (t Table) View() string

View renders the table.

Jump to

Keyboard shortcuts

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