diff options
Diffstat (limited to 'src/selection.rs')
| -rw-r--r-- | src/selection.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/selection.rs b/src/selection.rs index 016cf649..35e44c1d 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -7,6 +7,8 @@ //! MouseUp → Text extracted, copied via OSC 52, highlight stays //! Next click / key → Selection cleared //! +//! Double-click copy also briefly highlights the selected word. +//! //! Rows are stored in screen-buffer coordinates instead of viewport-relative //! coordinates. That keeps selection stable while the pane scrolls. @@ -59,6 +61,23 @@ impl Selection { } } + /// Create an active selection from an explicit viewport-row range. + pub(crate) fn range( + pane_id: PaneId, + viewport_row: u16, + start_col: u16, + end_col: u16, + metrics: Option<ScrollMetrics>, + ) -> Self { + let row = absolute_row_for_viewport_row(viewport_row, metrics); + Self { + pane_id, + anchor: (row, start_col), + cursor: (row, end_col), + phase: Phase::Dragging, + } + } + /// Convert the anchor's absolute row and pane-relative column back to /// screen coordinates. Adds the pane origin before clamping so the /// returned (screen_row, screen_col) can be compared directly against @@ -114,6 +133,11 @@ impl Selection { self.phase == Phase::Dragging || self.phase == Phase::Done } + /// Whether this selection was already finalized and copied. + pub fn is_done(&self) -> bool { + self.phase == Phase::Done + } + /// Whether the user just clicked without dragging (not a selection). pub fn was_just_click(&self) -> bool { self.phase == Phase::Anchored |
