--- key handlers ------------------------------------------------------
(msg tea.KeyMsg)
| 256 | // --- key handlers ------------------------------------------------------ |
| 257 | |
| 258 | func (m model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
| 259 | key := msg.String() |
| 260 | |
| 261 | if key == "ctrl+c" { |
| 262 | _ = m.saver.Flush() |
| 263 | return m, tea.Quit |
| 264 | } |
| 265 | if m.transition != nil { |
| 266 | return m, nil |
| 267 | } |
| 268 | if m.renaming { |
| 269 | return m.handleRenameKey(msg, key) |
| 270 | } |
| 271 | if m.fontMenu != nil { |
| 272 | return m.handleFontMenuKey(key) |
| 273 | } |
| 274 | if m.bgMenu != nil { |
| 275 | return m.handleBgMenuKey(msg, key) |
| 276 | } |
| 277 | if m.pull.Active { |
| 278 | if mdl, cmd, handled := m.handlePullKey(key); handled { |
| 279 | return mdl, cmd |
| 280 | } |
| 281 | } |
| 282 | switch m.mode { |
| 283 | case ModeBoard: |
| 284 | return m.handleBoardKey(key) |
| 285 | case ModeEdit: |
| 286 | return m.handleEditKey(msg, key) |
| 287 | } |
| 288 | return m, nil |
| 289 | } |
| 290 | |
| 291 | // handlePullKey lets the keyboard drive the in-progress string pull — |
| 292 | // arrows nudge the virtual endpoint, tab/S-tab snap to other notes, |
no test coverage detected