add extend motions, color cursor in select mode
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user