In the middle of stuff
This commit is contained in:
parent
80b7f75d24
commit
3b01a032ba
5 changed files with 1278 additions and 1473 deletions
|
@ -1448,6 +1448,7 @@ impl EditorElement {
|
||||||
|
|
||||||
let snapshot = editor.snapshot(cx);
|
let snapshot = editor.snapshot(cx);
|
||||||
let style = self.style.clone();
|
let style = self.style.clone();
|
||||||
|
dbg!(&style.text.font());
|
||||||
let font_id = cx.text_system().font_id(&style.text.font()).unwrap();
|
let font_id = cx.text_system().font_id(&style.text.font()).unwrap();
|
||||||
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
||||||
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
div, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext, BackgroundExecutor,
|
div, Action, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext,
|
||||||
Context, Div, EventEmitter, ForegroundExecutor, InputEvent, KeyDownEvent, Keystroke, Model,
|
BackgroundExecutor, Context, Div, EventEmitter, ForegroundExecutor, InputEvent, KeyDownEvent,
|
||||||
ModelContext, Render, Result, Task, TestDispatcher, TestPlatform, View, ViewContext,
|
Keystroke, Model, ModelContext, Render, Result, Task, TestDispatcher, TestPlatform, TextStyle,
|
||||||
VisualContext, WindowContext, WindowHandle, WindowOptions,
|
View, ViewContext, VisualContext, WindowContext, WindowHandle, WindowOptions,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail};
|
use anyhow::{anyhow, bail};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
|
@ -83,8 +83,16 @@ impl TestAppContext {
|
||||||
));
|
));
|
||||||
let asset_source = Arc::new(());
|
let asset_source = Arc::new(());
|
||||||
let http_client = util::http::FakeHttpClient::with_404_response();
|
let http_client = util::http::FakeHttpClient::with_404_response();
|
||||||
|
let cx = AppContext::new(platform, asset_source, http_client);
|
||||||
|
let lock = cx.borrow_mut();
|
||||||
|
lock.push_text_style(crate::TextStyleRefinement {
|
||||||
|
font_family: "Helvetica".into(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
drop(lock);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
app: AppContext::new(platform, asset_source, http_client),
|
app: cx,
|
||||||
background_executor,
|
background_executor,
|
||||||
foreground_executor,
|
foreground_executor,
|
||||||
dispatcher: dispatcher.clone(),
|
dispatcher: dispatcher.clone(),
|
||||||
|
@ -199,6 +207,15 @@ impl TestAppContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dispatch_action<A>(&mut self, window: AnyWindowHandle, action: A)
|
||||||
|
where
|
||||||
|
A: Action,
|
||||||
|
{
|
||||||
|
window
|
||||||
|
.update(self, |_, cx| cx.dispatch_action(action.boxed_clone()))
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn dispatch_keystroke(
|
pub fn dispatch_keystroke(
|
||||||
&mut self,
|
&mut self,
|
||||||
window: AnyWindowHandle,
|
window: AnyWindowHandle,
|
||||||
|
@ -376,6 +393,13 @@ impl<'a> VisualTestContext<'a> {
|
||||||
pub fn from_window(window: AnyWindowHandle, cx: &'a mut TestAppContext) -> Self {
|
pub fn from_window(window: AnyWindowHandle, cx: &'a mut TestAppContext) -> Self {
|
||||||
Self { cx, window }
|
Self { cx, window }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dispatch_action<A>(&mut self, action: A)
|
||||||
|
where
|
||||||
|
A: Action,
|
||||||
|
{
|
||||||
|
self.cx.dispatch_action(self.window, action)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Context for VisualTestContext<'a> {
|
impl<'a> Context for VisualTestContext<'a> {
|
||||||
|
|
|
@ -422,8 +422,11 @@ impl<'a> WindowContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_action(&mut self, action: Box<dyn Action>) {
|
pub fn dispatch_action(&mut self, action: Box<dyn Action>) {
|
||||||
|
dbg!("BEFORE FOCUS");
|
||||||
if let Some(focus_handle) = self.focused() {
|
if let Some(focus_handle) = self.focused() {
|
||||||
|
dbg!("BEFORE DEFER", focus_handle.id);
|
||||||
self.defer(move |cx| {
|
self.defer(move |cx| {
|
||||||
|
dbg!("AFTER DEFER");
|
||||||
if let Some(node_id) = cx
|
if let Some(node_id) = cx
|
||||||
.window
|
.window
|
||||||
.current_frame
|
.current_frame
|
||||||
|
|
|
@ -38,10 +38,10 @@ use futures::{
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, point, rems, size, Action, AnyModel, AnyView, AnyWeakView, AppContext,
|
actions, div, point, rems, size, Action, AnyModel, AnyView, AnyWeakView, AppContext,
|
||||||
AsyncAppContext, AsyncWindowContext, Bounds, Component, Div, Entity, EntityId, EventEmitter,
|
AsyncAppContext, AsyncWindowContext, Bounds, Component, Div, Entity, EntityId, EventEmitter,
|
||||||
FocusHandle, GlobalPixels, KeyContext, Model, ModelContext, ParentElement, Point, Render, Size,
|
FocusHandle, FocusableKeyDispatch, GlobalPixels, KeyContext, Model, ModelContext,
|
||||||
StatefulInteractive, StatelessInteractive, StatelessInteractivity, Styled, Subscription, Task,
|
ParentElement, Point, Render, Size, StatefulInteractive, StatefulInteractivity,
|
||||||
View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle,
|
StatelessInteractive, StatelessInteractivity, Styled, Subscription, Task, View, ViewContext,
|
||||||
WindowOptions,
|
VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle, WindowOptions,
|
||||||
};
|
};
|
||||||
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
|
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
@ -3409,10 +3409,6 @@ impl Workspace {
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!()
|
|
||||||
// #[cfg(any(test, feature = "test-support"))]
|
|
||||||
// pub fn test_new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
|
|
||||||
// use node_runtime::FakeNodeRuntime;
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
||||||
use gpui::Context;
|
use gpui::Context;
|
||||||
|
@ -3432,7 +3428,10 @@ impl Workspace {
|
||||||
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
|
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
|
||||||
node_runtime: FakeNodeRuntime::new(),
|
node_runtime: FakeNodeRuntime::new(),
|
||||||
});
|
});
|
||||||
Self::new(0, project, app_state, cx)
|
let workspace = Self::new(0, project, app_state, cx);
|
||||||
|
dbg!(&workspace.focus_handle);
|
||||||
|
workspace.focus_handle.focus(cx);
|
||||||
|
workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn render_dock(&self, position: DockPosition, cx: &WindowContext) -> Option<AnyElement<Self>> {
|
// fn render_dock(&self, position: DockPosition, cx: &WindowContext) -> Option<AnyElement<Self>> {
|
||||||
|
@ -3710,13 +3709,14 @@ fn notify_if_database_failed(workspace: WindowHandle<Workspace>, cx: &mut AsyncA
|
||||||
impl EventEmitter<Event> for Workspace {}
|
impl EventEmitter<Event> for Workspace {}
|
||||||
|
|
||||||
impl Render for Workspace {
|
impl Render for Workspace {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self, StatefulInteractivity<Self>, FocusableKeyDispatch<Self>>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
let mut context = KeyContext::default();
|
let mut context = KeyContext::default();
|
||||||
context.add("Workspace");
|
context.add("Workspace");
|
||||||
|
|
||||||
self.add_workspace_actions_listeners(div())
|
self.add_workspace_actions_listeners(div())
|
||||||
|
.track_focus(&self.focus_handle)
|
||||||
.context(context)
|
.context(context)
|
||||||
.relative()
|
.relative()
|
||||||
.size_full()
|
.size_full()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue