aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-22 14:25:40 +0000
committerBlaž Hrastnik2022-03-28 02:02:21 +0000
commit96a4eb84838d4cbfb9313968278985ea1986a3bc (patch)
tree24506b4194cae8028130727933be8c640b7e54cf /helix-term/src/ui
parent5c162ef995e3822cd465f2c83874a040ebe153b8 (diff)
Remove more push_layer calls
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 3c39a517..a90debdb 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -26,6 +26,19 @@ use helix_view::{Document, Editor, View};
use std::path::PathBuf;
+pub fn prompt(
+ cx: &mut crate::commands::Context,
+ prompt: std::borrow::Cow<'static, str>,
+ history_register: Option<char>,
+ completion_fn: impl FnMut(&Editor, &str) -> Vec<prompt::Completion> + 'static,
+ callback_fn: impl FnMut(&mut crate::compositor::Context, &str, PromptEvent) + 'static,
+) {
+ let mut prompt = Prompt::new(prompt, history_register, completion_fn, callback_fn);
+ // Calculate initial completion
+ prompt.recalculate_completion(cx.editor);
+ cx.push_layer(Box::new(prompt));
+}
+
pub fn regex_prompt(
cx: &mut crate::commands::Context,
prompt: std::borrow::Cow<'static, str>,