|
|
@ -91,15 +91,25 @@ impl<T> FilePicker<T> {
|
|
|
|
callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
|
|
|
|
callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
|
|
|
|
preview_fn: impl Fn(&Editor, &T) -> Option<FileLocation> + 'static,
|
|
|
|
preview_fn: impl Fn(&Editor, &T) -> Option<FileLocation> + 'static,
|
|
|
|
) -> Self {
|
|
|
|
) -> Self {
|
|
|
|
|
|
|
|
let truncate_start = true;
|
|
|
|
|
|
|
|
let mut picker = Picker::new(options, format_fn, callback_fn);
|
|
|
|
|
|
|
|
picker.truncate_start = truncate_start;
|
|
|
|
|
|
|
|
|
|
|
|
Self {
|
|
|
|
Self {
|
|
|
|
picker: Picker::new(options, format_fn, callback_fn),
|
|
|
|
picker,
|
|
|
|
truncate_start: true,
|
|
|
|
truncate_start,
|
|
|
|
preview_cache: HashMap::new(),
|
|
|
|
preview_cache: HashMap::new(),
|
|
|
|
read_buffer: Vec::with_capacity(1024),
|
|
|
|
read_buffer: Vec::with_capacity(1024),
|
|
|
|
file_fn: Box::new(preview_fn),
|
|
|
|
file_fn: Box::new(preview_fn),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn truncate_start(mut self, truncate_start: bool) -> Self {
|
|
|
|
|
|
|
|
self.truncate_start = truncate_start;
|
|
|
|
|
|
|
|
self.picker.truncate_start = truncate_start;
|
|
|
|
|
|
|
|
self
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
|
|
|
|
fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
|
|
|
|
self.picker
|
|
|
|
self.picker
|
|
|
|
.selection()
|
|
|
|
.selection()
|
|
|
@ -176,7 +186,6 @@ impl<T: 'static> Component for FilePicker<T> {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let picker_area = area.with_width(picker_width);
|
|
|
|
let picker_area = area.with_width(picker_width);
|
|
|
|
self.picker.truncate_start = self.truncate_start;
|
|
|
|
|
|
|
|
self.picker.render(picker_area, surface, cx);
|
|
|
|
self.picker.render(picker_area, surface, cx);
|
|
|
|
|
|
|
|
|
|
|
|
if !render_preview {
|
|
|
|
if !render_preview {
|
|
|
|