Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

1.1 KB
Raw Blame
/// Expands to a literal so platform-specific hints can use `concat!` without allocating.
#[cfg(target_os = "macos")]
#[macro_export]
macro_rules! alt_key_name {
    () => {
        "option"
    };
}

/// Expands to a literal so platform-specific hints can use `concat!` without allocating.
#[cfg(not(target_os = "macos"))]
#[macro_export]
macro_rules! alt_key_name {
    () => {
        "alt"
    };
}

/// The platform style to use when rendering UI.
///
/// This can be used to abstract over platform differences.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub enum PlatformStyle {
    /// Display in macOS style.
    Mac,
    /// Display in Linux style.
    Linux,
    /// Display in Windows style.
    Windows,
}

impl PlatformStyle {
    /// Returns the [`PlatformStyle`] for the current platform.
    pub const fn platform() -> Self {
        if cfg!(any(target_os = "linux", target_os = "freebsd")) {
            Self::Linux
        } else if cfg!(target_os = "windows") {
            Self::Windows
        } else {
            Self::Mac
        }
    }
}