diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-03-03 22:11:15 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:39 +0300 |
commit | 5e306130fb10e55a05985475b6e4f3a83903cf6f (patch) | |
tree | 4285bd720b7d690e88b6078c59da20b41b7f2039 /ui | |
parent | d4c64916f0efdad4774503e5bae4e86ba40770fa (diff) |
Fix clippy warnings
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/contacts.rs | 16 | ||||
-rw-r--r-- | ui/src/components/mail/accounts.rs | 4 | ||||
-rw-r--r-- | ui/src/components/mail/accounts/contacts.rs | 105 | ||||
-rw-r--r-- | ui/src/components/mail/compose.rs | 73 | ||||
-rw-r--r-- | ui/src/components/mail/listing/compact.rs | 2 | ||||
-rw-r--r-- | ui/src/components/utilities.rs | 4 | ||||
-rw-r--r-- | ui/src/components/utilities/widgets.rs | 21 | ||||
-rw-r--r-- | ui/src/types/keys.rs | 2 |
8 files changed, 25 insertions, 202 deletions
diff --git a/ui/src/components/contacts.rs b/ui/src/components/contacts.rs index 8c0ae1fd..8488a80f 100644 --- a/ui/src/components/contacts.rs +++ b/ui/src/components/contacts.rs @@ -28,10 +28,10 @@ pub use self::contact_list::*; #[derive(Debug)] enum ViewMode { - ReadOnly, + //ReadOnly, Read, - Edit, - New, + //Edit, + //New, } #[derive(Debug)] @@ -69,9 +69,9 @@ impl fmt::Display for ContactManager { impl ContactManager { fn initialize(&mut self) { - let (width, height) = self.content.size(); + let (width, _) = self.content.size(); - let (x, y) = write_string_to_grid( + let (x, _) = write_string_to_grid( "Contact Name ", &mut self.content, Color::Byte(33), @@ -79,7 +79,7 @@ impl ContactManager { ((0, 0), (width, 0)), false, ); - let (x, y) = write_string_to_grid( + let (x, _) = write_string_to_grid( "Last edited: ", &mut self.content, Color::Byte(250), @@ -87,7 +87,7 @@ impl ContactManager { ((x, 0), (width, 0)), false, ); - let (x, y) = write_string_to_grid( + write_string_to_grid( &self.card.last_edited(), &mut self.content, Color::Byte(250), @@ -115,7 +115,7 @@ impl Component for ContactManager { self.initialized = true; } clear_area(grid, area); - let (width, height) = self.content.size(); + let (width, _height) = self.content.size(); copy_area(grid, &self.content, area, ((0, 0), (width - 1, 0))); let upper_left = upper_left!(area); diff --git a/ui/src/components/mail/accounts.rs b/ui/src/components/mail/accounts.rs index 56c71095..8fdc620b 100644 --- a/ui/src/components/mail/accounts.rs +++ b/ui/src/components/mail/accounts.rs @@ -19,10 +19,6 @@ * along with meli. If not, see <http://www.gnu.org/licenses/>. */ -mod contacts; - -pub use contacts::*; - use super::*; use std::fmt; diff --git a/ui/src/components/mail/accounts/contacts.rs b/ui/src/components/mail/accounts/contacts.rs deleted file mode 100644 index 61b8cbaa..00000000 --- a/ui/src/components/mail/accounts/contacts.rs +++ /dev/null @@ -1,105 +0,0 @@ -/* - * meli - ui crate. - * - * Copyright 2019 Manos Pitsidianakis - * - * This file is part of meli. - * - * meli is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * meli is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with meli. If not, see <http://www.gnu.org/licenses/>. - */ - -use super::*; - -#[derive(Debug)] -pub struct ContactsPanel { - content: CellBuffer, - dirty: bool, -} - -impl fmt::Display for ContactsPanel { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "contacts") - } -} - - -impl Component for ContactsPanel { - fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { - if self.dirty { - self.dirty = false; - } - clear_area(grid, area); - - let (width, height) = self.content.size(); - copy_area(grid, &self.content, area, ((0, 0), (width - 1, height - 1))); - context.dirty_areas.push_back(area); - } - fn process_event(&mut self, _event: &mut UIEvent, _context: &mut Context) -> bool { - false - } - fn is_dirty(&self) -> bool { - self.dirty - } - fn set_dirty(&mut self) { - self.dirty = true; - } -} - -impl ContactsPanel { - pub fn new(context: &Context) -> ContactsPanel { - let mut content = CellBuffer::new(120, 25 + context.accounts.len() * 20, Cell::default()); - write_string_to_grid( - "Contacts", - &mut content, - Color::Default, - Color::Default, - ((2, 3), (120 - 1, 3)), - true, - ); - - for (i, a) in context.accounts.iter().enumerate() { - create_box(&mut content, ((2,5+i*10 ), (120-1, 15+i*10))); - let (x, y) = write_string_to_grid( - a.name(), - &mut content, - Color::Default, - Color::Default, - ((3, 5 + i*10), (120 - 2, 5 + i*10)), - true, - ); - write_string_to_grid( - " ▒██▒ ", - &mut content, - Color::Byte(32), - Color::Default, - ((x, y), (120 - 2, 5 + i*10)), - true, - ); - write_string_to_grid( - &a.runtime_settings.account().identity, - &mut content, - Color::Default, - Color::Default, - ((4, y + 2), (120 - 2, y + 2)), - true, - ); - - } - - ContactsPanel { - content, - dirty: true, - } - } -} diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 3137df32..00d2493e 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -29,7 +29,7 @@ use std::str::FromStr; enum Cursor { Headers, Body, - Attachments, + //Attachments, } #[derive(Debug)] @@ -71,7 +71,7 @@ impl Default for Composer { enum ViewMode { Discard(Uuid), Pager, - Selector(Selector), + //Selector(Selector), Overview, } @@ -99,14 +99,6 @@ impl ViewMode { false } } - - fn is_selector(&self) -> bool { - if let ViewMode::Selector(_) = self { - true - } else { - false - } - } } impl fmt::Display for Composer { @@ -183,34 +175,7 @@ impl Composer { } } - fn draw_header_table(&mut self, grid: &mut CellBuffer, area: Area) { - let upper_left = upper_left!(area); - let bottom_right = bottom_right!(area); - - let headers = self.draft.headers(); - { - let (mut x, mut y) = upper_left; - for &k in &["Date", "From", "To", "Cc", "Bcc", "Subject"] { - let bg_color = Color::Default; - - - let update = { - let (x, y) = write_string_to_grid( - k, - grid, - Color::Default, - bg_color, - ((x, y), set_y(bottom_right, y)), - true, - ); - let (x, y) = write_string_to_grid( - ": ", - grid, - Color::Default, - bg_color, - ((x, y), set_y(bottom_right, y)), - true, - ); + /* let (x, y) = if k == "From" { write_string_to_grid( "◀ ", @@ -240,15 +205,7 @@ impl Composer { ((x, y), set_y(bottom_right, y)), true, ) - } else { - (x, y) - } - }; - x = get_x(upper_left); - y = update.1 + 1; - } - } - } + */ } impl Component for Composer { @@ -341,9 +298,6 @@ impl Component for Composer { ViewMode::Overview | ViewMode::Pager => { self.pager.draw(grid, body_area, context); }, - ViewMode::Selector(ref mut s) => { - s.draw(grid, body_area, context); - }, ViewMode::Discard(_) => { /* Let user choose whether to quit with/without saving or cancel */ let mid_x = width!(area) / 2; @@ -421,12 +375,6 @@ impl Component for Composer { return true; } }, - (ViewMode::Selector(ref mut s), _) => { - if s.process_event(event, context) { - self.dirty = true; - return true; - } - }, _ => {} } if self.form.process_event(event, context) { @@ -434,19 +382,6 @@ impl Component for Composer { } match event.event_type { - UIEventType::Input(Key::Esc) if self.mode.is_selector() => { - self.mode = ViewMode::Overview; - return true; - }, - UIEventType::Input(Key::Char('\n')) if self.mode.is_selector() => { - let mut old_mode = std::mem::replace(&mut self.mode, ViewMode::Overview); - if let ViewMode::Selector(s) = old_mode { - eprintln!("collected {:?}", s.collect()); - } else { - unreachable!() - } - return true; - }, UIEventType::Resize => { self.set_dirty(); }, diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index e39f27d6..2af9d6e8 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -525,7 +525,7 @@ impl Component for CompactListing { } fn get_shortcuts(&self) -> ShortcutMap { - let mut map = self.view.as_ref().map(|p| p.get_shortcuts()).unwrap_or(ShortcutMap::default()); + let mut map = self.view.as_ref().map(|p| p.get_shortcuts()).unwrap_or_default(); map.insert(Key::Char('\n'), "Open thread.".into()); map.insert(Key::PageUp, "Go to previous page.".into()); diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index cde01e22..a1a81a0a 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -397,7 +397,7 @@ impl Component for Pager { } context.dirty_areas.push_back(area); } - fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { + fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool { match event.event_type { UIEventType::Input(Key::Char('k')) => { if self.cursor_pos > 0 { @@ -937,7 +937,7 @@ impl Component for Selector { ); context.dirty_areas.push_back(area); } - fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { + fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool { let (width, height) = self.content.size(); match event.event_type { UIEventType::Input(Key::Char(' ')) => { diff --git a/ui/src/components/utilities/widgets.rs b/ui/src/components/utilities/widgets.rs index 090885ae..2f522ca6 100644 --- a/ui/src/components/utilities/widgets.rs +++ b/ui/src/components/utilities/widgets.rs @@ -72,7 +72,7 @@ impl Field { }, TextArea(_, _) => { }, - Choice(_, cursor) => { + Choice(_, _cursor) => { } } @@ -80,7 +80,7 @@ impl Field { } impl Component for Field { - fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { + fn draw(&mut self, grid: &mut CellBuffer, area: Area, _context: &mut Context) { write_string_to_grid( self.as_str(), grid, @@ -89,7 +89,7 @@ impl Component for Field { area, true); } - fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { + fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool { match event.event_type { UIEventType::InsertInput(Key::Right) => { match self { @@ -294,10 +294,8 @@ impl Component for FormWidget { context.dirty_areas.push_back(area); } fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { - if self.focus == FormFocus::Buttons { - if self.buttons.process_event(event, context) { - return true; - } + if self.focus == FormFocus::Buttons && self.buttons.process_event(event, context) { + return true; } match event.event_type { @@ -341,7 +339,7 @@ impl Component for FormWidget { UIEventType::ChangeMode(UIMode::Normal) if self.focus == FormFocus::TextInput => { self.focus = FormFocus::Fields; }, - UIEventType::InsertInput(Key::Char(k)) if self.focus == FormFocus::TextInput => { + UIEventType::InsertInput(Key::Char(_)) if self.focus == FormFocus::TextInput => { let field = self.fields.get_mut(&self.layout[self.cursor]).unwrap(); field.process_event(event, context); }, @@ -402,14 +400,13 @@ impl<T> ButtonWidget<T> where T: std::fmt::Debug + Default + Send { impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default + Send { - fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { + fn draw(&mut self, grid: &mut CellBuffer, area: Area, _context: &mut Context) { let upper_left = upper_left!(area); - let bottom_right = bottom_right!(area); let mut len = 0; for (i, k) in self.layout.iter().enumerate() { let cur_len = k.len(); - let (x, y) = write_string_to_grid( + write_string_to_grid( k.as_str(), grid, Color::Default, @@ -420,7 +417,7 @@ impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default + Send len += cur_len + 3; } } - fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { + fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool { match event.event_type { UIEventType::Input(Key::Char('\n')) => { self.result = Some(self.buttons.remove(&self.layout[self.cursor]).unwrap_or_default()); diff --git a/ui/src/types/keys.rs b/ui/src/types/keys.rs index 6be97782..e3db0176 100644 --- a/ui/src/types/keys.rs +++ b/ui/src/types/keys.rs @@ -201,7 +201,7 @@ derive_csi_sequence!("End Bracketed Paste Mode", BracketModeEnd, "?2003l"); pub const BRACKET_PASTE_START: &[u8] = b"\x1B[200~"; pub const BRACKET_PASTE_END: &[u8] = b"\x1B[201~"; -const FIELDS: &'static [&'static str] = &[]; +const FIELDS: &[&str] = &[]; impl<'de> Deserialize<'de> for Key { |