Skip to content

Commit

Permalink
all: Renamed EnigoSettings to Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pentamassiv committed Nov 8, 2023
1 parent 83c02d4 commit 35c6d94
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Cross platform input simulation in Rust!
- [x] Custom Parser

```Rust
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

enigo.mouse_move_to(500, 200);
enigo.mouse_click(MouseButton::Left);
Expand Down
4 changes: 2 additions & 2 deletions examples/dsl.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use enigo::{Enigo, EnigoSettings, KeyboardControllable};
use enigo::{Enigo, KeyboardControllable, Settings};
use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

// write text and select all
enigo.key_sequence_parse("{+UNICODE}{{Hello World!}} ❤️{-UNICODE}{+CTRL}a{-CTRL}");
Expand Down
4 changes: 2 additions & 2 deletions examples/key.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use enigo::{Enigo, EnigoSettings, Key, KeyboardControllable};
use enigo::{Enigo, Key, KeyboardControllable, Settings};
use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

enigo.key_down(Key::Unicode('a'));
thread::sleep(Duration::from_secs(1));
Expand Down
4 changes: 2 additions & 2 deletions examples/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use enigo::{Enigo, EnigoSettings, Key, KeyboardControllable};
use enigo::{Enigo, Key, KeyboardControllable, Settings};
use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

// write text
enigo.key_sequence("Hello World! here is a lot of text ❤️");
Expand Down
4 changes: 2 additions & 2 deletions examples/layout.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use enigo::{Enigo, EnigoSettings, Key, KeyboardControllable};
use enigo::{Enigo, Key, KeyboardControllable, Settings};
use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
thread::sleep(Duration::from_secs(4));
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

enigo.key_click(Key::PageDown);
enigo.key_click(enigo::Key::UpArrow);
Expand Down
4 changes: 2 additions & 2 deletions examples/mouse.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use enigo::{Enigo, EnigoSettings, MouseButton, MouseControllable};
use enigo::{Enigo, MouseButton, MouseControllable, Settings};
use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
let wait_time = Duration::from_secs(2);
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

thread::sleep(Duration::from_secs(4));
println!("screen dimensions: {:?}", enigo.main_display_size());
Expand Down
4 changes: 2 additions & 2 deletions examples/platform_specific.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use enigo::{Enigo, EnigoSettings, Key, KeyboardControllable};
use enigo::{Enigo, Key, KeyboardControllable, Settings};
use std::thread;
use std::time::Duration;

// This example will do different things depending on the platform
fn main() {
env_logger::init();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

#[cfg(target_os = "macos")]
enigo.key_click(Key::Launchpad); // macOS: Open launchpad
Expand Down
4 changes: 2 additions & 2 deletions examples/timer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use enigo::EnigoSettings;
use enigo::Settings;
use enigo::{Enigo, Key, KeyboardControllable};
use std::thread;
use std::time::Duration;
Expand All @@ -7,7 +7,7 @@ use std::time::Instant;
fn main() {
env_logger::init();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();

let now = Instant::now();

Expand Down
28 changes: 14 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! # Examples
//! ```no_run
//! use enigo::*;
//! let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
//! let mut enigo = Enigo::new(&Settings::default()).unwrap();
//! //paste
//! enigo.key_down(Key::Control);
//! enigo.key_click(Key::Unicode('v'));
Expand All @@ -34,7 +34,7 @@
//!
//! ```no_run
//! use enigo::*;
//! let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
//! let mut enigo = Enigo::new(&Settings::default()).unwrap();
//! enigo.mouse_move_to(500, 200);
//! enigo.mouse_down(MouseButton::Left);
//! enigo.mouse_move_relative(100, 100);
Expand Down Expand Up @@ -132,7 +132,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_move_to(500, 200);
/// ```
fn mouse_move_to(&mut self, x: i32, y: i32) {
Expand All @@ -155,7 +155,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_move_relative(100, 100);
/// ```
fn mouse_move_relative(&mut self, x: i32, y: i32) {
Expand All @@ -179,7 +179,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_down(MouseButton::Left);
/// ```
fn mouse_down(&mut self, button: MouseButton) {
Expand All @@ -205,7 +205,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_down(MouseButton::Right);
/// enigo.mouse_up(MouseButton::Right);
/// ```
Expand All @@ -230,7 +230,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_click(MouseButton::Right);
/// ```
fn mouse_click(&mut self, button: MouseButton) {
Expand All @@ -255,7 +255,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_scroll_x(2);
/// ```
fn mouse_scroll_x(&mut self, length: i32) {
Expand All @@ -280,7 +280,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.mouse_scroll_y(2);
/// ```
fn mouse_scroll_y(&mut self, length: i32) {
Expand All @@ -300,7 +300,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// let (width, height) = enigo.main_display_size();
/// ```
#[must_use]
Expand All @@ -320,7 +320,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// let (x, y) = enigo.mouse_location();
/// ```
#[must_use]
Expand Down Expand Up @@ -381,7 +381,7 @@ where
///
/// ```no_run
/// use enigo::*;
/// let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
/// let mut enigo = Enigo::new(&Settings::default()).unwrap();
/// enigo.key_sequence("hello world ❤️");
/// ```
fn key_sequence(&mut self, sequence: &str) {
Expand Down Expand Up @@ -668,7 +668,7 @@ impl Error for NewConError {}
/// Settings for creating the Enigo stuct and it's behaviour
#[allow(dead_code)] // It is not dead code on other platforms
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EnigoSettings {
pub struct Settings {
/// Sleep delay on macOS
pub mac_delay: u32,
/// Sleep delay on Linux X11
Expand All @@ -682,7 +682,7 @@ pub struct EnigoSettings {
pub release_keys_when_dropped: bool,
}

impl Default for EnigoSettings {
impl Default for Settings {
fn default() -> Self {
debug!("using default settings");
Self {
Expand Down
8 changes: 4 additions & 4 deletions src/linux/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use log::{debug, error, trace, warn};

use crate::{
Axis, Coordinate, Direction, EnigoSettings, InputError, InputResult, Key,
KeyboardControllableNext, MouseButton, MouseControllableNext, NewConError,
Axis, Coordinate, Direction, InputError, InputResult, Key, KeyboardControllableNext,
MouseButton, MouseControllableNext, NewConError, Settings,
};

// If none of these features is enabled, there is no way to simulate input
Expand Down Expand Up @@ -42,10 +42,10 @@ impl Enigo {
/// # Errors
/// Have a look at the documentation of `NewConError` to see under which
/// conditions an error will be returned.
pub fn new(settings: &EnigoSettings) -> Result<Self, NewConError> {
pub fn new(settings: &Settings) -> Result<Self, NewConError> {
let mut connection_established = false;
#[allow(unused_variables)]
let EnigoSettings {
let Settings {
linux_delay,
x11_display,
wayland_display,
Expand Down
8 changes: 4 additions & 4 deletions src/macos/macos_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use log::{debug, error, info};
use objc::{class, msg_send, runtime::Class, sel, sel_impl};

use crate::{
Axis, Coordinate, Direction, EnigoSettings, InputError, InputResult, Key,
KeyboardControllableNext, MouseButton, MouseControllableNext, NewConError,
Axis, Coordinate, Direction, InputError, InputResult, Key, KeyboardControllableNext,
MouseButton, MouseControllableNext, NewConError, Settings,
};

// required for NSEvent
Expand Down Expand Up @@ -422,8 +422,8 @@ impl Enigo {
/// # Errors
/// Have a look at the documentation of `NewConError` to see under which
/// conditions an error will be returned.
pub fn new(settings: &EnigoSettings) -> Result<Self, NewConError> {
let EnigoSettings {
pub fn new(settings: &Settings) -> Result<Self, NewConError> {
let Settings {
mac_delay: delay,
release_keys_when_dropped,
..
Expand Down
8 changes: 4 additions & 4 deletions src/win/win_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use windows::Win32::UI::WindowsAndMessaging::{
};

use crate::{
Axis, Coordinate, Direction, EnigoSettings, InputError, InputResult, Key,
KeyboardControllableNext, MouseButton, MouseControllableNext, NewConError,
Axis, Coordinate, Direction, InputError, InputResult, Key, KeyboardControllableNext,
MouseButton, MouseControllableNext, NewConError, Settings,
};

type ScanCode = u16;
Expand Down Expand Up @@ -361,8 +361,8 @@ impl Enigo {
/// # Errors
/// Have a look at the documentation of `NewConError` to see under which
/// conditions an error will be returned.
pub fn new(settings: &EnigoSettings) -> Result<Self, NewConError> {
let EnigoSettings {
pub fn new(settings: &Settings) -> Result<Self, NewConError> {
let Settings {
release_keys_when_dropped,
..
} = settings;
Expand Down
4 changes: 2 additions & 2 deletions tests/browser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::mpsc::channel;

use common::BrowserEvent;
use enigo::{Enigo, EnigoSettings, Key, KeyboardControllable};
use enigo::{Enigo, Key, KeyboardControllable, Settings};

mod common;

Expand All @@ -16,7 +16,7 @@ fn browser_events() {
common::launch_browser(&rs);
println!("Browser was launched");

let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.key_click(Key::F11);
// Full screen animation
std::thread::sleep(std::time::Duration::from_millis(3000));
Expand Down
4 changes: 2 additions & 2 deletions tests/common/key.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::mpsc::Receiver;

use enigo::{Enigo, EnigoSettings, Key, KeyboardControllable};
use enigo::{Enigo, Key, KeyboardControllable, Settings};

use super::BrowserEvent;

Expand All @@ -12,7 +12,7 @@ pub fn run(recv: &Receiver<BrowserEvent>) {
}

fn press(recv: &Receiver<BrowserEvent>, key: Key) {
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.key_down(key);
let ev = recv
.recv_timeout(std::time::Duration::from_millis(5000))
Expand Down
8 changes: 4 additions & 4 deletions tests/common/mouse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::mpsc::Receiver;

use enigo::{Enigo, EnigoSettings, MouseControllable};
use enigo::{Enigo, MouseControllable, Settings};

use super::BrowserEvent;

Expand All @@ -24,7 +24,7 @@ pub fn run(recv: &Receiver<BrowserEvent>) {
}

fn set(recv: &Receiver<BrowserEvent>, position: (i32, i32)) {
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.mouse_move_to(position.0, position.1);
println!("Executed Enigo");
let ev = recv
Expand All @@ -41,7 +41,7 @@ fn set(recv: &Receiver<BrowserEvent>, position: (i32, i32)) {
}

fn rel(recv: &Receiver<BrowserEvent>, offset: (i32, i32)) {
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.mouse_move_relative(offset.0, offset.1);
println!("Executed Enigo");
let ev = recv
Expand All @@ -58,7 +58,7 @@ fn rel(recv: &Receiver<BrowserEvent>, offset: (i32, i32)) {
}

fn scroll(recv: &Receiver<BrowserEvent>) {
let mut enigo = Enigo::new(&EnigoSettings::default()).unwrap();
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.mouse_scroll_x(1);
println!("Executed Enigo");
let ev = recv
Expand Down

0 comments on commit 35c6d94

Please sign in to comment.