diff options
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/readline.rs | 7 |
3 files changed, 8 insertions, 1 deletions
@@ -385,6 +385,7 @@ dependencies = [ "signal-hook-async-std", "terminal_size", "textmode", + "unicode-width", "vt100", ] @@ -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) { |