2019-09-12 00:41:11 +00:00
|
|
|
pub mod data_collection;
|
2019-09-14 21:07:18 +00:00
|
|
|
use data_collection::{processes, temperature};
|
2019-09-08 23:56:23 +00:00
|
|
|
|
2019-09-14 20:46:14 +00:00
|
|
|
pub struct App {
|
2019-09-08 23:56:23 +00:00
|
|
|
pub should_quit : bool,
|
2019-09-09 22:34:13 +00:00
|
|
|
pub process_sorting_type : processes::ProcessSorting,
|
|
|
|
pub process_sorting_reverse : bool,
|
|
|
|
pub to_be_resorted : bool,
|
2019-09-12 02:10:49 +00:00
|
|
|
pub current_selected_process_position : u64,
|
2019-09-14 21:07:18 +00:00
|
|
|
pub temperature_type : temperature::TemperatureType,
|
2019-09-14 20:46:14 +00:00
|
|
|
pub update_rate_in_milliseconds : u64,
|
2019-09-14 21:07:18 +00:00
|
|
|
pub show_average_cpu : bool,
|
2019-09-08 23:56:23 +00:00
|
|
|
}
|
|
|
|
|
2019-09-14 20:46:14 +00:00
|
|
|
impl App {
|
2019-09-14 21:07:18 +00:00
|
|
|
pub fn new(show_average_cpu : bool, temperature_type : temperature::TemperatureType, update_rate_in_milliseconds : u64) -> App {
|
2019-09-09 04:09:58 +00:00
|
|
|
App {
|
2019-09-14 21:07:18 +00:00
|
|
|
process_sorting_type : processes::ProcessSorting::CPU,
|
2019-09-09 04:09:58 +00:00
|
|
|
should_quit : false,
|
2019-09-10 22:22:34 +00:00
|
|
|
process_sorting_reverse : true,
|
2019-09-09 22:34:13 +00:00
|
|
|
to_be_resorted : false,
|
2019-09-12 02:10:49 +00:00
|
|
|
current_selected_process_position : 0,
|
2019-09-14 20:46:14 +00:00
|
|
|
temperature_type,
|
|
|
|
update_rate_in_milliseconds,
|
2019-09-14 21:07:18 +00:00
|
|
|
show_average_cpu,
|
2019-09-09 04:09:58 +00:00
|
|
|
}
|
2019-09-08 23:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn on_key(&mut self, c : char) {
|
|
|
|
match c {
|
|
|
|
'q' => self.should_quit = true,
|
2019-09-10 22:22:34 +00:00
|
|
|
'h' => self.on_right(),
|
|
|
|
'j' => self.on_down(),
|
|
|
|
'k' => self.on_up(),
|
|
|
|
'l' => self.on_left(),
|
2019-09-09 04:09:58 +00:00
|
|
|
'c' => {
|
2019-09-15 01:48:29 +00:00
|
|
|
// TODO: This should depend on what tile you're on!
|
2019-09-10 22:22:34 +00:00
|
|
|
match self.process_sorting_type {
|
|
|
|
processes::ProcessSorting::CPU => self.process_sorting_reverse = !self.process_sorting_reverse,
|
|
|
|
_ => {
|
|
|
|
self.process_sorting_type = processes::ProcessSorting::CPU;
|
|
|
|
self.process_sorting_reverse = true;
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 22:34:13 +00:00
|
|
|
self.to_be_resorted = true;
|
2019-09-09 04:09:58 +00:00
|
|
|
}
|
|
|
|
'm' => {
|
2019-09-10 22:22:34 +00:00
|
|
|
match self.process_sorting_type {
|
|
|
|
processes::ProcessSorting::MEM => self.process_sorting_reverse = !self.process_sorting_reverse,
|
|
|
|
_ => {
|
|
|
|
self.process_sorting_type = processes::ProcessSorting::MEM;
|
|
|
|
self.process_sorting_reverse = true;
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 22:34:13 +00:00
|
|
|
self.to_be_resorted = true;
|
2019-09-09 04:09:58 +00:00
|
|
|
}
|
|
|
|
'p' => {
|
2019-09-10 22:22:34 +00:00
|
|
|
match self.process_sorting_type {
|
|
|
|
processes::ProcessSorting::PID => self.process_sorting_reverse = !self.process_sorting_reverse,
|
|
|
|
_ => {
|
|
|
|
self.process_sorting_type = processes::ProcessSorting::PID;
|
|
|
|
self.process_sorting_reverse = false;
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 22:34:13 +00:00
|
|
|
self.to_be_resorted = true;
|
2019-09-09 04:09:58 +00:00
|
|
|
}
|
|
|
|
'n' => {
|
2019-09-10 22:22:34 +00:00
|
|
|
match self.process_sorting_type {
|
|
|
|
processes::ProcessSorting::NAME => self.process_sorting_reverse = !self.process_sorting_reverse,
|
|
|
|
_ => {
|
|
|
|
self.process_sorting_type = processes::ProcessSorting::NAME;
|
|
|
|
self.process_sorting_reverse = false;
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 22:34:13 +00:00
|
|
|
self.to_be_resorted = true;
|
2019-09-09 04:09:58 +00:00
|
|
|
}
|
2019-09-08 23:56:23 +00:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 22:34:13 +00:00
|
|
|
pub fn on_left(&mut self) {
|
|
|
|
}
|
2019-09-08 23:56:23 +00:00
|
|
|
|
2019-09-09 22:34:13 +00:00
|
|
|
pub fn on_right(&mut self) {
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn on_up(&mut self) {
|
|
|
|
}
|
2019-09-08 23:56:23 +00:00
|
|
|
|
2019-09-09 22:34:13 +00:00
|
|
|
pub fn on_down(&mut self) {
|
2019-09-08 23:56:23 +00:00
|
|
|
}
|
|
|
|
}
|