Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Checkpoint
Nathan Soboba22da00bfe0
diff --git a/crates/storybook/src/gpui3/element.rs b/crates/storybook/src/gpui3/element.rsindex ea54e1a9c3a..afb50fabec2 100644--- a/crates/storybook/src/gpui3/element.rs+++ b/crates/storybook/src/gpui3/element.rs@@ -1,5 +1,4 @@-use super::{Handle, Layout, LayoutId, Pixels, Point, ViewContext, WindowContext};-use anyhow::Result;+use super::{Handle, Layout, LayoutId, Pixels, Point, Result, ViewContext, WindowContext};use std::{any::Any, cell::RefCell, marker::PhantomData, rc::Rc};pub trait Element: 'static {diff --git a/crates/storybook/src/gpui3/elements.rs b/crates/storybook/src/gpui3/elements.rsindex 9bd9727f21b..3847db24cc5 100644--- a/crates/storybook/src/gpui3/elements.rs+++ b/crates/storybook/src/gpui3/elements.rs@@ -1,40 +1,8 @@-use std::marker::PhantomData;--use anyhow::Result;--use super::{Element, IntoAnyElement, Layout, LayoutId, ParentElement, ViewContext};--pub struct Div<S>(PhantomData<S>);+pub mod div;+pub mod editor;-impl<S: 'static> Element for Div<S> {- type State = S;- type FrameState = ();-- fn layout(- &mut self,- state: &mut Self::State,- cx: &mut ViewContext<Self::State>,- ) -> Result<(LayoutId, Self::FrameState)> {- todo!()- }-- fn paint(- &mut self,- layout: Layout,- state: &mut Self::State,- frame_state: &mut Self::FrameState,- cx: &mut ViewContext<Self::State>,- ) -> Result<()> {- todo!()- }-}--impl<S> ParentElement<S> for Div<S> {- fn child(self, child: impl IntoAnyElement<S>) -> Self {- todo!()- }-}+use super::*;+use std::marker::PhantomData;-pub fn div<S>() -> Div<S> {- todo!()-}+pub use div::div;+pub use editor::field;diff --git a/crates/storybook/src/gpui3/elements/div.rs b/crates/storybook/src/gpui3/elements/div.rsnew file mode 100644index 00000000000..7d3f70042b0--- /dev/null+++ b/crates/storybook/src/gpui3/elements/div.rs@@ -0,0 +1,38 @@+use super::{+ Element, IntoAnyElement, Layout, LayoutId, ParentElement, PhantomData, Result, ViewContext,+};++pub struct Div<S>(PhantomData<S>);++impl<S: 'static> Element for Div<S> {+ type State = S;+ type FrameState = ();++ fn layout(+ &mut self,+ state: &mut Self::State,+ cx: &mut ViewContext<Self::State>,+ ) -> Result<(LayoutId, Self::FrameState)> {+ todo!()+ }++ fn paint(+ &mut self,+ layout: Layout,+ state: &mut Self::State,+ frame_state: &mut Self::FrameState,+ cx: &mut ViewContext<Self::State>,+ ) -> Result<()> {+ todo!()+ }+}++impl<S> ParentElement<S> for Div<S> {+ fn child(self, child: impl IntoAnyElement<S>) -> Self {+ todo!()+ }+}++pub fn div<S>() -> Div<S> {+ todo!()+}diff --git a/crates/storybook/src/gpui3/elements/editor.rs b/crates/storybook/src/gpui3/elements/editor.rsnew file mode 100644index 00000000000..77f27d3d1fc--- /dev/null+++ b/crates/storybook/src/gpui3/elements/editor.rs@@ -0,0 +1,61 @@+use super::{Element, Handle, Layout, LayoutId, Result, SharedString, ViewContext};+use std::marker::PhantomData;++pub fn field<S>(editor: Handle<Editor>) -> EditorElement<S> {+ EditorElement {+ editor,+ field: true,+ placeholder_text: None,+ parent_state: PhantomData,+ }+}++pub struct EditorElement<S> {+ editor: Handle<Editor>,+ field: bool,+ placeholder_text: Option<SharedString>,+ parent_state: PhantomData<S>,+}++impl<S> EditorElement<S> {+ pub fn field(mut self) -> Self {+ self.field = true;+ self+ }++ pub fn placeholder_text(mut self, text: impl Into<SharedString>) -> Self {+ self.placeholder_text = Some(text.into());+ self+ }+}++impl<S: 'static> Element for EditorElement<S> {+ type State = S;+ type FrameState = ();++ fn layout(+ &mut self,+ _: &mut Self::State,+ cx: &mut ViewContext<Self::State>,+ ) -> Result<(LayoutId, Self::FrameState)> {+ self.editor.update(cx, |editor, cx| todo!())+ }++ fn paint(+ &mut self,+ layout: Layout,+ state: &mut Self::State,+ frame_state: &mut Self::FrameState,+ cx: &mut ViewContext<Self::State>,+ ) -> Result<()> {+ self.editor.update(cx, |editor, cx| todo!())+ }+}++pub struct Editor {}++impl Editor {+ pub fn new(_: &mut ViewContext<Self>) -> Self {+ Editor {}+ }+}diff --git a/crates/storybook/src/gpui3/mod.rs b/crates/storybook/src/gpui3/mod.rsindex 3813b200cbe..cbe23ca3554 100644--- a/crates/storybook/src/gpui3/mod.rs+++ b/crates/storybook/src/gpui3/mod.rs@@ -9,7 +9,6 @@ mod window;use anyhow::Result;pub use gpui2::ArcCow;use gpui2::Reference;-use std::marker::PhantomData;pub use app::*;pub use element::*;@@ -19,6 +18,8 @@ pub use style::*;use taffy::TaffyLayoutEngine;pub use window::*;+use self::editor::Editor;+pub trait Context {type EntityContext<'a, 'w, T: 'static>;@@ -56,7 +57,7 @@ fn workspace(cx: &mut WindowContext) -> View<Workspace> {}struct CollabPanel {- filter_editor: Handle<Editor>,+ filter_editor: Handle<editor::Editor>,}fn collab_panel(cx: &mut WindowContext) -> View<CollabPanel> {@@ -76,65 +77,6 @@ impl CollabPanel {}}-fn field<S>(editor: Handle<Editor>) -> EditorElement<S> {- EditorElement {- editor,- field: true,- placeholder_text: None,- parent_state: PhantomData,- }-}--struct EditorElement<S> {- editor: Handle<Editor>,- field: bool,- placeholder_text: Option<SharedString>,- parent_state: PhantomData<S>,-}--impl<S> EditorElement<S> {- pub fn field(mut self) -> Self {- self.field = true;- self- }-- pub fn placeholder_text(mut self, text: impl Into<SharedString>) -> Self {- self.placeholder_text = Some(text.into());- self- }-}--impl<S: 'static> Element for EditorElement<S> {- type State = S;- type FrameState = ();-- fn layout(- &mut self,- _: &mut Self::State,- cx: &mut ViewContext<Self::State>,- ) -> Result<(LayoutId, Self::FrameState)> {- self.editor.update(cx, |editor, cx| todo!())- }-- fn paint(- &mut self,- layout: Layout,- state: &mut Self::State,- frame_state: &mut Self::FrameState,- cx: &mut ViewContext<Self::State>,- ) -> Result<()> {- self.editor.update(cx, |editor, cx| todo!())- }-}--struct Editor {}--impl Editor {- pub fn new(_: &mut ViewContext<Self>) -> Self {- Editor {}- }-}-#[cfg(test)]mod tests {use super::*;diff --git a/crates/storybook/src/gpui3/taffy.rs b/crates/storybook/src/gpui3/taffy.rsindex 7405b0161ab..9fe8adefe79 100644--- a/crates/storybook/src/gpui3/taffy.rs+++ b/crates/storybook/src/gpui3/taffy.rs@@ -1,8 +1,7 @@use super::{AbsoluteLength, Bounds, DefiniteLength, Edges, Layout, LayoutEngine, LayoutId, Length, Pixels,- Point, Size, Style,+ Point, Result, Size, Style,};-use anyhow::Result;use gpui2::taffy::{self, Taffy};use std::fmt::Debug;