From 40aeeeaa79d990367f167db68e7a46d8f99a9810 Mon Sep 17 00:00:00 2001 From: sgrtye Date: Fri, 27 Jun 2025 20:20:31 +0100 Subject: [PATCH] feat(tui): enhance prompt function to echo out input explicitly & add Backspace support --- src/tui.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tui.rs b/src/tui.rs index 9427b1b..02a1dbc 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -22,10 +22,21 @@ pub(crate) fn prompt() -> String { while let Event::Key(KeyEvent { code, .. }) = crossterm::event::read().unwrap() { match code { KeyCode::Enter => { + eprintln!(); break; } KeyCode::Char(c) => { line.push(c); + eprint!("{}", c); + let _ = stderr().flush(); + } + KeyCode::Backspace => { + if !line.is_empty() { + line.pop(); + + eprint!("\x08 \x08"); + let _ = stderr().flush(); + } } _ => {} }