pub struct MadSkin {Show 16 fields
pub paragraph: LineStyle,
pub bold: CompoundStyle,
pub italic: CompoundStyle,
pub strikeout: CompoundStyle,
pub inline_code: CompoundStyle,
pub code_block: LineStyle,
pub headers: [LineStyle; 8],
pub scrollbar: ScrollBarStyle,
pub table: LineStyle,
pub bullet: StyledChar,
pub quote_mark: StyledChar,
pub horizontal_rule: StyledChar,
pub ellipsis: CompoundStyle,
pub table_border_chars: &'static TableBorderChars,
pub list_items_indentation_mode: ListItemsIndentationMode,
pub special_chars: HashMap<Compound<'static>, StyledChar>,
}Expand description
A skin defining how a parsed markdown appears on the terminal (fg and bg colors, bold, italic, underline, etc.)
Fields§
§paragraph: LineStyle§bold: CompoundStyle§italic: CompoundStyle§strikeout: CompoundStyle§inline_code: CompoundStyle§code_block: LineStyle§headers: [LineStyle; 8]§scrollbar: ScrollBarStyle§table: LineStyle§bullet: StyledChar§quote_mark: StyledChar§horizontal_rule: StyledChar§ellipsis: CompoundStyle§table_border_chars: &'static TableBorderChars§list_items_indentation_mode: ListItemsIndentationMode§special_chars: HashMap<Compound<'static>, StyledChar>compounds which should be replaced with special renders. Experimental. This API will probably change (comments welcome) Do not use compounds with a length different than 1.
Implementations§
Source§impl MadSkin
impl MadSkin
Sourcepub fn no_style() -> MadSkin
pub fn no_style() -> MadSkin
Build a customizable skin with no style, most useful when your application must run in no-color mode, for example when piped to a file.
Note that without style you have no underline, no strikeout, etc.
Sourcepub fn default_dark() -> MadSkin
pub fn default_dark() -> MadSkin
Build a customizable skin with gray levels suitable when the terminal has a dark background
To determine whether the terminal is in light mode, you may use the terminal-light crate.
Sourcepub fn default_light() -> MadSkin
pub fn default_light() -> MadSkin
Build a customizable skin with gray levels suitable when the terminal has a light background
To determine whether the terminal is in light mode, you may use the terminal-light crate.
Sourcepub fn limit_to_ascii(&mut self)
pub fn limit_to_ascii(&mut self)
Change the characters used for table borders, bullets, etc. to be in the non extended ASCII range
Sourcepub fn blend_with<C>(&mut self, color: C, weight: f32)
pub fn blend_with<C>(&mut self, color: C, weight: f32)
Sourcepub fn set_fg(&mut self, fg: Color)
pub fn set_fg(&mut self, fg: Color)
Change the foreground of most styles (the ones which commonly have a default or uniform baground, don’t change code styles for example).
This can be used either as a first step in skin customization or as the only change done to a default skin.
Sourcepub fn set_bg(&mut self, bg: Color)
pub fn set_bg(&mut self, bg: Color)
Change the background of most styles (the ones which commonly have a default or uniform baground, don’t change code styles for example).
This can be used either as a first step in skin customization or as the only change done to a default skin.
Sourcepub fn set_headers_fg(&mut self, c: Color)
pub fn set_headers_fg(&mut self, c: Color)
Set a common foreground color for all header levels
(it’s still possible to change them individually with
skin.headers[i])
Sourcepub fn set_headers_bg(&mut self, c: Color)
pub fn set_headers_bg(&mut self, c: Color)
Set a common background color for all header levels
(it’s still possible to change them individually with
skin.headers[i])
Sourcepub fn set_global_bg(&mut self, c: Color)
pub fn set_global_bg(&mut self, c: Color)
set a common background for the paragraph, headers, rules, etc.
Sourcepub fn visible_composite_length(
&self,
kind: CompositeKind,
compounds: &[Compound<'_>],
) -> usize
pub fn visible_composite_length( &self, kind: CompositeKind, compounds: &[Compound<'_>], ) -> usize
Return the number of visible cells
pub fn visible_line_length(&self, line: &Line<'_>) -> usize
Sourcepub const fn line_style(&self, kind: CompositeKind) -> &LineStyle
pub const fn line_style(&self, kind: CompositeKind) -> &LineStyle
return the style to apply to a given line
Sourcepub fn compound_style(
&self,
line_style: &LineStyle,
compound: &Compound<'_>,
) -> CompoundStyle
pub fn compound_style( &self, line_style: &LineStyle, compound: &Compound<'_>, ) -> CompoundStyle
return the style appliable to a given compound. It’s a composition of the various appliable base styles.
Sourcepub fn inline<'k, 's>(&'k self, src: &'s str) -> FmtInline<'k, 's>
pub fn inline<'k, 's>(&'k self, src: &'s str) -> FmtInline<'k, 's>
return a formatted line or part of line.
Don’t use this function if src is expected to be several lines.
Sourcepub fn text<'k, 's>(
&'k self,
src: &'s str,
width: Option<usize>,
) -> FmtText<'k, 's>
pub fn text<'k, 's>( &'k self, src: &'s str, width: Option<usize>, ) -> FmtText<'k, 's>
return a formatted text.
Code blocs will be right justified
Sourcepub fn term_text<'k, 's>(&'k self, src: &'s str) -> FmtText<'k, 's>
pub fn term_text<'k, 's>(&'k self, src: &'s str) -> FmtText<'k, 's>
return a formatted text, with lines wrapped or justified for the current terminal width.
Code blocs will be right justified
Sourcepub fn area_text<'k, 's>(&'k self, src: &'s str, area: &Area) -> FmtText<'k, 's>
pub fn area_text<'k, 's>(&'k self, src: &'s str, area: &Area) -> FmtText<'k, 's>
return a formatted text, with lines wrapped or justified for the passed area width (with space for a scrollbar).
Code blocs will be right justified
pub fn write_in_area(&self, markdown: &str, area: &Area) -> Result<(), Error>
Sourcepub fn write_in_area_on<W>(
&self,
w: &mut W,
markdown: &str,
area: &Area,
) -> Result<(), Error>where
W: Write,
pub fn write_in_area_on<W>(
&self,
w: &mut W,
markdown: &str,
area: &Area,
) -> Result<(), Error>where
W: Write,
queue the rendered markdown in the specified area, without flush
Sourcepub fn print_inline(&self, src: &str)
pub fn print_inline(&self, src: &str)
do a print! of the given src interpreted as a markdown span
Don’t use this function if the string is expected to be several
lines or have typed lines (titles, bullets, code fences, etc.):
use print_text instead.
Sourcepub fn print_text(&self, src: &str)
pub fn print_text(&self, src: &str)
do a print! of the given src interpreted as a markdown text
Sourcepub fn print_expander(&self, expander: TextTemplateExpander<'_, '_>)
pub fn print_expander(&self, expander: TextTemplateExpander<'_, '_>)
do a print! of the given expander
Sourcepub fn write_expander<W>(
&self,
w: &mut W,
expander: TextTemplateExpander<'_, '_>,
) -> Result<(), Error>where
W: Write,
pub fn write_expander<W>(
&self,
w: &mut W,
expander: TextTemplateExpander<'_, '_>,
) -> Result<(), Error>where
W: Write,
do a print! of the given expander
Sourcepub fn print_owning_expander(
&self,
expander: &OwningTemplateExpander<'_>,
template: &TextTemplate<'_>,
)
pub fn print_owning_expander( &self, expander: &OwningTemplateExpander<'_>, template: &TextTemplate<'_>, )
do a print! of the given owning expander
Sourcepub fn write_owning_expander<W>(
&self,
w: &mut W,
expander: &OwningTemplateExpander<'_>,
template: &TextTemplate<'_>,
) -> Result<(), Error>where
W: Write,
pub fn write_owning_expander<W>(
&self,
w: &mut W,
expander: &OwningTemplateExpander<'_>,
template: &TextTemplate<'_>,
) -> Result<(), Error>where
W: Write,
do a print! of the given owning expander
Sourcepub fn print_owning_expander_md<T>(
&self,
expander: &OwningTemplateExpander<'_>,
template: T,
)
pub fn print_owning_expander_md<T>( &self, expander: &OwningTemplateExpander<'_>, template: T, )
do a print! of the given owning expander
Sourcepub fn write_owning_expander_md<T, W>(
&self,
w: &mut W,
expander: &OwningTemplateExpander<'_>,
template: T,
) -> Result<(), Error>
pub fn write_owning_expander_md<T, W>( &self, w: &mut W, expander: &OwningTemplateExpander<'_>, template: T, ) -> Result<(), Error>
do a print! of the given owning expander
pub fn print_composite(&self, composite: Composite<'_>)
pub fn write_composite<W>(
&self,
w: &mut W,
composite: Composite<'_>,
) -> Result<(), Error>where
W: Write,
Sourcepub fn write_composite_fill<W>(
&self,
w: &mut W,
composite: Composite<'_>,
width: usize,
align: Alignment,
) -> Result<(), Error>where
W: Write,
pub fn write_composite_fill<W>(
&self,
w: &mut W,
composite: Composite<'_>,
width: usize,
align: Alignment,
) -> Result<(), Error>where
W: Write,
write a composite filling the given width
Ellision or truncation may occur, but no wrap. Use Alignement::Unspecified for a smart internal ellision
Sourcepub fn write_inline_on<W>(&self, w: &mut W, src: &str) -> Result<(), Error>where
W: Write,
pub fn write_inline_on<W>(&self, w: &mut W, src: &str) -> Result<(), Error>where
W: Write,
parse the given src as a markdown snippet and write it on
the given Write
Sourcepub fn write_text_on<W>(&self, w: &mut W, src: &str) -> Result<(), Error>where
W: Write,
pub fn write_text_on<W>(&self, w: &mut W, src: &str) -> Result<(), Error>where
W: Write,
parse the given src as a markdown text and write it on
the given Write
Sourcepub fn write_inline(&self, src: &str) -> Result<(), Error>
pub fn write_inline(&self, src: &str) -> Result<(), Error>
parse the given src as a markdown snippet and write it on stdout
Sourcepub fn write_text(&self, src: &str) -> Result<(), Error>
pub fn write_text(&self, src: &str) -> Result<(), Error>
parse the given src as a markdown text and write it on stdout
Sourcepub fn write_fmt_composite(
&self,
f: &mut Formatter<'_>,
fc: &FmtComposite<'_>,
outer_width: Option<usize>,
with_right_completion: bool,
with_margins: bool,
) -> Result<(), Error>
pub fn write_fmt_composite( &self, f: &mut Formatter<'_>, fc: &FmtComposite<'_>, outer_width: Option<usize>, with_right_completion: bool, with_margins: bool, ) -> Result<(), Error>
Write a composite.
This function is internally used and normally not needed outside of Termimad’s implementation. Its arguments may change.
Sourcepub fn write_fmt_line(
&self,
f: &mut Formatter<'_>,
line: &FmtLine<'_>,
width: Option<usize>,
with_right_completion: bool,
) -> Result<(), Error>
pub fn write_fmt_line( &self, f: &mut Formatter<'_>, line: &FmtLine<'_>, width: Option<usize>, with_right_completion: bool, ) -> Result<(), Error>
Write a line in the passed formatter, with completions.
Right completion is optional because:
- if a text isn’t right completed it shrinks better when you reduce the width of the terminal
- right completion is useful to overwrite previous rendering without flickering (in scrollable views)
Trait Implementations§
Source§impl Default for MadSkin
impl Default for MadSkin
Source§fn default() -> MadSkin
fn default() -> MadSkin
Build a customizable skin.
It’s initialized with sensible gray level settings which should work whatever the terminal colors.
If you want a default skin and you already know if your terminal is light or dark, you may use MadSkin::default_light or MadSkin::default_dark.