2021-09-08 18:58:21 +02:00
|
|
|
use tui::style::{Color, Style};
|
|
|
|
use tui::widgets::{Block, List, ListItem};
|
|
|
|
|
|
|
|
pub struct Info {
|
|
|
|
info: String,
|
|
|
|
keys: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Info {
|
|
|
|
pub fn new(info: &str) -> Self {
|
|
|
|
Self {
|
|
|
|
info: String::from(info),
|
|
|
|
keys: String::from(
|
2023-02-17 16:23:21 +01:00
|
|
|
"Tab Cycle widgets C-s Save C-r Reload C-q Quit ↑ ↓ Select tags or image line Return Select",
|
2021-09-08 18:58:21 +02:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn render(&self) -> List {
|
|
|
|
let items = vec![
|
|
|
|
ListItem::new(self.info.clone()),
|
|
|
|
ListItem::new(self.keys.clone()),
|
|
|
|
];
|
|
|
|
List::new(items)
|
|
|
|
.block(Block::default())
|
|
|
|
.style(Style::default().fg(Color::White).bg(Color::Black))
|
|
|
|
.highlight_style(Style::default().bg(Color::Black))
|
|
|
|
}
|
|
|
|
|
2021-11-03 15:39:32 +01:00
|
|
|
/// set a text to display
|
2021-11-03 15:06:54 +01:00
|
|
|
pub fn set_text(&mut self, info: &str) {
|
2021-09-08 18:58:21 +02:00
|
|
|
self.info = String::from(info);
|
|
|
|
}
|
2021-11-03 15:06:54 +01:00
|
|
|
|
2021-11-03 15:39:32 +01:00
|
|
|
/// print a text to display
|
2021-11-03 15:06:54 +01:00
|
|
|
pub fn set_info(&mut self, text: &dyn std::fmt::Display) {
|
|
|
|
self.info = format!("{}", text);
|
|
|
|
}
|
2021-09-08 18:58:21 +02:00
|
|
|
}
|