Skip to content

Commit

Permalink
Ran rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
msanders committed Feb 8, 2020
1 parent ae3ca0d commit fd1f7aa
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
comment_width = 79
error_on_line_overflow = true
format_strings = true
wrap_comments = true
10 changes: 5 additions & 5 deletions src/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use autopilot::alert::Response;
use pyo3::prelude::*;

/// Displays alert with the given attributes. If `cancel_button` is not
/// given, only the default button is displayed. Returns `True` if the
/// default button was pressed, or `False` if cancelled. Note that the
/// arguments are keywords, and can be passed as named parameters (e.g.,
/// `alert(msg='bar', title='foo')`).
/// Displays alert with the given attributes. If `cancel_button` is not given,
/// only the default button is displayed. Returns `True` if the default button
/// was pressed, or `False` if cancelled. Note that the arguments are keywords,
/// and can be passed as named parameters (e.g., `alert(msg='bar',
/// title='foo')`).
///
/// NOTE: Due to limitations in the Win32 API, Windows currently replaces
/// `default_button` with 'OK' and `cancel_button` (if given) with 'Cancel'.
Expand Down
34 changes: 17 additions & 17 deletions src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ impl pyo3::class::PyBufferProtocol for Bitmap {
#[pymethods]
impl Bitmap {
/// Saves image to absolute path in the given format. The image type is
/// determined from the filename if possible, unless format is given. If the
/// file already exists, it will be overwritten. Currently only jpeg and png
/// files are supported.
/// determined from the filename if possible, unless format is given. If
/// the file already exists, it will be overwritten. Currently only jpeg
/// and png files are supported.
///
/// Exceptions:
/// - `IOError` is thrown if the file could not be saved.
Expand Down Expand Up @@ -182,9 +182,9 @@ impl Bitmap {
}

/// Attempts to find `color` inside `rect` in `bmp` from the given
/// `start_point`. Returns coordinates if found, or `None` if not. If `rect`
/// is `None`, `bmp.bounds` is used instead. If `start_point` is `None`, the
/// origin of `rect` is used.
/// `start_point`. Returns coordinates if found, or `None` if not. If
/// `rect` is `None`, `bmp.bounds` is used instead. If `start_point` is
/// `None`, the origin of `rect` is used.
///
/// Tolerance is defined as a float in the range from 0 to 1, where 0 is an
/// exact match and 1 matches anything.
Expand All @@ -206,10 +206,10 @@ impl Bitmap {
}
}

/// Returns list of all `(x, y)` coordinates inside `rect` in `bmp` matching
/// `color` from the given `start_point`. If `rect` is `None`, `bmp.bounds`
/// is used instead. If `start_point` is `None`, the origin of `rect` is
/// used.
/// Returns list of all `(x, y)` coordinates inside `rect` in `bmp`
/// matching `color` from the given `start_point`. If `rect` is `None`,
/// `bmp.bounds` is used instead. If `start_point` is `None`, the origin of
/// `rect` is used.
fn find_every_color(
&self,
color: (u8, u8, u8),
Expand Down Expand Up @@ -251,9 +251,9 @@ impl Bitmap {
}

/// Attempts to find `needle` inside `rect` in `bmp` from the given
/// `start_point`. Returns coordinates if found, or `None` if not. If `rect`
/// is `None`, `bmp.bounds` is used instead. If `start_point` is `None`, the
/// origin of `rect` is used.
/// `start_point`. Returns coordinates if found, or `None` if not. If
/// `rect` is `None`, `bmp.bounds` is used instead. If `start_point` is
/// `None`, the origin of `rect` is used.
///
/// Tolerance is defined as a float in the range from 0 to 1, where 0 is an
/// exact match and 1 matches anything.
Expand All @@ -277,10 +277,10 @@ impl Bitmap {
}
}

/// Returns list of all `(x, y)` coordinates inside `rect` in `bmp` matching
/// `needle` from the given `start_point`. If `rect` is `None`, `bmp.bounds`
/// is used instead. If `start_point` is `None`, the origin of `rect` is
/// used.
/// Returns list of all `(x, y)` coordinates inside `rect` in `bmp`
/// matching `needle` from the given `start_point`. If `rect` is `None`,
/// `bmp.bounds` is used instead. If `start_point` is `None`, the origin of
/// `rect` is used.
fn find_every_bitmap(
&self,
needle: &Bitmap,
Expand Down
9 changes: 5 additions & 4 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use internal::rgb_to_hex;
use pyo3::prelude::*;

/// Returns hexadecimal value of given RGB tuple. `r`, `g`, and `b` must be
/// in the range 0 - 255.
/// Returns hexadecimal value of given RGB tuple. `r`, `g`, and `b` must be in
/// the range 0 - 255.
#[pyfunction]
fn py_rgb_to_hex(red: u8, green: u8, blue: u8) -> PyResult<u32> {
Ok(rgb_to_hex(red, green, blue))
Expand All @@ -25,8 +25,9 @@ fn hex_to_rgb(hex: u32) -> PyResult<(u8, u8, u8)> {
Ok((red, green, blue))
}

/// This module provides functions for converting between the hexadecimal format
/// used by autopy methods and other more readable formats (e.g., RGB tuples).
/// This module provides functions for converting between the hexadecimal
/// format used by autopy methods and other more readable formats (e.g., RGB
/// tuples).
#[pymodule(color)]
fn init(py: Python, m: &PyModule) -> PyResult<()> {
m.add("rgb_to_hex", wrap_pyfunction!(py_rgb_to_hex)(py))?;
Expand Down
4 changes: 2 additions & 2 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ fn toggle(
}
}

/// Convenience wrapper around `toggle()` that holds down and then releases
/// the given key and modifiers.
/// Convenience wrapper around `toggle()` that holds down and then releases the
/// given key and modifiers.
#[pyfunction]
fn tap(
key: &PyAny,
Expand Down
11 changes: 6 additions & 5 deletions src/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ fn location() -> PyResult<(f64, f64)> {
}

/// Holds down or releases the given mouse button in the current position.
/// Button can be `LEFT`, `RIGHT`, `MIDDLE`, or `None` to default to the
/// left button.
/// Button can be `LEFT`, `RIGHT`, `MIDDLE`, or `None` to default to the left
/// button.
#[pyfunction]
fn toggle(button: Option<&Button>, down: bool) -> PyResult<()> {
use autopilot::mouse::Button::*;
autopilot::mouse::toggle(button.map_or(Left, |x| x.button), down);
Ok(())
}

/// Convenience wrapper around `toggle()` that holds down and then releases
/// the given mouse button. By default, the left button is pressed.
/// Convenience wrapper around `toggle()` that holds down and then releases the
/// given mouse button. By default, the left button is pressed.
#[pyfunction]
fn click(button: Option<&Button>, delay: Option<f64>) -> PyResult<()> {
let delay_ms: Option<u64> = delay.map(|x| x as u64 * 1000);
Expand Down Expand Up @@ -97,7 +97,8 @@ fn smooth_move(x: f64, y: f64, duration: Option<f64>) -> PyResult<()> {
/// system, where the origin is at the top left.
#[pymodule(mouse)]
fn init(py: Python, m: &PyModule) -> PyResult<()> {
// Workaround bug where #[pyfunction(m, "move")] identifier causes error in pyo3.
// Workaround bug where #[pyfunction(m, "move")] identifier causes error in
// pyo3.
m.add("move", wrap_pyfunction!(move_py)(py))?;
m.add_wrapped(wrap_pyfunction!(location))?;
m.add_wrapped(wrap_pyfunction!(toggle))?;
Expand Down
6 changes: 2 additions & 4 deletions src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ use image::Pixel;
use internal::{rgb_to_hex, FromImageError};
use pyo3::prelude::*;

/// Returns the scale of the main screen, i.e. how many pixels are in a
/// point.
/// Returns the scale of the main screen, i.e. how many pixels are in a point.
#[pyfunction]
fn scale() -> PyResult<f64> {
Ok(autopilot::screen::scale())
}

/// Returns a tuple `(width, height)` of the size of the main screen in
/// points.
/// Returns a tuple `(width, height)` of the size of the main screen in points.
#[pyfunction]
fn size() -> PyResult<(f64, f64)> {
let size = autopilot::screen::size();
Expand Down

0 comments on commit fd1f7aa

Please sign in to comment.