1package sudoku23import (4 "charm.land/bubbles/v2/key"5 "github.com/FelineStateMachine/puzzletea/game"6)78type KeyMap struct {9 game.CursorKeyMap10 FillValue key.Binding11 ClearCell key.Binding12}1314var DefaultKeyMap = KeyMap{15 CursorKeyMap: game.DefaultCursorKeyMap,16 FillValue: key.NewBinding(17 key.WithKeys("1", "2", "3", "4", "5", "6", "7", "8", "9"),18 key.WithHelp("1-9", "Fill"),19 ),20 ClearCell: key.NewBinding(21 key.WithKeys("backspace"),22 key.WithHelp("bkspc", "Clear"),23 ),24}2526func (m *Model) updateKeyBindings() {27 m.keys.Up.SetEnabled(m.cursor.Y > 0)28 m.keys.Down.SetEnabled(m.cursor.Y < 8)29 m.keys.Left.SetEnabled(m.cursor.X > 0)30 m.keys.Right.SetEnabled(m.cursor.X < 8)31 allowInteraction := !m.IsProvidedCell()32 m.keys.FillValue.SetEnabled(allowInteraction)33 m.keys.ClearCell.SetEnabled(allowInteraction)34}3536func (m Model) IsProvidedCell() bool {37 return m.providedGrid[m.cursor.Y][m.cursor.X]38}3940func (m Model) GetFullHelp() [][]key.Binding {41 return [][]key.Binding{42 {m.keys.Up, m.keys.Down, m.keys.Left, m.keys.Right},43 {m.keys.FillValue, m.keys.ClearCell},44 }45}