2
0
Fork 0
mirror of https://github.com/ClementTsang/bottom synced 2025-02-15 12:48:28 +00:00

Some basic cleaning

This commit is contained in:
ClementTsang 2020-01-06 23:07:58 -05:00
parent e71e22f726
commit ad190a144d
4 changed files with 19 additions and 7 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "bottom"
version = "0.1.1"
version = "0.2.0"
authors = ["Clement Tsang <clementjhtsang@gmail.com>"]
edition = "2018"
repository = "https://github.com/ClementTsang/bottom"

View file

@ -34,10 +34,20 @@ fn cpu_usage_calculation(prev_idle: &mut f64, prev_non_idle: &mut f64) -> error:
path.push("stat");
let stat_results = std::fs::read_to_string(path)?;
let first_line = stat_results.split('\n').collect::<Vec<&str>>()[0];
let first_line: &str;
let split_results = stat_results.split('\n').collect::<Vec<&str>>();
if split_results.is_empty() {
return Err(error::BottomError::InvalidIO {
message: format!(
"Unable to properly split the stat results; saw {} values, expected at least 1 value.",
split_results.len()
),
});
} else {
first_line = split_results[0];
}
// TODO: Consider grabbing by number of threads instead, and summing the total?
// ie: 4 threads, so: (prev - cur) / cpu_0 + ... + (prev - cur) / cpu_n instead? This might be how top does it?
let val = first_line.split_whitespace().collect::<Vec<&str>>();
// SC in case that the parsing will fail due to length:

View file

@ -47,9 +47,8 @@ pub fn kill_process_given_pid(pid: u32) -> crate::utils::error::Result<()> {
message: "Sorry, macOS support is not implemented yet!".to_string(),
});
} else {
// TODO: Others?
return Err(BottomError::GenericError {
message: "Sorry, support operating systems outside the main three is not implemented yet!".to_string(),
message: "Sorry, support operating systems outside the main three are not implemented yet!".to_string(),
});
}

View file

@ -373,6 +373,10 @@ fn draw_cpu_legend<B: backend::Backend>(f: &mut Frame<B>, app_state: &mut app::A
.render(f, draw_loc);
}
fn _draw_memory_table<B: backend::Backend>(_f: &mut Frame<B>, _app_state: &app::App, _draw_loc: Rect) {
todo!("Not implemented yet..."); // TODO: For basic mode
}
fn draw_memory_graph<B: backend::Backend>(f: &mut Frame<B>, app_state: &app::App, draw_loc: Rect) {
let mem_data: &[(f64, f64)] = &(app_state.canvas_data.mem_data);
let swap_data: &[(f64, f64)] = &(app_state.canvas_data.swap_data);
@ -598,7 +602,6 @@ fn draw_disk_table<B: backend::Backend>(f: &mut Frame<B>, app_state: &mut app::A
)
});
// TODO: We may have to dynamically remove some of these table elements based on size...
Table::new(["Disk", "Mount", "Used", "Total", "Free", "R/s", "W/s"].iter(), disk_rows)
.block(
Block::default()