#![deny(missing_docs)]
This commit is contained in:
parent
dc9d6d3dc3
commit
7c07a21966
8 changed files with 18 additions and 7 deletions
|
@ -3,6 +3,7 @@ use errors::ScreenshotError;
|
||||||
use gui::GUI;
|
use gui::GUI;
|
||||||
use options::{Options, Region};
|
use options::{Options, Region};
|
||||||
|
|
||||||
|
/// The main capture routine.
|
||||||
pub fn capture(opt: &Options) -> Result<(), ScreenshotError> {
|
pub fn capture(opt: &Options) -> Result<(), ScreenshotError> {
|
||||||
let gui = GUI::new()?;
|
let gui = GUI::new()?;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ impl GUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Brings up an interactive selection GUI.
|
/// Brings up an interactive selection GUI.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn interactive_select(&self) -> Result<Rectangle, ScreenshotError> {
|
pub fn interactive_select(&self) -> Result<Rectangle, ScreenshotError> {
|
||||||
let window = SelectWindow::new(&self.display);
|
let window = SelectWindow::new(&self.display);
|
||||||
let root = self.display.get_default_root_window()?;
|
let root = self.display.get_default_root_window()?;
|
||||||
|
@ -64,7 +63,8 @@ impl GUI {
|
||||||
while done == 0 && self.display.pending()? > 0 {
|
while done == 0 && self.display.pending()? > 0 {
|
||||||
let ev = self.display.next_event()?;
|
let ev = self.display.next_event()?;
|
||||||
match ev.kind() {
|
match ev.kind() {
|
||||||
EventKind::None => (),
|
EventKind::ButtonPress => (),
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(ScreenshotError::Error)
|
Err(ScreenshotError::Error)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
//! Safe-ish bindings to imlib2 (at least the only parts I need).
|
//! Safe-ish bindings to imlib2 (at least the only parts I need).
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
|
||||||
|
|
||||||
mod errors;
|
mod errors;
|
||||||
mod image;
|
mod image;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
//! Screenshot capturing utility.
|
||||||
|
|
||||||
#![feature(try_from)]
|
#![feature(try_from)]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
|
|
|
@ -2,26 +2,32 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use ScreenshotError;
|
use ScreenshotError;
|
||||||
|
|
||||||
|
/// A region option
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum Region {
|
pub enum Region {
|
||||||
Fullscreen,
|
Fullscreen,
|
||||||
ActiveWindow,
|
ActiveWindow,
|
||||||
Selection,
|
Selection,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Optiosn for screenshot
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
|
/// The region to select
|
||||||
#[structopt(parse(try_from_str = "Region::from_str"))]
|
#[structopt(parse(try_from_str = "Region::from_str"))]
|
||||||
pub region: Region,
|
pub region: Region,
|
||||||
|
|
||||||
|
/// The file to save the screenshot to
|
||||||
#[structopt(short = "o", long = "out", parse(from_os_str))]
|
#[structopt(short = "o", long = "out", parse(from_os_str))]
|
||||||
pub outfile: PathBuf,
|
pub outfile: PathBuf,
|
||||||
|
|
||||||
|
/// Whether or not to also copy it to the clipboard
|
||||||
#[structopt(short = "c")]
|
#[structopt(short = "c")]
|
||||||
pub clipboard: bool,
|
pub clipboard: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Region {
|
impl Region {
|
||||||
pub fn from_str(x: &str) -> Result<Self, ScreenshotError> {
|
pub(self) fn from_str(x: &str) -> Result<Self, ScreenshotError> {
|
||||||
match x {
|
match x {
|
||||||
"fullscreen" => Ok(Region::Fullscreen),
|
"fullscreen" => Ok(Region::Fullscreen),
|
||||||
"window" => Ok(Region::ActiveWindow),
|
"window" => Ok(Region::ActiveWindow),
|
||||||
|
|
|
@ -2,11 +2,13 @@ use xlib::{Display, Rectangle, Window};
|
||||||
|
|
||||||
use errors::ScreenshotError;
|
use errors::ScreenshotError;
|
||||||
|
|
||||||
|
/// A window that's opened for the user to select a region
|
||||||
pub struct SelectWindow {
|
pub struct SelectWindow {
|
||||||
inner: Window,
|
inner: Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SelectWindow {
|
impl SelectWindow {
|
||||||
|
/// Creates a new SelectWindow
|
||||||
pub fn new(display: &Display) -> Result<Self, ScreenshotError> {
|
pub fn new(display: &Display) -> Result<Self, ScreenshotError> {
|
||||||
// TODO: unhardcode
|
// TODO: unhardcode
|
||||||
let window = Window::create(display, None, Rectangle::new(0, 0, 1920, 1080))?;
|
let window = Window::create(display, None, Rectangle::new(0, 0, 1920, 1080))?;
|
||||||
|
|
|
@ -11,6 +11,9 @@ pub struct Event {
|
||||||
|
|
||||||
/// Type of event
|
/// Type of event
|
||||||
pub enum EventKind {
|
pub enum EventKind {
|
||||||
|
/// Was a button pressed
|
||||||
|
ButtonPress,
|
||||||
|
|
||||||
/// None event
|
/// None event
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
//!
|
//!
|
||||||
//! I need this for my project.
|
//! I need this for my project.
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
|
||||||
|
|
||||||
mod display;
|
mod display;
|
||||||
mod drawable;
|
mod drawable;
|
||||||
mod errors;
|
mod errors;
|
||||||
|
|
Loading…
Reference in a new issue