1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

gui: move last_mouse_terminal_coords to per-pane state

This commit is contained in:
Wez Furlong 2022-03-19 07:10:18 -07:00
parent bd9088372a
commit 5f1b0cff18
3 changed files with 12 additions and 5 deletions

View File

@ -159,6 +159,7 @@ pub struct PaneState {
pub overlay: Option<Rc<dyn Pane>>,
bell_start: Option<Instant>,
pub mouse_terminal_coords: Option<(usize, StableRowIndex)>,
}
/// Data used when synchronously formatting pane and window titles
@ -309,7 +310,6 @@ pub struct TermWindow {
/// If so, we ignore mouse events until released
is_click_to_focus: bool,
last_mouse_coords: (usize, i64),
last_mouse_terminal_coords: (usize, StableRowIndex),
window_drag_position: Option<MouseEvent>,
current_mouse_event: Option<MouseEvent>,
prev_cursor: PrevCursorPos,
@ -709,7 +709,6 @@ impl TermWindow {
fancy_tab_bar: None,
right_status: String::new(),
last_mouse_coords: (0, -1),
last_mouse_terminal_coords: (0, 0),
window_drag_position: None,
current_mouse_event: None,
prev_cursor: PrevCursorPos::new(),

View File

@ -554,7 +554,9 @@ impl super::TermWindow {
.unwrap_or(dims.physical_top)
+ y as StableRowIndex;
self.last_mouse_terminal_coords = (x, stable_row); // FIXME: per-pane
self.pane_state(pane.pane_id())
.mouse_terminal_coords
.replace((x, stable_row));
let (top, mut lines) = pane.get_lines_with_hyperlinks_applied(
stable_row..stable_row + 1,

View File

@ -58,7 +58,10 @@ impl super::TermWindow {
) {
self.selection(pane.pane_id()).seqno = pane.get_current_seqno();
let mode = mode.unwrap_or(SelectionMode::Cell);
let (x, y) = self.last_mouse_terminal_coords;
let (x, y) = match self.pane_state(pane.pane_id()).mouse_terminal_coords {
Some(coords) => coords,
None => return,
};
match mode {
SelectionMode::Cell => {
let end = SelectionCoordinate { x, y };
@ -145,7 +148,10 @@ impl super::TermWindow {
}
pub fn select_text_at_mouse_cursor(&mut self, mode: SelectionMode, pane: &Rc<dyn Pane>) {
let (x, y) = self.last_mouse_terminal_coords;
let (x, y) = match self.pane_state(pane.pane_id()).mouse_terminal_coords {
Some(coords) => coords,
None => return,
};
match mode {
SelectionMode::Line => {
let start = SelectionCoordinate { x, y };