fix warnings
This commit is contained in:
parent
c27678efc2
commit
a1c43eec08
|
@ -76,7 +76,7 @@ derive_color!("High-intensity light magenta.", LightMagenta, "13");
|
||||||
derive_color!("High-intensity light cyan.", LightCyan, "14");
|
derive_color!("High-intensity light cyan.", LightCyan, "14");
|
||||||
derive_color!("High-intensity light white.", LightWhite, "15");
|
derive_color!("High-intensity light white.", LightWhite, "15");
|
||||||
|
|
||||||
impl<'a> Color for &'a Color {
|
impl<'a> Color for &'a dyn Color {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
(*self).write_fg(f)
|
(*self).write_fg(f)
|
||||||
|
@ -283,7 +283,7 @@ impl<W: Write> DetectColors for W {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Detect a color using OSC 4.
|
/// Detect a color using OSC 4.
|
||||||
fn detect_color(stdout: &mut Write, stdin: &mut Read, color: u16) -> io::Result<bool> {
|
fn detect_color(stdout: &mut dyn Write, stdin: &mut dyn Read, color: u16) -> io::Result<bool> {
|
||||||
// Is the color available?
|
// Is the color available?
|
||||||
// Use `ESC ] 4 ; color ; ? BEL`.
|
// Use `ESC ] 4 ; color ; ? BEL`.
|
||||||
write!(stdout, "\x1B]4;{};?\x07", color)?;
|
write!(stdout, "\x1B]4;{};?\x07", color)?;
|
||||||
|
|
18
src/event.rs
18
src/event.rs
|
@ -110,7 +110,7 @@ pub fn parse_event<I>(item: u8, iter: &mut I) -> Result<Event, Error>
|
||||||
Some(Ok(b'O')) => {
|
Some(Ok(b'O')) => {
|
||||||
match iter.next() {
|
match iter.next() {
|
||||||
// F1-F4
|
// F1-F4
|
||||||
Some(Ok(val @ b'P'...b'S')) => Event::Key(Key::F(1 + val - b'P')),
|
Some(Ok(val @ b'P'..=b'S')) => Event::Key(Key::F(1 + val - b'P')),
|
||||||
_ => return Err(error),
|
_ => return Err(error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,8 @@ pub fn parse_event<I>(item: u8, iter: &mut I) -> Result<Event, Error>
|
||||||
b'\n' | b'\r' => Ok(Event::Key(Key::Char('\n'))),
|
b'\n' | b'\r' => Ok(Event::Key(Key::Char('\n'))),
|
||||||
b'\t' => Ok(Event::Key(Key::Char('\t'))),
|
b'\t' => Ok(Event::Key(Key::Char('\t'))),
|
||||||
b'\x7F' => Ok(Event::Key(Key::Backspace)),
|
b'\x7F' => Ok(Event::Key(Key::Backspace)),
|
||||||
c @ b'\x01'...b'\x1A' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1 + b'a') as char))),
|
c @ b'\x01'..=b'\x1A' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1 + b'a') as char))),
|
||||||
c @ b'\x1C'...b'\x1F' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1C + b'4') as char))),
|
c @ b'\x1C'..=b'\x1F' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1C + b'4') as char))),
|
||||||
b'\0' => Ok(Event::Key(Key::Null)),
|
b'\0' => Ok(Event::Key(Key::Null)),
|
||||||
c => {
|
c => {
|
||||||
Ok({
|
Ok({
|
||||||
|
@ -148,7 +148,7 @@ fn parse_csi<I>(iter: &mut I) -> Option<Event>
|
||||||
{
|
{
|
||||||
Some(match iter.next() {
|
Some(match iter.next() {
|
||||||
Some(Ok(b'[')) => match iter.next() {
|
Some(Ok(b'[')) => match iter.next() {
|
||||||
Some(Ok(val @ b'A'...b'E')) => Event::Key(Key::F(1 + val - b'A')),
|
Some(Ok(val @ b'A'..=b'E')) => Event::Key(Key::F(1 + val - b'A')),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
},
|
},
|
||||||
Some(Ok(b'D')) => Event::Key(Key::Left),
|
Some(Ok(b'D')) => Event::Key(Key::Left),
|
||||||
|
@ -215,7 +215,7 @@ fn parse_csi<I>(iter: &mut I) -> Option<Event>
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let event = match cb {
|
let event = match cb {
|
||||||
0...2 | 64...65 => {
|
0..=2 | 64..=65 => {
|
||||||
let button = match cb {
|
let button = match cb {
|
||||||
0 => MouseButton::Left,
|
0 => MouseButton::Left,
|
||||||
1 => MouseButton::Middle,
|
1 => MouseButton::Middle,
|
||||||
|
@ -237,7 +237,7 @@ fn parse_csi<I>(iter: &mut I) -> Option<Event>
|
||||||
|
|
||||||
Event::Mouse(event)
|
Event::Mouse(event)
|
||||||
}
|
}
|
||||||
Some(Ok(c @ b'0'...b'9')) => {
|
Some(Ok(c @ b'0'..=b'9')) => {
|
||||||
// Numbered escape code.
|
// Numbered escape code.
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
buf.push(c);
|
buf.push(c);
|
||||||
|
@ -298,9 +298,9 @@ fn parse_csi<I>(iter: &mut I) -> Option<Event>
|
||||||
4 | 8 => Event::Key(Key::End),
|
4 | 8 => Event::Key(Key::End),
|
||||||
5 => Event::Key(Key::PageUp),
|
5 => Event::Key(Key::PageUp),
|
||||||
6 => Event::Key(Key::PageDown),
|
6 => Event::Key(Key::PageDown),
|
||||||
v @ 11...15 => Event::Key(Key::F(v - 10)),
|
v @ 11..=15 => Event::Key(Key::F(v - 10)),
|
||||||
v @ 17...21 => Event::Key(Key::F(v - 11)),
|
v @ 17..=21 => Event::Key(Key::F(v - 11)),
|
||||||
v @ 23...24 => Event::Key(Key::F(v - 12)),
|
v @ 23..=24 => Event::Key(Key::F(v - 12)),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl<R: Read> Iterator for EventsAndRaw<R> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(2) => {
|
Ok(2) => {
|
||||||
let mut option_iter = &mut Some(buf[1]).into_iter();
|
let option_iter = &mut Some(buf[1]).into_iter();
|
||||||
let result = {
|
let result = {
|
||||||
let mut iter = option_iter.map(|c| Ok(c)).chain(source.bytes());
|
let mut iter = option_iter.map(|c| Ok(c)).chain(source.bytes());
|
||||||
parse_event(buf[0], &mut iter)
|
parse_event(buf[0], &mut iter)
|
||||||
|
|
Loading…
Reference in New Issue