summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/readline.rs7
3 files changed, 8 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 77c5df0..1edc916 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -385,6 +385,7 @@ dependencies = [
"signal-hook-async-std",
"terminal_size",
"textmode",
+ "unicode-width",
"vt100",
]
diff --git a/Cargo.toml b/Cargo.toml
index 9e1c444..e5cb362 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,7 @@ signal-hook = "0.3.10"
signal-hook-async-std = "0.2.1"
terminal_size = "0.1.17"
textmode = { path = "../textmode", version = "0.1.1", features = ["async"] }
+unicode-width = "0.1.9"
vt100 = { path = "../vt100-rust", version = "0.12.0" }
[features]
diff --git a/src/readline.rs b/src/readline.rs
index ff5f9a9..37fc054 100644
--- a/src/readline.rs
+++ b/src/readline.rs
@@ -1,4 +1,5 @@
use textmode::Textmode as _;
+use unicode_width::UnicodeWidthChar as _;
pub struct Readline {
size: (u16, u16),
@@ -74,7 +75,11 @@ impl Readline {
}
fn backspace(&mut self) {
- self.input_line.pop();
+ let mut width = 0;
+ while width == 0 {
+ width =
+ self.input_line.pop().map_or(1, |c| c.width().unwrap_or(0));
+ }
}
fn clear_input(&mut self) {