@@ -33,7 +33,7 @@ use util::ResultExt;
use std::{fmt::Debug, ops::RangeInclusive};
use std::{mem, ops::Range};
-use crate::{DeployContextMenu, TerminalView};
+use crate::TerminalView;
///The information generated during layout that is nescessary for painting
pub struct LayoutState {
@@ -429,19 +429,20 @@ impl TerminalElement {
),
)
// Context menu
- .on_click(MouseButton::Right, move |e, _: &mut TerminalView, cx| {
- let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx) {
- conn_handle.update(cx, |terminal, _cx| terminal.mouse_mode(e.shift))
- } else {
- // If we can't get the model handle, probably can't deploy the context menu
- true
- };
- if !mouse_mode {
- cx.dispatch_action(DeployContextMenu {
- position: e.position,
- });
- }
- })
+ .on_click(
+ MouseButton::Right,
+ move |event, view: &mut TerminalView, cx| {
+ let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx) {
+ conn_handle.update(cx, |terminal, _cx| terminal.mouse_mode(event.shift))
+ } else {
+ // If we can't get the model handle, probably can't deploy the context menu
+ true
+ };
+ if !mouse_mode {
+ view.deploy_context_menu(event.position, cx);
+ }
+ },
+ )
.on_move(move |event, _: &mut TerminalView, cx| {
if cx.is_parent_view_focused() {
if let Some(conn_handle) = connection.upgrade(cx) {
@@ -9,7 +9,7 @@ use gpui::{
actions,
elements::{AnchorCorner, ChildView, Flex, Label, ParentElement, Stack},
geometry::vector::Vector2F,
- impl_actions, impl_internal_actions,
+ impl_actions,
keymap_matcher::{KeymapContext, Keystroke},
platform::KeyDownEvent,
AnyElement, AnyViewHandle, AppContext, Element, Entity, ModelHandle, Task, View, ViewContext,
@@ -50,11 +50,6 @@ const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
#[derive(Clone, Debug, PartialEq)]
pub struct ScrollTerminal(pub i32);
-#[derive(Clone, PartialEq)]
-pub struct DeployContextMenu {
- pub position: Vector2F,
-}
-
#[derive(Clone, Default, Deserialize, PartialEq)]
pub struct SendText(String);
@@ -68,8 +63,6 @@ actions!(
impl_actions!(terminal, [SendText, SendKeystroke]);
-impl_internal_actions!(project_panel, [DeployContextMenu]);
-
pub fn init(cx: &mut AppContext) {
cx.add_action(TerminalView::deploy);
@@ -78,7 +71,6 @@ pub fn init(cx: &mut AppContext) {
//Useful terminal views
cx.add_action(TerminalView::send_text);
cx.add_action(TerminalView::send_keystroke);
- cx.add_action(TerminalView::deploy_context_menu);
cx.add_action(TerminalView::copy);
cx.add_action(TerminalView::paste);
cx.add_action(TerminalView::clear);
@@ -197,14 +189,14 @@ impl TerminalView {
cx.emit(Event::Wakeup);
}
- pub fn deploy_context_menu(&mut self, action: &DeployContextMenu, cx: &mut ViewContext<Self>) {
+ pub fn deploy_context_menu(&mut self, position: Vector2F, cx: &mut ViewContext<Self>) {
let menu_entries = vec![
ContextMenuItem::action("Clear", Clear),
ContextMenuItem::action("Close", pane::CloseActiveItem),
];
self.context_menu.update(cx, |menu, cx| {
- menu.show(action.position, AnchorCorner::TopLeft, menu_entries, cx)
+ menu.show(position, AnchorCorner::TopLeft, menu_entries, cx)
});
cx.notify();