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.

Revert changes to `gpui2` crate

Marshall Bowersa4bde421dbde
diff --git a/crates/gpui2/src/color.rs b/crates/gpui2/src/color.rs
index b128ea691c1..11590f967cd 100644
--- a/crates/gpui2/src/color.rs
+++ b/crates/gpui2/src/color.rs
@@ -160,15 +160,6 @@ pub fn black() -> Hsla {
}
}
-pub fn white() -> Hsla {
- Hsla {
- h: 0.,
- s: 0.,
- l: 1.,
- a: 1.,
- }
-}
-
impl From<Rgba> for Hsla {
fn from(color: Rgba) -> Self {
let r = color.r;
diff --git a/crates/gpui2/src/elements/text.rs b/crates/gpui2/src/elements/text.rs
index 3ee35eea307..323b3d9f89e 100644
--- a/crates/gpui2/src/elements/text.rs
+++ b/crates/gpui2/src/elements/text.rs
@@ -12,21 +12,11 @@ use parking_lot::Mutex;
use std::sync::Arc;
use util::arc_cow::ArcCow;
-impl<V: 'static> IntoElement<V> for ArcCow<'static, str> {
+impl<V: 'static, S: Into<ArcCow<'static, str>>> IntoElement<V> for S {
type Element = Text;
fn into_element(self) -> Self::Element {
- Text { text: self }
- }
-}
-
-impl<V: 'static> IntoElement<V> for &'static str {
- type Element = Text;
-
- fn into_element(self) -> Self::Element {
- Text {
- text: ArcCow::from(self),
- }
+ Text { text: self.into() }
}
}
diff --git a/crates/gpui2/src/gpui2.rs b/crates/gpui2/src/gpui2.rs
index b10b6629b59..355697595ff 100644
--- a/crates/gpui2/src/gpui2.rs
+++ b/crates/gpui2/src/gpui2.rs
@@ -6,7 +6,6 @@ pub mod interactive;
pub mod style;
pub mod view;
pub mod view_context;
-pub mod view_handle;
pub use color::*;
pub use element::{AnyElement, Element, IntoElement, Layout, ParentElement};
diff --git a/crates/gpui2/src/style.rs b/crates/gpui2/src/style.rs
index dc25bb4b221..ecb9d79a6c4 100644
--- a/crates/gpui2/src/style.rs
+++ b/crates/gpui2/src/style.rs
@@ -22,8 +22,6 @@ use gpui2_macros::styleable_helpers;
use refineable::{Refineable, RefinementCascade};
use std::sync::Arc;
-pub type StyleCascade = RefinementCascade<Style>;
-
#[derive(Clone, Refineable, Debug)]
#[refineable(debug)]
pub struct Style {
@@ -131,7 +129,7 @@ impl Style {
color: self.text_color.map(Into::into),
font_family: self.font_family.clone(),
font_size: self.font_size.map(|size| size * cx.rem_size()),
- font_weight: self.font_weight.map(Into::into),
+ font_weight: self.font_weight,
font_style: self.font_style,
underline: None,
})
diff --git a/crates/gpui2/src/view_context.rs b/crates/gpui2/src/view_context.rs
index b0f6426ef84..d6c0960a348 100644
--- a/crates/gpui2/src/view_context.rs
+++ b/crates/gpui2/src/view_context.rs
@@ -3,10 +3,7 @@ use std::{any::TypeId, rc::Rc};
use crate::{element::LayoutId, style::Style};
use anyhow::{anyhow, Result};
use derive_more::{Deref, DerefMut};
-use gpui::{
- geometry::Size, scene::EventHandler, AnyWindowHandle, BorrowWindowContext, EventContext,
- Layout, MeasureParams, WindowContext,
-};
+use gpui::{geometry::Size, scene::EventHandler, EventContext, Layout, MeasureParams};
pub use gpui::{taffy::tree::NodeId, ViewContext as LegacyViewContext};
#[derive(Deref, DerefMut)]
@@ -80,35 +77,3 @@ impl<'a, 'b, 'c, V: 'static> ViewContext<'a, 'b, 'c, V> {
.computed_layout(layout_id)
}
}
-
-impl<'a, 'b, 'c, V: 'static> BorrowWindowContext for ViewContext<'a, 'b, 'c, V> {
- type Result<T> = T;
-
- fn read_window<T, F>(&self, window: AnyWindowHandle, f: F) -> Self::Result<T>
- where
- F: FnOnce(&WindowContext) -> T,
- {
- self.legacy_cx.read_window(window, f)
- }
-
- fn read_window_optional<T, F>(&self, window: AnyWindowHandle, f: F) -> Option<T>
- where
- F: FnOnce(&WindowContext) -> Option<T>,
- {
- self.legacy_cx.read_window_optional(window, f)
- }
-
- fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Self::Result<T>
- where
- F: FnOnce(&mut WindowContext) -> T,
- {
- self.legacy_cx.update_window(window, f)
- }
-
- fn update_window_optional<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Option<T>
- where
- F: FnOnce(&mut WindowContext) -> Option<T>,
- {
- self.legacy_cx.update_window_optional(window, f)
- }
-}