add progress bar to help_popup
@@ -48,7 +48,7 @@ use tui::{
style::{Color, Modifier, Style},
terminal::Frame,
text::{Span, Spans, Text},
- widgets::{Block, BorderType, Borders, Clear, List, ListItem, Paragraph, Wrap},
+ widgets::{LineGauge, Block, BorderType, Borders, Clear, List, ListItem, Paragraph, Wrap, Gauge},
};
use rustyline::history::SearchDirection as HistoryDirection;
@@ -918,11 +918,36 @@ impl TaskwarriorTui {
fn draw_help_popup(&mut self, f: &mut Frame<impl Backend>, percent_x: u16, percent_y: u16) {
let area = centered_rect(percent_x, percent_y, f.size());
f.render_widget(Clear, area);
+
+ let chunks = Layout::default()
+ .constraints(
+ [
+ Constraint::Max(area.height-1),
+ Constraint::Max(1),
+ ]
+ .as_ref()
+ )
+ .margin(0)
+ .split(area);
+
self.help_popup.scroll = std::cmp::min(
self.help_popup.scroll,
- (self.help_popup.text_height as u16).saturating_sub(area.height),
+ (self.help_popup.text_height as u16).saturating_sub(chunks[0].height-3),
);
- f.render_widget(&self.help_popup, area);
+
+ let mut ratio = (self.help_popup.scroll + chunks[0].height) as f64 / self.help_popup.text_height as f64;
+
+ if ratio > 1.0 {
+ ratio = 1.0;
+ }
+
+ let gauge = LineGauge::default()
+ .block(Block::default())
+ .gauge_style(Style::default().fg(Color::Gray))
+ .ratio(ratio);
+
+ f.render_widget(gauge, chunks[1]);
+ f.render_widget(&self.help_popup, chunks[0]);
}
fn draw_context_menu(&mut self, f: &mut Frame<impl Backend>, percent_x: u16, percent_y: u16) {
