Struct term_transcript::svg::TemplateOptions
source · pub struct TemplateOptions {
pub width: usize,
pub palette: Palette,
pub additional_styles: String,
pub font_family: String,
pub window_frame: bool,
pub scroll: Option<ScrollOptions>,
pub wrap: Option<WrapOptions>,
pub line_numbers: Option<LineNumbers>,
}svg only.Expand description
Configurable options of a Template.
§Serialization
Options can be deserialized from serde-supported encoding formats, such as TOML. This is used
in the CLI app to read options from a file:
let options_toml = r#"
width = 900
window_frame = true
line_numbers = 'continuous'
wrap.hard_break_at = 100
scroll = { max_height = 300, pixels_per_scroll = 18, interval = 1.5 }
[palette.colors]
black = '#3c3836'
red = '#b85651'
green = '#8f9a52'
yellow = '#c18f41'
blue = '#68948a'
magenta = '#ab6c7d'
cyan = '#72966c'
white = '#a89984'
[palette.intense_colors]
black = '#5a524c'
red = '#b85651'
green = '#a9b665'
yellow = '#d8a657'
blue = '#7daea3'
magenta = '#d3869b'
cyan = '#89b482'
white = '#ddc7a1'
"#;
let options: TemplateOptions = toml::from_str(options_toml)?;
assert_eq!(options.width, 900);
assert_matches!(options.wrap, Some(WrapOptions::HardBreakAt(100)));
assert_eq!(
options.palette.colors.green,
RgbColor(0x8f, 0x9a, 0x52)
);Fields§
§width: usizeWidth of the rendered terminal window in pixels. The default value is 720.
palette: PalettePalette of terminal colors. The default value of Palette is used by default.
additional_styles: StringCSS instructions to add at the beginning of the SVG <style> tag. This is mostly useful
to import fonts in conjunction with font_family.
The value is not validated in any way, so supplying invalid CSS instructions can lead to broken SVG rendering.
font_family: StringFont family specification in the CSS format. Should be monospace.
window_frame: boolIndicates whether to display a window frame around the shell. Default value is false.
scroll: Option<ScrollOptions>Options for the scroll animation. If set to None (which is the default),
no scrolling will be enabled, and the height of the generated image is not limited.
wrap: Option<WrapOptions>Text wrapping options. The default value of WrapOptions is used by default.
line_numbers: Option<LineNumbers>Line numbering options.
Implementations§
source§impl TemplateOptions
impl TemplateOptions
sourcepub fn render_data<'s>(
&'s self,
transcript: &'s Transcript
) -> Result<HandlebarsData<'s>, TermError>
pub fn render_data<'s>( &'s self, transcript: &'s Transcript ) -> Result<HandlebarsData<'s>, TermError>
Generates data for rendering.
§Errors
Returns an error if output cannot be rendered to HTML (e.g., it contains invalid SGR sequences).
Trait Implementations§
source§impl Clone for TemplateOptions
impl Clone for TemplateOptions
source§fn clone(&self) -> TemplateOptions
fn clone(&self) -> TemplateOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for TemplateOptions
impl Debug for TemplateOptions
source§impl Default for TemplateOptions
impl Default for TemplateOptions
source§impl<'de> Deserialize<'de> for TemplateOptions
impl<'de> Deserialize<'de> for TemplateOptions
source§fn 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>,
Auto Trait Implementations§
impl RefUnwindSafe for TemplateOptions
impl Send for TemplateOptions
impl Sync for TemplateOptions
impl Unpin for TemplateOptions
impl UnwindSafe for TemplateOptions
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.