Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Highlight termina on external files drag and drop
Kirill Bulatov6c4670287d7b
diff --git a/crates/terminal_view2/src/terminal_element.rs b/crates/terminal_view2/src/terminal_element.rsindex ec1e1736c31..eb7348b9357 100644--- a/crates/terminal_view2/src/terminal_element.rs+++ b/crates/terminal_view2/src/terminal_element.rs@@ -4,8 +4,9 @@ use gpui::{BorrowWindow, Bounds, DispatchPhase, Element, ElementId, ExternalPaths, FocusHandle, Font,FontStyle, FontWeight, HighlightStyle, Hsla, InteractiveElement, InteractiveElementState,Interactivity, IntoElement, LayoutId, Model, ModelContext, ModifiersChangedEvent, MouseButton,- Pixels, PlatformInputHandler, Point, Rgba, ShapedLine, StatefulInteractiveElement, Styled,- TextRun, TextStyle, TextSystem, UnderlineStyle, WhiteSpace, WindowContext,+ Pixels, PlatformInputHandler, Point, Rgba, ShapedLine, StatefulInteractiveElement,+ StyleRefinement, Styled, TextRun, TextStyle, TextSystem, UnderlineStyle, WhiteSpace,+ WindowContext,};use itertools::Itertools;use language::CursorShape;@@ -24,7 +25,7 @@ use terminal::{use theme::{ActiveTheme, Theme, ThemeSettings};use ui::Tooltip;-use std::mem;+use std::{any::TypeId, mem};use std::{fmt::Debug, ops::RangeInclusive};///The information generated during layout that is necessary for painting@@ -689,6 +690,10 @@ impl TerminalElement {}});+ self.interactivity.drag_over_styles.push((+ TypeId::of::<ExternalPaths>(),+ StyleRefinement::default().bg(cx.theme().colors().drop_target_background),+ ));self.interactivity.on_drop::<ExternalPaths>({let focus = focus.clone();let terminal = terminal.clone();@@ -787,8 +792,6 @@ impl Element for TerminalElement {) {let mut layout = self.compute_layout(bounds, cx);- let theme = cx.theme();-cx.paint_quad(fill(bounds, layout.background_color));let origin = bounds.origin + Point::new(layout.gutter, px(0.));@@ -801,16 +804,8 @@ impl Element for TerminalElement {.map(|cursor| cursor.bounding_rect(origin)),};- let terminal_focus_handle = self.focus.clone();- let terminal_handle = self.terminal.clone();self.register_mouse_listeners(origin, layout.mode, bounds, cx);- // todo!(change this to work in terms of on_drag_move or some such)- // .drag_over::<ExternalPaths>(|style| {- // // todo!() why does not it work? z-index of elements?- // style.bg(cx.theme().colors().ghost_element_hover)- // })-let mut interactivity = mem::take(&mut self.interactivity);interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {cx.handle_input(&self.focus, terminal_input_handler);diff --git a/crates/terminal_view2/src/terminal_panel.rs b/crates/terminal_view2/src/terminal_panel.rsindex 245add3eeb9..3c7b2a2e0e9 100644--- a/crates/terminal_view2/src/terminal_panel.rs+++ b/crates/terminal_view2/src/terminal_panel.rs@@ -4,8 +4,8 @@ use crate::TerminalView;use db::kvp::KEY_VALUE_STORE;use gpui::{actions, div, serde_json, AppContext, AsyncWindowContext, Div, Entity, EventEmitter,- FocusHandle, FocusableView, ParentElement, Render, Styled, Subscription, Task, View,- ViewContext, VisualContext, WeakView, WindowContext,+ ExternalPaths, FocusHandle, FocusableView, ParentElement, Render, Styled, Subscription, Task,+ View, ViewContext, VisualContext, WeakView, WindowContext,};use project::Fs;use serde::{Deserialize, Serialize};@@ -64,6 +64,9 @@ impl TerminalPanel {return item.downcast::<TerminalView>().is_some();}}+ if a.downcast_ref::<ExternalPaths>().is_some() {+ return true;+ }false})),@@ -72,13 +75,6 @@ impl TerminalPanel {pane.set_can_split(false, cx);pane.set_can_navigate(false, cx);// todo!()- // pane.on_can_drop(move |drag_and_drop, cx| {- // drag_and_drop- // .currently_dragged::<DraggedItem>(window)- // .map_or(false, |(_, item)| {- // item.handle.act_as::<TerminalView>(cx).is_some()- // })- // });// pane.set_render_tab_bar_buttons(cx, move |pane, cx| {// let this = weak_self.clone();// Flex::row()