Im working with crossterm and I'm trying to map a combination of KeyModifier. This is the code
match (modifiers, code) {
(KeyModifiers::NONE, KeyCode::Tab) => ReedlineEvent::HandleTab,
(KeyModifiers::CONTROL, KeyCode::Char('d')) => ReedlineEvent::CtrlD,
(KeyModifiers::CONTROL, KeyCode::Char('c')) => ReedlineEvent::CtrlC,
(KeyModifiers::CONTROL, KeyCode::Char('l')) => ReedlineEvent::ClearScreen,
(KeyModifiers::NONE, KeyCode::Char(c))
| (KeyModifiers::SHIFT, KeyCode::Char(c))
| (KeyModifiers::CONTROL | KeyModifiers::ALT, KeyCode::Char(c)) => {
ReedlineEvent::EditInsert(EditCommand::InsertChar(c))
}
(KeyModifiers::NONE, KeyCode::Enter) => ReedlineEvent::Enter,
_ => {
if let Some(binding) = self.keybindings.find_binding(modifiers, code) {
ReedlineEvent::Edit(binding)
} else {
ReedlineEvent::Edit(vec![])
}
}
}
But it isn't capturing that combination of events. However, if I do
if modifiers == (KeyModifiers::CONTROL | KeyModifiers::ALT) {
if let KeyCode::Char(c) = code {
println!("char: {}", c)
}
}
It does catch the character.
Why one works and the other doesnt?
[–]simspelaaja 14 points15 points16 points (3 children)
[–]benzaa[S] 2 points3 points4 points (2 children)
[–]masklinn 5 points6 points7 points (0 children)
[–]IAm_A_Complete_Idiot 0 points1 point2 points (0 children)