Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands.rs')
| -rw-r--r-- | helix-term/src/commands.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 6a35e812..788d10f0 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -87,6 +87,11 @@ use grep_searcher::{sinks, BinaryDetection, SearcherBuilder}; use ignore::{DirEntry, WalkBuilder, WalkState}; pub type OnKeyCallback = Box<dyn FnOnce(&mut Context, KeyEvent)>; +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum OnKeyCallbackKind { + PseudoPending, + Fallback, +} pub struct Context<'a> { pub register: Option<char>, @@ -94,7 +99,7 @@ pub struct Context<'a> { pub editor: &'a mut Editor, pub callback: Vec<crate::compositor::Callback>, - pub on_next_key_callback: Option<OnKeyCallback>, + pub on_next_key_callback: Option<(OnKeyCallback, OnKeyCallbackKind)>, pub jobs: &'a mut Jobs, } @@ -120,7 +125,19 @@ impl Context<'_> { &mut self, on_next_key_callback: impl FnOnce(&mut Context, KeyEvent) + 'static, ) { - self.on_next_key_callback = Some(Box::new(on_next_key_callback)); + self.on_next_key_callback = Some(( + Box::new(on_next_key_callback), + OnKeyCallbackKind::PseudoPending, + )); + } + + #[inline] + pub fn on_next_key_fallback( + &mut self, + on_next_key_callback: impl FnOnce(&mut Context, KeyEvent) + 'static, + ) { + self.on_next_key_callback = + Some((Box::new(on_next_key_callback), OnKeyCallbackKind::Fallback)); } #[inline] |