Skip to main content

Frame

Struct Frame 

Source
pub struct Frame { /* private fields */ }
Expand description

Rows of styled runs, with interned styles. See the module docs.

Implementations§

Source§

impl Frame

Source

pub fn to_html(&self, options: &HtmlOptions<'_>) -> String

A self-contained HTML document, with core’s template (rich::export::CONSOLE_HTML_FORMAT). See Frame::to_html_with.

Source

pub fn to_html_with( &self, options: &HtmlOptions<'_>, code_format: &str, ) -> Result<String, ExportFormatError>

HTML in code_format, a Python format string with the fields {code}, {stylesheet}, {foreground} and {background}, as core’s export_html_with. "{code}" alone gives the markup to embed in a page of one’s own (with inline styles, it needs no stylesheet).

A linked run becomes <a href>. With regions (and HtmlOptions::regions), each row’s cells of a region are wrapped in <span class="rich-region rich-ROLE" data-region="N">, nested as the regions are, so the text keeps its place in the grid; the first wrapper of a region carries its ARIA role and label.

Source

pub fn to_svg(&self, options: &SvgOptions<'_>) -> String

A self-contained SVG image of a terminal, with core’s template (rich::svg::CONSOLE_SVG_FORMAT). Linked text is wrapped in <a>.

Source§

impl Frame

Source

pub fn with_placements(self, placements: Vec<Placement>) -> Frame

This frame with placements beside its cells.

Source

pub fn set_placements(&mut self, placements: Vec<Placement>)

Replace the placements beside this frame’s cells.

Source

pub fn placements(&self) -> &[Placement]

The graphics placed on this frame’s cells.

Source§

impl Frame

Source

pub fn with_regions(self, recorder: &RegionRecorder) -> Frame

This frame with the regions recorder recorded, as spans of the cells their tags cover. A region that drew nothing that is still in the frame is left out, and its children move up to the nearest ancestor that remains.

Source

pub fn regions(&self) -> Vec<Region>

The regions: those recorded with Frame::with_regions, then one RegionRole::Link region per stretch of runs sharing a link target. A link region’s parent is the innermost recorded region holding its first cell.

Source

pub fn has_regions(&self) -> bool

Whether the frame has recorded regions (links aside).

Source§

impl Frame

Source

pub fn from_segments(segments: &[Segment]) -> Frame

Build a frame from a segment stream, one run per piece of a segment between line breaks. Control segments are dropped.

Source

pub fn merged(&self) -> Frame

A copy with adjacent runs of one style on a row merged into one, and empty runs dropped: what shows, not how it was split. Line breaks are no longer part of any run, so Frame::to_ansi of the result writes them unstyled.

Source

pub fn height(&self) -> usize

The number of rows. A final line break does not start a new row.

Source

pub fn row(&self, index: usize) -> &[Run]

The runs of row index. Panics when index >= height().

Source

pub fn row_width(&self, index: usize) -> usize

The width of row index in cells.

Source

pub fn width(&self) -> usize

The widest row, in cells.

Source

pub fn run_text(&self, run: &Run) -> &str

The text of run.

Source

pub fn styles(&self) -> &StyleTable

Source

pub fn ends_with_newline(&self) -> bool

Whether the stream ended with a line break.

Source

pub fn run_count(&self) -> usize

The total number of runs.

Source

pub fn plain(&self) -> String

Plain text: rows joined by line breaks, without styles.

Source

pub fn to_ansi(&self, console: &Console) -> String

Encode as console would: the same bytes as console.segments_to_string on the stream this frame was built from, less its control segments.

Source

pub fn encode(&self, system: Option<ColorSystem>, no_color: bool) -> String

Encode with an explicit colour system. no_color removes colours but keeps other attributes, as Console does when no_color is set.

Source

pub fn to_ansi_merged(&self, console: &Console) -> String

Encode after merging adjacent runs of one style, with line breaks unstyled. Fewer bytes than Frame::to_ansi, but not upstream’s.

Source

pub fn encode_span( &self, row: usize, columns: Range<usize>, system: Option<ColorSystem>, no_color: bool, ) -> String

Encode the runs covering columns of row row (clipped to the row), merging adjacent runs of one style. A run that starts before the range is cut at the grapheme boundary; a wide grapheme cut in half becomes a space. This is what a cell-level repaint writes for one Change.

Source

pub fn cells(&self, index: usize) -> Vec<Cell<'_>>

One cell per grapheme of row index, using core’s widths. A wide grapheme is followed by continuation cells, so a cell’s index in the result is its column. A zero-width grapheme occupies no column: it joins the cell before it, even across runs, or the first cell of the row when nothing precedes it.

Source

pub fn diff(&self, previous: &Frame) -> Vec<Change>

The cells that differ from previous, as column ranges per row, in row order. Styles compare by value, so the two frames need not share a style table. A row present in only one frame changes across its width.

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Frame

Source§

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

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

impl Default for Frame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Frame

§

impl !UnwindSafe for Frame

§

impl Freeze for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more