MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / handlePullKey

Method handlePullKey

internal/app/model.go:295–336  ·  view source on GitHub ↗

handlePullKey lets the keyboard drive the in-progress string pull — arrows nudge the virtual endpoint, tab/S-tab snap to other notes, enter commits at the current target (note or wall-pin), esc cancels. Returns `handled=true` to short-circuit the rest of the key router.

(key string)

Source from the content-addressed store, hash-verified

293// enter commits at the current target (note or wall-pin), esc cancels.
294// Returns `handled=true` to short-circuit the rest of the key router.
295func (m model) handlePullKey(key string) (tea.Model, tea.Cmd, bool) {
296 step := 1
297 switch key {
298 case "esc":
299 m.pull.Stop()
300 return m, nil, true
301 case "enter":
302 m.commitPullAt(m.pull.TargetX, m.pull.TargetY)
303 return m, nil, true
304 case "left", "h":
305 m.pull.SetTarget(m.pull.TargetX-step, m.pull.TargetY)
306 return m, nil, true
307 case "right", "l":
308 m.pull.SetTarget(m.pull.TargetX+step, m.pull.TargetY)
309 return m, nil, true
310 case "up", "k":
311 m.pull.SetTarget(m.pull.TargetX, m.pull.TargetY-step)
312 return m, nil, true
313 case "down", "j":
314 m.pull.SetTarget(m.pull.TargetX, m.pull.TargetY+step)
315 return m, nil, true
316 case "shift+left":
317 m.pull.SetTarget(m.pull.TargetX-5, m.pull.TargetY)
318 return m, nil, true
319 case "shift+right":
320 m.pull.SetTarget(m.pull.TargetX+5, m.pull.TargetY)
321 return m, nil, true
322 case "shift+up":
323 m.pull.SetTarget(m.pull.TargetX, m.pull.TargetY-5)
324 return m, nil, true
325 case "shift+down":
326 m.pull.SetTarget(m.pull.TargetX, m.pull.TargetY+5)
327 return m, nil, true
328 case "tab":
329 m.snapPullToNote(+1)
330 return m, nil, true
331 case "shift+tab":
332 m.snapPullToNote(-1)
333 return m, nil, true
334 }
335 return m, nil, false
336}
337
338// commitPullAt finalizes the pull: connects to a note if the target
339// lands on one, otherwise drops a wall-pin at the world coords beneath.

Callers 1

handleKeyMethod · 0.95

Calls 4

commitPullAtMethod · 0.95
snapPullToNoteMethod · 0.95
StopMethod · 0.80
SetTargetMethod · 0.80

Tested by

no test coverage detected