1package srcview23import tea "charm.land/bubbletea/v2"45// Key moves the active cell as a sheet's keys do, reporting whether the6// key was the view's: the arrows, Page Up and Down, Home and End, and7// with Ctrl the data's edges, which on a source are its first and last8// rows and columns.9func (v *View) Key(k tea.KeyPressMsg) bool {10 page := int64(max(v.Lines()-1, 1))11 switch k.String() {12 case "up":13 v.Move(-1, 0)14 case "down", "enter":15 v.Move(1, 0)16 case "left", "shift+tab":17 v.Move(0, -1)18 case "right", "tab":19 v.Move(0, 1)20 case "pgup":21 v.page(-page)22 case "pgdown":23 v.page(page)24 case "home", "ctrl+left":25 v.MoveTo(v.cur, 0)26 case "end", "ctrl+right":27 v.MoveTo(v.cur, -1)28 case "ctrl+up":29 v.MoveTo(0, v.col)30 case "ctrl+down":31 v.MoveTo(-1, v.col)32 case "ctrl+home":33 v.MoveTo(0, 0)34 case "ctrl+end":35 v.MoveTo(-1, -1)36 default:37 return false38 }39 return true40}4142// page moves the window and the active cell d rows, as a sheet's Page43// Up and Down do.44func (v *View) page(d int64) {45 v.top += d46 v.cur += d47 v.clamp()48 v.follow()49}