Struct termimad::MadSkin

source ·
pub struct MadSkin {
Show 14 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 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§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§

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.

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.

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.

Blend the foreground and background colors (if any) into the given dest color, with a weight in [0..1].

The dest color can be for example a crossterm color or a coolor one. A weight of 0 lets the skin unchanged.

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.

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.

Set a common foreground color for all header levels

(it’s still possible to change them individually with skin.headers[i])

Set a common background color for all header levels

(it’s still possible to change them individually with skin.headers[i])

set a common background for the paragraph, headers, rules, etc.

Return the number of visible chars in a composite

return a formatted text.

Code blocs will be right justified

return a formatted text, with lines wrapped or justified for the current terminal width.

Code blocs will be right justified

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

queue the rendered markdown in the specified area, without flush

do a print! of the given src interpreted as a markdown span

do a print! of the given src interpreted as a markdown text

do a print! of the given expander

do a print! of the given owning expander

do a print! of the given owning expander

write a composite filling the given width

Ellision or truncation may occur, but no wrap. Use Alignement::Unspecified for a smart internal ellision

parse the given src as a markdown snippet and write it on the given Write

parse the given src as a markdown text and write it on the given Write

parse the given src as a markdown snippet and write it on stdout

parse the given src as a markdown text and write it on stdout

Write a composite.

This function is internally used and normally not needed outside of Termimad’s implementation.

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.