redbear-power: show process count in tab bar
Tab bar now displays 'Process (42)' with live process count, giving at-a-glance visibility into how many processes are tracked.
This commit is contained in:
@@ -354,6 +354,7 @@ fn mem_bar_line<'a>(
|
||||
/// with the active tab highlighted. Hotkeys `1`/`2`/`3`/`4` switch
|
||||
/// directly; `T` cycles through them in order.
|
||||
pub fn render_tab_bar<'a>(app: &'a App) -> Tabs<'a> {
|
||||
let proc_count = app.processes.processes.len();
|
||||
let titles: Vec<Line<'a>> = [
|
||||
TabId::PerCpu,
|
||||
TabId::System,
|
||||
@@ -366,7 +367,14 @@ pub fn render_tab_bar<'a>(app: &'a App) -> Tabs<'a> {
|
||||
TabId::Process,
|
||||
]
|
||||
.iter()
|
||||
.map(|t| Line::from(t.name()))
|
||||
.map(|t| {
|
||||
let name = t.name();
|
||||
if matches!(t, TabId::Process) && proc_count > 0 {
|
||||
Line::from(format!("{} ({})", name, proc_count))
|
||||
} else {
|
||||
Line::from(name)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let selected = match app.current_tab {
|
||||
TabId::PerCpu => 0,
|
||||
|
||||
Reference in New Issue
Block a user