pub struct Parser { /* fields omitted */ }
Represents a parser (A TextProcessor
), that is able to read given texts and use TextBuffer
accordingly, to write text and styles matching to the text.
Note: This struct requires parser feature to be enabled.
Example:
use glerminal::{TerminalBuilder, TextBuffer, Parser};
let terminal = TerminalBuilder::new()
.with_title("Parser example!")
.with_dimensions((1280, 720))
.build();
let mut text_buffer;
match TextBuffer::create(&terminal, (80, 24)) {
Ok(buffer) => text_buffer = buffer,
Err(error) => panic!(format!("Failed to initialize text buffer: {}", error)),
}
let mut parser = Parser::new();
parser.add_color("red", [1.0, 0.0, 0.0, 1.0]);
parser.write(&mut text_buffer, "Hello, [fg=red]this color is red![/fg], [bg=red]this text has a red background[/bg] and [shake=0.5]this text shakes[/shake]");
terminal.flush(&mut text_buffer);
See TextBuffer for examples and more detailed documentation.
Creates a new Parser to use.
Adds a color to the parser to use later.
Parses the given text and immediately writes it to the text buffer
Parse any text into a ProcessedChar
s, alias for parser.process
Process the given processables with the given style and produce a list of ProcessedChar
s Strings and &'static str have From and Into for Processable so the following is possible: processor.process(vec!("something".into()));
Read more
Returns the "default value" for a type. Read more
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static