mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 10:29:35 +03:00
WIP
This commit is contained in:
parent
a25f962185
commit
4cb13fb39c
@ -7,8 +7,8 @@ use anyhow::{anyhow, Context, Result};
|
|||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, RenderedView,
|
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, Subscription, Task,
|
||||||
Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
View, ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
||||||
@ -731,7 +731,7 @@ impl Item for Editor {
|
|||||||
&self,
|
&self,
|
||||||
theme: &theme::Theme,
|
theme: &theme::Theme,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> Option<Vec<Box<dyn RenderedView>>> {
|
) -> Option<Vec<Box<dyn AnyRootElement>>> {
|
||||||
let cursor = self.selections.newest_anchor().head();
|
let cursor = self.selections.newest_anchor().head();
|
||||||
let multibuffer = &self.buffer().read(cx);
|
let multibuffer = &self.buffer().read(cx);
|
||||||
let (buffer_id, symbols) =
|
let (buffer_id, symbols) =
|
||||||
@ -753,7 +753,7 @@ impl Item for Editor {
|
|||||||
|
|
||||||
let filename_label = Label::new(filename, theme.workspace.breadcrumbs.default.text.clone());
|
let filename_label = Label::new(filename, theme.workspace.breadcrumbs.default.text.clone());
|
||||||
let mut breadcrumbs =
|
let mut breadcrumbs =
|
||||||
vec![Box::new(filename_label.boxed() as Element<Editor>) as Box<dyn RenderedView>];
|
vec![Box::new(filename_label.into_root(cx)) as Box<dyn AnyRootElement>];
|
||||||
breadcrumbs.extend(symbols.into_iter().map(|symbol| {
|
breadcrumbs.extend(symbols.into_iter().map(|symbol| {
|
||||||
Box::new(
|
Box::new(
|
||||||
Text::new(
|
Text::new(
|
||||||
@ -761,8 +761,8 @@ impl Item for Editor {
|
|||||||
theme.workspace.breadcrumbs.default.text.clone(),
|
theme.workspace.breadcrumbs.default.text.clone(),
|
||||||
)
|
)
|
||||||
.with_highlights(symbol.highlight_ranges)
|
.with_highlights(symbol.highlight_ranges)
|
||||||
.boxed() as Element<Editor>,
|
.into_root(cx) as Element<Editor>,
|
||||||
) as Box<dyn RenderedView>
|
) as Box<dyn AnyRootElement>
|
||||||
}));
|
}));
|
||||||
Some(breadcrumbs)
|
Some(breadcrumbs)
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,16 @@ pub trait Drawable<V: View> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn into_root(self, cx: &ViewContext<V>) -> RootElement<V>
|
||||||
|
where
|
||||||
|
Self: 'static + Sized,
|
||||||
|
{
|
||||||
|
RootElement {
|
||||||
|
element: self.boxed(),
|
||||||
|
view: cx.handle().downgrade(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn named(self, name: impl Into<Cow<'static, str>>) -> Element<V>
|
fn named(self, name: impl Into<Cow<'static, str>>) -> Element<V>
|
||||||
where
|
where
|
||||||
Self: 'static + Sized,
|
Self: 'static + Sized,
|
||||||
|
@ -15,8 +15,8 @@ use std::{
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use client::{proto, Client};
|
use client::{proto, Client};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyViewHandle, AppContext, Element, ModelHandle, RenderedView, Task, View, ViewContext,
|
elements::AnyRootElement, AnyViewHandle, AppContext, Element, ModelHandle, Task, View,
|
||||||
ViewHandle, WeakViewHandle,
|
ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use project::{Project, ProjectEntryId, ProjectPath};
|
use project::{Project, ProjectEntryId, ProjectPath};
|
||||||
use settings::{Autosave, Settings};
|
use settings::{Autosave, Settings};
|
||||||
@ -134,7 +134,11 @@ pub trait Item: View {
|
|||||||
ToolbarItemLocation::Hidden
|
ToolbarItemLocation::Hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {
|
fn breadcrumbs(
|
||||||
|
&self,
|
||||||
|
_theme: &Theme,
|
||||||
|
_cx: &ViewContext<Self>,
|
||||||
|
) -> Option<Vec<Box<dyn AnyRootElement>>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +225,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
|
|||||||
) -> gpui::Subscription;
|
) -> gpui::Subscription;
|
||||||
fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
|
fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
|
||||||
fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
|
fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
|
||||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>>;
|
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn AnyRootElement>>>;
|
||||||
fn serialized_item_kind(&self) -> Option<&'static str>;
|
fn serialized_item_kind(&self) -> Option<&'static str>;
|
||||||
fn show_toolbar(&self, cx: &AppContext) -> bool;
|
fn show_toolbar(&self, cx: &AppContext) -> bool;
|
||||||
}
|
}
|
||||||
@ -591,7 +595,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
|||||||
self.read(cx).breadcrumb_location()
|
self.read(cx).breadcrumb_location()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {
|
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn AnyRootElement>>> {
|
||||||
self.read(cx).breadcrumbs(theme, cx)
|
self.read(cx).breadcrumbs(theme, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user