implemented proper cursor placement for line editor

This commit is contained in:
2025-05-27 03:32:08 -04:00
parent 1e3715d353
commit 0e95e006d8
4 changed files with 84 additions and 19 deletions

View File

@@ -89,12 +89,14 @@ impl FernVi {
self.term.unwrite()?;
}
let offset = self.calculate_prompt_offset();
self.line.set_first_line_offset(offset);
let mut line_buf = self.prompt.clone();
line_buf.push_str(self.line.as_str());
self.term.recorded_write(&line_buf, offset)?;
self.term.position_cursor(self.line.cursor_display_coords(offset,width))?;
self.term.position_cursor(self.line.cursor_display_coords(width))?;
self.term.write(&self.mode.cursor_style());
Ok(())
}
pub fn calculate_prompt_offset(&self) -> usize {