From 30afb4c32e19e5ea3f35cda8cfb8782221daab98 Mon Sep 17 00:00:00 2001
From: ticki <ticki@users.noreply.github.com>
Date: Sat, 23 Jul 2016 18:50:33 +0200
Subject: [PATCH] Fix examples & merge

---
 examples/color.rs   |  5 -----
 examples/keys.rs    |  3 ++-
 examples/mouse.rs   | 25 +++++++++++--------------
 examples/rainbow.rs |  3 ++-
 src/event.rs        |  3 +++
 src/scroll.rs       |  4 ++++
 6 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/examples/color.rs b/examples/color.rs
index 6cddc6fc..16071be9 100644
--- a/examples/color.rs
+++ b/examples/color.rs
@@ -2,14 +2,9 @@ extern crate termion;
 
 use termion::{color, style};
 
-use std::io;
-
 fn main() {
     println!("{}Red", color::Fg(color::Red));
-
     println!("{}Blue", color::Fg(color::Blue));
-
     println!("{}Blue'n'Bold{}", style::Bold, style::Reset);
-
     println!("{}Just plain italic", style::Italic);
 }
diff --git a/examples/keys.rs b/examples/keys.rs
index cda96418..3317a5a6 100644
--- a/examples/keys.rs
+++ b/examples/keys.rs
@@ -1,6 +1,7 @@
 extern crate termion;
 
-use termion::input::{TermRead, Key};
+use termion::event::Key;
+use termion::input::TermRead;
 use termion::raw::IntoRawMode;
 use std::io::{Write, stdout, stdin};
 
diff --git a/examples/mouse.rs b/examples/mouse.rs
index 9d8a5987..0c1c5952 100644
--- a/examples/mouse.rs
+++ b/examples/mouse.rs
@@ -1,24 +1,22 @@
 extern crate termion;
 
-fn main() {
-    use termion::{TermRead, TermWrite, IntoRawMode, Key, Event, MouseEvent};
-    use std::io::{Write, stdout, stdin};
+use termion::event::{Key, Event, MouseEvent};
+use termion::input::TermRead;
+use termion::raw::IntoRawMode;
+use std::io::{Write, stdout, stdin};
 
+fn main() {
     let stdin = stdin();
     let mut stdout = stdout().into_raw_mode().unwrap().with_mouse().unwrap();
 
-    stdout.clear().unwrap();
-    stdout.goto(0, 0).unwrap();
-    stdout.write(b"q to exit. Type stuff, use alt, click around...").unwrap();
-    stdout.flush().unwrap();
+    write!(stdout, "{}{}q to exit. Type stuff, use alt, click around...", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap();
 
-    let mut x = 0;
-    let mut y = 0;
+    let mut x = 1;
+    let mut y = 1;
 
     for c in stdin.events() {
-        stdout.goto(5, 5).unwrap();
-        stdout.clear_line().unwrap();
         let evt = c.unwrap();
+        writeln!(stdout, "{:?}{}{}", evt, termion::cursor::Goto(5, 5), termion::clear::CurrentLine).unwrap();
         match evt {
             Event::Key(Key::Char('q')) => break,
             Event::Mouse(me) => {
@@ -32,10 +30,9 @@ fn main() {
             }
             _ => {}
         }
-        println!("{:?}", evt);
-        stdout.goto(x, y).unwrap();
+        writeln!(stdout, "{:?}{}", evt, termion::cursor::Goto(x, y)).unwrap();
         stdout.flush().unwrap();
     }
 
-    stdout.show_cursor().unwrap();
+    write!(stdout, "{}", termion::cursor::Show).unwrap();
 }
diff --git a/examples/rainbow.rs b/examples/rainbow.rs
index 06c2710a..03c22821 100644
--- a/examples/rainbow.rs
+++ b/examples/rainbow.rs
@@ -2,8 +2,9 @@
 
 extern crate termion;
 
+use termion::event::Key;
+use termion::input::TermRead;
 use termion::raw::IntoRawMode;
-use termion::input::{TermRead, Key};
 use std::io::{Write, stdout, stdin};
 
 fn rainbow<W: Write>(stdout: &mut W, blue: u8) {
diff --git a/src/event.rs b/src/event.rs
index fde57f46..8d533d93 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -1,3 +1,5 @@
+//! Mouse and key events.
+
 use std::io::{Error, ErrorKind};
 use std::ascii::AsciiExt;
 use std::str;
@@ -273,6 +275,7 @@ where I: Iterator<Item = Result<u8, Error>>
     }
 }
 
+#[cfg(test)]
 #[test]
 fn test_parse_utf8() {
     let st = "abcéŷ¤£€ù%323";
diff --git a/src/scroll.rs b/src/scroll.rs
index 5bdf4d78..2744507f 100644
--- a/src/scroll.rs
+++ b/src/scroll.rs
@@ -1,3 +1,7 @@
+//! Scrolling.
+
+use std::fmt;
+
 /// Scroll up.
 #[derive(Copy, Clone, PartialEq, Eq)]
 pub struct Up(pub u16);
-- 
GitLab