1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Port of rich's justify2.py — panel justification demo.
//!
//! Creates a small non-expanding panel and prints it four times with
//! different justify settings: default, left, center, right.
use gilt::console::Console;
use gilt::panel::Panel;
use gilt::style::Style;
use gilt::text::{JustifyMethod, Text};
fn main() {
let mut console = Console::builder()
.width(20)
.force_terminal(true)
.no_color(false)
.build();
let style = "bold white on blue";
// Create a small non-expanding panel with styled content
let content = Text::new("Gilt", Style::null());
let panel = Panel::fit(content).style(Style::parse("on red").unwrap_or_else(|_| Style::null()));
// Default justify (no explicit justify)
console.print_styled(&panel, Some(style), None, None, false, true, false);
// Left justify
console.print_styled(
&panel,
Some(style),
Some(JustifyMethod::Left),
None,
false,
true,
false,
);
// Center justify
console.print_styled(
&panel,
Some(style),
Some(JustifyMethod::Center),
None,
false,
true,
false,
);
// Right justify
console.print_styled(
&panel,
Some(style),
Some(JustifyMethod::Right),
None,
false,
true,
false,
);
}