pub struct Frame { /* private fields */ }Expand description
Rows of styled runs, with interned styles. See the module docs.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn to_html(&self, options: &HtmlOptions<'_>) -> String
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.
Sourcepub fn to_html_with(
&self,
options: &HtmlOptions<'_>,
code_format: &str,
) -> Result<String, ExportFormatError>
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.
Sourcepub fn to_svg(&self, options: &SvgOptions<'_>) -> String
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
impl Frame
Sourcepub fn with_placements(self, placements: Vec<Placement>) -> Frame
pub fn with_placements(self, placements: Vec<Placement>) -> Frame
This frame with placements beside its cells.
Sourcepub fn set_placements(&mut self, placements: Vec<Placement>)
pub fn set_placements(&mut self, placements: Vec<Placement>)
Replace the placements beside this frame’s cells.
Sourcepub fn placements(&self) -> &[Placement]
pub fn placements(&self) -> &[Placement]
The graphics placed on this frame’s cells.
Source§impl Frame
impl Frame
Sourcepub fn with_regions(self, recorder: &RegionRecorder) -> Frame
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.
Sourcepub fn regions(&self) -> Vec<Region>
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.
Sourcepub fn has_regions(&self) -> bool
pub fn has_regions(&self) -> bool
Whether the frame has recorded regions (links aside).
Source§impl Frame
impl Frame
Sourcepub fn from_segments(segments: &[Segment]) -> Frame
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.
Sourcepub fn merged(&self) -> Frame
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.
Sourcepub fn row(&self, index: usize) -> &[Run]
pub fn row(&self, index: usize) -> &[Run]
The runs of row index. Panics when index >= height().
pub fn styles(&self) -> &StyleTable
Sourcepub fn ends_with_newline(&self) -> bool
pub fn ends_with_newline(&self) -> bool
Whether the stream ended with a line break.
Sourcepub fn to_ansi(&self, console: &Console) -> String
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.
Sourcepub fn encode(&self, system: Option<ColorSystem>, no_color: bool) -> String
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.
Sourcepub fn to_ansi_merged(&self, console: &Console) -> String
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.
Sourcepub fn encode_span(
&self,
row: usize,
columns: Range<usize>,
system: Option<ColorSystem>,
no_color: bool,
) -> String
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.
Sourcepub fn cells(&self, index: usize) -> Vec<Cell<'_>>
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.