keyfork-prompt: allow delete-word

This commit is contained in:
Ryan Heywood 2023-12-26 13:35:56 -05:00
parent 6c25cb8f31
commit 1cdbab1a1d
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 4 additions and 1 deletions

View File

@ -8,7 +8,7 @@ use keyfork_mnemonic_util::Wordlist;
use crossterm::{
cursor,
event::{read, Event, KeyCode},
event::{read, Event, KeyCode, KeyModifiers},
style::{Print, PrintStyledContent, Stylize},
terminal,
tty::IsTty,
@ -110,6 +110,9 @@ where
KeyCode::Backspace => {
input.pop();
}
KeyCode::Char('w') if k.modifiers.contains(KeyModifiers::CONTROL) => {
while input.pop().is_some_and(|c| !c.is_whitespace()) {}
}
KeyCode::Char(' ') => {
if !input.chars().rev().next().is_some_and(char::is_whitespace) {
input.push(' ');