WIP
This commit is contained in:
@@ -4,7 +4,7 @@ use super::{
|
||||
};
|
||||
use crate::{Anchor, Editor, ExcerptId, ExcerptRange, ToPoint as _};
|
||||
use collections::{Bound, HashMap, HashSet};
|
||||
use gpui::{fonts::HighlightStyle, ElementBox, ViewContext};
|
||||
use gpui::{fonts::HighlightStyle, Element, ViewContext};
|
||||
use language::{BufferSnapshot, Chunk, Patch, Point};
|
||||
use parking_lot::Mutex;
|
||||
use std::{
|
||||
@@ -50,7 +50,7 @@ struct BlockRow(u32);
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
struct WrapRow(u32);
|
||||
|
||||
pub type RenderBlock = Arc<dyn Fn(&mut BlockContext) -> ElementBox<Editor>>;
|
||||
pub type RenderBlock = Arc<dyn Fn(&mut BlockContext) -> Element<Editor>>;
|
||||
|
||||
pub struct Block {
|
||||
id: BlockId,
|
||||
@@ -69,7 +69,7 @@ where
|
||||
pub position: P,
|
||||
pub height: u8,
|
||||
pub style: BlockStyle,
|
||||
pub render: Arc<dyn Fn(&mut BlockContext) -> ElementBox<Editor>>,
|
||||
pub render: Arc<dyn Fn(&mut BlockContext) -> Element<Editor>>,
|
||||
pub disposition: BlockDisposition,
|
||||
}
|
||||
|
||||
@@ -947,7 +947,7 @@ impl DerefMut for BlockContext<'_, '_, '_, '_> {
|
||||
}
|
||||
|
||||
impl Block {
|
||||
pub fn render(&self, cx: &mut BlockContext) -> ElementBox<Editor> {
|
||||
pub fn render(&self, cx: &mut BlockContext) -> Element<Editor> {
|
||||
self.render.lock()(cx)
|
||||
}
|
||||
|
||||
@@ -994,7 +994,7 @@ mod tests {
|
||||
use crate::display_map::suggestion_map::SuggestionMap;
|
||||
use crate::display_map::{fold_map::FoldMap, tab_map::TabMap, wrap_map::WrapMap};
|
||||
use crate::multi_buffer::MultiBuffer;
|
||||
use gpui::{elements::Empty, Element};
|
||||
use gpui::{elements::Empty, Drawable};
|
||||
use rand::prelude::*;
|
||||
use settings::Settings;
|
||||
use std::env;
|
||||
|
||||
@@ -41,7 +41,7 @@ use gpui::{
|
||||
keymap_matcher::KeymapContext,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
serde_json::{self, json},
|
||||
AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox, Entity,
|
||||
AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Drawable, Element, Entity,
|
||||
ModelHandle, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||
@@ -722,7 +722,7 @@ impl ContextMenu {
|
||||
cursor_position: DisplayPoint,
|
||||
style: EditorStyle,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> (DisplayPoint, ElementBox<Editor>) {
|
||||
) -> (DisplayPoint, Element<Editor>) {
|
||||
match self {
|
||||
ContextMenu::Completions(menu) => (cursor_position, menu.render(style, cx)),
|
||||
ContextMenu::CodeActions(menu) => menu.render(cursor_position, style, cx),
|
||||
@@ -774,7 +774,7 @@ impl CompletionsMenu {
|
||||
!self.matches.is_empty()
|
||||
}
|
||||
|
||||
fn render(&self, style: EditorStyle, cx: &mut ViewContext<Editor>) -> ElementBox<Editor> {
|
||||
fn render(&self, style: EditorStyle, cx: &mut ViewContext<Editor>) -> Element<Editor> {
|
||||
enum CompletionTag {}
|
||||
|
||||
let completions = self.completions.clone();
|
||||
@@ -951,7 +951,7 @@ impl CodeActionsMenu {
|
||||
mut cursor_position: DisplayPoint,
|
||||
style: EditorStyle,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> (DisplayPoint, ElementBox<Editor>) {
|
||||
) -> (DisplayPoint, Element<Editor>) {
|
||||
enum ActionTag {}
|
||||
|
||||
let container_style = style.autocomplete.container;
|
||||
@@ -2929,7 +2929,7 @@ impl Editor {
|
||||
style: &EditorStyle,
|
||||
active: bool,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<ElementBox<Self>> {
|
||||
) -> Option<Element<Self>> {
|
||||
if self.available_code_actions.is_some() {
|
||||
enum CodeActions {}
|
||||
Some(
|
||||
@@ -2960,7 +2960,7 @@ impl Editor {
|
||||
line_height: f32,
|
||||
gutter_margin: f32,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Vec<Option<ElementBox<Self>>> {
|
||||
) -> Vec<Option<Element<Self>>> {
|
||||
enum FoldIndicators {}
|
||||
|
||||
let style = style.folds.clone();
|
||||
@@ -2975,7 +2975,7 @@ impl Editor {
|
||||
MouseEventHandler::<FoldIndicators, _>::new(
|
||||
ix as usize,
|
||||
cx,
|
||||
|mouse_state, _| -> ElementBox<Editor> {
|
||||
|mouse_state, _| -> Element<Editor> {
|
||||
Svg::new(match fold_status {
|
||||
FoldStatus::Folded => style.folded_icon.clone(),
|
||||
FoldStatus::Foldable => style.foldable_icon.clone(),
|
||||
@@ -3028,7 +3028,7 @@ impl Editor {
|
||||
cursor_position: DisplayPoint,
|
||||
style: EditorStyle,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Option<(DisplayPoint, ElementBox<Editor>)> {
|
||||
) -> Option<(DisplayPoint, Element<Editor>)> {
|
||||
self.context_menu
|
||||
.as_ref()
|
||||
.map(|menu| menu.render(cursor_position, style, cx))
|
||||
@@ -6795,7 +6795,7 @@ impl Entity for Editor {
|
||||
}
|
||||
|
||||
impl View for Editor {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
|
||||
let style = self.style(cx);
|
||||
let font_changed = self.display_map.update(cx, |map, cx| {
|
||||
map.set_fold_ellipses_color(style.folds.ellipses.text_color);
|
||||
|
||||
@@ -31,7 +31,7 @@ use gpui::{
|
||||
json::{self, ToJson},
|
||||
platform::{CursorStyle, Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent},
|
||||
text_layout::{self, Line, RunStyle, TextLayoutCache},
|
||||
AppContext, Axis, Border, CursorRegion, Element, ElementBox, EventContext, MouseRegion, Quad,
|
||||
AppContext, Axis, Border, CursorRegion, Drawable, Element, EventContext, MouseRegion, Quad,
|
||||
SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
@@ -1611,7 +1611,7 @@ impl EditorElement {
|
||||
}
|
||||
}
|
||||
|
||||
impl Element<Editor> for EditorElement {
|
||||
impl Drawable<Editor> for EditorElement {
|
||||
type LayoutState = LayoutState;
|
||||
type PaintState = ();
|
||||
|
||||
@@ -2172,10 +2172,10 @@ pub struct LayoutState {
|
||||
scrollbar_row_range: Range<f32>,
|
||||
show_scrollbars: bool,
|
||||
max_row: u32,
|
||||
context_menu: Option<(DisplayPoint, ElementBox<Editor>)>,
|
||||
code_actions_indicator: Option<(u32, ElementBox<Editor>)>,
|
||||
hover_popovers: Option<(DisplayPoint, Vec<ElementBox<Editor>>)>,
|
||||
fold_indicators: Vec<Option<ElementBox<Editor>>>,
|
||||
context_menu: Option<(DisplayPoint, Element<Editor>)>,
|
||||
code_actions_indicator: Option<(u32, Element<Editor>)>,
|
||||
hover_popovers: Option<(DisplayPoint, Vec<Element<Editor>>)>,
|
||||
fold_indicators: Vec<Option<Element<Editor>>>,
|
||||
}
|
||||
|
||||
pub struct PositionMap {
|
||||
@@ -2226,7 +2226,7 @@ impl PositionMap {
|
||||
|
||||
struct BlockLayout {
|
||||
row: u32,
|
||||
element: ElementBox<Editor>,
|
||||
element: Element<Editor>,
|
||||
style: BlockStyle,
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use gpui::{
|
||||
elements::{Flex, MouseEventHandler, Padding, Text},
|
||||
impl_internal_actions,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
AppContext, Axis, Element, ElementBox, ModelHandle, Task, ViewContext,
|
||||
AppContext, Axis, Drawable, Element, ModelHandle, Task, ViewContext,
|
||||
};
|
||||
use language::{Bias, DiagnosticEntry, DiagnosticSeverity};
|
||||
use project::{HoverBlock, Project};
|
||||
@@ -283,7 +283,7 @@ impl HoverState {
|
||||
style: &EditorStyle,
|
||||
visible_rows: Range<u32>,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Option<(DisplayPoint, Vec<ElementBox<Editor>>)> {
|
||||
) -> Option<(DisplayPoint, Vec<Element<Editor>>)> {
|
||||
// If there is a diagnostic, position the popovers based on that.
|
||||
// Otherwise use the start of the hover range
|
||||
let anchor = self
|
||||
@@ -323,7 +323,7 @@ pub struct InfoPopover {
|
||||
}
|
||||
|
||||
impl InfoPopover {
|
||||
pub fn render(&self, style: &EditorStyle, cx: &mut ViewContext<Editor>) -> ElementBox<Editor> {
|
||||
pub fn render(&self, style: &EditorStyle, cx: &mut ViewContext<Editor>) -> Element<Editor> {
|
||||
MouseEventHandler::<InfoPopover, _>::new(0, cx, |_, cx| {
|
||||
let mut flex = Flex::new(Axis::Vertical).scrollable::<HoverBlock>(1, None, cx);
|
||||
flex.extend(self.contents.iter().map(|content| {
|
||||
@@ -378,7 +378,7 @@ pub struct DiagnosticPopover {
|
||||
}
|
||||
|
||||
impl DiagnosticPopover {
|
||||
pub fn render(&self, style: &EditorStyle, cx: &mut ViewContext<Editor>) -> ElementBox<Editor> {
|
||||
pub fn render(&self, style: &EditorStyle, cx: &mut ViewContext<Editor>) -> Element<Editor> {
|
||||
enum PrimaryDiagnostic {}
|
||||
|
||||
let mut text_style = style.hover_popover.prose.clone();
|
||||
|
||||
+19
-12
@@ -7,8 +7,8 @@ use anyhow::{anyhow, Context, Result};
|
||||
use collections::HashSet;
|
||||
use futures::future::try_join_all;
|
||||
use gpui::{
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, Subscription, Task,
|
||||
View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, RenderedView,
|
||||
Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use language::{
|
||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
||||
@@ -526,7 +526,7 @@ impl Item for Editor {
|
||||
detail: Option<usize>,
|
||||
style: &theme::Tab,
|
||||
cx: &AppContext,
|
||||
) -> ElementBox<Pane> {
|
||||
) -> Element<Pane> {
|
||||
Flex::row()
|
||||
.with_child(
|
||||
Label::new(self.title(cx).to_string(), style.label.clone())
|
||||
@@ -727,7 +727,11 @@ impl Item for Editor {
|
||||
ToolbarItemLocation::PrimaryLeft { flex: None }
|
||||
}
|
||||
|
||||
fn breadcrumbs(&self, theme: &theme::Theme, cx: &AppContext) -> Option<Vec<ElementBox<Pane>>> {
|
||||
fn breadcrumbs(
|
||||
&self,
|
||||
theme: &theme::Theme,
|
||||
cx: &AppContext,
|
||||
) -> Option<Vec<Box<dyn RenderedView>>> {
|
||||
let cursor = self.selections.newest_anchor().head();
|
||||
let multibuffer = &self.buffer().read(cx);
|
||||
let (buffer_id, symbols) =
|
||||
@@ -748,14 +752,17 @@ impl Item for Editor {
|
||||
.unwrap_or_else(|| "untitled".to_string());
|
||||
|
||||
let filename_label = Label::new(filename, theme.workspace.breadcrumbs.default.text.clone());
|
||||
let mut breadcrumbs = vec![filename_label.boxed()];
|
||||
let mut breadcrumbs =
|
||||
vec![Box::new(filename_label.boxed() as Element<Editor>) as Box<dyn RenderedView>];
|
||||
breadcrumbs.extend(symbols.into_iter().map(|symbol| {
|
||||
Text::new(
|
||||
symbol.text,
|
||||
theme.workspace.breadcrumbs.default.text.clone(),
|
||||
)
|
||||
.with_highlights(symbol.highlight_ranges)
|
||||
.boxed()
|
||||
Box::new(
|
||||
Text::new(
|
||||
symbol.text,
|
||||
theme.workspace.breadcrumbs.default.text.clone(),
|
||||
)
|
||||
.with_highlights(symbol.highlight_ranges)
|
||||
.boxed() as Element<Editor>,
|
||||
) as Box<dyn RenderedView>
|
||||
}));
|
||||
Some(breadcrumbs)
|
||||
}
|
||||
@@ -1078,7 +1085,7 @@ impl View for CursorPosition {
|
||||
"CursorPosition"
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
|
||||
if let Some(position) = self.position {
|
||||
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
|
||||
let mut text = format!("{},{}", position.row + 1, position.column + 1);
|
||||
|
||||
Reference in New Issue
Block a user