use gilt::console::Console;
use gilt::panel::Panel;
use gilt::rule::Rule;
use gilt::style::Style;
use gilt::text::{JustifyMethod, OverflowMethod, Text};
fn main() {
let mut console = Console::builder()
.width(40)
.force_terminal(true)
.no_color(false)
.build();
let sample = "The quick brown fox jumps over the lazy dog near the riverbank.";
console.print(&Rule::with_title("Text Justification (width 40)"));
let modes: &[(&str, JustifyMethod)] = &[
("Left", JustifyMethod::Left),
("Center", JustifyMethod::Center),
("Right", JustifyMethod::Right),
("Full", JustifyMethod::Full),
];
for (label, justify) in modes {
let rule = Rule::with_title(label).characters("-");
console.print(&rule);
let mut text = Text::new(sample, Style::null());
text.justify = Some(*justify);
let panel = Panel::new(text);
console.print(&panel);
}
console.print(&Rule::with_title("Overflow Modes"));
let long_word = "Supercalifragilisticexpialidocious";
let overflow_modes: &[(&str, OverflowMethod)] = &[
("Fold", OverflowMethod::Fold),
("Crop", OverflowMethod::Crop),
("Ellipsis", OverflowMethod::Ellipsis),
];
for (label, overflow) in overflow_modes {
let rule = Rule::with_title(label).characters("-");
console.print(&rule);
let mut text = Text::new(long_word, Style::null());
text.overflow = Some(*overflow);
let panel = Panel::new(text).width(25);
console.print(&panel);
}
console.print(&Rule::with_title("Centered Styled Text"));
let mut styled = Text::new("", Style::null());
styled.append_str("gilt", Some(Style::parse("bold magenta").unwrap()));
styled.append_str(" makes terminal output ", None);
styled.append_str("beautiful", Some(Style::parse("italic green").unwrap()));
styled.append_str(" and ", None);
styled.append_str("easy", Some(Style::parse("bold cyan").unwrap()));
styled.append_str(".", None);
styled.justify = Some(JustifyMethod::Center);
let panel = Panel::new(styled).title(Text::new("Styled & Centered", Style::null()));
console.print(&panel);
}