implemented more vi commands

implemented replace mode

re-implemented undo and redo
This commit is contained in:
2025-05-28 01:01:49 -04:00
parent 0e95e006d8
commit 1c33578478
6 changed files with 407 additions and 136 deletions

View File

@@ -181,6 +181,7 @@ impl Terminal {
Ok(())
}
/// Rewinds terminal writing, clears lines and lands on the anchor point of the prompt
pub fn unwrite(&mut self) -> ShResult<()> {
self.unposition_cursor()?;
let WriteMap { lines, cols, offset } = self.write_records;
@@ -194,7 +195,6 @@ impl Terminal {
}
pub fn position_cursor(&mut self, (lines,col): (usize,usize)) -> ShResult<()> {
dbg!(self.cursor_pos());
self.cursor_records.lines = lines;
self.cursor_records.cols = col;
self.cursor_records.offset = self.cursor_pos().1;
@@ -205,14 +205,11 @@ impl Terminal {
self.write(&format!("\x1b[{col}G"));
dbg!("done moving");
dbg!(self.cursor_pos());
Ok(())
}
/// Rewinds cursor positioning, lands on the end of the buffer
pub fn unposition_cursor(&mut self) ->ShResult<()> {
dbg!(self.cursor_pos());
let WriteMap { lines, cols, offset } = self.cursor_records;
for _ in 0..lines {
@@ -221,9 +218,6 @@ impl Terminal {
self.write(&format!("\x1b[{offset}G"));
dbg!("done moving back");
dbg!(self.cursor_pos());
Ok(())
}