Skip to content

Commit

Permalink
Initial refactoring of displayz
Browse files Browse the repository at this point in the history
- Bump Cargo.lock and dependencies.
- Use `cfg_attr` to expose platform-specific APIs in the `platform`
  module, then export with `pub use`.
- Create initial `common` module for abstracting displays.
- Make examples only run on Windows - pending refactoring of Windows
  backend.
- Add lints.

Resolves #michidkgh-2.
  • Loading branch information
shymega committed Jun 21, 2023
1 parent a3da03b commit f40bbc2
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 35 deletions.
196 changes: 170 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ keywords = ["display", "settings", "cli"]
categories = ["command-line-utilities", "config"]

[dependencies]
color-eyre = "0.6.1"
env_logger = "0.9.0"
log = "0.4.17"
color-eyre = "0.6.2"
env_logger = "0.10.0"
log = "0.4.18"
structopt = "0.3.26"
thiserror = "1.0.31"
winsafe = { version = "0.0.10", features = ["user"] }
thiserror = "1.0.40"

[target.'cfg(target_os = "windows")'.dependencies]
winsafe = { version = "0.0.16", features = ["user"] }
5 changes: 5 additions & 0 deletions examples/find.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(windows)]
use displayz::query_displays;

/// Finds displays by name and index
#[cfg(windows)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let display_set = query_displays()?;
println!("Discovered displays:\n{}", display_set);
Expand Down Expand Up @@ -32,3 +34,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

#[cfg(not(windows))]
fn main() {}
5 changes: 5 additions & 0 deletions examples/primary.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(windows)]
use displayz::{query_displays, refresh};

/// Sets a display to be the new primary display
#[cfg(windows)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let display_set = query_displays()?;
println!("Discovered displays:\n{}", display_set);
Expand All @@ -22,3 +24,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

#[cfg(not(windows))]
fn main() {}
5 changes: 5 additions & 0 deletions examples/resolution.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(windows)]
use displayz::{query_displays, refresh, Resolution};

/// Prints and changes the current resolution of the primary display
#[cfg(windows)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let display_set = query_displays()?;
println!("Discovered displays:\n{}", display_set);
Expand All @@ -25,3 +27,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

#[cfg(not(windows))]
fn main() {}
Loading

0 comments on commit f40bbc2

Please sign in to comment.