redbear-power: process state coloring + MEM% display
- STATE column color-coded: R=green, D=red, Z=dark gray, T=yellow (htop-style) - RSS column now shows memory percentage alongside absolute value: '1.2G (3.4%)' - Process row spans refactored for per-column styling
This commit is contained in:
@@ -1257,6 +1257,14 @@ pub fn render_process_panel<'a>(app: &'a App, focused: bool) -> Paragraph<'a> {
|
||||
}
|
||||
_ => crate::process::ProcessInfo::format_memory_kb(p.rss_kb),
|
||||
};
|
||||
let mem_pct = if app.meminfo.total_kib > 0 {
|
||||
format!(
|
||||
" ({:.1}%)",
|
||||
p.rss_kb as f64 * 100.0 / app.meminfo.total_kib as f64
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
// Three per-PID sparklines: IO-RATE (12 samples),
|
||||
// CPU% (6 samples), RSS (6 samples). The smaller
|
||||
// CPU/RSS sparklines are 6 chars wide to keep the
|
||||
@@ -1291,10 +1299,15 @@ pub fn render_process_panel<'a>(app: &'a App, focused: bool) -> Paragraph<'a> {
|
||||
} else {
|
||||
theme::VALUE
|
||||
};
|
||||
let pre1 = format!(
|
||||
" {}{:<7} {} {:<5} {:<4} ",
|
||||
prefix, p.pid, p.state, p.sched_policy, p.priority,
|
||||
);
|
||||
let pre1a = format!(" {}{:<7} ", prefix, p.pid);
|
||||
let state_style = match p.state {
|
||||
'R' => theme::VALUE_OK,
|
||||
'D' => theme::VALUE_HOT,
|
||||
'Z' => theme::VALUE_OFF,
|
||||
'T' => theme::VALUE_WARM,
|
||||
_ => theme::VALUE,
|
||||
};
|
||||
let pre1b = format!(" {:<5} {:<4} ", p.sched_policy, p.priority);
|
||||
let nice_str = format!("{:<3}", p.nice);
|
||||
let nice_style = if p.nice < 0 {
|
||||
theme::VALUE_OK
|
||||
@@ -1305,19 +1318,29 @@ pub fn render_process_panel<'a>(app: &'a App, focused: bool) -> Paragraph<'a> {
|
||||
};
|
||||
let pre2 = format!(" {:<3} ", p.num_threads);
|
||||
let post = format!(
|
||||
" {:<11} {:<11} {:<11} {:<11} {:<11} {:<12} {:<6} {:<5} {:<3} ",
|
||||
" {:<11} {:<11} {:<11} {:<11} {:<11}{:<7} {:<12} {:<6} {:<5} {:<3} ",
|
||||
io_str,
|
||||
rate_str,
|
||||
thread_io_total_str,
|
||||
per_thread_str,
|
||||
mem_str,
|
||||
mem_pct,
|
||||
io_spark,
|
||||
cpu_spark,
|
||||
rss_spark,
|
||||
affinity_indicator,
|
||||
);
|
||||
let mut spans = vec![
|
||||
Span::styled(pre1, row_style),
|
||||
Span::styled(pre1a, row_style),
|
||||
Span::styled(
|
||||
p.state.to_string(),
|
||||
if is_cursor {
|
||||
app.theme.cursor_highlight
|
||||
} else {
|
||||
state_style
|
||||
},
|
||||
),
|
||||
Span::styled(pre1b, row_style),
|
||||
Span::styled(
|
||||
nice_str,
|
||||
if is_cursor {
|
||||
|
||||
Reference in New Issue
Block a user