MCPcopy Index your code
hub / github.com/cli/cli / View

Method View

internal/prompter/multi_select_with_search.go:301–337  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

299}
300
301func (m *multiSelectSearchField) View() string {
302 styles := m.activeStyles()
303 var sb strings.Builder
304
305 // Title.
306 if m.title != "" {
307 sb.WriteString(styles.Title.Render(m.title))
308 sb.WriteString("\n")
309 }
310
311 // Search input.
312 if m.searchTitle != "" {
313 sb.WriteString(styles.Description.Render(m.searchTitle))
314 sb.WriteString("\n")
315 }
316 sb.WriteString(m.search.View())
317 sb.WriteString("\n")
318
319 // Options list.
320 if m.loading {
321 m.spinner.Style = styles.MultiSelectSelector.UnsetString()
322 sb.WriteString(m.spinner.View() + " Loading...")
323 sb.WriteString("\n")
324 } else if len(m.options) == 0 {
325 sb.WriteString(styles.UnselectedOption.Render(" No results"))
326 sb.WriteString("\n")
327 } else {
328 for i, o := range m.options {
329 cursor := m.mode == msModeSelect && i == m.cursor
330 isSelected := m.selected[o.value]
331 sb.WriteString(m.renderOption(o, cursor, isSelected))
332 sb.WriteString("\n")
333 }
334 }
335
336 return styles.Base.Width(m.width).Height(m.height).Render(sb.String())
337}
338
339func (m *multiSelectSearchField) renderOption(o msOption, cursor, selected bool) string {
340 styles := m.activeStyles()

Callers

nothing calls this directly

Calls 5

activeStylesMethod · 0.95
renderOptionMethod · 0.95
RenderMethod · 0.65
ViewMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected