Implement default macOS menu items

- `Zed -> Hide`, bound to `cmd-h`
- `Zed -> Hide Others`, bound to `alt-cmd-h`
- `Zed -> Show All`
- `Window -> Minimize`, bound to `cmd-m`
- `Window -> Zoom`
This commit is contained in:
Antonio Scandurra 2022-08-03 15:13:30 +02:00
parent dc9df64078
commit 7cbf76ce80
8 changed files with 124 additions and 1 deletions

View file

@ -46,6 +46,11 @@ actions!(
zed,
[
About,
Hide,
HideOthers,
ShowAll,
Minimize,
Zoom,
Quit,
DebugElements,
OpenSettings,
@ -64,6 +69,25 @@ const MIN_FONT_SIZE: f32 = 6.0;
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
cx.add_action(about);
cx.add_global_action(|_: &Hide, cx: &mut gpui::MutableAppContext| {
cx.platform().hide();
});
cx.add_global_action(|_: &HideOthers, cx: &mut gpui::MutableAppContext| {
cx.platform().hide_other_apps();
});
cx.add_global_action(|_: &ShowAll, cx: &mut gpui::MutableAppContext| {
cx.platform().unhide_other_apps();
});
cx.add_action(
|_: &mut Workspace, _: &Minimize, cx: &mut ViewContext<Workspace>| {
cx.minimize_window();
},
);
cx.add_action(
|_: &mut Workspace, _: &Zoom, cx: &mut ViewContext<Workspace>| {
cx.zoom_window();
},
);
cx.add_global_action(quit);
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {