aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/prompt.rs
diff options
context:
space:
mode:
authorJoe Neeman2021-06-22 19:49:55 +0000
committerBlaž Hrastnik2021-06-23 01:03:11 +0000
commitfd1ae35051b57e689f6e6ef7e03c552a78f3f33a (patch)
treef52cd747784d77ae8bf85854d40f77a9b6e3af80 /helix-term/src/ui/prompt.rs
parent16883e754399eb5bfacdbc1f9c1c4ac57fd5de06 (diff)
Make the prompt callback take a Context.
Diffstat (limited to 'helix-term/src/ui/prompt.rs')
-rw-r--r--helix-term/src/ui/prompt.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 7ca4308c..07f360e5 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -20,7 +20,7 @@ pub struct Prompt {
completion: Vec<Completion>,
selection: Option<usize>,
completion_fn: Box<dyn FnMut(&str) -> Vec<Completion>>,
- callback_fn: Box<dyn FnMut(&mut Editor, &str, PromptEvent)>,
+ callback_fn: Box<dyn FnMut(&mut Context, &str, PromptEvent)>,
pub doc_fn: Box<dyn Fn(&str) -> Option<&'static str>>,
}
@@ -54,7 +54,7 @@ impl Prompt {
pub fn new(
prompt: String,
mut completion_fn: impl FnMut(&str) -> Vec<Completion> + 'static,
- callback_fn: impl FnMut(&mut Editor, &str, PromptEvent) + 'static,
+ callback_fn: impl FnMut(&mut Context, &str, PromptEvent) + 'static,
) -> Self {
Self {
prompt,
@@ -386,7 +386,7 @@ impl Component for Prompt {
modifiers: KeyModifiers::SHIFT,
} => {
self.insert_char(c);
- (self.callback_fn)(cx.editor, &self.line, PromptEvent::Update);
+ (self.callback_fn)(cx, &self.line, PromptEvent::Update);
}
KeyEvent {
code: KeyCode::Char('c'),
@@ -395,7 +395,7 @@ impl Component for Prompt {
| KeyEvent {
code: KeyCode::Esc, ..
} => {
- (self.callback_fn)(cx.editor, &self.line, PromptEvent::Abort);
+ (self.callback_fn)(cx, &self.line, PromptEvent::Abort);
return close_fn;
}
KeyEvent {
@@ -459,7 +459,7 @@ impl Component for Prompt {
modifiers: KeyModifiers::NONE,
} => {
self.delete_char_backwards();
- (self.callback_fn)(cx.editor, &self.line, PromptEvent::Update);
+ (self.callback_fn)(cx, &self.line, PromptEvent::Update);
}
KeyEvent {
code: KeyCode::Enter,
@@ -469,7 +469,7 @@ impl Component for Prompt {
self.completion = (self.completion_fn)(&self.line);
self.exit_selection();
} else {
- (self.callback_fn)(cx.editor, &self.line, PromptEvent::Validate);
+ (self.callback_fn)(cx, &self.line, PromptEvent::Validate);
return close_fn;
}
}