diff --git a/src/capture.rs b/src/capture.rs index 5999b98..cd98fa4 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -3,6 +3,7 @@ use errors::ScreenshotError; use gui::GUI; use options::{Options, Region}; +/// The main capture routine. pub fn capture(opt: &Options) -> Result<(), ScreenshotError> { let gui = GUI::new()?; diff --git a/src/gui.rs b/src/gui.rs index 8aba5cf..01bae88 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -53,7 +53,6 @@ impl GUI { } /// Brings up an interactive selection GUI. - #[allow(dead_code)] pub fn interactive_select(&self) -> Result { let window = SelectWindow::new(&self.display); let root = self.display.get_default_root_window()?; @@ -64,7 +63,8 @@ impl GUI { while done == 0 && self.display.pending()? > 0 { let ev = self.display.next_event()?; match ev.kind() { - EventKind::None => (), + EventKind::ButtonPress => (), + _ => (), } } Err(ScreenshotError::Error) diff --git a/src/imlib2/mod.rs b/src/imlib2/mod.rs index 179a91a..577a825 100644 --- a/src/imlib2/mod.rs +++ b/src/imlib2/mod.rs @@ -1,7 +1,5 @@ //! Safe-ish bindings to imlib2 (at least the only parts I need). -#![deny(missing_docs)] - mod errors; mod image; diff --git a/src/lib.rs b/src/lib.rs index ae3fcf9..0ac8452 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,7 @@ +//! Screenshot capturing utility. + #![feature(try_from)] +#![deny(missing_docs)] #[macro_use] extern crate failure; diff --git a/src/options.rs b/src/options.rs index ce01a96..7faf593 100644 --- a/src/options.rs +++ b/src/options.rs @@ -2,26 +2,32 @@ use std::path::PathBuf; use ScreenshotError; +/// A region option +#[allow(missing_docs)] pub enum Region { Fullscreen, ActiveWindow, Selection, } +/// Optiosn for screenshot #[derive(StructOpt)] pub struct Options { + /// The region to select #[structopt(parse(try_from_str = "Region::from_str"))] pub region: Region, + /// The file to save the screenshot to #[structopt(short = "o", long = "out", parse(from_os_str))] pub outfile: PathBuf, + /// Whether or not to also copy it to the clipboard #[structopt(short = "c")] pub clipboard: bool, } impl Region { - pub fn from_str(x: &str) -> Result { + pub(self) fn from_str(x: &str) -> Result { match x { "fullscreen" => Ok(Region::Fullscreen), "window" => Ok(Region::ActiveWindow), diff --git a/src/window.rs b/src/window.rs index 80beb08..da21997 100644 --- a/src/window.rs +++ b/src/window.rs @@ -2,11 +2,13 @@ use xlib::{Display, Rectangle, Window}; use errors::ScreenshotError; +/// A window that's opened for the user to select a region pub struct SelectWindow { inner: Window, } impl SelectWindow { + /// Creates a new SelectWindow pub fn new(display: &Display) -> Result { // TODO: unhardcode let window = Window::create(display, None, Rectangle::new(0, 0, 1920, 1080))?; diff --git a/src/xlib/event.rs b/src/xlib/event.rs index 414a01e..693d495 100644 --- a/src/xlib/event.rs +++ b/src/xlib/event.rs @@ -11,6 +11,9 @@ pub struct Event { /// Type of event pub enum EventKind { + /// Was a button pressed + ButtonPress, + /// None event None, } diff --git a/src/xlib/mod.rs b/src/xlib/mod.rs index 5cb5a7d..1b7855c 100644 --- a/src/xlib/mod.rs +++ b/src/xlib/mod.rs @@ -2,8 +2,6 @@ //! //! I need this for my project. -#![deny(missing_docs)] - mod display; mod drawable; mod errors;