MCPcopy Create free account
hub / github.com/cli/cli / renderOption

Method renderOption

internal/prompter/multi_select_with_search.go:339–356  ·  view source on GitHub ↗
(o msOption, cursor, selected bool)

Source from the content-addressed store, hash-verified

337}
338
339func (m *multiSelectSearchField) renderOption(o msOption, cursor, selected bool) string {
340 styles := m.activeStyles()
341
342 var parts []string
343 if cursor {
344 parts = append(parts, styles.MultiSelectSelector.String())
345 } else {
346 parts = append(parts, strings.Repeat(" ", lipgloss.Width(styles.MultiSelectSelector.String())))
347 }
348 if selected {
349 parts = append(parts, styles.SelectedPrefix.String())
350 parts = append(parts, styles.SelectedOption.Render(o.label))
351 } else {
352 parts = append(parts, styles.UnselectedPrefix.String())
353 parts = append(parts, styles.UnselectedOption.Render(o.label))
354 }
355 return lipgloss.JoinHorizontal(lipgloss.Left, parts...)
356}
357
358func (m *multiSelectSearchField) activeStyles() *huh.FieldStyles {
359 theme := m.theme

Callers 1

ViewMethod · 0.95

Calls 3

activeStylesMethod · 0.95
RenderMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected