#![deny(missing_docs)]

This commit is contained in:
Michael Zhang 2018-09-11 17:05:25 -05:00
parent dc9d6d3dc3
commit 7c07a21966
No known key found for this signature in database
GPG key ID: A1B65B603268116B
8 changed files with 18 additions and 7 deletions

View file

@ -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()?;

View file

@ -53,7 +53,6 @@ impl GUI {
}
/// Brings up an interactive selection GUI.
#[allow(dead_code)]
pub fn interactive_select(&self) -> Result<Rectangle, ScreenshotError> {
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)

View file

@ -1,7 +1,5 @@
//! Safe-ish bindings to imlib2 (at least the only parts I need).
#![deny(missing_docs)]
mod errors;
mod image;

View file

@ -1,4 +1,7 @@
//! Screenshot capturing utility.
#![feature(try_from)]
#![deny(missing_docs)]
#[macro_use]
extern crate failure;

View file

@ -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<Self, ScreenshotError> {
pub(self) fn from_str(x: &str) -> Result<Self, ScreenshotError> {
match x {
"fullscreen" => Ok(Region::Fullscreen),
"window" => Ok(Region::ActiveWindow),

View file

@ -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<Self, ScreenshotError> {
// TODO: unhardcode
let window = Window::create(display, None, Rectangle::new(0, 0, 1920, 1080))?;

View file

@ -11,6 +11,9 @@ pub struct Event {
/// Type of event
pub enum EventKind {
/// Was a button pressed
ButtonPress,
/// None event
None,
}

View file

@ -2,8 +2,6 @@
//!
//! I need this for my project.
#![deny(missing_docs)]
mod display;
mod drawable;
mod errors;