extra statuses (percent/partial action)

This commit is contained in:
alice pellerin
2026-03-17 04:27:20 -05:00
parent 86f6c43651
commit 9eeeca9034
2 changed files with 46 additions and 15 deletions
+22
View File
@@ -26,6 +26,10 @@ impl Widget for &App {
let status_line_area = Rect::new(area.x, area.bottom() - 1, area.width, 1);
self.render_status_line().render(status_line_area, buf);
self.render_extra_statuses()
.right_aligned()
.render(status_line_area, buf);
}
}
@@ -283,3 +287,21 @@ mod status_line {
}
}
}
mod extra_statuses {
use crate::app::{App, PartialAction};
use ratatui::text::Line;
impl App {
pub fn render_extra_statuses(&self) -> Line<'_> {
#[allow(clippy::cast_precision_loss)]
let percentage = self.cursor.head as f64 / (self.contents.len() - 1) as f64 * 100.0;
let partial_action = self.partial_action
.as_ref()
.map_or("", PartialAction::label);
format!("{partial_action} {percentage:.0}% ").into()
}
}
}