Struct termwiz::surface::line::Line

source ·
pub struct Line { /* private fields */ }

Implementations§

source§

impl Line

source

pub fn with_width_and_cell(width: usize, cell: Cell, seqno: SequenceNo) -> Self

source

pub fn from_cells(cells: Vec<Cell>, seqno: SequenceNo) -> Self

source

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.

source

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.

source

pub fn with_width(width: usize, seqno: SequenceNo) -> Self

source

pub fn from_text( s: &str, attrs: &CellAttributes, seqno: SequenceNo, unicode_version: Option<UnicodeVersion> ) -> Line

source

pub fn from_text_with_wrapped_last_col( s: &str, attrs: &CellAttributes, seqno: SequenceNo ) -> Line

source

pub fn resize_and_clear( &mut self, width: usize, seqno: SequenceNo, blank_attr: CellAttributes )

source

pub fn resize(&mut self, width: usize, seqno: SequenceNo)

source

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)

source

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.

source

pub fn clear_appdata(&self)

source

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.

source

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

source

pub fn current_seqno(&self) -> SequenceNo

source

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

source

pub fn is_single_width(&self) -> bool

Check whether the line is single-width.

source

pub fn set_single_width(&mut self, seqno: SequenceNo)

Force single-width. This also implicitly sets double-height-(top/bottom) and dirty.

source

pub fn is_double_width(&self) -> bool

Check whether the line is double-width and not double-height.

source

pub fn set_double_width(&mut self, seqno: SequenceNo)

Force double-width. This also implicitly sets double-height-(top/bottom) and dirty.

source

pub fn is_double_height_top(&self) -> bool

Check whether the line is double-height-top.

source

pub fn set_double_height_top(&mut self, seqno: SequenceNo)

Force double-height top-half. This also implicitly sets double-width and dirty.

source

pub fn is_double_height_bottom(&self) -> bool

Check whether the line is double-height-bottom.

source

pub fn set_double_height_bottom(&mut self, seqno: SequenceNo)

Force double-height bottom-half. This also implicitly sets double-width and dirty.

source

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

source

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.

source

pub fn set_bidi_info( &mut self, enabled: bool, direction: ParagraphDirectionHint, seqno: SequenceNo )

source

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.

source

pub fn semantic_zone_ranges(&mut self) -> &[ZoneRange]

If we have any cells with an implicit hyperlink, remove the hyperlink from the cell attributes but leave the remainder of the attributes alone.

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.

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.

Returns true if the line contains a hyperlink

source

pub fn as_str(&self) -> Cow<'_, str>

Recompose line into the corresponding utf8 string.

source

pub fn split_off(&mut self, idx: usize, seqno: SequenceNo) -> Self

source

pub fn compute_double_click_range<F: Fn(&str) -> bool>( &self, click_col: usize, is_word: F ) -> DoubleClickRange

source

pub fn columns_as_str(&self, range: Range<usize>) -> String

Returns a substring from the line.

source

pub fn columns_as_line(&self, range: Range<usize>) -> Self

source

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.

source

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.

source

pub fn set_cell_clearing_image_placements( &mut self, idx: usize, cell: Cell, seqno: SequenceNo )

source

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.

source

pub fn insert_cell( &mut self, x: usize, cell: Cell, right_margin: usize, seqno: SequenceNo )

source

pub fn erase_cell(&mut self, x: usize, seqno: SequenceNo)

source

pub fn remove_cell(&mut self, x: usize, seqno: SequenceNo)

source

pub fn erase_cell_with_margin( &mut self, x: usize, right_margin: usize, seqno: SequenceNo, blank_attr: CellAttributes )

source

pub fn prune_trailing_blanks(&mut self, seqno: SequenceNo)

source

pub fn fill_range(&mut self, cols: Range<usize>, cell: &Cell, seqno: SequenceNo)

source

pub fn len(&self) -> usize

source

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.

source

pub fn get_cell(&self, cell_index: usize) -> Option<CellRef<'_>>

source

pub fn cluster( &self, bidi_hint: Option<ParagraphDirectionHint> ) -> Vec<CellCluster>

source

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.

source

pub fn cells_mut(&mut self) -> &mut [Cell]

source

pub fn is_whitespace(&self) -> bool

Return true if the line consists solely of whitespace cells

source

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.

source

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.

source

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.

source

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.

source

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

Trait Implementations§

source§

impl Clone for Line

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Line

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Line

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a> From<&'a str> for Line

source§

fn from(s: &str) -> Line

Converts to this type from the input type.
source§

impl PartialEq for Line

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Line

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,