pub struct Line { /* private fields */ }
Implementations
sourceimpl 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.
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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn wrap(self, width: usize, seqno: SequenceNo) -> Vec<Self>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Wrap the line so that it fits within the provided width. Returns the list of resultant line(s)
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_reverse(&self) -> bool
pub fn is_reverse(&self) -> bool
Check whether the reverse video bit is set. If it is set, then the line should be displayed with foreground/background colors reversed.
sourcepub fn set_reverse(&mut self, reverse: bool, seqno: SequenceNo)
pub fn set_reverse(&mut self, reverse: bool, seqno: SequenceNo)
Force the reverse bit set. This also implicitly sets dirty.
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 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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Line
impl<'de> Deserialize<'de> for Line
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Line
Auto Trait Implementations
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more