keyfork-prompt: add KEYFORK_PROMPT_MNEMONIC_MODE=steel
This commit is contained in:
parent
1699975b57
commit
f206cd5db1
|
@ -122,9 +122,15 @@ where
|
|||
W: Write + AsRawFd,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
self.write.execute(DisableBracketedPaste).expect(bug!("can't restore bracketed paste"));
|
||||
self.write.execute(LeaveAlternateScreen).expect(bug!("can't leave alternate screen"));
|
||||
self.terminal.disable_raw_mode().expect(bug!("can't disable raw mode"));
|
||||
self.write
|
||||
.execute(DisableBracketedPaste)
|
||||
.expect(bug!("can't restore bracketed paste"));
|
||||
self.write
|
||||
.execute(LeaveAlternateScreen)
|
||||
.expect(bug!("can't leave alternate screen"));
|
||||
self.terminal
|
||||
.disable_raw_mode()
|
||||
.expect(bug!("can't disable raw mode"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,6 +294,20 @@ where
|
|||
}
|
||||
KeyCode::Char(c) => {
|
||||
input.push(c);
|
||||
let entry_mode = std::env::var("KEYFORK_PROMPT_MNEMONIC_MODE");
|
||||
if entry_mode.is_ok_and(|mode| mode.to_ascii_lowercase() == "steel") {
|
||||
let word = input.split_whitespace().next_back().map(ToOwned::to_owned);
|
||||
if let Some(steel_word) = word {
|
||||
if steel_word.len() >= 4 {
|
||||
for word in words.iter().filter(|word| word.len() >= 4) {
|
||||
if word[..4] == steel_word {
|
||||
input.push_str(&word[4..]);
|
||||
input.push(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue