mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 05:12:40 +03:00
allow window_decorations to work with config_builder
We need to manually convert to string, as the default ToDynamic impl encodes the underlying bits value from the bitfield and that doesn't round trip with the try_from String impl
This commit is contained in:
parent
44f31c9667
commit
b4dae6c2a3
@ -1271,7 +1271,7 @@ impl KeyEvent {
|
||||
bitflags! {
|
||||
#[derive(Deserialize, Serialize, FromDynamic, ToDynamic)]
|
||||
#[serde(try_from = "String")]
|
||||
#[dynamic(try_from = "String")]
|
||||
#[dynamic(try_from = "String", into = "String")]
|
||||
pub struct WindowDecorations: u8 {
|
||||
const TITLE = 1;
|
||||
const RESIZE = 2;
|
||||
@ -1283,6 +1283,28 @@ bitflags! {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<String> for &WindowDecorations {
|
||||
fn into(self) -> String {
|
||||
let mut s = vec![];
|
||||
if self.contains(WindowDecorations::TITLE) {
|
||||
s.push("TITLE");
|
||||
}
|
||||
if self.contains(WindowDecorations::RESIZE) {
|
||||
s.push("RESIZE");
|
||||
}
|
||||
if self.contains(WindowDecorations::MACOS_FORCE_ENABLE_SHADOW) {
|
||||
s.push("MACOS_FORCE_ENABLE_SHADOW");
|
||||
} else if self.contains(WindowDecorations::MACOS_FORCE_DISABLE_SHADOW) {
|
||||
s.push("MACOS_FORCE_DISABLE_SHADOW");
|
||||
}
|
||||
if s.is_empty() {
|
||||
"NONE".to_string()
|
||||
} else {
|
||||
s.join("|")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for WindowDecorations {
|
||||
type Error = String;
|
||||
fn try_from(s: String) -> std::result::Result<WindowDecorations, String> {
|
||||
|
Loading…
Reference in New Issue
Block a user