1package game23import (4 "charm.land/bubbles/v2/key"5 tea "charm.land/bubbletea/v2"6)78type Cursor struct {9 X, Y int10}1112// Move updates the cursor position based on the key message and bounds.13// Returns true if the cursor moved.14func (c *Cursor) Move(keys CursorKeyMap, msg tea.KeyPressMsg, maxX, maxY int) bool {15 switch {16 case key.Matches(msg, keys.Up):17 if c.Y > 0 {18 c.Y--19 return true20 }21 case key.Matches(msg, keys.Down):22 if c.Y < maxY {23 c.Y++24 return true25 }26 case key.Matches(msg, keys.Left):27 if c.X > 0 {28 c.X--29 return true30 }31 case key.Matches(msg, keys.Right):32 if c.X < maxX {33 c.X++34 return true35 }36 }37 return false38}