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

Enums

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

Traits

Functions

  • Iterate over all Markers in given string.
  • 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 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