diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-09 13:16:59 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-09 13:16:59 +0300 |
commit | 73a34a5306f56c1ebe15a71f956480211fdf180c (patch) | |
tree | bbc2717df78dacea7c4e0620772a4a2c3af83237 | |
parent | 651501ea8fa1e1f0fb828efc4878c25e0befb908 (diff) |
Fix warnings
-rw-r--r-- | src/ui.rs | 4 | ||||
-rw-r--r-- | src/ui/components.rs | 11 | ||||
-rw-r--r-- | src/ui/components/processes.rs | 8 | ||||
-rw-r--r-- | src/ui/components/utilities.rs | 6 | ||||
-rw-r--r-- | src/ui/state.rs | 6 |
5 files changed, 21 insertions, 14 deletions
@@ -23,19 +23,23 @@ * This library exports the public types and methods of its modules */ +#[allow(dead_code)] mod text_processing; pub use crate::ui::text_processing::*; #[macro_use] +#[allow(dead_code)] mod types; pub use crate::ui::types::*; #[macro_use] +#[allow(dead_code)] mod terminal; pub use crate::ui::terminal::*; pub mod state; pub use crate::ui::state::*; +#[allow(dead_code)] pub mod components; pub use crate::ui::components::*; pub use crate::ui::username::*; diff --git a/src/ui/components.rs b/src/ui/components.rs index 9571c9b..a413afe 100644 --- a/src/ui/components.rs +++ b/src/ui/components.rs @@ -336,12 +336,13 @@ pub fn create_box(grid: &mut CellBuffer, area: Area) { let upper_left = upper_left!(area); let bottom_right = bottom_right!(area); - for x in get_x(upper_left)..=get_x(bottom_right) { - //grid[(x, get_y(upper_left))].set_ch(HORZ_BOUNDARY); - //grid[(x, get_y(bottom_right))].set_ch(HORZ_BOUNDARY); - //grid[(x, get_y(bottom_right))].set_ch('▒'); - //grid[(x, get_y(bottom_right))].set_fg(Color::Byte(240)); + /*for x in get_x(upper_left)..=get_x(bottom_right) { + grid[(x, get_y(upper_left))].set_ch(HORZ_BOUNDARY); + grid[(x, get_y(bottom_right))].set_ch(HORZ_BOUNDARY); + grid[(x, get_y(bottom_right))].set_ch('▒'); + grid[(x, get_y(bottom_right))].set_fg(Color::Byte(240)); } + */ for y in get_y(upper_left)..=get_y(bottom_right) { //grid[(get_x(upper_left), y)].set_ch(VERT_BOUNDARY); diff --git a/src/ui/components/processes.rs b/src/ui/components/processes.rs index 6d6ae5c..e563e3c 100644 --- a/src/ui/components/processes.rs +++ b/src/ui/components/processes.rs @@ -465,7 +465,7 @@ impl Component for ProcessList { ); } Err((bin, rest)) => { - let (x, y) = write_string_to_grid( + let (x, _) = write_string_to_grid( &format!( "{pid:>max_pid$} {ppid:>max_ppid$} {username:>max_username$} {vm_rss:>max_vm_rss$} {cpu_percent:>max_cpu_percent$}% {state:>max_state$} ", pid = p.pid, @@ -572,7 +572,7 @@ impl Component for ProcessList { clear_area(grid, box_area); create_box(grid, box_area); let mut x = 1; - for (i, s) in SIGNAL_LIST.chunks(11).enumerate() { + for s in SIGNAL_LIST.chunks(11) { let mut y = 0; for sig in s { write_string_to_grid( @@ -753,7 +753,9 @@ impl Component for ProcessList { kill( nix::unistd::Pid::from_raw(processes[self.cursor].i), nix::sys::signal::Signal::from_c_int(*n as i32).unwrap(), - ); + ) + .ok() + .take(); } self.mode = Normal; self.dirty = true; diff --git a/src/ui/components/utilities.rs b/src/ui/components/utilities.rs index f74d8bc..2828bc1 100644 --- a/src/ui/components/utilities.rs +++ b/src/ui/components/utilities.rs @@ -122,8 +122,8 @@ pub fn get_stat(boot_time: &mut usize) -> Vec<Stat> { /// A horizontally split in half container. #[derive(Debug)] pub struct Window { - top_bars: Box<Component>, - list: Box<Component>, + top_bars: Box<dyn Component>, + list: Box<dyn Component>, } impl fmt::Display for Window { @@ -133,7 +133,7 @@ impl fmt::Display for Window { } impl Window { - pub fn new(top_bars: Box<Component>, list: Box<Component>) -> Self { + pub fn new(top_bars: Box<dyn Component>, list: Box<dyn Component>) -> Self { Window { top_bars, list } } } diff --git a/src/ui/state.rs b/src/ui/state.rs index b9e5f04..ff2cb1c 100644 --- a/src/ui/state.rs +++ b/src/ui/state.rs @@ -21,7 +21,7 @@ /*! The application's state. -The UI crate has an Box<Component>-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct. +The UI crate has an Box<dyn Component>-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct. `State` owns all the Components of the UI. In the application's main event loop, input is handed to the state in the form of `UIEvent` objects which traverse the component graph. Components decide to handle each input or not. @@ -74,7 +74,7 @@ pub struct State { grid: CellBuffer, stdout: Option<StateStdout>, - components: Vec<Box<Component>>, + components: Vec<Box<dyn Component>>, pub dirty_areas: VecDeque<Area>, sender: Sender<ThreadEvent>, receiver: Receiver<ThreadEvent>, @@ -328,7 +328,7 @@ impl State { ); } } - pub fn register_component(&mut self, component: Box<Component>) { + pub fn register_component(&mut self, component: Box<dyn Component>) { self.components.push(component); } /// The application's main loop sends `UIEvents` to state via this method. |