(msg tea.Msg)
| 161 | } |
| 162 | |
| 163 | func (m selectModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 164 | switch msg := msg.(type) { |
| 165 | case tea.KeyPressMsg: |
| 166 | switch msg.Keystroke() { |
| 167 | case "ctrl+c", "escape": |
| 168 | m.cancelled = true |
| 169 | m.done = true |
| 170 | return m, tea.Quit |
| 171 | case "up", "shift+tab", "k": |
| 172 | if m.cursor > 0 { |
| 173 | m.cursor-- |
| 174 | } |
| 175 | case "down", "tab", "j": |
| 176 | if m.cursor < len(m.options)-1 { |
| 177 | m.cursor++ |
| 178 | } |
| 179 | case "enter": |
| 180 | m.done = true |
| 181 | return m, tea.Quit |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | return m, nil |
| 186 | } |
| 187 | |
| 188 | func (m selectModel) View() tea.View { |
| 189 | if m.done { |
nothing calls this directly
no outgoing calls
no test coverage detected