Use ipc_channel crate to communicate between cli and app

We still aren't handling CLI requests in the app, but this lays the foundation for bi-directional communication.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Nathan Sobo 2022-04-15 17:33:56 -06:00 committed by Antonio Scandurra
parent 01eb2dce24
commit 75f0326e54
10 changed files with 134 additions and 52 deletions

View file

@ -248,7 +248,7 @@ impl App {
self
}
pub fn on_quit<F>(self, mut callback: F) -> Self
pub fn on_quit<F>(&mut self, mut callback: F) -> &mut Self
where
F: 'static + FnMut(&mut MutableAppContext),
{
@ -260,7 +260,7 @@ impl App {
self
}
pub fn on_event<F>(self, mut callback: F) -> Self
pub fn on_event<F>(&mut self, mut callback: F) -> &mut Self
where
F: 'static + FnMut(Event, &mut MutableAppContext) -> bool,
{
@ -274,7 +274,7 @@ impl App {
self
}
pub fn on_open_files<F>(self, mut callback: F) -> Self
pub fn on_open_files<F>(&mut self, mut callback: F) -> &mut Self
where
F: 'static + FnMut(Vec<PathBuf>, &mut MutableAppContext),
{
@ -288,6 +288,20 @@ impl App {
self
}
pub fn on_open_urls<F>(&mut self, mut callback: F) -> &mut Self
where
F: 'static + FnMut(Vec<String>, &mut MutableAppContext),
{
let cx = self.0.clone();
self.0
.borrow_mut()
.foreground_platform
.on_open_urls(Box::new(move |paths| {
callback(paths, &mut *cx.borrow_mut())
}));
self
}
pub fn run<F>(self, on_finish_launching: F)
where
F: 'static + FnOnce(&mut MutableAppContext),