This commit is contained in:
sxyazi 2023-11-12 05:55:46 +08:00
parent 060ffd0411
commit ac4f3a3446
No known key found for this signature in database
3 changed files with 7 additions and 1 deletions

View file

@ -8,6 +8,9 @@ pub struct Opt;
impl From<&Exec> for Opt {
fn from(_: &Exec) -> Self { Self }
}
impl From<()> for Opt {
fn from(_: ()) -> Self { Self }
}
impl Input {
pub fn backward(&mut self, _: impl Into<Opt>) -> bool {

View file

@ -10,6 +10,9 @@ pub struct Opt {
impl From<&Exec> for Opt {
fn from(e: &Exec) -> Self { Self { end_of_word: e.named.contains_key("end-of-word") } }
}
impl From<bool> for Opt {
fn from(end_of_word: bool) -> Self { Self { end_of_word } }
}
impl Input {
pub fn forward(&mut self, opt: impl Into<Opt>) -> bool {

View file

@ -67,7 +67,7 @@ impl Input {
Key { code: KeyCode::Char('d'), shift: false, ctrl: true, alt: false } => {
self.forward_delete()
}
Key { code: KeyCode::Char('b'), shift: false, ctrl: false, alt: true } => self.backward(),
Key { code: KeyCode::Char('b'), shift: false, ctrl: false, alt: true } => self.backward(()),
Key { code: KeyCode::Char('f'), shift: false, ctrl: false, alt: true } => self.forward(false),
_ => false,
}