This commit is contained in:
alice pellerin
2026-03-18 04:05:43 -05:00
parent 98f4c56852
commit 11075723d8
7 changed files with 87 additions and 5 deletions
+29
View File
@@ -0,0 +1,29 @@
use std::cmp::min;
use crate::{app::App, cursor::Cursor};
pub enum EditAction {
Delete {
cursor: Cursor,
data: Vec<u8>
}
}
impl App {
pub fn execute_and_add(&mut self, edit_action: EditAction) {
self.execute_edit(&edit_action);
self.edit_history.push(edit_action);
}
fn execute_edit(&mut self, edit_action: &EditAction) {
match edit_action {
EditAction::Delete { cursor, .. } => self.delete_at(*cursor),
}
}
fn delete_at(&mut self, cursor: Cursor) {
self.contents.drain(cursor.range());
self.cursor.head = min(cursor.head, cursor.tail);
self.cursor.collapse();
}
}