pub struct Line { /* private fields */ }
Implementations§
source§impl Line
impl Line
pub fn with_width_and_cell(width: usize, cell: Cell, seqno: SequenceNo) -> Self
pub fn from_cells(cells: Vec<Cell>, seqno: SequenceNo) -> Self
sourcepub fn new(seqno: SequenceNo) -> Self
pub fn new(seqno: SequenceNo) -> Self
Create a new line using cluster storage, optimized for appending and lower memory utilization. The line will automatically switch to cell storage when necessary to apply edits.
sourcepub fn compute_shape_hash(&self) -> [u8; 16]
pub fn compute_shape_hash(&self) -> [u8; 16]
Computes a hash over the line that will change if the way that the line contents are shaped would change. This is independent of the seqno and is based purely on the content of the line.
Line doesn’t implement Hash in terms of this function as compute_shape_hash doesn’t every possible bit of internal state, and we don’t want to encourage using Line directly as a hash key.
pub fn with_width(width: usize, seqno: SequenceNo) -> Self
pub fn from_text( s: &str, attrs: &CellAttributes, seqno: SequenceNo, unicode_version: Option<UnicodeVersion> ) -> Line
pub fn from_text_with_wrapped_last_col( s: &str, attrs: &CellAttributes, seqno: SequenceNo ) -> Line
pub fn resize_and_clear( &mut self, width: usize, seqno: SequenceNo, blank_attr: CellAttributes )
pub fn resize(&mut self, width: usize, seqno: SequenceNo)
sourcepub fn wrap(self, width: usize, seqno: SequenceNo) -> Vec<Self>
pub fn wrap(self, width: usize, seqno: SequenceNo) -> Vec<Self>
Wrap the line so that it fits within the provided width. Returns the list of resultant line(s)
sourcepub fn set_appdata<T: Any + Send + Sync>(&self, appdata: Arc<T>)
pub fn set_appdata<T: Any + Send + Sync>(&self, appdata: Arc<T>)
Set arbitrary application specific data for the line.
Only one piece of appdata can be tracked per line,
so this is only suitable for the overall application
and not for use by “middleware” crates.
A Weak reference is stored.
get_appdata
is used to retrieve a previously stored reference.
pub fn clear_appdata(&self)
sourcepub fn get_appdata(&self) -> Option<Arc<dyn Any + Send + Sync>>
pub fn get_appdata(&self) -> Option<Arc<dyn Any + Send + Sync>>
Retrieve the appdata for the line, if any. This may return None in the case where the underlying data has been released: Line only stores a Weak reference to it.
sourcepub fn changed_since(&self, seqno: SequenceNo) -> bool
pub fn changed_since(&self, seqno: SequenceNo) -> bool
Returns true if the line’s last changed seqno is more recent than the provided seqno parameter
pub fn current_seqno(&self) -> SequenceNo
sourcepub fn update_last_change_seqno(&mut self, seqno: SequenceNo)
pub fn update_last_change_seqno(&mut self, seqno: SequenceNo)
Annotate the line with the sequence number of a change. This can be used together with Line::changed_since to manage caching and rendering
sourcepub fn is_single_width(&self) -> bool
pub fn is_single_width(&self) -> bool
Check whether the line is single-width.
sourcepub fn set_single_width(&mut self, seqno: SequenceNo)
pub fn set_single_width(&mut self, seqno: SequenceNo)
Force single-width. This also implicitly sets double-height-(top/bottom) and dirty.
sourcepub fn is_double_width(&self) -> bool
pub fn is_double_width(&self) -> bool
Check whether the line is double-width and not double-height.
sourcepub fn set_double_width(&mut self, seqno: SequenceNo)
pub fn set_double_width(&mut self, seqno: SequenceNo)
Force double-width. This also implicitly sets double-height-(top/bottom) and dirty.
sourcepub fn is_double_height_top(&self) -> bool
pub fn is_double_height_top(&self) -> bool
Check whether the line is double-height-top.
sourcepub fn set_double_height_top(&mut self, seqno: SequenceNo)
pub fn set_double_height_top(&mut self, seqno: SequenceNo)
Force double-height top-half. This also implicitly sets double-width and dirty.
sourcepub fn is_double_height_bottom(&self) -> bool
pub fn is_double_height_bottom(&self) -> bool
Check whether the line is double-height-bottom.
sourcepub fn set_double_height_bottom(&mut self, seqno: SequenceNo)
pub fn set_double_height_bottom(&mut self, seqno: SequenceNo)
Force double-height bottom-half. This also implicitly sets double-width and dirty.
sourcepub fn set_bidi_enabled(&mut self, enabled: bool, seqno: SequenceNo)
pub fn set_bidi_enabled(&mut self, enabled: bool, seqno: SequenceNo)
Set a flag the indicate whether the line should have the bidi algorithm applied during rendering
sourcepub fn set_direction(
&mut self,
direction: Direction,
auto_detect: bool,
seqno: SequenceNo
)
pub fn set_direction( &mut self, direction: Direction, auto_detect: bool, seqno: SequenceNo )
Set the bidi direction for the line.
This affects both the bidi algorithm (if enabled via set_bidi_enabled)
and the layout direction of the line.
auto_detect
specifies whether the direction should be auto-detected
before falling back to the specified direction.
pub fn set_bidi_info( &mut self, enabled: bool, direction: ParagraphDirectionHint, seqno: SequenceNo )
sourcepub fn bidi_info(&self) -> (bool, ParagraphDirectionHint)
pub fn bidi_info(&self) -> (bool, ParagraphDirectionHint)
Returns a tuple of (BIDI_ENABLED, Direction), indicating whether the line should have the bidi algorithm applied and its base direction, respectively.
pub fn semantic_zone_ranges(&mut self) -> &[ZoneRange]
sourcepub fn invalidate_implicit_hyperlinks(&mut self, seqno: SequenceNo)
pub fn invalidate_implicit_hyperlinks(&mut self, seqno: SequenceNo)
If we have any cells with an implicit hyperlink, remove the hyperlink from the cell attributes but leave the remainder of the attributes alone.
sourcepub fn scan_and_create_hyperlinks(&mut self, rules: &[Rule])
pub fn scan_and_create_hyperlinks(&mut self, rules: &[Rule])
Scan through the line and look for sequences that match the provided
rules. Matching sequences are considered to be implicit hyperlinks
and will have a hyperlink attribute associated with them.
This function will only make changes if the line has been invalidated
since the last time this function was called.
This function does not remember the values of the rules
slice, so it
is the responsibility of the caller to call invalidate_implicit_hyperlinks
if it wishes to call this function with different rules
.
sourcepub fn apply_hyperlink_rules(rules: &[Rule], logical_line: &mut [&mut Line])
pub fn apply_hyperlink_rules(rules: &[Rule], logical_line: &mut [&mut Line])
Scan through a logical line that is comprised of an array of
physical lines and look for sequences that match the provided
rules. Matching sequences are considered to be implicit hyperlinks
and will have a hyperlink attribute associated with them.
This function will only make changes if the line has been invalidated
since the last time this function was called.
This function does not remember the values of the rules
slice, so it
is the responsibility of the caller to call invalidate_implicit_hyperlinks
if it wishes to call this function with different rules
.
This function will call Line::clear_appdata on lines where hyperlinks are adjusted.
sourcepub fn has_hyperlink(&self) -> bool
pub fn has_hyperlink(&self) -> bool
Returns true if the line contains a hyperlink
pub fn split_off(&mut self, idx: usize, seqno: SequenceNo) -> Self
pub fn compute_double_click_range<F: Fn(&str) -> bool>( &self, click_col: usize, is_word: F ) -> DoubleClickRange
sourcepub fn columns_as_str(&self, range: Range<usize>) -> String
pub fn columns_as_str(&self, range: Range<usize>) -> String
Returns a substring from the line.
pub fn columns_as_line(&self, range: Range<usize>) -> Self
sourcepub fn set_cell(&mut self, idx: usize, cell: Cell, seqno: SequenceNo)
pub fn set_cell(&mut self, idx: usize, cell: Cell, seqno: SequenceNo)
If we’re about to modify a cell obscured by a double-width character ahead of that cell, we need to nerf that sequence of cells to avoid partial rendering concerns. Similarly, when we assign a cell, we need to blank out those occluded successor cells.
sourcepub fn set_cell_grapheme(
&mut self,
idx: usize,
text: &str,
width: usize,
attr: CellAttributes,
seqno: SequenceNo
)
pub fn set_cell_grapheme( &mut self, idx: usize, text: &str, width: usize, attr: CellAttributes, seqno: SequenceNo )
Assign a cell using grapheme text with a known width and attributes. This is a micro-optimization over first constructing a Cell from the grapheme info. If assigning this particular cell can be optimized to an append to the interal clustered storage then the cost of constructing and dropping the Cell can be avoided.
pub fn set_cell_clearing_image_placements( &mut self, idx: usize, cell: Cell, seqno: SequenceNo )
sourcepub fn overlay_text_with_attribute(
&mut self,
start_idx: usize,
text: &str,
attr: CellAttributes,
seqno: SequenceNo
)
pub fn overlay_text_with_attribute( &mut self, start_idx: usize, text: &str, attr: CellAttributes, seqno: SequenceNo )
Place text starting at the specified column index. Each grapheme of the text run has the same attributes.
pub fn insert_cell( &mut self, x: usize, cell: Cell, right_margin: usize, seqno: SequenceNo )
pub fn erase_cell(&mut self, x: usize, seqno: SequenceNo)
pub fn remove_cell(&mut self, x: usize, seqno: SequenceNo)
pub fn erase_cell_with_margin( &mut self, x: usize, right_margin: usize, seqno: SequenceNo, blank_attr: CellAttributes )
pub fn prune_trailing_blanks(&mut self, seqno: SequenceNo)
pub fn fill_range(&mut self, cols: Range<usize>, cell: &Cell, seqno: SequenceNo)
pub fn len(&self) -> usize
sourcepub fn visible_cells<'a>(&'a self) -> impl Iterator<Item = CellRef<'a>>
pub fn visible_cells<'a>(&'a self) -> impl Iterator<Item = CellRef<'a>>
Iterates the visible cells, respecting the width of the cell. For instance, a double-width cell overlaps the following (blank) cell, so that blank cell is omitted from the iterator results. The iterator yields (column_index, Cell). Column index is the index into Self::cells, and due to the possibility of skipping the characters that follow wide characters, the column index may skip some positions. It is returned as a convenience to the consumer as using .enumerate() on this iterator wouldn’t be as useful.
pub fn get_cell(&self, cell_index: usize) -> Option<CellRef<'_>>
pub fn cluster( &self, bidi_hint: Option<ParagraphDirectionHint> ) -> Vec<CellCluster>
sourcepub fn compress_for_scrollback(&mut self)
pub fn compress_for_scrollback(&mut self)
Adjusts the internal storage so that it occupies less space. Subsequent mutations will incur some overhead to re-materialize the storage in a form that is suitable for mutation.
pub fn cells_mut(&mut self) -> &mut [Cell]
sourcepub fn is_whitespace(&self) -> bool
pub fn is_whitespace(&self) -> bool
Return true if the line consists solely of whitespace cells
sourcepub fn last_cell_was_wrapped(&self) -> bool
pub fn last_cell_was_wrapped(&self) -> bool
Return true if the last cell in the line has the wrapped attribute, indicating that the following line is logically a part of this one.
sourcepub fn set_last_cell_was_wrapped(&mut self, wrapped: bool, seqno: SequenceNo)
pub fn set_last_cell_was_wrapped(&mut self, wrapped: bool, seqno: SequenceNo)
Adjust the value of the wrapped attribute on the last cell of this line.
sourcepub fn append_line(&mut self, other: Line, seqno: SequenceNo)
pub fn append_line(&mut self, other: Line, seqno: SequenceNo)
Concatenate the cells from other with this line, appending them to this line. This function is used by rewrapping logic when joining wrapped lines back together.
sourcepub fn cells_mut_for_attr_changes_only(&mut self) -> &mut [Cell]
pub fn cells_mut_for_attr_changes_only(&mut self) -> &mut [Cell]
mutable access the cell data, but the caller must take care to only mutate attributes rather than the cell textual content. Use set_cell if you need to modify the textual content of the cell, so that important invariants are upheld.
sourcepub fn changes(&self, start_attr: &CellAttributes) -> Vec<Change>
pub fn changes(&self, start_attr: &CellAttributes) -> Vec<Change>
Given a starting attribute value, produce a series of Change entries to recreate the current line