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
|
use tui::{
buffer::Buffer,
layout::Rect,
style::{Color, Modifier, Style},
widgets::{Paragraph, Text, Widget},
};
pub struct Header;
impl Header {
pub fn render(&self, bg_color: Color, area: Rect, buf: &mut Buffer) {
let text_color = Color::Black;
let standard = Style {
fg: text_color,
bg: bg_color,
..Default::default()
};
let modified = |text: &'static str, modifier| {
Text::Styled(
text.into(),
Style {
modifier,
..standard
},
)
};
let bold = |text: &'static str| modified(text, Modifier::BOLD);
let italic = |text: &'static str| modified(text, Modifier::UNDERLINED);
let text = |text: &'static str| Text::Styled(text.into(), standard);
let lines = [
bold(" D"),
text("isk "),
bold("U"),
text("sage "),
bold("A"),
text("nalyzer v"),
text(env!("CARGO_PKG_VERSION")),
text(" "),
italic("(press "),
modified("?", Modifier::BOLD | Modifier::UNDERLINED),
italic(" for help)"),
];
Paragraph::new(lines.iter())
.style(Style {
fg: text_color,
bg: bg_color,
..Default::default()
})
.draw(area, buf);
}
}
|