mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-23 09:08:36 +02:00
feat(wm): allow resize-axis for custom primary col
This commit allows the resize-axis cmd on Axis::Horizontal to operate on the Primary column of a CustomLayout. Note that this will only operate on a CustomLayout that has met the window count threshold to enable the tertiary column. If it has not, the layout will render as DefaultLayout::Columns, which does not support the resize-axis cmd.
This commit is contained in:
@@ -2,6 +2,7 @@ use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::ops::Deref;
|
||||
use std::ops::DerefMut;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use color_eyre::eyre::anyhow;
|
||||
@@ -22,6 +23,12 @@ impl Deref for CustomLayout {
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for CustomLayout {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl CustomLayout {
|
||||
pub fn from_path_buf(path: PathBuf) -> Result<Self> {
|
||||
let invalid_filetype = anyhow!("custom layouts must be json or yaml files");
|
||||
@@ -75,6 +82,14 @@ impl CustomLayout {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_primary_width_percentage(&mut self, percentage: usize) {
|
||||
for column in self.iter_mut() {
|
||||
if let Column::Primary(Option::Some(ColumnWidth::WidthPercentage(current))) = column {
|
||||
*current = percentage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn is_valid(&self) -> bool {
|
||||
// A valid layout must have at least one column
|
||||
|
||||
Reference in New Issue
Block a user