use zellij_utils::errors::prelude::*;
use crate::resize_pty;
use crate::tab::{get_next_terminal_position, HoldForCommand, Pane};
use crate::{
os_input_output::ServerOsApi,
panes::sixel::SixelImageStore,
panes::{FloatingPanes, TiledPanes},
panes::{LinkHandler, PaneId, PluginPane, TerminalPane},
plugins::PluginInstruction,
pty::PtyInstruction,
thread_bus::ThreadSenders,
ClientId,
};
use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::rc::Rc;
use zellij_utils::{
data::{Palette, Style},
input::layout::{
FloatingPaneLayout, PluginUserConfiguration, Run, RunPluginLocation, TiledPaneLayout,
},
pane_size::{Offset, PaneGeom, Size, SizeInPixels, Viewport},
};
pub struct LayoutApplier<'a> {
viewport: Rc<RefCell<Viewport>>, // includes all non-UI panes
senders: ThreadSenders,
sixel_image_store: Rc<RefCell<SixelImageStore>>,
link_handler: Rc<RefCell<LinkHandler>>,
terminal_emulator_colors: Rc<RefCell<Palette>>,
terminal_emulator_color_codes: Rc<RefCell<HashMap<usize, String>>>,
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
connected_clients: Rc<RefCell<HashSet<ClientId>>>,
style: Style,
display_area: Rc<RefCell<Size>>, // includes all panes (including eg. the status bar and tab bar in the default layout)
tiled_panes: &'a mut TiledPanes,
floating_panes: &'a mut FloatingPanes,
draw_pane_frames: bool,
focus_pane_id: &'a mut Option<PaneId>,
os_api: Box<dyn ServerOsApi>,
debug: bool,
arrow_fonts: bool,
styled_underlines: bool,
}
impl<'a> LayoutApplier<'a> {
pub fn new(
viewport: &Rc<RefCell<Viewport>>,
senders: &ThreadSenders,
sixel_image_store: &Rc<RefCell<SixelImageStore>>,
link_handler: &Rc<RefCell<LinkHandler>>,
terminal_emulator_colors: &Rc<RefCell<Palette>>,
terminal_emulator_color_codes: &Rc<RefCell<HashMap<usize, String>>>,
character_cell_size: &Rc<RefCell<Option<SizeInPixels>>>,
connected_clients: &Rc<RefCell<HashSet<ClientId>>>,
style: &Style,
display_area: &Rc<RefCell<Size>>, // includes all panes (including eg. the status bar and tab bar in the default layout)