diff --git a/src/terminal.rs b/src/terminal.rs index edb9abe..3e06094 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -4,11 +4,12 @@ use alacritty_terminal::{ event::{Event, EventListener, Notify, OnResize, WindowSize}, event_loop::{EventLoop, Msg, Notifier}, grid::Dimensions, + index::Point, sync::FairMutex, term::{ cell::Flags, color::{Colors, Rgb}, - TermMode, + viewport_to_point, TermMode, }, tty, Term, }; @@ -399,6 +400,11 @@ impl Terminal { self.buffer.redraw() } + + pub fn viewport_to_point(&self, point: Point) -> Point { + let term = self.term.lock(); + viewport_to_point(term.grid().display_offset(), point) + } } impl Drop for Terminal { diff --git a/src/terminal_box.rs b/src/terminal_box.rs index e2ad578..bae2006 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only use alacritty_terminal::{ - index::{Column as TermColumn, Line as TermLine, Point as TermPoint, Side as TermSide}, + index::{Column as TermColumn, Point as TermPoint, Side as TermSide}, selection::{Selection, SelectionType}, }; use cosmic::{ @@ -466,9 +466,10 @@ where //TODO: better calculation of position let col = x / terminal.size().cell_width; let row = y / terminal.size().cell_height; - //TODO: scroll row - let location = - TermPoint::new(TermLine(row as i32), TermColumn(col as usize)); + let location = terminal.viewport_to_point(TermPoint::new( + row as usize, + TermColumn(col as usize), + )); let side = if col.fract() < 0.5 { TermSide::Left } else { @@ -542,9 +543,10 @@ where //TODO: better calculation of position let col = x / terminal.size().cell_width; let row = y / terminal.size().cell_height; - //TODO: scroll row - let location = - TermPoint::new(TermLine(row as i32), TermColumn(col as usize)); + let location = terminal.viewport_to_point(TermPoint::new( + row as usize, + TermColumn(col as usize), + )); let side = if col.fract() < 0.5 { TermSide::Left } else {