Trait tui_markup::generator::Generator
source · [−]pub trait Generator<'a> where
Self::Err: LocatedError + Display,
Self::Convertor: TagConvertor<'a>, {
type Convertor;
type Output;
type Err;
fn convertor(&mut self) -> &mut Self::Convertor;
fn generate(
&mut self,
markup: Vec<Vec<ItemG<'a, Self>>>
) -> Result<Self::Output, Self::Err>;
}Expand description
Generator generates final output to show tui markup in some backend.
How to add support for new backend
Some concepts:
- Markup text/Source: the text you write in tui markup language.
- Parser: parse markup text into a series of Item, which usually be called as AST.
- Tag Convertor: Convert raw tag string like
green,bg:66ccff,mod:binto Tag. - Generator: generator final output from
Item<Tag>.
So the whole pipeline is:
Source --- Parser --> Item --- Tag Convertor --> Item<Tag> --- Generator --> Output --> Show it in some backendThe source, parser, Item, Tag, is already defined, so just write a Tag Convertor and a Generator, a new backend will be supported.
Required Associated Types
Error type.
If the generator can’t fall, please use GeneratorInfallible.