crates/workspace/src/workspace.rs 🔗
@@ -95,7 +95,7 @@ actions!(
ToggleLeftSidebar,
ToggleRightSidebar,
NewTerminal,
- NewSearch,
+ NewSearch
]
);
Joseph T. Lyons created
add command to copy system information to the clipboard
crates/workspace/src/workspace.rs | 2
crates/zed/src/menus.rs | 13 ++++++--
crates/zed/src/system_specs.rs | 46 +++++++++++++++++++++++++++++++++
crates/zed/src/zed.rs | 18 ++++++++++++
4 files changed, 73 insertions(+), 6 deletions(-)
@@ -95,7 +95,7 @@ actions!(
ToggleLeftSidebar,
ToggleRightSidebar,
NewTerminal,
- NewSearch,
+ NewSearch
]
);
@@ -339,10 +339,8 @@ pub fn menus() -> Vec<Menu<'static>> {
},
MenuItem::Separator,
MenuItem::Action {
- name: "Documentation",
- action: Box::new(crate::OpenBrowser {
- url: "https://zed.dev/docs".into(),
- }),
+ name: "Copy System Specs Into Clipboard",
+ action: Box::new(crate::CopySystemSpecsIntoClipboard),
},
MenuItem::Action {
name: "Give Feedback",
@@ -350,6 +348,13 @@ pub fn menus() -> Vec<Menu<'static>> {
url: super::feedback::NEW_ISSUE_URL.into(),
}),
},
+ MenuItem::Separator,
+ MenuItem::Action {
+ name: "Documentation",
+ action: Box::new(crate::OpenBrowser {
+ url: "https://zed.dev/docs".into(),
+ }),
+ },
MenuItem::Action {
name: "Zed Twitter",
action: Box::new(crate::OpenBrowser {
@@ -0,0 +1,46 @@
+use std::{env, fmt::Display};
+
+use gpui::AppContext;
+use util::channel::ReleaseChannel;
+
+pub struct SystemSpecs {
+ os_name: &'static str,
+ os_version: Option<String>,
+ app_version: &'static str,
+ release_channel: &'static str,
+ architecture: &'static str,
+}
+
+impl SystemSpecs {
+ pub fn new(cx: &AppContext) -> Self {
+ let platform = cx.platform();
+
+ SystemSpecs {
+ os_name: platform.os_name(),
+ os_version: platform
+ .os_version()
+ .ok()
+ .map(|os_version| os_version.to_string()),
+ app_version: env!("CARGO_PKG_VERSION"),
+ release_channel: cx.global::<ReleaseChannel>().dev_name(),
+ architecture: env::consts::ARCH,
+ }
+ }
+}
+
+impl Display for SystemSpecs {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let os_information = match &self.os_version {
+ Some(os_version) => format!("OS: {} {}", self.os_name, os_version),
+ None => format!("OS: {}", self.os_name),
+ };
+ let system_specs = [
+ os_information,
+ format!("Zed: {} ({})", self.app_version, self.release_channel),
+ format!("Architecture: {}", self.architecture),
+ ]
+ .join("\n");
+
+ write!(f, "{system_specs}")
+ }
+}
@@ -1,6 +1,7 @@
mod feedback;
pub mod languages;
pub mod menus;
+pub mod system_specs;
#[cfg(any(test, feature = "test-support"))]
pub mod test;
@@ -21,7 +22,7 @@ use gpui::{
},
impl_actions,
platform::{WindowBounds, WindowOptions},
- AssetSource, AsyncAppContext, TitlebarOptions, ViewContext, WindowKind,
+ AssetSource, AsyncAppContext, ClipboardItem, TitlebarOptions, ViewContext, WindowKind,
};
use language::Rope;
use lazy_static::lazy_static;
@@ -33,6 +34,7 @@ use serde::Deserialize;
use serde_json::to_string_pretty;
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
use std::{env, path::Path, str, sync::Arc};
+use system_specs::SystemSpecs;
use util::{channel::ReleaseChannel, paths, ResultExt};
pub use workspace;
use workspace::{sidebar::SidebarSide, AppState, Workspace};
@@ -67,6 +69,7 @@ actions!(
ResetBufferFontSize,
InstallCommandLineInterface,
ResetDatabase,
+ CopySystemSpecsIntoClipboard
]
);
@@ -245,6 +248,19 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
},
);
+ cx.add_action(
+ |_: &mut Workspace, _: &CopySystemSpecsIntoClipboard, cx: &mut ViewContext<Workspace>| {
+ let system_specs = SystemSpecs::new(cx).to_string();
+ let item = ClipboardItem::new(system_specs.clone());
+ cx.prompt(
+ gpui::PromptLevel::Info,
+ &format!("Copied into clipboard:\n\n{system_specs}"),
+ &["OK"],
+ );
+ cx.write_to_clipboard(item);
+ },
+ );
+
activity_indicator::init(cx);
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
settings::KeymapFileContent::load_defaults(cx);