Add split view panes

This commit is contained in:
2026-05-08 01:47:19 -04:00
parent ccb3972b75
commit 23b108c8dd
13 changed files with 419 additions and 6 deletions
+27
View File
@@ -1,5 +1,7 @@
use crate::{SplitId, TabId};
pub const MAX_SPLIT_PANES: usize = 4;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SplitAxis {
Horizontal,
@@ -57,4 +59,29 @@ impl SplitLayout {
pub fn panes(&self) -> &[SplitPane] {
&self.panes
}
#[must_use]
pub fn contains_tab(&self, tab_id: &TabId) -> bool {
self.panes.iter().any(|pane| pane.tab_id() == tab_id)
}
#[must_use]
pub fn pane_count(&self) -> usize {
self.panes.len()
}
pub fn add_pane(&mut self, pane: SplitPane) -> bool {
if self.panes.len() >= MAX_SPLIT_PANES || self.contains_tab(pane.tab_id()) {
return false;
}
self.panes.push(pane);
true
}
pub fn remove_tab(&mut self, tab_id: &TabId) -> bool {
let original_len = self.panes.len();
self.panes.retain(|pane| pane.tab_id() != tab_id);
self.panes.len() != original_len
}
}