aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/input/layout.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-02-08 17:35:55 +0100
committerGitHub <noreply@github.com>2024-02-08 17:35:55 +0100
commit326c8cd3c6566e8fa4acd3a9369c718ce96f6625 (patch)
tree805ded9e78a35e9cd1ae91594358c8888a53abe2 /zellij-utils/src/input/layout.rs
parentdocs(changelog): cwd fixes (diff)
downloadsl0ppij-326c8cd3c6566e8fa4acd3a9369c718ce96f6625.tar.gz
sl0ppij-326c8cd3c6566e8fa4acd3a9369c718ce96f6625.tar.xz
sl0ppij-326c8cd3c6566e8fa4acd3a9369c718ce96f6625.zip
feat(panes): allow specifying coordinates for a new floating pane through the CLI or plugins (#3122)
* working * add tests * add coordinates to all the places * refactor: move things around: * style(fmt): rustfmt * style(code): cleanups
Diffstat (limited to 'zellij-utils/src/input/layout.rs')
-rw-r--r--zellij-utils/src/input/layout.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs
index 7f65d605..3dfadb40 100644
--- a/zellij-utils/src/input/layout.rs
+++ b/zellij-utils/src/input/layout.rs
@@ -69,6 +69,17 @@ pub enum SplitSize {
Fixed(usize), // An absolute number of columns or rows
}
+impl SplitSize {
+ pub fn to_fixed(&self, full_size: usize) -> usize {
+ match self {
+ SplitSize::Percent(percent) => {
+ ((*percent as f64 / 100.0) * full_size as f64).floor() as usize
+ },
+ SplitSize::Fixed(fixed) => *fixed,
+ }
+ }
+}
+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub enum Run {
#[serde(rename = "plugin")]