Refine mouse event naming
This commit is contained in:
parent
3e23d1f48d
commit
6e53deb1b2
11 changed files with 353 additions and 393 deletions
|
@ -6,7 +6,7 @@ use alacritty_terminal::grid::Dimensions;
|
|||
/// with modifications for our circumstances
|
||||
use alacritty_terminal::index::{Column as GridCol, Line as GridLine, Point, Side};
|
||||
use alacritty_terminal::term::TermMode;
|
||||
use gpui::scene::ScrollWheelRegionEvent;
|
||||
use gpui::scene::MouseScrollWheel;
|
||||
use gpui::{geometry::vector::Vector2F, MouseButtonEvent, MouseMovedEvent, ScrollWheelEvent};
|
||||
|
||||
use crate::TerminalSize;
|
||||
|
@ -115,7 +115,7 @@ impl MouseButton {
|
|||
pub fn scroll_report(
|
||||
point: Point,
|
||||
scroll_lines: i32,
|
||||
e: &ScrollWheelRegionEvent,
|
||||
e: &MouseScrollWheel,
|
||||
mode: TermMode,
|
||||
) -> Option<impl Iterator<Item = Vec<u8>>> {
|
||||
if mode.intersects(TermMode::MOUSE_MODE) {
|
||||
|
|
|
@ -53,7 +53,7 @@ use thiserror::Error;
|
|||
use gpui::{
|
||||
geometry::vector::{vec2f, Vector2F},
|
||||
keymap::Keystroke,
|
||||
scene::{DownRegionEvent, DragRegionEvent, ScrollWheelRegionEvent, UpRegionEvent},
|
||||
scene::{MouseDown, MouseDrag, MouseScrollWheel, MouseUp},
|
||||
ClipboardItem, Entity, ModelContext, MouseButton, MouseMovedEvent, MutableAppContext, Task,
|
||||
};
|
||||
|
||||
|
@ -971,7 +971,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mouse_drag(&mut self, e: DragRegionEvent, origin: Vector2F) {
|
||||
pub fn mouse_drag(&mut self, e: MouseDrag, origin: Vector2F) {
|
||||
let position = e.position.sub(origin);
|
||||
self.last_mouse_position = Some(position);
|
||||
|
||||
|
@ -997,7 +997,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
fn drag_line_delta(&mut self, e: DragRegionEvent) -> Option<f32> {
|
||||
fn drag_line_delta(&mut self, e: MouseDrag) -> Option<f32> {
|
||||
//TODO: Why do these need to be doubled? Probably the same problem that the IME has
|
||||
let top = e.region.origin_y() + (self.last_content.size.line_height * 2.);
|
||||
let bottom = e.region.lower_left().y() - (self.last_content.size.line_height * 2.);
|
||||
|
@ -1011,7 +1011,7 @@ impl Terminal {
|
|||
Some(scroll_delta)
|
||||
}
|
||||
|
||||
pub fn mouse_down(&mut self, e: &DownRegionEvent, origin: Vector2F) {
|
||||
pub fn mouse_down(&mut self, e: &MouseDown, origin: Vector2F) {
|
||||
let position = e.position.sub(origin);
|
||||
let point = grid_point(
|
||||
position,
|
||||
|
@ -1029,7 +1029,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn left_click(&mut self, e: &DownRegionEvent, origin: Vector2F) {
|
||||
pub fn left_click(&mut self, e: &MouseDown, origin: Vector2F) {
|
||||
let position = e.position.sub(origin);
|
||||
if !self.mouse_mode(e.shift) {
|
||||
//Hyperlinks
|
||||
|
@ -1071,7 +1071,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mouse_up(&mut self, e: &UpRegionEvent, origin: Vector2F, cx: &mut ModelContext<Self>) {
|
||||
pub fn mouse_up(&mut self, e: &MouseUp, origin: Vector2F, cx: &mut ModelContext<Self>) {
|
||||
let settings = cx.global::<Settings>();
|
||||
let copy_on_select = settings
|
||||
.terminal_overrides
|
||||
|
@ -1103,7 +1103,7 @@ impl Terminal {
|
|||
}
|
||||
|
||||
///Scroll the terminal
|
||||
pub fn scroll_wheel(&mut self, e: ScrollWheelRegionEvent, origin: Vector2F) {
|
||||
pub fn scroll_wheel(&mut self, e: MouseScrollWheel, origin: Vector2F) {
|
||||
let mouse_mode = self.mouse_mode(e.shift);
|
||||
|
||||
if let Some(scroll_lines) = self.determine_scroll_lines(&e, mouse_mode) {
|
||||
|
@ -1142,11 +1142,7 @@ impl Terminal {
|
|||
self.hyperlink_from_position(self.last_mouse_position);
|
||||
}
|
||||
|
||||
fn determine_scroll_lines(
|
||||
&mut self,
|
||||
e: &ScrollWheelRegionEvent,
|
||||
mouse_mode: bool,
|
||||
) -> Option<i32> {
|
||||
fn determine_scroll_lines(&mut self, e: &MouseScrollWheel, mouse_mode: bool) -> Option<i32> {
|
||||
let scroll_multiplier = if mouse_mode { 1. } else { SCROLL_MULTIPLIER };
|
||||
|
||||
match e.phase {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue