diff --git a/src/async.rs b/src/async.rs index ea024891640682443424dd9e907409168b5a37cb..c0bd3d1bf63c4287e2d4d9a30a07db5f16ee0ec0 100644 --- a/src/async.rs +++ b/src/async.rs @@ -53,6 +53,7 @@ pub fn async_stdin() -> AsyncReader { /// /// This acts as any other stream, with the exception that reading from it won't block. Instead, /// the buffer will only be partially updated based on how much the internal buffer holds. +#[derive(Debug)] pub struct AsyncReader { /// The underlying mpsc receiver. recv: mpsc::Receiver>, diff --git a/src/cursor.rs b/src/cursor.rs index bbc039406746d62958bdd998649a966462aa8ace..0021d5993edaa1922ff29152964eb0827cf239d6 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -31,7 +31,7 @@ derive_csi_sequence!("Save the cursor.", Save, "s"); /// print!("{}{}Stuff", termion::clear::All, termion::cursor::Goto(5, 3)); /// } /// ``` -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Goto(pub u16, pub u16); impl From for String { @@ -55,7 +55,7 @@ impl fmt::Display for Goto { } /// Move cursor left. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Left(pub u16); impl From for String { @@ -72,7 +72,7 @@ impl fmt::Display for Left { } /// Move cursor right. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Right(pub u16); impl From for String { @@ -89,7 +89,7 @@ impl fmt::Display for Right { } /// Move cursor up. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Up(pub u16); impl From for String { @@ -106,7 +106,7 @@ impl fmt::Display for Up { } /// Move cursor down. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Down(pub u16); impl From for String { @@ -178,6 +178,7 @@ impl DetectCursorPos for W { /// Hide the cursor for the lifetime of this struct. /// It will hide the cursor on creation with from() and show it back on drop(). +#[derive(Debug)] pub struct HideCursor { /// The output target. output: W, diff --git a/src/input.rs b/src/input.rs index 5c8ecf4666a8560bba2ccc907856f74a8a84febc..c3a46e208ea309963adc8c734f3aa0b0efa54b3e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -7,6 +7,7 @@ use event::{self, Event, Key}; use raw::IntoRawMode; /// An iterator over input keys. +#[derive(Debug)] pub struct Keys { iter: Events, } @@ -27,6 +28,7 @@ impl Iterator for Keys { } /// An iterator over input events. +#[derive(Debug)] pub struct Events { inner: EventsAndRaw } @@ -40,6 +42,7 @@ impl Iterator for Events { } /// An iterator over input events and the bytes that define them. +#[derive(Debug)] pub struct EventsAndRaw { source: R, leftover: Option, @@ -182,6 +185,7 @@ const EXIT_MOUSE_SEQUENCE: &'static str = csi!("?1006l\x1b[?1015l\x1b[?1002l\x1b /// A terminal with added mouse support. /// /// This can be obtained through the `From` implementations. +#[derive(Debug)] pub struct MouseTerminal { term: W, } diff --git a/src/lib.rs b/src/lib.rs index 1d8f66fa1622d71cc5cb9e36a3cdec4ed68c97f8..e13567966c6945234a2e0415045e6b575161f6d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ //! Supports Redox, Mac OS X, and Linux (or, in general, ANSI terminals). //! //! For more information refer to the [README](https://github.com/redox-os/termion). +#![deny(missing_debug_implementations)] #![warn(missing_docs)] extern crate numtoa; diff --git a/src/macros.rs b/src/macros.rs index 5fd70b933a9e23eafdd2eae8d0548766eb805db2..10536380f9778702b17a58a83de6c16095cfedf7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -7,7 +7,7 @@ macro_rules! csi { macro_rules! derive_csi_sequence { ($doc:expr, $name:ident, $value:expr) => { #[doc = $doc] - #[derive(Copy, Clone)] + #[derive(Copy, Clone, Debug)] pub struct $name; impl fmt::Display for $name { diff --git a/src/raw.rs b/src/raw.rs index 0dbfb569e2f6cdf8ec75c1cee83138f6cd9b8b0f..096ea095f2b14d506bbd4dedc18bcd93498f7428 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -22,19 +22,32 @@ //! } //! ``` +use std::fmt; use std::io::{self, Write}; use std::ops; -use sys::Termios; +use sys::Termios as SysTermios; use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr}; /// The timeout of an escape code control sequence, in milliseconds. pub const CONTROL_SEQUENCE_TIMEOUT: u64 = 100; +/// A wrapper around sys::Termios that implements std::fmt::Debug. +// This workaround can go once libc gets adjusted so that all public +// types implement Debug https://github.com/rust-lang/rfcs/pull/2235. +struct Termios(SysTermios); + +impl fmt::Debug for Termios { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "termion::sys::Termios") + } +} + /// A terminal restorer, which keeps the previous state of the terminal, and restores it, when /// dropped. /// /// Restoring will entirely bring back the old TTY state. +#[derive(Debug)] pub struct RawTerminal { prev_ios: Termios, output: W, @@ -42,7 +55,7 @@ pub struct RawTerminal { impl Drop for RawTerminal { fn drop(&mut self) { - set_terminal_attr(&self.prev_ios).unwrap(); + set_terminal_attr(&self.prev_ios.0).unwrap(); } } @@ -95,7 +108,7 @@ impl IntoRawMode for W { set_terminal_attr(&ios)?; Ok(RawTerminal { - prev_ios: prev_ios, + prev_ios: Termios(prev_ios), output: self, }) } @@ -103,7 +116,7 @@ impl IntoRawMode for W { impl RawTerminal { pub fn suspend_raw_mode(&self) -> io::Result<()> { - set_terminal_attr(&self.prev_ios)?; + set_terminal_attr(&self.prev_ios.0)?; Ok(()) } diff --git a/src/screen.rs b/src/screen.rs index 822399e27c6a620d672e66ccc699c6907af4e234..7c27f85bf226fc5e3af2b40b1ca51abba4df245f 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -24,6 +24,7 @@ use std::ops; use std::fmt; /// Switch to the main screen buffer of the terminal. +#[derive(Debug)] pub struct ToMainScreen; impl fmt::Display for ToMainScreen { @@ -33,6 +34,7 @@ impl fmt::Display for ToMainScreen { } /// Switch to the alternate screen buffer of the terminal. +#[derive(Debug)] pub struct ToAlternateScreen; impl fmt::Display for ToAlternateScreen { @@ -46,6 +48,7 @@ impl fmt::Display for ToAlternateScreen { /// /// This is achieved by switching the terminal to the alternate screen on creation and /// automatically switching it back to the original screen on drop. +#[derive(Debug)] pub struct AlternateScreen { /// The output target. output: W, diff --git a/src/scroll.rs b/src/scroll.rs index 2744507f3c7a32404094e97b795b6c109a0134ff..3ab97ac9a77a1c70874bd8598a9e9e0d5c118b8b 100644 --- a/src/scroll.rs +++ b/src/scroll.rs @@ -3,7 +3,7 @@ use std::fmt; /// Scroll up. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Up(pub u16); impl fmt::Display for Up { @@ -13,7 +13,7 @@ impl fmt::Display for Up { } /// Scroll down. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Down(pub u16); impl fmt::Display for Down {