diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-01-06 01:42:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-06 01:42:55 +0000 |
commit | 2920cbe7103f03a45080bfb7610bd7f481f36361 (patch) | |
tree | 4839deca8a54d8e2546d124eb26178fd1eac4d4a /src/ansi.rs | |
parent | 650b5a0cbaccc6de2b53240372c2be79739d5d12 (diff) | |
download | alacritty-2920cbe7103f03a45080bfb7610bd7f481f36361.tar.gz alacritty-2920cbe7103f03a45080bfb7610bd7f481f36361.zip |
Add clippy check to travis
This commit adds clippy as a required step of the build process. To make
this possible, all existing clippy issues have been resolved.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r-- | src/ansi.rs | 121 |
1 files changed, 52 insertions, 69 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index 8ff7d06b..22e84a21 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -360,6 +360,9 @@ pub enum CursorStyle { /// Cursor is a vertical bar `⎸` Beam, + + /// Cursor is a box like `☐` + HollowBlock, } impl Default for CursorStyle { @@ -731,18 +734,16 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> // TODO replace OSC parsing with parser combinators #[inline] fn osc_dispatch(&mut self, params: &[&[u8]]) { - macro_rules! unhandled { - () => {{ - let mut buf = String::new(); - for items in params { - buf.push_str("["); - for item in *items { - buf.push_str(&format!("{:?},", *item as char)); - } - buf.push_str("],"); + fn unhandled(params: &[&[u8]]) { + let mut buf = String::new(); + for items in params { + buf.push_str("["); + for item in *items { + buf.push_str(&format!("{:?},", *item as char)); } - warn!("[unhandled osc_dispatch]: [{}] at line {}", &buf, line!()); - }} + buf.push_str("],"); + } + warn!("[unhandled osc_dispatch]: [{}] at line {}", &buf, line!()); } if params.is_empty() || params[0].is_empty() { @@ -752,13 +753,13 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> match params[0] { // Set window title b"0" | b"2" => { - if params.len() < 2 { - return unhandled!(); - } - - if let Ok(utf8_title) = str::from_utf8(params[1]) { - self.handler.set_title(utf8_title); + if params.len() >= 2 { + if let Ok(utf8_title) = str::from_utf8(params[1]) { + self.handler.set_title(utf8_title); + return; + } } + unhandled(params); }, // Set icon name @@ -767,70 +768,60 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> // Set color index b"4" => { - if params.len() == 1 || params.len() % 2 == 0 { - return unhandled!(); - } - - for chunk in params[1..].chunks(2) { - if let Some(index) = parse_number(chunk[0]) { - if let Some(color) = parse_rgb_color(chunk[1]) { - self.handler.set_color(index as usize, color); - } else { - unhandled!(); + if params.len() > 1 && params.len() % 2 != 0 { + for chunk in params[1..].chunks(2) { + let index = parse_number(chunk[0]); + let color = parse_rgb_color(chunk[0]); + if let (Some(i), Some(c)) = (index, color) { + self.handler.set_color(i as usize, c); + return; } - } else { - unhandled!(); } } + unhandled(params); } // Set foreground color b"10" => { - if params.len() < 2 { - return unhandled!(); - } - - if let Some(color) = parse_rgb_color(params[1]) { - self.handler.set_color(NamedColor::Foreground as usize, color); - } else { - unhandled!() + if params.len() >= 2 { + if let Some(color) = parse_rgb_color(params[1]) { + self.handler.set_color(NamedColor::Foreground as usize, color); + return; + } } + unhandled(params); } // Set background color b"11" => { - if params.len() < 2 { - return unhandled!(); - } - - if let Some(color) = parse_rgb_color(params[1]) { - self.handler.set_color(NamedColor::Background as usize, color); - } else { - unhandled!() + if params.len() >= 2 { + if let Some(color) = parse_rgb_color(params[1]) { + self.handler.set_color(NamedColor::Background as usize, color); + return; + } } + unhandled(params); } // Set text cursor color b"12" => { - if params.len() < 2 { - return unhandled!(); - } - - if let Some(color) = parse_rgb_color(params[1]) { - self.handler.set_color(NamedColor::Cursor as usize, color); - } else { - unhandled!() + if params.len() >= 2 { + if let Some(color) = parse_rgb_color(params[1]) { + self.handler.set_color(NamedColor::Cursor as usize, color); + return; + } } + unhandled(params); } // Set clipboard b"52" => { if params.len() < 3 { - return unhandled!(); + return unhandled(params); } match params[2] { - b"?" => unhandled!(), + b"?" => unhandled(params), selection => { if let Ok(string) = base64::decode(selection) { if let Ok(utf8_string) = str::from_utf8(&string) { @@ -855,29 +846,21 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> for param in ¶ms[1..] { match parse_number(param) { Some(index) => self.handler.reset_color(index as usize), - None => unhandled!(), + None => unhandled(params), } } } // Reset foreground color - b"110" => { - self.handler.reset_color(NamedColor::Foreground as usize); - } + b"110" => self.handler.reset_color(NamedColor::Foreground as usize), // Reset background color - b"111" => { - self.handler.reset_color(NamedColor::Background as usize); - } + b"111" => self.handler.reset_color(NamedColor::Background as usize), // Reset text cursor color - b"112" => { - self.handler.reset_color(NamedColor::Cursor as usize); - } + b"112" => self.handler.reset_color(NamedColor::Cursor as usize), - _ => { - unhandled!(); - } + _ => unhandled(params), } } @@ -1389,7 +1372,7 @@ mod tests { use super::{Processor, Handler, Attr, TermInfo, Color, StandardCharset, CharsetIndex, parse_rgb_color, parse_number}; use ::Rgb; - /// The /dev/null of io::Write + /// The /dev/null of `io::Write` struct Void; impl io::Write for Void { |