Add help menu items to visit zed.dev and the zed twitter page

This commit is contained in:
Max Brunsfeld 2022-05-27 13:16:39 -07:00
parent df4f3051bc
commit 1c932ae4ce
2 changed files with 29 additions and 4 deletions

View file

@ -247,10 +247,25 @@ pub fn menus() -> Vec<Menu<'static>> {
},
Menu {
name: "Help",
items: vec![MenuItem::Action {
name: "Command Palette",
action: Box::new(command_palette::Toggle),
}],
items: vec![
MenuItem::Action {
name: "Command Palette",
action: Box::new(command_palette::Toggle),
},
MenuItem::Separator,
MenuItem::Action {
name: "Zed.dev",
action: Box::new(crate::OpenBrowser {
url: "https://zed.dev".into(),
}),
},
MenuItem::Action {
name: "Zed Twitter",
action: Box::new(crate::OpenBrowser {
url: "https://twitter.com/zeddotdev".into(),
}),
},
],
},
]
}

View file

@ -14,6 +14,7 @@ use editor::Editor;
use gpui::{
actions,
geometry::vector::vec2f,
impl_actions,
platform::{WindowBounds, WindowOptions},
AsyncAppContext, ViewContext,
};
@ -23,6 +24,7 @@ use project::Project;
pub use project::{self, fs};
use project_panel::ProjectPanel;
use search::{BufferSearchBar, ProjectSearchBar};
use serde::Deserialize;
use serde_json::to_string_pretty;
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
use std::{
@ -33,6 +35,13 @@ use util::ResultExt;
pub use workspace;
use workspace::{AppState, Workspace};
#[derive(Deserialize, Clone)]
struct OpenBrowser {
url: Arc<str>,
}
impl_actions!(zed, [OpenBrowser]);
actions!(
zed,
[
@ -61,6 +70,7 @@ lazy_static! {
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
cx.add_action(about);
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| {
cx.update_global::<Settings, _, _>(|settings, cx| {
settings.buffer_font_size = (settings.buffer_font_size + 1.0).max(MIN_FONT_SIZE);