pub struct Selection {
pub start: BufferPos,
pub end: BufferPos,
}Expand description
Inclusive selection over the combined buffer.
Invariant: after normalization, (start.line, start.col) <= (end.line, end.col).
Fields§
§start: BufferPos§end: BufferPosImplementations§
Source§impl Selection
impl Selection
pub const fn new(start: BufferPos, end: BufferPos) -> Self
Sourcepub fn normalized(self) -> Self
pub fn normalized(self) -> Self
Normalize start/end ordering.
Sourcepub fn char_at(pos: BufferPos, grid: &Grid, scrollback: &Scrollback) -> Self
pub fn char_at(pos: BufferPos, grid: &Grid, scrollback: &Scrollback) -> Self
Select exactly one character cell (wide chars expand to include both columns).
Sourcepub fn line_at(line: u32, grid: &Grid, scrollback: &Scrollback) -> Self
pub fn line_at(line: u32, grid: &Grid, scrollback: &Scrollback) -> Self
Select the whole logical line (all columns).
Sourcepub fn word_at(pos: BufferPos, grid: &Grid, scrollback: &Scrollback) -> Self
pub fn word_at(pos: BufferPos, grid: &Grid, scrollback: &Scrollback) -> Self
Select a “word” at the given position.
Heuristics: contiguous run of is_word_char characters, or contiguous
whitespace if the clicked cell is whitespace.
Sourcepub fn extract_text(&self, grid: &Grid, scrollback: &Scrollback) -> String
pub fn extract_text(&self, grid: &Grid, scrollback: &Scrollback) -> String
Extract selected text from the buffer (scrollback + viewport).
- Wide continuation cells are skipped (wide chars appear once).
- Trailing spaces on each emitted line are trimmed.
- Soft-wrapped scrollback lines (where the next line has
wrapped=true) are joined without inserting a newline.
Source§impl Selection
impl Selection
Sourcepub fn extract_copy(
&self,
grid: &Grid,
scrollback: &Scrollback,
opts: &CopyOptions,
) -> String
pub fn extract_copy( &self, grid: &Grid, scrollback: &Scrollback, opts: &CopyOptions, ) -> String
Extract text with configurable copy options.
Enhanced version of extract_text that handles:
- Unicode combining marks (grapheme cluster preservation)
- Wide-character deduplication (continuation cells skipped)
- Soft-wrap joining (wrapped scrollback lines merged)
- Trailing whitespace trimming
Sourcepub fn extract_rect(
&self,
grid: &Grid,
scrollback: &Scrollback,
opts: &CopyOptions,
) -> String
pub fn extract_rect( &self, grid: &Grid, scrollback: &Scrollback, opts: &CopyOptions, ) -> String
Extract text for a rectangular (block/column) selection.
Each line contributes only the columns between min_col and max_col of the normalized selection. Lines are always separated by newlines (soft-wrap joining does not apply to rectangular selections since the column slice semantics would be ambiguous across wrapped runs).