summaryrefslogtreecommitdiffstats
path: root/src/interactive/widgets/header.rs
blob: 7026b4b21c3ca7e4e6b5ed2470b7499851e34475 (plain)
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
use tui::buffer::Buffer;
use tui::layout::Rect;
use tui::style::{Color, Modifier, Style};
use tui::widgets::{Paragraph, Text, Widget};

pub struct Header;

impl Header {
    pub fn render(&self, area: Rect, buf: &mut Buffer) {
        let bg_color = Color::LightYellow;
        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("alyzer 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);
    }
}