Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Sobo6d2b27689d86
diff --git a/crates/gpui3/src/elements.rs b/crates/gpui3/src/elements.rsindex 16095129195..83c27b8a3b1 100644--- a/crates/gpui3/src/elements.rs+++ b/crates/gpui3/src/elements.rs@@ -4,3 +4,6 @@ mod svg;mod text;pub use div::*;+pub use img::*;+pub use svg::*;+pub use text::*;diff --git a/crates/gpui3/src/platform/mac/platform.rs b/crates/gpui3/src/platform/mac/platform.rsindex 25a9e035832..eaa66461c24 100644--- a/crates/gpui3/src/platform/mac/platform.rs+++ b/crates/gpui3/src/platform/mac/platform.rs@@ -1123,7 +1123,7 @@ mod tests {}fn build_platform() -> MacPlatform {- let mut platform = MacPlatform::new();+ let platform = MacPlatform::new();platform.0.borrow_mut().pasteboard = unsafe { NSPasteboard::pasteboardWithUniqueName(nil) };platform}diff --git a/crates/storybook2/src/collab_panel.rs b/crates/storybook2/src/collab_panel.rsindex 26e7f778718..5931a8a9b0e 100644--- a/crates/storybook2/src/collab_panel.rs+++ b/crates/storybook2/src/collab_panel.rs@@ -1,12 +1,9 @@use crate::theme::{theme, Theme};-use gpui2::{- elements::{div, div::ScrollState, img, svg},- style::{StyleHelpers, Styleable},- ArcCow, Element, IntoElement, ParentElement, ViewContext,+use gpui3::{+ div, img, svg, ArcCow, Element, IntoAnyElement, ParentElement, ScrollState, Styled, ViewContext,};use std::marker::PhantomData;-#[derive(Element)]pub struct CollabPanelElement<V: 'static> {view_type: PhantomData<V>,scroll_state: ScrollState,@@ -22,7 +19,7 @@ pub fn collab_panel<V: 'static>(scroll_state: ScrollState) -> CollabPanelElement}impl<V: 'static> CollabPanelElement<V> {- fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);// Panel@@ -117,10 +114,10 @@ impl<V: 'static> CollabPanelElement<V> {fn list_section_header(&self,- label: impl IntoElement<V>,+ label: impl IntoAnyElement<V>,expanded: bool,theme: &Theme,- ) -> impl Element<V> {+ ) -> impl Element {div().h_7().px_2()@@ -146,9 +143,9 @@ impl<V: 'static> CollabPanelElement<V> {fn list_item(&self,avatar_uri: impl Into<ArcCow<'static, str>>,- label: impl IntoElement<V>,+ label: impl IntoAnyElement<V>,theme: &Theme,- ) -> impl Element<V> {+ ) -> impl Element {div().h_7().px_2()diff --git a/crates/storybook2/src/element_ext.rs b/crates/storybook2/src/element_ext.rsindex 42334d27b6d..d7c5e3d1afe 100644--- a/crates/storybook2/src/element_ext.rs+++ b/crates/storybook2/src/element_ext.rs@@ -1,22 +1,17 @@use crate::theme::{Theme, Themed};use gpui3::Element;-use std::marker::PhantomData;pub trait ElementExt: Element {- fn themed(self, theme: Theme) -> Themed<V, Self>+ fn themed(self, theme: Theme) -> Themed<Self>whereSelf: Sized;}-impl<V: 'static, E: Element> ElementExt for E {- fn themed(self, theme: Theme) -> Themed<V, Self>+impl<E: Element> ElementExt for E {+ fn themed(self, theme: Theme) -> Themed<Self>whereSelf: Sized,{- Themed {- child: self,- theme,- view_type: PhantomData,- }+ Themed { child: self, theme }}}diff --git a/crates/storybook2/src/theme.rs b/crates/storybook2/src/theme.rsindex e6627bcc6c2..30ce39d485d 100644--- a/crates/storybook2/src/theme.rs+++ b/crates/storybook2/src/theme.rs@@ -1,5 +1,5 @@use gpui3::{- serde_json, AppContext, Element, Hsla, IntoAnyElement, Layout, Vector2F, ViewContext,+ serde_json, AppContext, Element, Hsla, IntoAnyElement, Layout, LayoutId, Vector2F, ViewContext,WindowContext,};use serde::{de::Visitor, Deserialize, Deserializer};@@ -131,25 +131,24 @@ wheredeserializer.deserialize_map(SyntaxVisitor)}-pub struct Themed<V: 'static, E: Element<V>> {+pub struct Themed<E> {pub(crate) theme: Theme,pub(crate) child: E,- pub(crate) view_type: PhantomData<V>,}-impl<V: 'static, E: Element<V>> Element<V> for Themed<V, E> {+impl<E: Element> Element for Themed<E> {type FrameState = E::FrameState;fn layout(&mut self,- view: &mut V,- cx: &mut ViewContext<V>,- ) -> anyhow::Result<(gpui2::LayoutId, Self::FrameState)>+ state: &mut E::State,+ cx: &mut ViewContext<E::State>,+ ) -> anyhow::Result<(LayoutId, Self::FrameState)>whereSelf: Sized,{cx.push_theme(self.theme.clone());- let result = self.child.layout(view, cx);+ let result = self.child.layout(state, cx);cx.pop_theme();result}diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rsindex efc75088aba..d44160449ec 100644--- a/crates/storybook2/src/workspace.rs+++ b/crates/storybook2/src/workspace.rs@@ -1,18 +1,18 @@use crate::{collab_panel::collab_panel, theme::theme};-use gpui3::{div, Element, IntoAnyElement, ParentElement, ScrollState, Styled, ViewContext};+use gpui3::{div, img, svg, Element, ParentElement, ScrollState, Styled, ViewContext};-#[derive(Element, Default)]+#[derive(Default)]struct WorkspaceElement {left_scroll_state: ScrollState,right_scroll_state: ScrollState,}-pub fn workspace<V: 'static>() -> impl Element<V> {+pub fn workspace<V: 'static>() -> impl Element {WorkspaceElement::default()}impl WorkspaceElement {- fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div()@@ -41,15 +41,14 @@ impl WorkspaceElement {}}-#[derive(Element)]struct TitleBar;-pub fn titlebar<V: 'static>() -> impl Element<V> {+pub fn titlebar<V: 'static>() -> impl Element {TitleBar}impl TitleBar {- fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div().flex()@@ -62,7 +61,7 @@ impl TitleBar {.child(self.right_group(cx))}- fn left_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn left_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div().flex()@@ -136,7 +135,7 @@ impl TitleBar {)}- fn right_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn right_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div().flex()@@ -264,15 +263,14 @@ impl TitleBar {// ================================================================================ //-#[derive(Element)]struct StatusBar;-pub fn statusbar<V: 'static>() -> impl Element<V> {+pub fn statusbar<V: 'static>() -> impl Element {StatusBar}impl StatusBar {- fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div().flex()@@ -285,7 +283,7 @@ impl StatusBar {.child(self.right_group(cx))}- fn left_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn left_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div().flex()@@ -382,7 +380,7 @@ impl StatusBar {)}- fn right_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {+ fn right_group<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl Element {let theme = theme(cx);div().flex()