add G motion and up/down/left/right

This commit is contained in:
alice pellerin
2026-03-17 02:36:08 -05:00
parent 67dc63acec
commit 1d348ca5f8
3 changed files with 58 additions and 21 deletions
+3 -4
View File
@@ -1,5 +1,3 @@
use crate::BYTES_PER_LINE;
#[derive(Debug, Default, PartialEq, Eq)]
pub struct Cursor {
pub head: usize,
@@ -33,8 +31,9 @@ impl Cursor {
self.tail = self.head;
}
pub fn clamp(&mut self, scroll_position: usize, window_rows: usize) {
let max_row = scroll_position + window_rows * BYTES_PER_LINE - 1;
// TODO: in visual mode, should only clamp head
pub fn clamp(&mut self, scroll_position: usize, screen_size: usize) {
let max_row = scroll_position + screen_size - 1;
self.head = self.head.clamp(scroll_position, max_row);
self.tail = self.tail.clamp(scroll_position, max_row);