bottom/src/app.rs

93 lines
2.5 KiB
Rust
Raw Normal View History

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};
pub struct App {
pub should_quit : bool,
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,
pub update_rate_in_milliseconds : u64,
2019-09-14 21:07:18 +00:00
pub show_average_cpu : bool,
}
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,
process_sorting_reverse : true,
to_be_resorted : false,
2019-09-12 02:10:49 +00:00
current_selected_process_position : 0,
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
}
}
pub fn on_key(&mut self, c : char) {
match c {
'q' => self.should_quit = true,
'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' => {
// TODO: This should depend on what tile you're on!
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;
}
}
self.to_be_resorted = true;
2019-09-09 04:09:58 +00:00
}
'm' => {
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;
}
}
self.to_be_resorted = true;
2019-09-09 04:09:58 +00:00
}
'p' => {
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;
}
}
self.to_be_resorted = true;
2019-09-09 04:09:58 +00:00
}
'n' => {
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;
}
}
self.to_be_resorted = true;
2019-09-09 04:09:58 +00:00
}
_ => {}
}
}
pub fn on_left(&mut self) {
}
pub fn on_right(&mut self) {
}
pub fn on_up(&mut self) {
}
pub fn on_down(&mut self) {
}
}