diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 32da635e1..93a734b22 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -37,6 +37,8 @@ use std::fs; use std::path::Path; use std::{error::Error, path::PathBuf}; +use self::picker::PickerKeyHandler; + struct Utf8PathBuf { path: String, is_dir: bool, @@ -667,6 +669,8 @@ pub fn file_explorer( ) }; + type KeyHandler = PickerKeyHandler<(PathBuf, bool)>; + let picker = Picker::new( columns, 0, @@ -689,11 +693,11 @@ pub fn file_explorer( .with_cursor(cursor.unwrap_or_default()) .with_preview(|_editor, (path, _is_dir)| Some((path.as_path().into(), None))) .with_key_handlers(hashmap! { - alt!('n') => Box::new(create_file) as Box, - alt!('m') => Box::new(move_file) as Box, - alt!('d') => Box::new(delete_file) as Box, - alt!('c') => Box::new(copy_file) as Box, - alt!('y') => Box::new(copy_path) as Box + alt!('n') => Box::new(create_file) as KeyHandler, + alt!('m') => Box::new(move_file) as KeyHandler, + alt!('d') => Box::new(delete_file) as KeyHandler, + alt!('c') => Box::new(copy_file) as KeyHandler, + alt!('y') => Box::new(copy_path) as KeyHandler, }); Ok(picker) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 87937cc7b..639fb8732 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -259,7 +259,7 @@ pub struct Picker { widths: Vec, callback_fn: PickerCallback, - custom_key_handlers: PickerKeyHandler, + custom_key_handlers: PickerKeyHandlers, pub truncate_start: bool, /// Caches paths to documents @@ -395,7 +395,7 @@ impl Picker { } } - pub fn with_key_handlers(mut self, handlers: PickerKeyHandler) -> Self { + pub fn with_key_handlers(mut self, handlers: PickerKeyHandlers) -> Self { self.custom_key_handlers = handlers; self } @@ -1185,4 +1185,5 @@ impl Drop for Picker { } type PickerCallback = Box; -pub type PickerKeyHandler = HashMap>; +pub type PickerKeyHandler = Box; +pub type PickerKeyHandlers = HashMap>;