Merge branch 'element-types' of github.com:zed-industries/zed into element-types
This commit is contained in:
commit
b81b96f353
2 changed files with 209 additions and 204 deletions
|
@ -9413,14 +9413,17 @@ impl Render for Editor {
|
||||||
EditorMode::Full => cx.theme().colors().editor_background,
|
EditorMode::Full => cx.theme().colors().editor_background,
|
||||||
};
|
};
|
||||||
|
|
||||||
EditorElement::new(EditorStyle {
|
EditorElement::new(
|
||||||
|
cx.view(),
|
||||||
|
EditorStyle {
|
||||||
background,
|
background,
|
||||||
local_player: cx.theme().players().local(),
|
local_player: cx.theme().players().local(),
|
||||||
text: text_style,
|
text: text_style,
|
||||||
scrollbar_width: px(12.),
|
scrollbar_width: px(12.),
|
||||||
syntax: cx.theme().syntax().clone(),
|
syntax: cx.theme().syntax().clone(),
|
||||||
diagnostic_style: cx.theme().diagnostic_style(),
|
diagnostic_style: cx.theme().diagnostic_style(),
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,9 @@ use collections::{BTreeMap, HashMap};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace, BorrowWindow,
|
point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace, BorrowWindow,
|
||||||
Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element, ElementId,
|
Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element, ElementId,
|
||||||
ElementInputHandler, Entity, Hsla, Line, MouseButton, MouseDownEvent, MouseMoveEvent,
|
ElementInputHandler, Entity, EntityId, Hsla, Line, MouseButton, MouseDownEvent, MouseMoveEvent,
|
||||||
MouseUpEvent, ParentComponent, Pixels, ScrollWheelEvent, Size, Style, Styled, TextRun,
|
MouseUpEvent, ParentComponent, Pixels, ScrollWheelEvent, Size, Style, Styled, TextRun,
|
||||||
TextStyle, ViewContext, WindowContext,
|
TextStyle, View, ViewContext, WindowContext,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::language_settings::ShowWhitespaceSetting;
|
use language::language_settings::ShowWhitespaceSetting;
|
||||||
|
@ -111,12 +111,16 @@ impl SelectionLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EditorElement {
|
pub struct EditorElement {
|
||||||
|
editor_id: EntityId,
|
||||||
style: EditorStyle,
|
style: EditorStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditorElement {
|
impl EditorElement {
|
||||||
pub fn new(style: EditorStyle) -> Self {
|
pub fn new(editor: &View<Editor>, style: EditorStyle) -> Self {
|
||||||
Self { style }
|
Self {
|
||||||
|
editor_id: editor.entity_id(),
|
||||||
|
style,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mouse_down(
|
fn mouse_down(
|
||||||
|
@ -2405,7 +2409,7 @@ impl Element<Editor> for EditorElement {
|
||||||
type ElementState = ();
|
type ElementState = ();
|
||||||
|
|
||||||
fn element_id(&self) -> Option<gpui::ElementId> {
|
fn element_id(&self) -> Option<gpui::ElementId> {
|
||||||
None // todo! can we change the element trait to return an id here from the view context?
|
Some(self.editor_id.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(
|
fn initialize(
|
||||||
|
@ -2452,7 +2456,6 @@ impl Element<Editor> for EditorElement {
|
||||||
};
|
};
|
||||||
|
|
||||||
let dispatch_context = editor.dispatch_context(cx);
|
let dispatch_context = editor.dispatch_context(cx);
|
||||||
cx.with_element_id(Some(cx.view().entity_id()), |cx| {
|
|
||||||
cx.with_key_dispatch(
|
cx.with_key_dispatch(
|
||||||
dispatch_context,
|
dispatch_context,
|
||||||
Some(editor.focus_handle.clone()),
|
Some(editor.focus_handle.clone()),
|
||||||
|
@ -2646,7 +2649,6 @@ impl Element<Editor> for EditorElement {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue