| 274 | } |
| 275 | |
| 276 | func (m *multiSelectSearchField) updateSelect(msg tea.KeyPressMsg) (huh.Model, tea.Cmd) { |
| 277 | switch { |
| 278 | case key.Matches(msg, key.NewBinding(key.WithKeys("shift+tab"))): |
| 279 | // Back to search mode. |
| 280 | m.mode = msModeSearch |
| 281 | m.search.Focus() |
| 282 | return m, nil |
| 283 | |
| 284 | case key.Matches(msg, key.NewBinding(key.WithKeys("enter"))): |
| 285 | return m, huh.NextField |
| 286 | |
| 287 | case key.Matches(msg, key.NewBinding(key.WithKeys("up", "k"))): |
| 288 | if m.cursor > 0 { |
| 289 | m.cursor-- |
| 290 | } |
| 291 | return m, nil |
| 292 | |
| 293 | case key.Matches(msg, key.NewBinding(key.WithKeys("down", "j"))): |
| 294 | if m.cursor < len(m.options)-1 { |
| 295 | m.cursor++ |
| 296 | } |
| 297 | return m, nil |
| 298 | |
| 299 | case key.Matches(msg, key.NewBinding(key.WithKeys("space", "x"))): |
| 300 | if len(m.options) > 0 { |
| 301 | k := m.options[m.cursor].value |
| 302 | m.selected[k] = !m.selected[k] |
| 303 | if !m.selected[k] { |
| 304 | delete(m.selected, k) |
| 305 | } |
| 306 | } |
| 307 | return m, nil |
| 308 | } |
| 309 | |
| 310 | return m, nil |
| 311 | } |
| 312 | |
| 313 | func (m *multiSelectSearchField) View() string { |
| 314 | styles := m.activeStyles() |