summaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/tui_tab.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widgets/tui_tab.rs')
-rw-r--r--src/ui/widgets/tui_tab.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ui/widgets/tui_tab.rs b/src/ui/widgets/tui_tab.rs
new file mode 100644
index 0000000..55ca497
--- /dev/null
+++ b/src/ui/widgets/tui_tab.rs
@@ -0,0 +1,29 @@
+use tui::buffer::Buffer;
+use tui::layout::Rect;
+use tui::style::{Modifier, Style};
+use tui::widgets::{Paragraph, Text, Widget};
+
+pub struct TuiTabBar<'a> {
+ name: &'a str,
+ curr: usize,
+ len: usize,
+}
+
+impl<'a> TuiTabBar<'a> {
+ pub fn new(name: &'a str, curr: usize, len: usize) -> Self {
+ Self { name, curr, len }
+ }
+}
+
+impl<'a> Widget for TuiTabBar<'a> {
+ fn draw(&mut self, area: Rect, buf: &mut Buffer) {
+ let selected = Style::default().modifier(Modifier::REVERSED);
+
+ let text = [
+ Text::styled(format!("{}: {}", self.curr + 1, self.name), selected),
+ Text::raw(format!("/{}", self.len)),
+ ];
+
+ Paragraph::new(text.iter()).wrap(true).draw(area, buf);
+ }
+}