use super::types::{Pane, PaneBounds, PaneId, PaneNode};
use crate::config::Config;
use crate::tmux::TmuxPaneId;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::runtime::Runtime;
#[derive(Clone, Copy)]
pub(super) struct DividerUpdateContext {
pub(super) target_index: usize,
pub(super) new_x: f32,
pub(super) new_y: f32,
pub(super) bounds: PaneBounds,
pub(super) divider_width: f32,
}
pub(super) struct TmuxLayoutRebuildContext<'a> {
pub(super) existing_mappings: &'a HashMap<TmuxPaneId, PaneId>,
pub(super) new_tmux_panes: &'a [TmuxPaneId],
pub(super) existing_panes: &'a mut HashMap<PaneId, Pane>,
pub(super) config: &'a Config,
pub(super) runtime: Arc<Runtime>,
pub(super) new_mappings: &'a mut HashMap<TmuxPaneId, PaneId>,
}
pub(super) enum RemoveResult {
Removed(Option<PaneNode>),
NotFound(PaneNode),
}
pub(super) fn extract_panes_from_node(node: PaneNode, panes: &mut HashMap<PaneId, Pane>) {
match node {
PaneNode::Leaf(pane) => {
let pane = *pane; panes.insert(pane.id, pane);
}
PaneNode::Split { first, second, .. } => {
extract_panes_from_node(*first, panes);
extract_panes_from_node(*second, panes);
}
}
}