mirror of
https://github.com/uutils/procps.git
synced 2026-05-06 06:06:43 -04:00
top: tui impl I (irix or solaris)
This commit is contained in:
@@ -223,13 +223,19 @@ fn todo(_pid: u32, _stat: Stat) -> Box<dyn Column> {
|
||||
Box::new("TODO".to_string())
|
||||
}
|
||||
|
||||
fn cpu(pid: u32, _stat: Stat) -> Box<dyn Column> {
|
||||
fn cpu(pid: u32, stat: Stat) -> Box<dyn Column> {
|
||||
let binding = sysinfo().read().unwrap();
|
||||
let Some(proc) = binding.process(Pid::from_u32(pid)) else {
|
||||
return PercentValue::new_boxed(0.0);
|
||||
};
|
||||
|
||||
PercentValue::new_boxed(proc.cpu_usage())
|
||||
let cpu_usage = if stat.1.irix_mode {
|
||||
proc.cpu_usage()
|
||||
} else {
|
||||
proc.cpu_usage() / binding.cpus().len() as f32
|
||||
};
|
||||
|
||||
PercentValue::new_boxed(cpu_usage)
|
||||
}
|
||||
|
||||
fn pid(pid: u32, _stat: Stat) -> Box<dyn Column> {
|
||||
|
||||
@@ -74,6 +74,15 @@ pub fn handle_input(
|
||||
data.write().unwrap().1 = ProcList::new(settings, &tui_stat.read().unwrap());
|
||||
should_update.store(true, Ordering::Relaxed);
|
||||
}
|
||||
char!('I') => {
|
||||
{
|
||||
let mut stat = tui_stat.write().unwrap();
|
||||
stat.irix_mode = !stat.irix_mode;
|
||||
}
|
||||
|
||||
data.write().unwrap().1 = ProcList::new(settings, &tui_stat.read().unwrap());
|
||||
should_update.store(true, Ordering::Relaxed);
|
||||
}
|
||||
char!('l') => {
|
||||
let mut stat = tui_stat.write().unwrap();
|
||||
stat.show_load_avg = !stat.show_load_avg;
|
||||
|
||||
@@ -30,6 +30,7 @@ pub(crate) struct TuiStat {
|
||||
pub highlight_bold: bool,
|
||||
pub show_coordinates: bool,
|
||||
pub show_zeros: bool,
|
||||
pub irix_mode: bool,
|
||||
|
||||
pub filter: Option<crate::Filter>,
|
||||
}
|
||||
@@ -66,6 +67,7 @@ impl TuiStat {
|
||||
highlight_bold: false,
|
||||
show_coordinates: false,
|
||||
show_zeros: true,
|
||||
irix_mode: true,
|
||||
|
||||
filter: None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user