diff options
author | Jan Hrastnik | 2020-10-15 10:14:54 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-10-16 03:02:05 +0000 |
commit | 267602328c0c164136244517bbf7176f4c729c67 (patch) | |
tree | 1bb328e84d6639717ee47fe3a98ada4f21241f38 | |
parent | fa55b1e51c2310cf73689da37c5c57441d7e89c3 (diff) |
changed fn to fnmut
-rw-r--r-- | helix-term/src/editor.rs | 10 | ||||
-rw-r--r-- | helix-view/src/prompt.rs | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs index bdcb9ae0..f6af5b4a 100644 --- a/helix-term/src/editor.rs +++ b/helix-term/src/editor.rs @@ -66,7 +66,7 @@ impl Editor { Ok(editor) } - pub fn set_commands(self) { + pub fn set_prompt(self) { let commands = |input: &str| match input { "q" => self.should_close = true, _ => (), @@ -265,7 +265,7 @@ impl Editor { // render buffer text let buffer_string; if view.state.mode == Mode::Command { - buffer_string = &self.prompt.buffer; + buffer_string = &self.prompt.unwrap().buffer; self.surface .set_string(1, self.size.1 - 1, String::from(":"), text_color); self.surface @@ -291,7 +291,7 @@ impl Editor { mode => write!(stdout, "\x1B[2 q"), }; if view.state.mode() == Mode::Command { - pos = Position::new(self.size.0 as usize, 2 + self.prompt.cursor_loc); + pos = Position::new(self.size.0 as usize, 2 + self.prompt.unwrap().cursor_loc); } else { if let Some(path) = view.state.path() { self.surface @@ -314,7 +314,7 @@ impl Editor { let mut reader = EventStream::new(); let keymap = keymap::default(); - self.set_commands(); + self.set_prompt(); self.render(); loop { @@ -357,7 +357,7 @@ impl Editor { view.ensure_cursor_in_view(); } Mode::Command => { - self.prompt.handle_input(event, view); + self.prompt.unwrap().handle_input(event, view); } mode => { if let Some(command) = keymap[&mode].get(&keys) { diff --git a/helix-view/src/prompt.rs b/helix-view/src/prompt.rs index 8cfb9fde..b352a386 100644 --- a/helix-view/src/prompt.rs +++ b/helix-view/src/prompt.rs @@ -7,13 +7,13 @@ pub struct Prompt { pub buffer: String, pub cursor_loc: usize, completion_fn: Box<dyn FnMut(&str) -> Option<Vec<&str>>>, - callback_fn: Box<dyn Fn(&str)>, + callback_fn: Box<dyn FnMut(&str)>, } impl Prompt { pub fn new( completion_fn: impl FnMut(&str) -> Option<Vec<&str>> + 'static, - callback_fn: impl Fn(&str) + 'static, + callback_fn: impl FnMut(&str) + 'static, ) -> Prompt { Prompt { buffer: String::from(""), |