cursor/screen clamping

This commit is contained in:
alice pellerin
2026-03-17 00:38:40 -05:00
parent 813e48920c
commit 67dc63acec
2 changed files with 57 additions and 15 deletions
+9
View File
@@ -1,3 +1,5 @@
use crate::BYTES_PER_LINE;
#[derive(Debug, Default, PartialEq, Eq)]
pub struct Cursor {
pub head: usize,
@@ -31,6 +33,13 @@ 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;
self.head = self.head.clamp(scroll_position, max_row);
self.tail = self.tail.clamp(scroll_position, max_row);
}
pub fn move_to_next_word(&mut self, max: usize) {
if self.head == max { return }