ratatui_toolkit/widgets/markdown_widget/state/selection_state/methods/
enter.rs

1//! Enter selection mode.
2
3use crate::widgets::markdown_widget::foundation::types::SelectionPos;
4use crate::widgets::markdown_widget::state::selection_state::SelectionState;
5use ratatui::text::Line;
6
7impl SelectionState {
8    /// Enter selection mode at the given position.
9    ///
10    /// # Arguments
11    ///
12    /// * `x` - X coordinate (column)
13    /// * `y` - Y coordinate (document row)
14    /// * `lines` - Current rendered lines to freeze
15    /// * `width` - Current render width
16    pub fn enter(&mut self, x: i32, y: i32, lines: Vec<Line<'static>>, width: usize) {
17        self.active = true;
18        self.anchor = Some(SelectionPos::new(x, y));
19        self.cursor = Some(SelectionPos::new(x, y));
20        self.frozen_lines = Some(lines);
21        self.frozen_width = width;
22    }
23
24    /// Check if selection mode is active.
25    pub fn is_active(&self) -> bool {
26        self.active
27    }
28}