Start work on creating and saving new files
This commit is contained in:
+31
-1
@@ -21,7 +21,7 @@ use std::{
|
||||
fmt::{self, Debug},
|
||||
hash::{Hash, Hasher},
|
||||
marker::PhantomData,
|
||||
path::PathBuf,
|
||||
path::{Path, PathBuf},
|
||||
rc::{self, Rc},
|
||||
sync::{Arc, Weak},
|
||||
time::Duration,
|
||||
@@ -586,6 +586,22 @@ impl MutableAppContext {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn prompt_for_new_path<F>(&self, directory: &Path, done_fn: F)
|
||||
where
|
||||
F: 'static + FnOnce(Option<PathBuf>, &mut MutableAppContext),
|
||||
{
|
||||
let app = self.weak_self.as_ref().unwrap().upgrade().unwrap();
|
||||
let foreground = self.foreground.clone();
|
||||
self.platform().prompt_for_new_path(
|
||||
directory,
|
||||
Box::new(move |path| {
|
||||
foreground
|
||||
.spawn(async move { (done_fn)(path, &mut *app.borrow_mut()) })
|
||||
.detach();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn notify_view(&mut self, window_id: usize, view_id: usize) {
|
||||
self.pending_effects
|
||||
.push_back(Effect::ViewNotification { window_id, view_id });
|
||||
@@ -1765,6 +1781,20 @@ impl<'a, T: View> ViewContext<'a, T> {
|
||||
&self.app.ctx.background
|
||||
}
|
||||
|
||||
pub fn prompt_for_paths<F>(&self, options: PathPromptOptions, done_fn: F)
|
||||
where
|
||||
F: 'static + FnOnce(Option<Vec<PathBuf>>, &mut MutableAppContext),
|
||||
{
|
||||
self.app.prompt_for_paths(options, done_fn)
|
||||
}
|
||||
|
||||
pub fn prompt_for_new_path<F>(&self, directory: &Path, done_fn: F)
|
||||
where
|
||||
F: 'static + FnOnce(Option<PathBuf>, &mut MutableAppContext),
|
||||
{
|
||||
self.app.prompt_for_new_path(directory, done_fn)
|
||||
}
|
||||
|
||||
pub fn debug_elements(&self) -> crate::json::Value {
|
||||
self.app.debug_elements(self.window_id).unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user