blob: 49de3b845c54fe1b1952b68491fda95fcc231715 (
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
|
use ::tui::backend::Backend;
use ::tui::layout::{Alignment, Rect};
use ::tui::style::{Modifier, Style};
use ::tui::terminal::Frame;
use ::tui::widgets::{Paragraph, Text, Widget};
pub struct HelpText {
pub paused: bool,
}
const TEXT_WHEN_PAUSED: &str = " Press <SPACE> to resume.";
const TEXT_WHEN_NOT_PAUSED: &str = " Press <SPACE> to pause.";
impl HelpText {
pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
let text = {
let content = if self.paused {
TEXT_WHEN_PAUSED
} else {
TEXT_WHEN_NOT_PAUSED
};
[Text::styled(
content,
Style::default().modifier(Modifier::BOLD),
)]
};
Paragraph::new(text.iter())
.alignment(Alignment::Left)
.render(frame, rect);
}
}
|