diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2017-01-06 20:44:51 -0800 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2017-01-06 20:44:51 -0800 |
commit | 4e1f4c8cd7180606156b71ad0222f60e4559f2b3 (patch) | |
tree | 28d7a983f5639270976de1f794cc54cb349ea4a8 | |
parent | 49187d53f2f8b7cfca9105c3fb00d7c29e2a457b (diff) | |
download | alacritty-4e1f4c8cd7180606156b71ad0222f60e4559f2b3.tar.gz alacritty-4e1f4c8cd7180606156b71ad0222f60e4559f2b3.zip |
Clippy fixes!
-rw-r--r-- | src/config.rs | 3 | ||||
-rw-r--r-- | src/event.rs | 4 | ||||
-rw-r--r-- | src/index.rs | 4 | ||||
-rw-r--r-- | src/input.rs | 9 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/selection.rs | 6 | ||||
-rw-r--r-- | src/term/cell.rs | 2 | ||||
-rw-r--r-- | src/term/mod.rs | 24 | ||||
-rw-r--r-- | src/util.rs | 1 |
9 files changed, 27 insertions, 28 deletions
diff --git a/src/config.rs b/src/config.rs index 36f0c363..f36859c7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -713,7 +713,8 @@ fn rgb_from_hex<D>(deserializer: &mut D) -> ::std::result::Result<Rgb, D::Error> deserializer.deserialize_str(RgbVisitor) } -impl Rgb { +impl FromStr for Rgb { + type Err = (); fn from_str(s: &str) -> ::std::result::Result<Rgb, ()> { let mut chars = s.chars(); let mut rgb = Rgb::default(); diff --git a/src/event.rs b/src/event.rs index 66abbaa2..bdfe2708 100644 --- a/src/event.rs +++ b/src/event.rs @@ -153,12 +153,10 @@ impl<N: Notify> Processor<N> { processor.ctx.terminal.dirty = true; } }, - glutin::Event::Focused(true) => { - processor.ctx.terminal.dirty = true; - }, glutin::Event::MouseWheel(scroll_delta, touch_phase) => { processor.on_mouse_wheel(scroll_delta, touch_phase); }, + glutin::Event::Focused(true) | glutin::Event::Refresh | glutin::Event::Awakened => { processor.ctx.terminal.dirty = true; diff --git a/src/index.rs b/src/index.rs index 21ce0df5..25d5eaff 100644 --- a/src/index.rs +++ b/src/index.rs @@ -44,7 +44,7 @@ impl Ord for Point { use std::cmp::Ordering::*; match (self.line.cmp(&other.line), self.col.cmp(&other.col)) { (Equal, Equal) => Equal, - (Equal, ord) => ord, + (Equal, ord) | (ord, Equal) => ord, (Less, _) => Less, (Greater, _) => Greater, @@ -314,7 +314,7 @@ impl<T: PartialOrd<T>> Contains for Range<T> { impl<T: PartialOrd<T>> Contains for RangeInclusive<T> { type Content = T; fn contains_(&self, item: Self::Content) -> bool { - if let &RangeInclusive::NonEmpty{ref start, ref end} = self { + if let RangeInclusive::NonEmpty{ref start, ref end} = *self { (*start <= item) && (item <= *end) } else { false } } diff --git a/src/input.rs b/src/input.rs index f2bd461b..8823b89e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -209,11 +209,10 @@ impl<'a, N: Notify + 'a> Processor<'a, N> { line: point.line, col: point.col }, self.ctx.mouse.cell_side); - } else if self.ctx.terminal.mode().contains(mode::MOUSE_MOTION) { - // Only report motion when changing cells - if prev_line != self.ctx.mouse.line || prev_col != self.ctx.mouse.column { - self.mouse_report(0 + 32); - } + } else if self.ctx.terminal.mode().contains(mode::MOUSE_MOTION) + // Only report motion when changing cells + && (prev_line != self.ctx.mouse.line || prev_col != self.ctx.mouse.column) { + self.mouse_report(32); } } } diff --git a/src/main.rs b/src/main.rs index d53daf0f..f6ccc966 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,8 +13,8 @@ // limitations under the License. // //! Alacritty - The GPU Enhanced Terminal -#![feature(plugin)] #![cfg_attr(feature = "clippy", plugin(clippy))] +#![cfg_attr(feature = "clippy", feature(plugin))] #[macro_use] extern crate alacritty; diff --git a/src/selection.rs b/src/selection.rs index ff587b9d..3e5b799c 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -106,14 +106,14 @@ impl Selection { // Single-cell selections are a special case if start == end { - if start_side != end_side { + if start_side == end_side { + return None; + } else { return Some(Span { ty: SpanType::Inclusive, front: *front, tail: *tail }); - } else { - return None; } } diff --git a/src/term/cell.rs b/src/term/cell.rs index 499f99b8..021ce280 100644 --- a/src/term/cell.rs +++ b/src/term/cell.rs @@ -96,7 +96,7 @@ impl Cell { #[inline] pub fn reset(&mut self, template: &Cell) { // memcpy template to self - *self = template.clone(); + *self = *template; } #[inline] diff --git a/src/term/mod.rs b/src/term/mod.rs index eab73e74..45dd8a45 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -306,7 +306,7 @@ impl Term { mode: Default::default(), scroll_region: scroll_region, size_info: size, - template_cell: template.clone(), + template_cell: template, empty_cell: template, } } @@ -498,7 +498,7 @@ impl Term { println!("num_cols, num_lines = {}, {}", num_cols, num_lines); // Resize grids to new size - let template = self.template_cell.clone(); + let template = self.template_cell; self.grid.resize(num_lines, num_cols, &template); self.alt_grid.resize(num_lines, num_cols, &template); @@ -514,7 +514,7 @@ impl Term { self.tabs[0] = false; // Make sure bottom of terminal is clear - let template = self.empty_cell.clone(); + let template = self.empty_cell; self.grid.clear_region((self.cursor.line).., |c| c.reset(&template)); self.alt_grid.clear_region((self.cursor.line).., |c| c.reset(&template)); @@ -538,7 +538,7 @@ impl Term { ::std::mem::swap(&mut self.cursor, &mut self.alt_cursor); if self.alt { - let template = self.empty_cell.clone(); + let template = self.empty_cell; self.grid.clear(|c| c.reset(&template)); } } @@ -551,7 +551,7 @@ impl Term { debug_println!("scroll_down: {}", lines); // Copy of cell template; can't have it borrowed when calling clear/scroll - let template = self.empty_cell.clone(); + let template = self.empty_cell; // Clear `lines` lines at bottom of area { @@ -576,7 +576,7 @@ impl Term { debug_println!("scroll_up: {}", lines); // Copy of cell template; can't have it borrowed when calling clear/scroll - let template = self.empty_cell.clone(); + let template = self.empty_cell; // Clear `lines` lines starting from origin to origin + lines { @@ -636,7 +636,7 @@ impl ansi::Handler for Term { } let cell = &mut self.grid[&self.cursor]; - *cell = self.template_cell.clone(); + *cell = self.template_cell; cell.c = c; self.cursor.col += 1; } @@ -682,7 +682,7 @@ impl ansi::Handler for Term { // Cells were just moved out towards the end of the line; fill in // between source and dest with blanks. - let template = self.empty_cell.clone(); + let template = self.empty_cell; for c in &mut line[source..destination] { c.reset(&template); } @@ -834,7 +834,7 @@ impl ansi::Handler for Term { let end = start + count; let row = &mut self.grid[self.cursor.line]; - let template = self.empty_cell.clone(); + let template = self.empty_cell; for c in &mut row[start..end] { c.reset(&template); } @@ -861,7 +861,7 @@ impl ansi::Handler for Term { // Clear last `count` cells in line. If deleting 1 char, need to delete // 1 cell. - let template = self.empty_cell.clone(); + let template = self.empty_cell; let end = self.size_info.cols() - count; for c in &mut line[end..] { c.reset(&template); @@ -891,7 +891,7 @@ impl ansi::Handler for Term { #[inline] fn clear_line(&mut self, mode: ansi::LineClearMode) { debug_println!("clear_line: {:?}", mode); - let template = self.empty_cell.clone(); + let template = self.empty_cell; match mode { ansi::LineClearMode::Right => { let row = &mut self.grid[self.cursor.line]; @@ -917,7 +917,7 @@ impl ansi::Handler for Term { #[inline] fn clear_screen(&mut self, mode: ansi::ClearMode) { debug_println!("clear_screen: {:?}", mode); - let template = self.empty_cell.clone(); + let template = self.empty_cell; match mode { ansi::ClearMode::Below => { for row in &mut self.grid[self.cursor.line..] { diff --git a/src/util.rs b/src/util.rs index 2e34b2a6..ccb22cc9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -15,6 +15,7 @@ use std::cmp; #[cfg(not(feature = "nightly"))] #[inline(always)] +#[cfg_attr(feature = "clippy", allow(inline_always))] pub unsafe fn unlikely(x: bool) -> bool { x } |