pub struct LayoutEngine { /* private fields */ }Expand description
Layout engine - manages visual representation of all lines
Implementations§
Source§impl LayoutEngine
impl LayoutEngine
Sourcepub fn set_viewport_width(&mut self, width: usize)
pub fn set_viewport_width(&mut self, width: usize)
Set viewport width
Sourcepub fn viewport_width(&self) -> usize
pub fn viewport_width(&self) -> usize
Get viewport width
Sourcepub fn set_tab_width(&mut self, tab_width: usize)
pub fn set_tab_width(&mut self, tab_width: usize)
Set tab width (in cells) used for expanding '\t'.
If tab_width changes, all line layouts are recalculated.
Sourcepub fn from_lines(&mut self, lines: &[&str])
pub fn from_lines(&mut self, lines: &[&str])
Build layout from list of text lines
Sourcepub fn update_line(&mut self, line_index: usize, text: &str)
pub fn update_line(&mut self, line_index: usize, text: &str)
Update a specific line
Sourcepub fn insert_line(&mut self, line_index: usize, text: &str)
pub fn insert_line(&mut self, line_index: usize, text: &str)
Insert a line
Sourcepub fn delete_line(&mut self, line_index: usize)
pub fn delete_line(&mut self, line_index: usize)
Delete a line
Sourcepub fn get_line_layout(&self, line_index: usize) -> Option<&VisualLineInfo>
pub fn get_line_layout(&self, line_index: usize) -> Option<&VisualLineInfo>
Get visual information for a specific logical line
Sourcepub fn logical_line_count(&self) -> usize
pub fn logical_line_count(&self) -> usize
Get total number of logical lines
Sourcepub fn visual_line_count(&self) -> usize
pub fn visual_line_count(&self) -> usize
Get total number of visual lines
Sourcepub fn logical_to_visual_line(&self, logical_line: usize) -> usize
pub fn logical_to_visual_line(&self, logical_line: usize) -> usize
Convert logical line number to visual line number
Returns the line number of the first visual line of this logical line
Sourcepub fn visual_to_logical_line(&self, visual_line: usize) -> (usize, usize)
pub fn visual_to_logical_line(&self, visual_line: usize) -> (usize, usize)
Convert visual line number to logical line number and offset within line
Returns (logical_line, visual_line_in_logical)
Sourcepub fn logical_position_to_visual(
&self,
logical_line: usize,
column: usize,
) -> Option<(usize, usize)>
pub fn logical_position_to_visual( &self, logical_line: usize, column: usize, ) -> Option<(usize, usize)>
Convert logical coordinates (line, column) to visual coordinates (visual row number, x cell offset within row).
logical_line: Logical line number (0-based)column: Character column within the logical line (0-based, counted bychar)
Return value:
Some((visual_row, x)):visual_rowis the global visual row number,xis the cell offset within that visual rowNone: Line number out of range
Sourcepub fn logical_position_to_visual_allow_virtual(
&self,
logical_line: usize,
column: usize,
) -> Option<(usize, usize)>
pub fn logical_position_to_visual_allow_virtual( &self, logical_line: usize, column: usize, ) -> Option<(usize, usize)>
Convert logical coordinates (line, column) to visual coordinates, allowing column to exceed line end (virtual spaces).
Difference from logical_position_to_visual:
columnis not clamped toline_char_len- Excess portion is treated as virtual spaces of
' '(width=1)