feat: add __term/tui-markup-demo/
This commit is contained in:
20
__term/tui-markup-demo/src/main.rs
Normal file
20
__term/tui-markup-demo/src/main.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use ansi_term::{ANSIStrings, Color, Style};
|
||||
use tui_markup::generator::ANSIStringsGenerator;
|
||||
use tui_markup::{compile, compile_with};
|
||||
|
||||
fn main() {
|
||||
// Parse markup into some final result for showing
|
||||
let result = compile::<ANSIStringsGenerator>("You got a <yellow Coin>").unwrap();
|
||||
// Show it
|
||||
println!("{}", ANSIStrings(&result));
|
||||
|
||||
// With custom tag
|
||||
let generator = ANSIStringsGenerator::new(|tag: &str| match tag {
|
||||
"keyboard" => Some(Style::default().fg(Color::Blue).on(Color::Black).bold()),
|
||||
"bold" => Some(Style::default().bold()),
|
||||
"under" => Some(Style::default().underline()),
|
||||
_ => None,
|
||||
});
|
||||
let result = compile_with("Press <keyboard Space> to <bold <under jump>>", generator).unwrap();
|
||||
println!("{}", ANSIStrings(&result));
|
||||
}
|
||||
Reference in New Issue
Block a user