repeat x times

This commit is contained in:
alice pellerin
2026-03-21 16:41:10 -05:00
parent 823e186acd
commit 9ac66fc074
6 changed files with 483 additions and 383 deletions
+23
View File
@@ -11,6 +11,9 @@ pub struct App {
pub buffers: Vec<Buffer>,
pub current_buffer_index: usize,
pub primary_cursor_register: Vec<u8>,
pub other_cursor_registers: Vec<Vec<u8>>,
pub window_size: WindowSize,
pub should_quit: bool,
@@ -52,6 +55,9 @@ impl App {
buffers,
current_buffer_index: 0,
primary_cursor_register: Vec::new(),
other_cursor_registers: Vec::new(),
window_size,
should_quit: false,
@@ -84,6 +90,8 @@ impl App {
let maybe_app_action = self.buffers[self.current_buffer_index].handle_key(
key_event,
&self.config,
&self.primary_cursor_register,
&self.other_cursor_registers,
self.window_size
);
@@ -94,6 +102,8 @@ impl App {
AppAction::PreviousBuffer => self.previous_buffer(),
AppAction::NextBuffer => self.next_buffer(),
AppAction::Yank => self.yank(),
}
}
}
@@ -184,6 +194,19 @@ impl App {
}
}
fn yank(&mut self) {
self.primary_cursor_register = self.current_buffer()
.contents[self.current_buffer().primary_cursor.range()]
.to_vec();
self.other_cursor_registers = self.current_buffer().cursors
.iter()
.map(|cursor| {
self.current_buffer().contents[cursor.range()].to_vec()
})
.collect();
}
pub fn current_buffer(&self) -> &Buffer {
&self.buffers[self.current_buffer_index]
}