Skip to content

Commit 1fd874e

Browse files
authored
fix(tui/windows): fix text prompts on windows not displaying any text (#463)
This change addresses #389. The _crossterm_ implementation on Windows places the terminal in Raw Mode, which means: > Input will not be forwarded to screen > Input will not be processed on enter press > Special keys like backspace and CTRL+C will not be processed by terminal driver To address these issues, I've made the echoing explicit to ensure user input is visible, and also added support for Backspace, as it didn't work previously. I've tested this on Windows and confirmed it's working correctly, with the username and confirmation displayed as expected, and the password remaining hidden. I haven't tested on Linux yet, but it should be working just fine; please kindly verify it first. ![test](https://github.com/user-attachments/assets/df44bf86-b9e0-4a2f-a44d-5281eb58005a) ![20250627204729](https://github.com/user-attachments/assets/35ab6d0b-6761-4056-92da-eb4ad6ff87ea) fixes #389
1 parent 6cb3aec commit 1fd874e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/tui.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@ pub(crate) fn prompt() -> String {
2222
while let Event::Key(KeyEvent { code, .. }) = crossterm::event::read().unwrap() {
2323
match code {
2424
KeyCode::Enter => {
25+
eprintln!();
2526
break;
2627
}
2728
KeyCode::Char(c) => {
2829
line.push(c);
30+
eprint!("{}", c);
31+
let _ = stderr().flush();
32+
}
33+
KeyCode::Backspace => {
34+
if !line.is_empty() {
35+
line.pop();
36+
37+
eprint!("\x08 \x08");
38+
let _ = stderr().flush();
39+
}
2940
}
3041
_ => {}
3142
}

0 commit comments

Comments
 (0)