aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index c4113f9..95d24d5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -118,6 +118,18 @@ impl Session {
self.type_byte(*b);
}
}
+
+ fn del_left(&mut self) {
+ if self.line.del_left().is_some() {
+ cursor::move_cursor(Direction::Left, 1);
+ self.line.display_post(b" ");
+ }
+ }
+
+ fn del_right(&mut self) {
+ self.line.del_right();
+ self.line.display_post(b" ");
+ }
}
fn read1() -> u8 {
@@ -190,8 +202,8 @@ fn event_loop() {
// take previous command for editing
let cmd = se.history[se.history.len() - 1].clone();
se.type_bytes(&cmd);
- } else if se.line.del_left().is_some() {
- print!("\x08 \x08");
+ } else {
+ se.del_left();
}
}
@@ -267,9 +279,7 @@ fn event_loop() {
}
b'3' => {
if seq.len() > 2 && seq[2] == b'~' {
- // delete
- se.line.del_right();
- se.line.display_post(b" ");
+ se.del_right();
} else {
todo!("unhandled: {seq:?}");
}