| 262 | } |
| 263 | |
| 264 | func (m *multiSelectSearchField) updateSelect(msg tea.KeyPressMsg) (huh.Model, tea.Cmd) { |
| 265 | switch { |
| 266 | case key.Matches(msg, key.NewBinding(key.WithKeys("shift+tab"))): |
| 267 | // Back to search mode. |
| 268 | m.mode = msModeSearch |
| 269 | m.search.Focus() |
| 270 | return m, nil |
| 271 | |
| 272 | case key.Matches(msg, key.NewBinding(key.WithKeys("enter"))): |
| 273 | return m, huh.NextField |
| 274 | |
| 275 | case key.Matches(msg, key.NewBinding(key.WithKeys("up", "k"))): |
| 276 | if m.cursor > 0 { |
| 277 | m.cursor-- |
| 278 | } |
| 279 | return m, nil |
| 280 | |
| 281 | case key.Matches(msg, key.NewBinding(key.WithKeys("down", "j"))): |
| 282 | if m.cursor < len(m.options)-1 { |
| 283 | m.cursor++ |
| 284 | } |
| 285 | return m, nil |
| 286 | |
| 287 | case key.Matches(msg, key.NewBinding(key.WithKeys("space", "x"))): |
| 288 | if len(m.options) > 0 { |
| 289 | k := m.options[m.cursor].value |
| 290 | m.selected[k] = !m.selected[k] |
| 291 | if !m.selected[k] { |
| 292 | delete(m.selected, k) |
| 293 | } |
| 294 | } |
| 295 | return m, nil |
| 296 | } |
| 297 | |
| 298 | return m, nil |
| 299 | } |
| 300 | |
| 301 | func (m *multiSelectSearchField) View() string { |
| 302 | styles := m.activeStyles() |