redbear-power: nice value coloring + filter match highlighting

- NI column: green for negative (high priority), yellow for positive (low priority)
- Process filter: matching characters in COMM highlighted BOLD|REVERSED
  when filter is active (bottom/htop-style incremental search visual)
This commit is contained in:
2026-07-07 01:36:00 +03:00
parent ef3dd8b1fd
commit e729e4daec
@@ -1291,12 +1291,21 @@ pub fn render_process_panel<'a>(app: &'a App, focused: bool) -> Paragraph<'a> {
} else {
theme::VALUE
};
let pre = format!(
" {}{:<7} {} {:<5} {:<4} {:<3} {:<3} ",
prefix, p.pid, p.state, p.sched_policy, p.priority, p.nice, p.num_threads,
let pre1 = format!(
" {}{:<7} {} {:<5} {:<4} ",
prefix, p.pid, p.state, p.sched_policy, p.priority,
);
let nice_str = format!("{:<3}", p.nice);
let nice_style = if p.nice < 0 {
theme::VALUE_OK
} else if p.nice > 0 {
theme::VALUE_WARM
} else {
theme::VALUE
};
let pre2 = format!(" {:<3} ", p.num_threads);
let post = format!(
" {:<11} {:<11} {:<11} {:<11} {:<11} {:<12} {:<6} {:<5} {:<3} {}",
" {:<11} {:<11} {:<11} {:<11} {:<11} {:<12} {:<6} {:<5} {:<3} ",
io_str,
rate_str,
thread_io_total_str,
@@ -1306,15 +1315,50 @@ pub fn render_process_panel<'a>(app: &'a App, focused: bool) -> Paragraph<'a> {
cpu_spark,
rss_spark,
affinity_indicator,
comm_truncated,
);
let mut spans = vec![Span::styled(pre, row_style)];
let mut spans = vec![
Span::styled(pre1, row_style),
Span::styled(
nice_str,
if is_cursor {
app.theme.cursor_highlight
} else {
nice_style
},
),
Span::styled(pre2, row_style),
];
if is_cursor {
spans.push(Span::styled(cpu_str, app.theme.cursor_highlight));
} else {
spans.push(Span::styled(cpu_str, cpu_style));
}
spans.push(Span::styled(post, row_style));
if !filter_lower.is_empty() && comm_truncated.to_lowercase().contains(&filter_lower) {
let lower = comm_truncated.to_lowercase();
let mut last = 0;
while let Some(pos) = lower[last..].find(&filter_lower) {
let abs = last + pos;
if abs > last {
spans.push(Span::styled(
comm_truncated[last..abs].to_string(),
row_style,
));
}
spans.push(Span::styled(
comm_truncated[abs..abs + filter_lower.len()].to_string(),
row_style.add_modifier(
ratatui::style::Modifier::BOLD | ratatui::style::Modifier::REVERSED,
),
));
last = abs + filter_lower.len();
}
if last < comm_truncated.len() {
spans.push(Span::styled(comm_truncated[last..].to_string(), row_style));
}
} else {
spans.push(Span::styled(comm_truncated, row_style));
}
lines.push(Line::from(spans));
}
Paragraph::new(lines)