Create an API for assigning the menubar contents

This commit is contained in:
Max Brunsfeld
2021-04-08 16:01:36 -07:00
parent 0a12774680
commit 334de06322
9 changed files with 216 additions and 60 deletions
+16 -8
View File
@@ -4,7 +4,7 @@ use log::LevelFilter;
use simplelog::SimpleLogger;
use std::{fs, path::PathBuf};
use zed::{
assets, editor, file_finder, settings,
assets, editor, file_finder, menus, settings,
workspace::{self, OpenParams},
};
@@ -14,10 +14,18 @@ fn main() {
let app = gpui::App::new(assets::Assets).unwrap();
let (_, settings_rx) = settings::channel(&app.font_cache()).unwrap();
{
let mut app = app.clone();
platform::runner()
.on_finish_launching(move || {
platform::runner()
.set_menus(menus::MENUS)
.on_menu_command({
let app = app.clone();
move |command| {
log::info!("menu command: {}", command);
app.dispatch_global_action(command, ())
}
})
.on_finish_launching({
let mut app = app.clone();
move || {
workspace::init(&mut app);
editor::init(&mut app);
file_finder::init(&mut app);
@@ -36,9 +44,9 @@ fn main() {
},
);
}
})
.run();
}
}
})
.run();
}
fn init_logger() {