(msg tea.Msg)
| 173 | } |
| 174 | |
| 175 | func (m tuiModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 176 | switch msg := msg.(type) { |
| 177 | case tea.WindowSizeMsg: |
| 178 | m.width = msg.Width |
| 179 | m.height = msg.Height |
| 180 | m.currentView.SetSize(msg.Width, msg.Height) |
| 181 | |
| 182 | case tea.KeyMsg: |
| 183 | // Handle quit confirmation modal input |
| 184 | if m.showQuitConfirmation { |
| 185 | switch msg.String() { |
| 186 | case "y", "Y", "enter": |
| 187 | // Confirm quit |
| 188 | return m, tea.Quit |
| 189 | case "n", "N", "esc", "q": |
| 190 | // Cancel quit |
| 191 | m.showQuitConfirmation = false |
| 192 | return m, nil |
| 193 | case "ctrl+c": |
| 194 | // Hard quit bypasses confirmation |
| 195 | return m, tea.Quit |
| 196 | } |
| 197 | // Ignore other keys when modal is open |
| 198 | return m, nil |
| 199 | } |
| 200 | |
| 201 | // Handle profile selector modal input |
| 202 | if m.showProfileSelector { |
| 203 | switch msg.String() { |
| 204 | case "ctrl+c": |
| 205 | // Hard quit from profile selector |
| 206 | return m, tea.Quit |
| 207 | case "q": |
| 208 | // Show quit confirmation |
| 209 | m.showQuitConfirmation = true |
| 210 | return m, nil |
| 211 | case "down", "j": |
| 212 | // Cycle forward through profile options |
| 213 | m.selectedProfileIndex = (m.selectedProfileIndex + 1) % len(m.availableProfiles) |
| 214 | return m, nil |
| 215 | case "up", "k": |
| 216 | // Cycle backward through profile options |
| 217 | m.selectedProfileIndex = (m.selectedProfileIndex - 1 + len(m.availableProfiles)) % len(m.availableProfiles) |
| 218 | return m, nil |
| 219 | case "enter": |
| 220 | // Confirm selection and switch profile |
| 221 | selectedProfileName := m.availableProfiles[m.selectedProfileIndex] |
| 222 | m.showProfileSelector = false |
| 223 | |
| 224 | // Switch to the selected profile |
| 225 | return m, m.switchProfile(selectedProfileName) |
| 226 | case "esc": |
| 227 | // Cancel without switching |
| 228 | m.showProfileSelector = false |
| 229 | return m, nil |
| 230 | } |
| 231 | // Ignore other keys when modal is open |
| 232 | return m, nil |
nothing calls this directly
no test coverage detected