add extend motions, color cursor in select mode

This commit is contained in:
alice pellerin
2026-03-18 04:12:41 -05:00
parent 11075723d8
commit bfc67a2671
4 changed files with 109 additions and 9 deletions
+30
View File
@@ -83,6 +83,36 @@ impl Cursor {
self.head -= self.head % 4;
}
}
pub fn extend_to_next_word(&mut self, max: usize) {
if self.head == max { return }
if self.head.is_multiple_of(4) { // at the beginning of a word
self.head = (self.head + 4).min(max);
} else {
self.head = self.head.next_multiple_of(4).min(max);
}
}
pub fn extend_to_next_end(&mut self, max: usize) {
if self.head == max { return }
if self.head % 4 == 3 { // at the end of a word
self.head = (self.head + 4).min(max);
} else {
self.head = ((self.head + 1).next_multiple_of(4) - 1).min(max);
}
}
pub const fn extend_to_previous_beginning(&mut self) {
if self.head == 0 { return }
if self.head.is_multiple_of(4) { // at the beginning of a word
self.head -= 4;
} else {
self.head -= self.head % 4;
}
}
}
mod tests {