Skip to content

Commit a9d2725

Browse files
committed
fix: align CPU and RAM progress bars with consistent formatting
1 parent 2925cd7 commit a9d2725

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -612,18 +612,18 @@ fn render_system_info(app: &App, frame: &mut Frame, area: Rect, is_selected: boo
612612
let uptime_hours = uptime / 3600;
613613
let uptime_mins = (uptime % 3600) / 60;
614614

615-
let cpu_bar = "█".repeat(((cpu_usage / 10.0) as usize).min(10).max(0));
616-
let mem_bar = "█".repeat(((memory_percent / 10) as usize).min(10).max(0));
615+
let cpu_blocks = ((cpu_usage / 10.0).round() as usize).min(10).max(0);
616+
let mem_blocks = ((memory_percent as f64 / 10.0).round() as usize).min(10).max(0);
617+
let cpu_bar = "█".repeat(cpu_blocks) + &" ".repeat(10 - cpu_blocks);
618+
let mem_bar = "█".repeat(mem_blocks) + &" ".repeat(10 - mem_blocks);
617619

618620
let content = vec![
619-
format!("▶ CPU: {:.1}% [{}{}]",
621+
format!("▶ CPU: {:5.1}% [{}]",
620622
cpu_usage,
621-
cpu_bar,
622-
" ".repeat(10usize.saturating_sub(cpu_bar.len()))),
623-
format!("▶ RAM: {:.1}% [{}{}]",
623+
cpu_bar),
624+
format!("▶ RAM: {:5.1}% [{}]",
624625
memory_percent,
625-
mem_bar,
626-
" ".repeat(10usize.saturating_sub(mem_bar.len()))),
626+
mem_bar),
627627
format!("▶ Memory: {} / {}",
628628
App::format_memory_size(memory_usage),
629629
App::format_memory_size(total_memory)),

0 commit comments

Comments
 (0)