Implement terminal pane drag and drop overrides
This commit is contained in:
parent
c4e306162c
commit
518868a12f
4 changed files with 103 additions and 59 deletions
|
@ -1,12 +1,12 @@
|
|||
use editor::{Cursor, HighlightedRange, HighlightedRangeLine};
|
||||
use gpui::{
|
||||
div, fill, point, px, red, relative, AnyElement, AsyncWindowContext, AvailableSpace,
|
||||
BorrowWindow, Bounds, DispatchPhase, Element, ElementId, ExternalPaths, FocusHandle, Font,
|
||||
FontStyle, FontWeight, HighlightStyle, Hsla, InteractiveBounds, InteractiveElement,
|
||||
BorrowWindow, Bounds, DispatchPhase, Element, ElementId, FocusHandle, Font, FontStyle,
|
||||
FontWeight, HighlightStyle, Hsla, InteractiveBounds, InteractiveElement,
|
||||
InteractiveElementState, Interactivity, IntoElement, LayoutId, Model, ModelContext,
|
||||
ModifiersChangedEvent, MouseButton, MouseMoveEvent, Pixels, PlatformInputHandler, Point,
|
||||
ShapedLine, StatefulInteractiveElement, StyleRefinement, Styled, TextRun, TextStyle,
|
||||
TextSystem, UnderlineStyle, WhiteSpace, WindowContext,
|
||||
ShapedLine, StatefulInteractiveElement, Styled, TextRun, TextStyle, TextSystem, UnderlineStyle,
|
||||
WhiteSpace, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::CursorShape;
|
||||
|
@ -25,7 +25,7 @@ use terminal::{
|
|||
use theme::{ActiveTheme, Theme, ThemeSettings};
|
||||
use ui::Tooltip;
|
||||
|
||||
use std::{any::TypeId, mem};
|
||||
use std::mem;
|
||||
use std::{fmt::Debug, ops::RangeInclusive};
|
||||
|
||||
///The information generated during layout that is necessary for painting
|
||||
|
@ -677,28 +677,6 @@ 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();
|
||||
move |external_paths, cx| {
|
||||
cx.focus(&focus);
|
||||
let mut new_text = external_paths
|
||||
.paths()
|
||||
.iter()
|
||||
.map(|path| format!(" {path:?}"))
|
||||
.join("");
|
||||
new_text.push(' ');
|
||||
terminal.update(cx, |terminal, _| {
|
||||
terminal.paste(&new_text);
|
||||
});
|
||||
cx.stop_propagation();
|
||||
}
|
||||
});
|
||||
|
||||
// Mouse mode handlers:
|
||||
// All mouse modes need the extra click handlers
|
||||
if mode.intersects(TermMode::MOUSE_MODE) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue