diff --git a/Cargo.toml b/Cargo.toml index 91415d0..ad625ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "termion" -version = "1.0.2" +version = "1.0.3" authors = ["Ticki "] description = "A bindless library for manipulating terminals." repository = "https://github.com/ticki/termion" diff --git a/src/cursor.rs b/src/cursor.rs index 093016f..3f0f555 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -23,7 +23,7 @@ impl fmt::Display for Goto { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { debug_assert!(self != &Goto(0, 0), "Goto is one-based."); - write!(f, csi!("{};{}H"), self.0, self.1) + write!(f, csi!("{};{}H"), self.1, self.0) } } diff --git a/src/event.rs b/src/event.rs index 466654b..675830e 100644 --- a/src/event.rs +++ b/src/event.rs @@ -118,8 +118,8 @@ where I: Iterator> // X10 emulation mouse encoding: ESC [ CB Cx Cy (6 characters only). let cb = iter.next().unwrap().unwrap() as i8 - 32; // (1, 1) are the coords for upper left. - let cy = (iter.next().unwrap().unwrap() as u8).saturating_sub(32) as u16; let cx = (iter.next().unwrap().unwrap() as u8).saturating_sub(32) as u16; + let cy = (iter.next().unwrap().unwrap() as u8).saturating_sub(32) as u16; Event::Mouse(match cb & 0b11 { 0 => { if cb & 0x40 != 0 { @@ -156,8 +156,8 @@ where I: Iterator> let ref mut nums = str_buf.split(';'); let cb = nums.next().unwrap().parse::().unwrap(); - let cy = nums.next().unwrap().parse::().unwrap(); let cx = nums.next().unwrap().parse::().unwrap(); + let cy = nums.next().unwrap().parse::().unwrap(); let button = match cb { 0 => MouseButton::Left, @@ -195,8 +195,8 @@ where I: Iterator> let ref mut nums = str_buf.split(';'); let cb = nums.next().unwrap().parse::().unwrap(); - let cy = nums.next().unwrap().parse::().unwrap() - 1; - let cx = nums.next().unwrap().parse::().unwrap() - 1; + let cx = nums.next().unwrap().parse::().unwrap(); + let cy = nums.next().unwrap().parse::().unwrap(); let event = match cb { 32 => MouseEvent::Press(MouseButton::Left, cx, cy), @@ -259,8 +259,7 @@ where I: Iterator> /// Parse `c` as either a single byte ASCII char or a variable size UTF-8 char. fn parse_utf8_char(c: u8, iter: &mut I) -> Result -where I: Iterator> -{ + where I: Iterator> { let error = Err(Error::new(ErrorKind::Other, "Input character is not valid UTF-8")); if c.is_ascii() { Ok(c as char) diff --git a/src/input.rs b/src/input.rs index e5bdc14..4335511 100644 --- a/src/input.rs +++ b/src/input.rs @@ -176,11 +176,11 @@ mod test { assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Char('c'))); assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Backspace)); assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Left)); - assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Press(MouseButton::WheelUp, 4, 2))); - assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Press(MouseButton::Left, 4, 2))); - assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Press(MouseButton::Left, 3, 1))); - assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Release(4, 2))); - assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Release(3, 1))); + assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Press(MouseButton::WheelUp, 2, 4))); + assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Press(MouseButton::Left, 2, 4))); + assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Press(MouseButton::Left, 2, 4))); + assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Release(2, 4))); + assert_eq!(i.next().unwrap().unwrap(), Event::Mouse(MouseEvent::Release(2, 4))); assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Char('b'))); assert!(i.next().is_none()); }