multi-cursor actions

This commit is contained in:
alice pellerin
2026-03-20 23:44:10 -05:00
parent 9906e76ab5
commit f81d220d93
4 changed files with 114 additions and 17 deletions
+1 -3
View File
@@ -171,11 +171,9 @@ impl Buffer {
}
pub fn combine_cursors_if_overlapping(&mut self) {
if self.cursors.is_empty() { return; }
let mut index = 0;
while index < self.cursors.len() - 1 {
while !self.cursors.is_empty() && index < self.cursors.len() - 1 {
while index < self.cursors.len() - 1 &&
self.cursors[index].range().is_overlapping(
&self.cursors[index + 1].range())
+19 -12
View File
@@ -221,18 +221,25 @@ mod hex {
let span = SPAN_FOR_BYTE[byte as usize].clone();
let head_color = match self.mode {
Mode::Select => Color::Yellow,
_ => Color::Gray
};
match iter::once(&self.primary_cursor)
.chain(&self.cursors)
.find_map(|cursor| cursor.contains(address))
{
Some(InCursor::Head) => span.bg(head_color),
Some(InCursor::Rest) => span.bg(Color::select_grey()),
None => span,
if let Some(place_in_cursor) = self.primary_cursor.contains(address) {
let head_color = match self.mode {
Mode::Select => Color::Yellow,
_ => Color::Gray
};
match place_in_cursor {
InCursor::Head => span.bg(head_color),
InCursor::Rest => span.bg(Color::select_grey()),
}
} else {
match self.cursors
.iter()
.find_map(|cursor| cursor.contains(address))
{
Some(InCursor::Head) => span.on_gray(),
Some(InCursor::Rest) => span.bg(Color::select_grey()),
None => span,
}
}
}