Skip to content

Commit c98a2f1

Browse files
committed
Initial refactoring of displayz
- 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.
1 parent a3da03b commit c98a2f1

16 files changed

Lines changed: 257 additions & 35 deletions

File tree

Cargo.lock

Lines changed: 170 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ keywords = ["display", "settings", "cli"]
1313
categories = ["command-line-utilities", "config"]
1414

1515
[dependencies]
16-
color-eyre = "0.6.1"
17-
env_logger = "0.9.0"
18-
log = "0.4.17"
16+
color-eyre = "0.6.2"
17+
env_logger = "0.10.0"
18+
log = "0.4.18"
1919
structopt = "0.3.26"
20-
thiserror = "1.0.31"
21-
winsafe = { version = "0.0.10", features = ["user"] }
20+
thiserror = "1.0.40"
21+
22+
[target.'cfg(target_os = "windows")'.dependencies]
23+
winsafe = { version = "0.0.16", features = ["user"] }

examples/find.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#[cfg(windows)]
12
use displayz::query_displays;
23

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

3335
Ok(())
3436
}
37+
38+
#[cfg(not(windows))]
39+
fn main() {}

examples/primary.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#[cfg(windows)]
12
use displayz::{query_displays, refresh};
23

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

2325
Ok(())
2426
}
27+
28+
#[cfg(not(windows))]
29+
fn main() {}

examples/resolution.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#[cfg(windows)]
12
use displayz::{query_displays, refresh, Resolution};
23

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

2628
Ok(())
2729
}
30+
31+
#[cfg(not(windows))]
32+
fn main() {}

0 commit comments

Comments
 (0)