(msg tea.Msg)
| 238 | } |
| 239 | |
| 240 | func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 241 | m.queryInput.SetValue(sanitizeEscapeCodes(m.queryInput.Value())) |
| 242 | switch msg := msg.(type) { |
| 243 | case tea.KeyMsg: |
| 244 | switch { |
| 245 | case key.Matches(msg, loadedKeyBindings.Quit): |
| 246 | m.quitting = true |
| 247 | return m, tea.Quit |
| 248 | case key.Matches(msg, loadedKeyBindings.SelectEntry): |
| 249 | if len(m.tableEntries) != 0 && m.table != nil { |
| 250 | m.selected = Selected |
| 251 | } |
| 252 | return m, tea.Quit |
| 253 | case key.Matches(msg, loadedKeyBindings.SelectEntryAndChangeDir): |
| 254 | if len(m.tableEntries) != 0 && m.table != nil { |
| 255 | m.selected = SelectedWithChangeDir |
| 256 | } |
| 257 | return m, tea.Quit |
| 258 | case key.Matches(msg, loadedKeyBindings.DeleteEntry): |
| 259 | if m.table == nil { |
| 260 | return m, nil |
| 261 | } |
| 262 | err := deleteHistoryEntry(m.ctx, *m.tableEntries[m.table.Cursor()]) |
| 263 | if err != nil { |
| 264 | m.fatalErr = err |
| 265 | return m, nil |
| 266 | } |
| 267 | cmd := runQueryAndUpdateTable(m, true, true) |
| 268 | preventTableOverscrolling(m) |
| 269 | return m, cmd |
| 270 | case key.Matches(msg, loadedKeyBindings.Help): |
| 271 | m.help.ShowAll = !m.help.ShowAll |
| 272 | return m, nil |
| 273 | case key.Matches(msg, loadedKeyBindings.JumpStartOfInput): |
| 274 | m.queryInput.SetCursor(0) |
| 275 | return m, nil |
| 276 | case key.Matches(msg, loadedKeyBindings.JumpEndOfInput): |
| 277 | m.queryInput.SetCursor(len(m.queryInput.Value())) |
| 278 | return m, nil |
| 279 | case key.Matches(msg, loadedKeyBindings.WordLeft): |
| 280 | wordBoundaries := calculateWordBoundaries(m.queryInput.Value()) |
| 281 | lastBoundary := 0 |
| 282 | for _, boundary := range wordBoundaries { |
| 283 | if boundary >= m.queryInput.Position() { |
| 284 | m.queryInput.SetCursor(lastBoundary) |
| 285 | break |
| 286 | } |
| 287 | lastBoundary = boundary |
| 288 | } |
| 289 | return m, nil |
| 290 | case key.Matches(msg, loadedKeyBindings.WordRight): |
| 291 | wordBoundaries := calculateWordBoundaries(m.queryInput.Value()) |
| 292 | for _, boundary := range wordBoundaries { |
| 293 | if boundary > m.queryInput.Position() { |
| 294 | m.queryInput.SetCursor(boundary) |
| 295 | break |
| 296 | } |
| 297 | } |
no test coverage detected