mod floating_pane_grid;
use zellij_utils::{
data::{Direction, PaneInfo, ResizeStrategy},
position::Position,
};
use crate::resize_pty;
use crate::tab::{pane_info_for_pane, Pane};
use floating_pane_grid::FloatingPaneGrid;
use crate::{
os_input_output::ServerOsApi,
output::{FloatingPanesStack, Output},
panes::{ActivePanes, PaneId},
plugins::PluginInstruction,
thread_bus::ThreadSenders,
ui::pane_contents_and_ui::PaneContentsAndUi,
ClientId,
};
use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::rc::Rc;
use std::time::Instant;
use zellij_utils::{
data::{ModeInfo, Style},
errors::prelude::*,
input::command::RunCommand,
input::layout::{FloatingPaneLayout, Run, RunPlugin},
pane_size::{Dimension, Offset, PaneGeom, Size, SizeInPixels, Viewport},
};
const RESIZE_INCREMENT_WIDTH: usize = 5;
const RESIZE_INCREMENT_HEIGHT: usize = 2;
pub struct FloatingPanes {
panes: BTreeMap<PaneId, Box<dyn Pane>>,
display_area: Rc<RefCell<Size>>,
viewport: Rc<RefCell<Viewport>>,
connected_clients: Rc<RefCell<HashSet<ClientId>>>,
connected_clients_in_app: Rc<RefCell<HashSet<ClientId>>>,
mode_info: Rc<RefCell<HashMap<ClientId, ModeInfo>>>,
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
default_mode_info: ModeInfo,
style: Style,
session_is_mirrored: bool,
desired_pane_positions: HashMap<PaneId, PaneGeom>, // this represents the positions of panes the user moved with intention, rather than by resizing the terminal window
z_indices: Vec<PaneId>,
active_panes: ActivePanes,
show_panes: bool,
pane_being_moved_with_mouse: Option<(PaneId, Position)>,
senders: ThreadSenders,
}
#[allow(clippy::borrowed_box)]
#[allow(clippy::too_many_arguments)]
impl FloatingPanes {
pub fn new(
display_area: Rc<RefCell<Size>>,
viewport: Rc<RefCell<Viewport>>,
connected_clients: Rc<RefCell<HashSet<ClientId>>>,
connected_clients_in_app: Rc<RefCell<HashSet<ClientId>>>,
mode_info: Rc<