()
| 299 | } |
| 300 | |
| 301 | func (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 | |
| 339 | func (m *multiSelectSearchField) renderOption(o msOption, cursor, selected bool) string { |
| 340 | styles := m.activeStyles() |
nothing calls this directly
no test coverage detected