logiguard fork v3: full patch set on verified 8c74db0 tree
Includes prior-session patches (carry forward so the app compiles): - crates/gpui/build.rs: cross-compile manifest fix - crates/gpui/src/platform.rs: PlatformWindow::activate_with_token trait method - crates/gpui/src/window.rs: Window::activate_with_token public API - crates/gpui_linux/src/linux/wayland/window.rs: WaylandWindow::activate_with_token + activate() keyboard-serial fix Plus the focus-serial fix: - serial.rs: SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; latest_serial_of() Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
15
crates/env_var/Cargo.toml
Normal file
15
crates/env_var/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "env_var"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
publish.workspace = true
|
||||
license = "GPL-3.0-or-later"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/env_var.rs"
|
||||
|
||||
[dependencies]
|
||||
gpui_shared_string.workspace = true
|
||||
1
crates/env_var/LICENSE-GPL
Symbolic link
1
crates/env_var/LICENSE-GPL
Symbolic link
@@ -0,0 +1 @@
|
||||
../../LICENSE-GPL
|
||||
40
crates/env_var/src/env_var.rs
Normal file
40
crates/env_var/src/env_var.rs
Normal file
@@ -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