mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-23 09:08:36 +02:00
feat(cli): add cycle-layout command (#556)
* Command to ToggleLayout * Just improve logic of figuring out next layout * Addr review: rename to "Cycle" instead of toggle, and add a small comment * As per review comments, implement cycle method on DefaultLayout * I forgot to remove this, my bad * feat(cli): fixups for cycle-layout cmd * Update komorebic/src/main.rs Co-authored-by: Kushashwa Ravi Shrimali <kushashwaravishrimali@gmail.com> --------- Co-authored-by: LGUG2Z <jadeiqbal@fastmail.com> Co-authored-by: جاد <LGUG2Z@users.noreply.github.com>
This commit is contained in:
committed by
LGUG2Z
parent
557d1962a7
commit
e9fb9297e9
@@ -20,6 +20,7 @@ pub enum DefaultLayout {
|
||||
VerticalStack,
|
||||
HorizontalStack,
|
||||
UltrawideVerticalStack,
|
||||
// NOTE: If any new layout is added, please make sure to register the same in `DefaultLayout::cycle`
|
||||
}
|
||||
|
||||
impl DefaultLayout {
|
||||
@@ -125,4 +126,28 @@ impl DefaultLayout {
|
||||
Option::from(r)
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn cycle_next(self) -> Self {
|
||||
match self {
|
||||
Self::BSP => Self::Columns,
|
||||
Self::Columns => Self::Rows,
|
||||
Self::Rows => Self::VerticalStack,
|
||||
Self::VerticalStack => Self::HorizontalStack,
|
||||
Self::HorizontalStack => Self::UltrawideVerticalStack,
|
||||
Self::UltrawideVerticalStack => Self::BSP,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn cycle_previous(self) -> Self {
|
||||
match self {
|
||||
Self::BSP => Self::UltrawideVerticalStack,
|
||||
Self::UltrawideVerticalStack => Self::HorizontalStack,
|
||||
Self::HorizontalStack => Self::VerticalStack,
|
||||
Self::VerticalStack => Self::Rows,
|
||||
Self::Rows => Self::Columns,
|
||||
Self::Columns => Self::BSP,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user