Remove handle to view from TerminalElement
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
a860a6cd62
commit
f54a289b6f
2 changed files with 4 additions and 16 deletions
|
@ -11,7 +11,7 @@ use gpui::{
|
||||||
serde_json::json,
|
serde_json::json,
|
||||||
text_layout::{Line, RunStyle},
|
text_layout::{Line, RunStyle},
|
||||||
Drawable, Element, EventContext, FontCache, ModelContext, MouseRegion, Quad, SceneBuilder,
|
Drawable, Element, EventContext, FontCache, ModelContext, MouseRegion, Quad, SceneBuilder,
|
||||||
SizeConstraint, TextLayoutCache, ViewContext, WeakModelHandle, WeakViewHandle,
|
SizeConstraint, TextLayoutCache, ViewContext, WeakModelHandle,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::CursorShape;
|
use language::CursorShape;
|
||||||
|
@ -161,20 +161,17 @@ impl LayoutRect {
|
||||||
///We need to keep a reference to the view for mouse events, do we need it for any other terminal stuff, or can we move that to connection?
|
///We need to keep a reference to the view for mouse events, do we need it for any other terminal stuff, or can we move that to connection?
|
||||||
pub struct TerminalElement {
|
pub struct TerminalElement {
|
||||||
terminal: WeakModelHandle<Terminal>,
|
terminal: WeakModelHandle<Terminal>,
|
||||||
view: WeakViewHandle<TerminalView>,
|
|
||||||
focused: bool,
|
focused: bool,
|
||||||
cursor_visible: bool,
|
cursor_visible: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TerminalElement {
|
impl TerminalElement {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
view: WeakViewHandle<TerminalView>,
|
|
||||||
terminal: WeakModelHandle<Terminal>,
|
terminal: WeakModelHandle<Terminal>,
|
||||||
focused: bool,
|
focused: bool,
|
||||||
cursor_visible: bool,
|
cursor_visible: bool,
|
||||||
) -> TerminalElement {
|
) -> TerminalElement {
|
||||||
TerminalElement {
|
TerminalElement {
|
||||||
view,
|
|
||||||
terminal,
|
terminal,
|
||||||
focused,
|
focused,
|
||||||
cursor_visible,
|
cursor_visible,
|
||||||
|
@ -387,14 +384,13 @@ impl TerminalElement {
|
||||||
&self,
|
&self,
|
||||||
scene: &mut SceneBuilder,
|
scene: &mut SceneBuilder,
|
||||||
origin: Vector2F,
|
origin: Vector2F,
|
||||||
view_id: usize,
|
|
||||||
visible_bounds: RectF,
|
visible_bounds: RectF,
|
||||||
mode: TermMode,
|
mode: TermMode,
|
||||||
_cx: &mut ViewContext<TerminalView>,
|
cx: &mut ViewContext<TerminalView>,
|
||||||
) {
|
) {
|
||||||
let connection = self.terminal;
|
let connection = self.terminal;
|
||||||
|
|
||||||
let mut region = MouseRegion::new::<Self>(view_id, 0, visible_bounds);
|
let mut region = MouseRegion::new::<Self>(cx.view_id(), 0, visible_bounds);
|
||||||
|
|
||||||
// Terminal Emulator controlled behavior:
|
// Terminal Emulator controlled behavior:
|
||||||
region = region
|
region = region
|
||||||
|
@ -740,14 +736,7 @@ impl Drawable<TerminalView> for TerminalElement {
|
||||||
let origin = bounds.origin() + vec2f(layout.size.cell_width, 0.);
|
let origin = bounds.origin() + vec2f(layout.size.cell_width, 0.);
|
||||||
|
|
||||||
// Elements are ephemeral, only at paint time do we know what could be clicked by a mouse
|
// Elements are ephemeral, only at paint time do we know what could be clicked by a mouse
|
||||||
self.attach_mouse_handlers(
|
self.attach_mouse_handlers(scene, origin, visible_bounds, layout.mode, cx);
|
||||||
scene,
|
|
||||||
origin,
|
|
||||||
self.view.id(),
|
|
||||||
visible_bounds,
|
|
||||||
layout.mode,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
|
|
||||||
scene.push_cursor_region(gpui::CursorRegion {
|
scene.push_cursor_region(gpui::CursorRegion {
|
||||||
bounds,
|
bounds,
|
||||||
|
|
|
@ -399,7 +399,6 @@ impl View for TerminalView {
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.with_child(
|
.with_child(
|
||||||
TerminalElement::new(
|
TerminalElement::new(
|
||||||
cx.handle().downgrade(),
|
|
||||||
terminal_handle,
|
terminal_handle,
|
||||||
focused,
|
focused,
|
||||||
self.should_show_cursor(focused, cx),
|
self.should_show_cursor(focused, cx),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue