diff --git a/Cargo.lock b/Cargo.lock index 9260377f..0375efc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3247,10 +3247,11 @@ dependencies = [ [[package]] name = "komorebi-layouts" version = "0.1.42" -source = "git+https://github.com/LGUG2Z/komorebi?rev=f08aa55511d77ca56ab0e789efabeb0a237a463e#f08aa55511d77ca56ab0e789efabeb0a237a463e" +source = "git+https://github.com/LGUG2Z/komorebi?rev=c6a780c6ceb696951765e7d1831bb8e5a8815d86#c6a780c6ceb696951765e7d1831bb8e5a8815d86" dependencies = [ "clap", "color-eyre", + "komorebi-scrolling", "objc2-core-foundation", "schemars 1.2.3", "serde", @@ -3260,10 +3261,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "komorebi-scrolling" +version = "0.1.42" +source = "git+https://github.com/LGUG2Z/komorebi?rev=c6a780c6ceb696951765e7d1831bb8e5a8815d86#c6a780c6ceb696951765e7d1831bb8e5a8815d86" + [[package]] name = "komorebi-themes" version = "0.1.42" -source = "git+https://github.com/LGUG2Z/komorebi?rev=f08aa55511d77ca56ab0e789efabeb0a237a463e#f08aa55511d77ca56ab0e789efabeb0a237a463e" +source = "git+https://github.com/LGUG2Z/komorebi?rev=c6a780c6ceb696951765e7d1831bb8e5a8815d86#c6a780c6ceb696951765e7d1831bb8e5a8815d86" dependencies = [ "base16-egui-themes", "catppuccin-egui", diff --git a/Cargo.toml b/Cargo.toml index 3a414ca2..995f4b88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ members = [ version = "0.1.0" [workspace.dependencies] -komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "f08aa55511d77ca56ab0e789efabeb0a237a463e" } -komorebi-layouts = { git = "https://github.com/LGUG2Z/komorebi", rev = "f08aa55511d77ca56ab0e789efabeb0a237a463e", features = [ +komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "c6a780c6ceb696951765e7d1831bb8e5a8815d86" } +komorebi-layouts = { git = "https://github.com/LGUG2Z/komorebi", rev = "c6a780c6ceb696951765e7d1831bb8e5a8815d86", features = [ "darwin", "schemars", ] } diff --git a/deny.toml b/deny.toml index cbf4a412..c4f7d090 100644 --- a/deny.toml +++ b/deny.toml @@ -53,6 +53,11 @@ crate = "komorebi-client" expression = "LicenseRef-Komorebi-2.0" license-files = [] +[[licenses.clarify]] +crate = "komorebi-scrolling" +expression = "LicenseRef-Komorebi-2.0" +license-files = [] + [[licenses.clarify]] crate = "komorebi-layouts" expression = "LicenseRef-Komorebi-2.0" diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index ecea9d70..c34724d4 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -31,6 +31,7 @@ pub use komorebi_layouts::OperationDirection; pub use komorebi_layouts::Rect; pub use komorebi_layouts::ScrollingLayoutOptions; pub use komorebi_layouts::Sizing; +pub use komorebi_layouts::scrolling::ScrollingCentering; pub use komorebi_layouts::validate_ratios; // Keep local modules that aren't in komorebi-layouts diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 644e691d..b5e3e3e9 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -2996,7 +2996,7 @@ mod tests { layout_options: Some(LayoutOptions { scrolling: Some(ScrollingLayoutOptions { columns: 2, - center_focused_column: Some(true), + center_focused_column: Some(crate::core::ScrollingCentering::Always), }), grid: None, column_ratios: None, @@ -3011,7 +3011,7 @@ mod tests { .layout_options .and_then(|o| o.scrolling) .and_then(|s| s.center_focused_column), - Some(true) + Some(crate::core::ScrollingCentering::Always) ); } diff --git a/nix/komorebi-options.nix b/nix/komorebi-options.nix index 243c853f..9608530d 100644 --- a/nix/komorebi-options.nix +++ b/nix/komorebi-options.nix @@ -211,9 +211,9 @@ let lib.types.submodule { options = { center_focused_column = lib.mkOption { - type = (lib.types.nullOr lib.types.bool); + type = lib.types.anything; default = null; - description = "With an odd number of visible columns, keep the focused window column centered"; + description = "When to centre the focused column: `Never` (the default), `Always`, or `OnOverflow`, which\nis when it does not fit on the screen together with the column that focus came from. A\nboolean is also accepted, where `true` is `Always` and `false` is `Never`"; }; columns = lib.mkOption { type = lib.types.int; diff --git a/schema.json b/schema.json index ca58137d..921c30c5 100644 --- a/schema.json +++ b/schema.json @@ -3395,16 +3395,44 @@ "b" ] }, + "ScrollingCentering": { + "description": "When the Scrolling layout centres the focused column\n\nA boolean is also accepted when reading, for the layout option that used to be one: `true` is\n`Always` and `false` is `Never`.", + "oneOf": [ + { + "description": "Scroll just far enough to bring the focused column into view, and no further", + "type": "string", + "const": "Never" + }, + { + "description": "Keep the focused column in the middle of the screen", + "type": "string", + "const": "Always" + }, + { + "description": "Centre the focused column when it does not fit on the screen together with the column that\nfocus came from", + "type": "string", + "const": "OnOverflow" + } + ] + }, "ScrollingLayoutOptions": { "description": "Options for the Scrolling layout", "type": "object", "properties": { "center_focused_column": { - "description": "With an odd number of visible columns, keep the focused window column centered", - "type": [ - "boolean", - "null" - ] + "description": "When to centre the focused column: `Never` (the default), `Always`, or `OnOverflow`, which\nis when it does not fit on the screen together with the column that focus came from. A\nboolean is also accepted, where `true` is `Always` and `false` is `Never`", + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/$defs/ScrollingCentering" + }, + { + "type": "null" + } + ], + "default": null }, "columns": { "description": "Desired number of visible columns (default: 3)",