From 2610b697a83d3681e06ede37844c83f6b7191561 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Thu, 19 Jul 2018 19:44:59 -0700 Subject: [PATCH] Rustfmt --- src/backend/blt.rs | 6 ++---- src/backend/dummy.rs | 2 +- src/views/button.rs | 7 +++++-- src/views/checkbox.rs | 3 ++- src/views/edit_view.rs | 3 ++- src/views/list_view.rs | 25 +++++++++++++++---------- src/views/menu_popup.rs | 25 +++++++++++++++---------- src/views/menubar.rs | 6 ++++-- src/views/radio.rs | 3 ++- src/views/scroll_view.rs | 24 ++++++++++++++---------- src/views/select_view.rs | 22 +++++++++++++--------- src/views/slider_view.rs | 6 ++++-- src/views/text_area.rs | 24 ++++++++++++++---------- 13 files changed, 93 insertions(+), 63 deletions(-) diff --git a/src/backend/blt.rs b/src/backend/blt.rs index 7d0cf3b..fb210a8 100644 --- a/src/backend/blt.rs +++ b/src/backend/blt.rs @@ -20,7 +20,6 @@ use event::{Event, Key, MouseButton, MouseEvent}; use theme::{BaseColor, Color, ColorPair, Effect}; use vec::Vec2; - enum ColorRole { Foreground, Background, @@ -309,7 +308,8 @@ impl backend::Backend for Backend { } fn prepare_input( - &mut self, event_sink: &Sender>, input_request: backend::InputRequest, + &mut self, event_sink: &Sender>, + input_request: backend::InputRequest, ) { match input_request { backend::InputRequest::Peek => event_sink.send(self.parse_next()), @@ -326,8 +326,6 @@ impl backend::Backend for Backend { event_sink.send(Some(Event::Refresh)); } } - - } } diff --git a/src/backend/dummy.rs b/src/backend/dummy.rs index 6c310b3..aae1de8 100644 --- a/src/backend/dummy.rs +++ b/src/backend/dummy.rs @@ -4,7 +4,7 @@ use event; use theme; use vec::Vec2; -use crossbeam_channel::{Sender}; +use crossbeam_channel::Sender; pub struct Backend; diff --git a/src/views/button.rs b/src/views/button.rs index 3066195..5fd4788 100644 --- a/src/views/button.rs +++ b/src/views/button.rs @@ -173,8 +173,11 @@ impl View for Button { event: MouseEvent::Release(MouseButton::Left), position, offset, - } if position - .fits_in_rect(offset + (self_offset, 0), self.req_size()) => + } + if position.fits_in_rect( + offset + (self_offset, 0), + self.req_size(), + ) => { EventResult::Consumed(Some(self.callback.clone())) } diff --git a/src/views/checkbox.rs b/src/views/checkbox.rs index b695c28..224e14b 100644 --- a/src/views/checkbox.rs +++ b/src/views/checkbox.rs @@ -132,7 +132,8 @@ impl View for Checkbox { event: MouseEvent::Release(MouseButton::Left), position, offset, - } if position.fits_in_rect(offset, (3, 1)) => + } + if position.fits_in_rect(offset, (3, 1)) => { self.toggle() } diff --git a/src/views/edit_view.rs b/src/views/edit_view.rs index b53c28d..e187836 100644 --- a/src/views/edit_view.rs +++ b/src/views/edit_view.rs @@ -670,7 +670,8 @@ impl View for EditView { event: MouseEvent::Press(_), position, offset, - } if position.fits_in_rect(offset, (self.last_length, 1)) => + } + if position.fits_in_rect(offset, (self.last_length, 1)) => { if let Some(position) = position.checked_sub(offset) { self.cursor = self.offset diff --git a/src/views/list_view.rs b/src/views/list_view.rs index b47a307..45bcf53 100644 --- a/src/views/list_view.rs +++ b/src/views/list_view.rs @@ -345,12 +345,13 @@ impl View for ListView { event: MouseEvent::Press(MouseButton::Left), position, offset, - } if position - .checked_sub(offset) - .map(|position| { - self.scrollbase.start_drag(position, self.last_size.x) - }) - .unwrap_or(false) => + } + if position + .checked_sub(offset) + .map(|position| { + self.scrollbase.start_drag(position, self.last_size.x) + }) + .unwrap_or(false) => { return EventResult::Consumed(None); } @@ -358,7 +359,8 @@ impl View for ListView { event: MouseEvent::Hold(MouseButton::Left), position, offset, - } if self.scrollbase.is_dragging() => + } + if self.scrollbase.is_dragging() => { let position = position.saturating_sub(offset); self.scrollbase.drag(position); @@ -367,7 +369,8 @@ impl View for ListView { Event::Mouse { event: MouseEvent::Release(MouseButton::Left), .. - } if self.scrollbase.is_dragging() => + } + if self.scrollbase.is_dragging() => { self.scrollbase.release_grab(); return EventResult::Consumed(None); @@ -420,7 +423,8 @@ impl View for ListView { Event::Mouse { event: MouseEvent::WheelDown, .. - } if self.scrollbase.can_scroll_down() => + } + if self.scrollbase.can_scroll_down() => { self.scrollbase.scroll_down(5); EventResult::Consumed(None) @@ -428,7 +432,8 @@ impl View for ListView { Event::Mouse { event: MouseEvent::WheelUp, .. - } if self.scrollbase.can_scroll_up() => + } + if self.scrollbase.can_scroll_up() => { self.scrollbase.scroll_up(5); EventResult::Consumed(None) diff --git a/src/views/menu_popup.rs b/src/views/menu_popup.rs index 4118af3..156d925 100644 --- a/src/views/menu_popup.rs +++ b/src/views/menu_popup.rs @@ -297,7 +297,8 @@ impl View for MenuPopup { Event::Mouse { event: MouseEvent::WheelUp, .. - } if self.scrollbase.can_scroll_up() => + } + if self.scrollbase.can_scroll_up() => { fix_scroll = false; self.scrollbase.scroll_up(1); @@ -305,7 +306,8 @@ impl View for MenuPopup { Event::Mouse { event: MouseEvent::WheelDown, .. - } if self.scrollbase.can_scroll_down() => + } + if self.scrollbase.can_scroll_down() => { fix_scroll = false; self.scrollbase.scroll_down(1); @@ -314,13 +316,15 @@ impl View for MenuPopup { event: MouseEvent::Press(MouseButton::Left), position, offset, - } if self.scrollbase.scrollable() - && position - .checked_sub(offset + (0, 1)) - .map(|position| { - self.scrollbase.start_drag(position, self.last_size.x) - }) - .unwrap_or(false) => + } + if self.scrollbase.scrollable() + && position + .checked_sub(offset + (0, 1)) + .map(|position| { + self.scrollbase + .start_drag(position, self.last_size.x) + }) + .unwrap_or(false) => { fix_scroll = false; } @@ -338,7 +342,8 @@ impl View for MenuPopup { event: MouseEvent::Press(_), position, offset, - } if position.fits_in_rect(offset, self.last_size) => + } + if position.fits_in_rect(offset, self.last_size) => { // eprintln!("Position: {:?} / {:?}", position, offset); // eprintln!("Last size: {:?}", self.last_size); diff --git a/src/views/menubar.rs b/src/views/menubar.rs index 3c3b472..6ab05b9 100644 --- a/src/views/menubar.rs +++ b/src/views/menubar.rs @@ -318,7 +318,8 @@ impl View for Menubar { event: MouseEvent::Press(btn), position, offset, - } if position.fits(offset) && position.y == offset.y => + } + if position.fits(offset) && position.y == offset.y => { if let Some(child) = position .checked_sub(offset) @@ -336,7 +337,8 @@ impl View for Menubar { event: MouseEvent::Release(btn), position, offset, - } if position.fits(offset) && position.y == offset.y => + } + if position.fits(offset) && position.y == offset.y => { if let Some(child) = position .checked_sub(offset) diff --git a/src/views/radio.rs b/src/views/radio.rs index 733026f..4979a7b 100644 --- a/src/views/radio.rs +++ b/src/views/radio.rs @@ -184,7 +184,8 @@ impl View for RadioButton { event: MouseEvent::Release(MouseButton::Left), position, offset, - } if position.fits_in_rect(offset, self.req_size()) => + } + if position.fits_in_rect(offset, self.req_size()) => { self.select(); EventResult::Consumed(None) diff --git a/src/views/scroll_view.rs b/src/views/scroll_view.rs index a7761b3..dbd483f 100644 --- a/src/views/scroll_view.rs +++ b/src/views/scroll_view.rs @@ -459,16 +459,18 @@ where Event::Mouse { event: MouseEvent::WheelUp, .. - } if self.enabled.y && self.offset.y > 0 => + } + if self.enabled.y && self.offset.y > 0 => { self.offset.y = self.offset.y.saturating_sub(3); } Event::Mouse { event: MouseEvent::WheelDown, .. - } if self.enabled.y - && (self.offset.y + self.available_size().y - < self.inner_size.y) => + } + if self.enabled.y + && (self.offset.y + self.available_size().y + < self.inner_size.y) => { self.offset.y = min( self.inner_size @@ -481,11 +483,12 @@ where event: MouseEvent::Press(MouseButton::Left), position, offset, - } if self.show_scrollbars - && position - .checked_sub(offset) - .map(|position| self.start_drag(position)) - .unwrap_or(false) => + } + if self.show_scrollbars + && position + .checked_sub(offset) + .map(|position| self.start_drag(position)) + .unwrap_or(false) => { // Just consume the event. } @@ -493,7 +496,8 @@ where event: MouseEvent::Hold(MouseButton::Left), position, offset, - } if self.show_scrollbars => + } + if self.show_scrollbars => { let position = position.saturating_sub(offset); self.drag(position); diff --git a/src/views/select_view.rs b/src/views/select_view.rs index 70b609c..a516ac9 100644 --- a/src/views/select_view.rs +++ b/src/views/select_view.rs @@ -435,7 +435,8 @@ impl SelectView { Event::Mouse { event: MouseEvent::WheelDown, .. - } if self.scrollbase.can_scroll_down() => + } + if self.scrollbase.can_scroll_down() => { fix_scroll = false; self.scrollbase.scroll_down(5); @@ -443,7 +444,8 @@ impl SelectView { Event::Mouse { event: MouseEvent::WheelUp, .. - } if self.scrollbase.can_scroll_up() => + } + if self.scrollbase.can_scroll_up() => { fix_scroll = false; self.scrollbase.scroll_up(5); @@ -452,12 +454,13 @@ impl SelectView { event: MouseEvent::Press(MouseButton::Left), position, offset, - } if position - .checked_sub(offset) - .map(|position| { - self.scrollbase.start_drag(position, self.last_size.x) - }) - .unwrap_or(false) => + } + if position + .checked_sub(offset) + .map(|position| { + self.scrollbase.start_drag(position, self.last_size.x) + }) + .unwrap_or(false) => { fix_scroll = false; } @@ -620,7 +623,8 @@ impl SelectView { event: MouseEvent::Release(MouseButton::Left), position, offset, - } if position.fits_in_rect(offset, self.last_size) => + } + if position.fits_in_rect(offset, self.last_size) => { self.open_popup() } diff --git a/src/views/slider_view.rs b/src/views/slider_view.rs index 1b4ac44..f79f994 100644 --- a/src/views/slider_view.rs +++ b/src/views/slider_view.rs @@ -169,7 +169,8 @@ impl View for SliderView { event: MouseEvent::Hold(MouseButton::Left), position, offset, - } if self.dragging => + } + if self.dragging => { let position = position.saturating_sub(offset); let position = self.orientation.get(&position); @@ -184,7 +185,8 @@ impl View for SliderView { event: MouseEvent::Press(MouseButton::Left), position, offset, - } if position.fits_in_rect(offset, self.req_size()) => + } + if position.fits_in_rect(offset, self.req_size()) => { if let Some(position) = position.checked_sub(offset) { self.dragging = true; diff --git a/src/views/text_area.rs b/src/views/text_area.rs index f63380c..604f68a 100644 --- a/src/views/text_area.rs +++ b/src/views/text_area.rs @@ -535,7 +535,8 @@ impl View for TextArea { Event::Mouse { event: MouseEvent::WheelUp, .. - } if self.scrollbase.can_scroll_up() => + } + if self.scrollbase.can_scroll_up() => { fix_scroll = false; self.scrollbase.scroll_up(5); @@ -543,7 +544,8 @@ impl View for TextArea { Event::Mouse { event: MouseEvent::WheelDown, .. - } if self.scrollbase.can_scroll_down() => + } + if self.scrollbase.can_scroll_down() => { fix_scroll = false; self.scrollbase.scroll_down(5); @@ -552,12 +554,13 @@ impl View for TextArea { event: MouseEvent::Press(MouseButton::Left), position, offset, - } if position - .checked_sub(offset) - .map(|position| { - self.scrollbase.start_drag(position, self.last_size.x) - }) - .unwrap_or(false) => + } + if position + .checked_sub(offset) + .map(|position| { + self.scrollbase.start_drag(position, self.last_size.x) + }) + .unwrap_or(false) => { fix_scroll = false; } @@ -574,8 +577,9 @@ impl View for TextArea { event: MouseEvent::Press(_), position, offset, - } if !self.rows.is_empty() - && position.fits_in_rect(offset, self.last_size) => + } + if !self.rows.is_empty() + && position.fits_in_rect(offset, self.last_size) => { if let Some(position) = position.checked_sub(offset) { let y = position.y + self.scrollbase.start_line;