aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-10-05 09:25:07 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-10-05 09:25:07 +0400
commit6fcdb4192275a8112fd45a91eb3e4b70c5ac684f (patch)
treebcd857c8e96952f81c5a049eeaec571c23b6febf /src/config.rs
parent3ac16074063db2cccdb10d9e5b832aaec0492bb4 (diff)
downloadniri-6fcdb4192275a8112fd45a91eb3e4b70c5ac684f.tar.gz
niri-6fcdb4192275a8112fd45a91eb3e4b70c5ac684f.tar.bz2
niri-6fcdb4192275a8112fd45a91eb3e4b70c5ac684f.zip
Refactor layout for configurability, add preset-column-widths option
layout.rs finally gets a struct actually named Layout.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index 730a0f4b..bb8cfcf6 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -22,6 +22,8 @@ pub struct Config {
pub prefer_no_csd: bool,
#[knuffel(child, default)]
pub cursor: Cursor,
+ #[knuffel(child, unwrap(children), default)]
+ pub preset_column_widths: Vec<PresetWidth>,
#[knuffel(child, default)]
pub binds: Binds,
#[knuffel(child, default)]
@@ -125,7 +127,7 @@ pub struct SpawnAtStartup {
pub command: Vec<String>,
}
-#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
+#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
pub struct FocusRing {
#[knuffel(child)]
pub off: bool,
@@ -189,6 +191,12 @@ impl Default for Cursor {
}
}
+#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
+pub enum PresetWidth {
+ Proportion(#[knuffel(argument)] f64),
+ Fixed(#[knuffel(argument)] i32),
+}
+
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
pub struct Binds(#[knuffel(children)] pub Vec<Bind>);
@@ -513,6 +521,13 @@ mod tests {
xcursor-size 16
}
+ preset-column-widths {
+ proportion 0.25
+ proportion 0.5
+ fixed 960
+ fixed 1280
+ }
+
binds {
Mod+T { spawn "alacritty"; }
Mod+Q { close-window; }
@@ -580,6 +595,12 @@ mod tests {
xcursor_theme: String::from("breeze_cursors"),
xcursor_size: 16,
},
+ preset_column_widths: vec![
+ PresetWidth::Proportion(0.25),
+ PresetWidth::Proportion(0.5),
+ PresetWidth::Fixed(960),
+ PresetWidth::Fixed(1280),
+ ],
binds: Binds(vec![
Bind {
key: Key {