Crate yew_ansi

Crate yew_ansi 

Source
Expand description

ANSI escape code rendering for the web

§Yew

html! {
    <AnsiStatic text="Hello \u{001b}[32mWorld\u{001b}[39;1m!" />
}

This will generate the following output (whitespace added for clarity):

<pre style="font-family: monospace">
    <span>Hello </span>
    <span style="color:#00ff00;">World</span>
    <span style="font-weight:bold;">!</span>
</pre>

Refer to AnsiRenderer and AnsiProps for more details.

§Parsing

If you want to parse text containing ANSI escape codes you can use get_sgr_segments to iterate over text segments along with their SgrEffect.

If you need more control, use get_markers to iterate over the raw Escape codes in the text.

Structs§

AnsiProps
Props that can be passed to the AnsiRenderer component.
AnsiRenderer
Component for rendering text containing ANSI escape codes.
CharCursor
Cursor for characters in a string slice.
ClassStyle
Combination of classes and inline styles.
InlineStyle
Style builder using only inline style attributes.
MarkerIter
Iterator yielding markers in a string.
SgrEffect
Describes the effect that multiple SGR parameters have on text.
SgrSegmentIter
Iterator over the SGR segments in a string slice.

Enums§

ColorEffect
Describes the color effect of multiple SGR parameters.
ColorName
The 8 colors defined by the original specification.
Csi
Control sequence.
Escape
ANSI Escape Sequence.
Marker
Parts of a string containing ANSI escape sequences.
Sgr
Select Graphic Rendition parameter.

Traits§

StyleBuilder
Builder for ClassStyle.

Functions§

get_markers
Iterate over all Markers in given string.
get_sgr_segments
Create an iterator which iterates over SGR segments in a string slice. Each item consists of a SgrEffect and the corresponding text slice it applies to.
read_next_sequence
Read the next sequence in the given slice. Returns the content before the escape sequence, the escape sequence itself, and everything following it. The escape sequence can be None if it’s invalid. If the slice doesn’t contain an escape sequence the entire string slice will be returned as the first item.

Type Aliases§

Ansi
ANSI component which takes a String.
AnsiRc
ANSI component which takes a Rc<String>.
AnsiStatic
ANSI component which takes a &'static str.