logiguard fork v2: patched GPUI on verified 8c74db0 tree
Rebuilt from the exact zed-industries/zed @ 8c74db00c4053d6c0a9037863d7bd048658da4ca tree (previous orphan was based on a stale/wrong fetch). Same 3-file patch: - serial.rs: add SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; add latest_serial_of() - window.rs: activate() uses keyboard-enter serial (Mutter focus gate) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
use gpui_shared_string::SharedString;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EnvVar {
|
||||
pub name: SharedString,
|
||||
/// Value of the environment variable. Also `None` when set to an empty string.
|
||||
pub value: Option<String>,
|
||||
}
|
||||
|
||||
impl EnvVar {
|
||||
pub fn new(name: SharedString) -> Self {
|
||||
let value = std::env::var(name.as_str()).ok();
|
||||
if value.as_ref().is_some_and(|v| v.is_empty()) {
|
||||
Self { name, value: None }
|
||||
} else {
|
||||
Self { name, value }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn or(self, other: EnvVar) -> EnvVar {
|
||||
if self.value.is_some() { self } else { other }
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a `LazyLock<EnvVar>` expression for use in a `static` declaration.
|
||||
#[macro_export]
|
||||
macro_rules! env_var {
|
||||
($name:expr) => {
|
||||
::std::sync::LazyLock::new(|| $crate::EnvVar::new(($name).into()))
|
||||
};
|
||||
}
|
||||
|
||||
/// Generates a `LazyLock<bool>` expression for use in a `static` declaration. Checks if the
|
||||
/// environment variable exists and is non-empty.
|
||||
#[macro_export]
|
||||
macro_rules! bool_env_var {
|
||||
($name:expr) => {
|
||||
::std::sync::LazyLock::new(|| $crate::EnvVar::new(($name).into()).value.is_some())
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user