aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 7b9b477..b696fbe 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -153,23 +153,24 @@ impl State {
fn update_cursor_col(&mut self, stdin: &mut BufReader<Stdin>) -> Result<(), Box<dyn Error>> {
let size = term::size()?;
let line = self.line();
- write!(stdout(), "\x1b[{}H\x1b[K", self.cursor_row + 1)?;
+ write!(stdout(), "\x1b[{}H", self.cursor_row + 1)?;
line.slice(0, self.line_offset).print(&mut stdout())?;
- let Ok((_, col)) = term::cursor_pos(stdin) else {
- let _ = line
- .slice(self.line_offset, line.len())
- .print(&mut stdout());
- return Err(Box::from("cursor_pos"));
- };
+ let (_, col) = term::cursor_pos(stdin)?;
if col == size.ws_col - 1 {
self.cursor_col = col - 1;
- write!(stdout(), "\x1b[D\x1b[K")?;
+ write!(
+ stdout(),
+ "\x1b[{};{}H\x1b[K",
+ self.cursor_row + 1,
+ self.cursor_col + 1
+ )?;
return Ok(());
}
if self.line_offset == line.len() {
if col > self.cursor_col {
self.cursor_col = col;
}
+ write!(stdout(), "\x1b[K")?;
return Ok(());
}
self.cursor_col = col;