Improved terminal selection ergonomics

This commit is contained in:
Mikayla Maki 2022-09-26 19:37:55 -07:00
parent a8e05c946e
commit 2ae3fbd6b2
2 changed files with 4 additions and 22 deletions

View file

@ -53,9 +53,7 @@ use thiserror::Error;
use gpui::{ use gpui::{
geometry::vector::{vec2f, Vector2F}, geometry::vector::{vec2f, Vector2F},
keymap::Keystroke, keymap::Keystroke,
scene::{ scene::{DownRegionEvent, DragRegionEvent, ScrollWheelRegionEvent, UpRegionEvent},
ClickRegionEvent, DownRegionEvent, DragRegionEvent, ScrollWheelRegionEvent, UpRegionEvent,
},
ClipboardItem, Entity, ModelContext, MouseButton, MouseMovedEvent, MutableAppContext, Task, ClipboardItem, Entity, ModelContext, MouseButton, MouseMovedEvent, MutableAppContext, Task,
}; };
@ -969,8 +967,6 @@ impl Terminal {
self.events self.events
.push_back(InternalEvent::Scroll(AlacScroll::Delta(scroll_lines))); .push_back(InternalEvent::Scroll(AlacScroll::Delta(scroll_lines)));
self.events
.push_back(InternalEvent::UpdateSelection(position))
} }
} }
} }
@ -996,21 +992,18 @@ impl Terminal {
self.last_content.size, self.last_content.size,
self.last_content.display_offset, self.last_content.display_offset,
); );
let side = mouse_side(position, self.last_content.size); // let side = mouse_side(position, self.last_content.size);
if self.mouse_mode(e.shift) { if self.mouse_mode(e.shift) {
if let Some(bytes) = mouse_button_report(point, e, true, self.last_content.mode) { if let Some(bytes) = mouse_button_report(point, e, true, self.last_content.mode) {
self.pty_tx.notify(bytes); self.pty_tx.notify(bytes);
} }
} else if e.button == MouseButton::Left { } else if e.button == MouseButton::Left {
self.events.push_back(InternalEvent::SetSelection(Some(( self.left_click(e, origin)
Selection::new(SelectionType::Simple, point, side),
point,
))));
} }
} }
pub fn left_click(&mut self, e: &ClickRegionEvent, origin: Vector2F) { pub fn left_click(&mut self, e: &DownRegionEvent, origin: Vector2F) {
let position = e.position.sub(origin); let position = e.position.sub(origin);
if !self.mouse_mode(e.shift) { if !self.mouse_mode(e.shift) {
//Hyperlinks //Hyperlinks

View file

@ -429,17 +429,6 @@ impl TerminalElement {
}, },
), ),
) )
// Handle click based selections
.on_click(
MouseButton::Left,
TerminalElement::generic_button_handler(
connection,
origin,
move |terminal, origin, e, _cx| {
terminal.left_click(&e, origin);
},
),
)
// Context menu // Context menu
.on_click(MouseButton::Right, move |e, cx| { .on_click(MouseButton::Right, move |e, cx| {
let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx.app) { let mouse_mode = if let Some(conn_handle) = connection.upgrade(cx.app) {