From d0d3ffcf7ba246114950cb44eb635eefa36641e6 Mon Sep 17 00:00:00 2001 From: LoganDark Date: Thu, 9 Jul 2020 01:21:18 -0700 Subject: [PATCH] Rename `unix`es to `posix` (#197) * Rename `unix`es to `posix` * Whoops * deprecate get_unix_menus in favor of get_posix_menus * doc fixes --- build.rs | 2 +- examples/menu.rs | 2 +- src/lib.rs | 27 +++++++++++++++++++-------- src/native/{unix => posix}/scalar.cpp | 0 src/os/mod.rs | 2 +- src/os/{unix => posix}/common.rs | 0 src/os/{unix => posix}/mod.rs | 6 +++--- src/os/{unix => posix}/wayland.rs | 2 +- src/os/{unix => posix}/x11.rs | 2 +- src/os/redox/mod.rs | 2 +- 10 files changed, 28 insertions(+), 17 deletions(-) rename src/native/{unix => posix}/scalar.cpp (100%) rename src/os/{unix => posix}/common.rs (100%) rename src/os/{unix => posix}/mod.rs (98%) rename src/os/{unix => posix}/wayland.rs (99%) rename src/os/{unix => posix}/x11.rs (99%) diff --git a/build.rs b/build.rs index 07b0092..c96e793 100644 --- a/build.rs +++ b/build.rs @@ -24,7 +24,7 @@ fn main() { } else if !env.contains("windows") { // build scalar on non-windows and non-mac cc::Build::new() - .file("src/native/unix/scalar.cpp") + .file("src/native/posix/scalar.cpp") .opt_level(3) // always build with opts for scaler so it's fast in debug also .compile("libscalar.a") } diff --git a/examples/menu.rs b/examples/menu.rs index 44cab10..44f8d5a 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -66,7 +66,7 @@ fn main() { let menu_handle = window.add_menu(&menu); - window.get_unix_menus().map(|menus| { + window.get_posix_menus().map(|menus| { println!("Menus {:?}", menus); }); diff --git a/src/lib.rs b/src/lib.rs index f9e54fa..18ef6df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,7 +113,7 @@ use self::os::redox as imp; target_os = "netbsd", target_os = "openbsd" ))] -use self::os::unix as imp; +use self::os::posix as imp; #[cfg(target_os = "windows")] use self::os::windows as imp; /// @@ -704,7 +704,7 @@ impl Window { /// on which window you have active. /// Linux/BSD/etc: /// Menus aren't supported as they depend on each WindowManager and is outside of the - /// scope for this library to support. Use [get_unix_menus] to get a structure + /// scope for this library to support. Use [get_posix_menus] to get a structure /// ``` /// #[inline] @@ -721,11 +721,11 @@ impl Window { } /// - /// Get Unix menu. Will only return menus on Unix class OSes + /// Get POSIX menus. Will only return menus on POSIX-like OSes like Linux or BSD /// otherwise ```None``` /// #[cfg(any(target_os = "macos", target_os = "windows"))] - pub fn get_unix_menus(&self) -> Option<&Vec> { + pub fn get_posix_menus(&self) -> Option<&Vec> { None } @@ -737,8 +737,16 @@ impl Window { target_os = "openbsd", target_os = "redox" ))] + pub fn get_posix_menus(&self) -> Option<&Vec> { + self.0.get_posix_menus() + } + + #[deprecated( + since = "0.17.0", + note = "`get_unix_menus` will be removed in 1.0.0, use `get_posix_menus` instead" + )] pub fn get_unix_menus(&self) -> Option<&Vec> { - self.0.get_unix_menus() + self.get_posix_menus() } /// @@ -764,8 +772,11 @@ pub const MENU_KEY_ALT: usize = 16; const MENU_ID_SEPARATOR: usize = 0xffffffff; /// -/// Used on Unix (Linux, FreeBSD, etc) as menus aren't supported in a native where there. -/// This structure can be used by calling [#get_unix_menus] on Window. +/// Used on POSIX systems (Linux, FreeBSD, etc) as menus aren't supported in a native way there. +/// This structure can be used by calling [#get_posix_menus] on Window. +/// +/// In version 1.0.0, this struct will be renamed to PosixMenu, but it remains UnixMenu for backwards compatibility +/// reasons. /// #[derive(Debug, Clone)] pub struct UnixMenu { @@ -780,7 +791,7 @@ pub struct UnixMenu { } /// -/// Used for on Unix (Linux, FreeBSD, etc) as menus aren't supported in a native where there. +/// Used on POSIX systems (Linux, FreeBSD, etc) as menus aren't supported in a native way there. /// This structure holds info for each item in a #UnixMenu /// #[derive(Debug, Clone)] diff --git a/src/native/unix/scalar.cpp b/src/native/posix/scalar.cpp similarity index 100% rename from src/native/unix/scalar.cpp rename to src/native/posix/scalar.cpp diff --git a/src/os/mod.rs b/src/os/mod.rs index 0fd7620..a298d0d 100644 --- a/src/os/mod.rs +++ b/src/os/mod.rs @@ -9,6 +9,6 @@ pub mod redox; target_os = "netbsd", target_os = "openbsd" ))] -pub mod unix; +pub mod posix; #[cfg(target_os = "windows")] pub mod windows; diff --git a/src/os/unix/common.rs b/src/os/posix/common.rs similarity index 100% rename from src/os/unix/common.rs rename to src/os/posix/common.rs diff --git a/src/os/unix/mod.rs b/src/os/posix/mod.rs similarity index 98% rename from src/os/unix/mod.rs rename to src/os/posix/mod.rs index 5fb19dd..b9c67cc 100644 --- a/src/os/unix/mod.rs +++ b/src/os/posix/mod.rs @@ -309,12 +309,12 @@ impl Window { } } - pub fn get_unix_menus(&self) -> Option<&Vec> { + pub fn get_posix_menus(&self) -> Option<&Vec> { match *self { #[cfg(feature = "x11")] - Window::X11(ref w) => w.get_unix_menus(), + Window::X11(ref w) => w.get_posix_menus(), #[cfg(feature = "wayland")] - Window::Wayland(ref w) => w.get_unix_menus(), + Window::Wayland(ref w) => w.get_posix_menus(), } } diff --git a/src/os/unix/wayland.rs b/src/os/posix/wayland.rs similarity index 99% rename from src/os/unix/wayland.rs rename to src/os/posix/wayland.rs index a04512f..8dbd986 100644 --- a/src/os/unix/wayland.rs +++ b/src/os/posix/wayland.rs @@ -694,7 +694,7 @@ impl Window { handle } - pub fn get_unix_menus(&self) -> Option<&Vec> { + pub fn get_posix_menus(&self) -> Option<&Vec> { //FIXME unimplemented!() } diff --git a/src/os/unix/x11.rs b/src/os/posix/x11.rs similarity index 99% rename from src/os/unix/x11.rs rename to src/os/posix/x11.rs index 1b74a9b..122aa58 100644 --- a/src/os/unix/x11.rs +++ b/src/os/posix/x11.rs @@ -775,7 +775,7 @@ impl Window { handle } - pub fn get_unix_menus(&self) -> Option<&Vec> { + pub fn get_posix_menus(&self) -> Option<&Vec> { Some(&self.menus) } diff --git a/src/os/redox/mod.rs b/src/os/redox/mod.rs index 791c290..91c9280 100644 --- a/src/os/redox/mod.rs +++ b/src/os/redox/mod.rs @@ -393,7 +393,7 @@ impl Window { handle } - pub fn get_unix_menus(&self) -> Option<&Vec> { + pub fn get_posix_menus(&self) -> Option<&Vec> { Some(&self.menus) }