()
| 231 | } |
| 232 | |
| 233 | func (m selectModel) View() string { |
| 234 | var s strings.Builder |
| 235 | |
| 236 | msg := pretty.Sprintf(pretty.Bold(), "? %s", m.message) |
| 237 | |
| 238 | if m.selected != "" { |
| 239 | selected := pretty.Sprint(DefaultStyles.Keyword, m.selected) |
| 240 | _, _ = s.WriteString(fmt.Sprintf("%s %s\n", msg, selected)) |
| 241 | |
| 242 | return s.String() |
| 243 | } |
| 244 | |
| 245 | if m.hideSearch { |
| 246 | _, _ = s.WriteString(fmt.Sprintf("%s [Use arrows to move]\n", msg)) |
| 247 | } else { |
| 248 | _, _ = s.WriteString(fmt.Sprintf( |
| 249 | "%s %s[Use arrows to move, type to filter]\n", |
| 250 | msg, |
| 251 | m.search.View(), |
| 252 | )) |
| 253 | } |
| 254 | |
| 255 | options, start := m.viewableOptions() |
| 256 | |
| 257 | for i, option := range options { |
| 258 | // Is this the currently selected option? |
| 259 | style := pretty.Wrap(" ", "") |
| 260 | if m.cursor == start+i { |
| 261 | style = pretty.Style{ |
| 262 | pretty.Wrap("> ", ""), |
| 263 | DefaultStyles.Keyword, |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | _, _ = s.WriteString(pretty.Sprint(style, option)) |
| 268 | _, _ = s.WriteString("\n") |
| 269 | } |
| 270 | |
| 271 | return s.String() |
| 272 | } |
| 273 | |
| 274 | func (m selectModel) viewableOptions() ([]string, int) { |
| 275 | options := m.filteredOptions() |
no test coverage detected