Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'main' into kvark-linux

Mikayla67555ee5b47d
diff --cc crates/gpui/Cargo.toml
index 864ed76935e,9e250acda93..0c7605eb361
--- a/crates/gpui/Cargo.toml
+++ b/crates/gpui/Cargo.toml
@@@ -33,8 -33,7 +33,8 @@@ dhat = { version = "0.3", optional = tr
env_logger = { version = "0.9", optional = true }
etagere = "0.2"
futures.workspace = true
- gpui_macros = { path = "../gpui_macros" }
+font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "d97147f" }
+ gpui_macros.workspace = true
image = "0.23"
itertools = "0.10"
lazy_static.workspace = true
@@@ -88,17 -86,9 +88,17 @@@ cocoa = "0.25
core-foundation = { version = "0.9.3", features = ["with-uuid"] }
core-graphics = "0.22.3"
core-text = "19.2"
-font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "d97147f" }
foreign-types = "0.3"
log.workspace = true
- media = { path = "../media" }
+ media.workspace = true
metal = "0.21.0"
objc = "0.2"
+
+[target.'cfg(target_os = "linux")'.dependencies]
+flume = "0.11"
+xcb = { version = "1.3", features = ["as-raw-xcb-connection"] }
+as-raw-xcb-connection = "1"
+#TODO: use these on all platforms
+blade-graphics = { git = "https://github.com/kvark/blade", rev = "f35bc605154e210ab6190291235889b6ddad73f1" }
+blade-macros = { git = "https://github.com/kvark/blade", rev = "f35bc605154e210ab6190291235889b6ddad73f1" }
+bytemuck = "1"
diff --cc crates/gpui/src/window/element_cx.rs
index 8b321b33776,e3d95de58d6..22ab59a84cb
--- a/crates/gpui/src/window/element_cx.rs
+++ b/crates/gpui/src/window/element_cx.rs
@@@ -32,11 -31,11 +32,11 @@@ use crate::
prelude::*, size, AnyTooltip, AppContext, AvailableSpace, Bounds, BoxShadow, ContentMask,
Corners, CursorStyle, DevicePixels, DispatchPhase, DispatchTree, ElementId, ElementStateBox,
EntityId, FocusHandle, FocusId, FontId, GlobalElementId, GlyphId, Hsla, ImageData,
- InputHandler, IsZero, KeyContext, KeyEvent, KeymatchMode, LayoutId, MonochromeSprite,
- MouseEvent, PaintQuad, Path, Pixels, PlatformInputHandler, Point, PolychromeSprite, Quad,
- RenderGlyphParams, RenderImageParams, RenderSvgParams, Scene, Shadow, SharedString, Size,
- StackingContext, StackingOrder, Style, TextStyleRefinement, Underline, UnderlineStyle, Window,
- WindowContext, SUBPIXEL_VARIANTS,
+ InputHandler, IsZero, KeyContext, KeyEvent, LayoutId, MonochromeSprite, MouseEvent, PaintQuad,
+ Path, Pixels, PlatformInputHandler, Point, PolychromeSprite, Quad, RenderGlyphParams,
+ RenderImageParams, RenderSvgParams, Scene, Shadow, SharedString, Size, StackingContext,
- StackingOrder, StrikethroughStyle, Style, Surface, TextStyleRefinement, Underline,
- UnderlineStyle, Window, WindowContext, SUBPIXEL_VARIANTS,
++ StackingOrder, StrikethroughStyle, Style, TextStyleRefinement, Underline, UnderlineStyle,
++ Window, WindowContext, SUBPIXEL_VARIANTS,
};
type AnyMouseListener = Box<dyn FnMut(&dyn Any, DispatchPhase, &mut ElementContext) + 'static>;
diff --cc crates/zed/src/main.rs
index c291773e4a1,f010468d26a..5a535cb5366
--- a/crates/zed/src/main.rs
+++ b/crates/zed/src/main.rs
@@@ -896,32 -894,42 +898,44 @@@ fn load_user_themes_in_background(fs: A
if let Some(theme_registry) =
cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
{
- if let Some(()) = theme_registry
- .load_user_themes(&paths::THEMES_DIR.clone(), fs)
+ let themes_dir = paths::THEMES_DIR.as_ref();
+ match fs
+ .metadata(themes_dir)
.await
- .log_err()
+ .ok()
+ .flatten()
+ .map(|m| m.is_dir)
{
- cx.update(|cx| {
- let mut theme_settings = ThemeSettings::get_global(cx).clone();
-
- if let Some(requested_theme) = theme_settings.requested_theme.clone() {
- if let Some(_theme) = theme_settings.switch_theme(&requested_theme, cx)
- {
- ThemeSettings::override_global(theme_settings, cx);
- }
- }
- })
- .log_err();
+ Some(is_dir) => {
+ anyhow::ensure!(is_dir, "Themes dir path {themes_dir:?} is not a directory")
+ }
+ None => {
+ fs.create_dir(themes_dir).await.with_context(|| {
+ format!("Failed to create themes dir at path {themes_dir:?}")
+ })?;
+ }
}
+ theme_registry.load_user_themes(themes_dir, fs).await?;
+ cx.update(|cx| {
+ let mut theme_settings = ThemeSettings::get_global(cx).clone();
+ if let Some(theme_selection) = theme_settings.theme_selection.clone() {
+ let theme_name = theme_selection.theme(*SystemAppearance::global(cx));
+
+ if let Some(_theme) = theme_settings.switch_theme(&theme_name, cx) {
+ ThemeSettings::override_global(theme_settings, cx);
+ }
+ }
+ })?;
}
+ anyhow::Ok(())
}
})
- .detach();
+ .detach_and_log_err(cx);
}
+//todo!(linux): Port fsevents to linux
/// Spawns a background task to watch the themes directory for changes.
+#[cfg(target_os = "macos")]
fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
cx.spawn(|cx| async move {
let mut events = fs