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

Method handleBgMenuKey

internal/app/model.go:469–523  ·  view source on GitHub ↗

handleBgMenuKey drives the background picker. Up/down move between the cork toggle, the color rows, and the custom-hex row, live-previewing as they go. Left/right/space toggle cork while the cork row is focused. On the custom row, rune/backspace edit the hex buffer (valid hex previews live). Enter c

(msg tea.KeyMsg, key string)

Source from the content-addressed store, hash-verified

467// row, rune/backspace edit the hex buffer (valid hex previews live). Enter
468// commits + persists; esc reverts to the background active at open time.
469func (m model) handleBgMenuKey(msg tea.KeyMsg, key string) (tea.Model, tea.Cmd) {
470 bm := m.bgMenu
471 preview := func() { m.workspace.Background = bm.Selected() }
472
473 switch key {
474 case "esc":
475 m.workspace.Background = bm.Saved
476 m.bgMenu = nil
477 return m, nil
478 case "enter":
479 m.workspace.Background = bm.Selected()
480 m.saver.Touch()
481 m.setToast("background: " + bm.Label())
482 m.bgMenu = nil
483 return m, nil
484 case "up", "ctrl+p":
485 bm.Move(-1)
486 preview()
487 return m, nil
488 case "down", "ctrl+n", "tab":
489 bm.Move(1)
490 preview()
491 return m, nil
492 case "left", "right", " ":
493 // Arrows toggle the cork overlay from anywhere in the menu.
494 bm.ToggleCork()
495 preview()
496 return m, nil
497 case "backspace":
498 if bm.OnCustom() {
499 bm.HexBackspace()
500 preview()
501 }
502 return m, nil
503 }
504 // On the custom row, hex digits (and '#') feed the input buffer.
505 if bm.OnCustom() && len(msg.Runes) > 0 {
506 bm.HexInput(msg.Runes)
507 preview()
508 return m, nil
509 }
510 // vim-style movement / cork toggle when not typing into the hex field.
511 switch key {
512 case "k":
513 bm.Move(-1)
514 preview()
515 case "j":
516 bm.Move(1)
517 preview()
518 case "h", "l":
519 bm.ToggleCork()
520 preview()
521 }
522 return m, nil
523}
524
525func (m model) handleBoardKey(key string) (tea.Model, tea.Cmd) {
526 switch key {

Callers 1

handleKeyMethod · 0.95

Calls 9

setToastMethod · 0.95
TouchMethod · 0.80
LabelMethod · 0.80
ToggleCorkMethod · 0.80
OnCustomMethod · 0.80
HexBackspaceMethod · 0.80
HexInputMethod · 0.80
SelectedMethod · 0.45
MoveMethod · 0.45

Tested by

no test coverage detected