use crate::Error;
use crate::FormatsOutput;
#[cfg(feature = "tmux_1_8")]
use crate::PaneTabs;
use std::str::FromStr;
pub const PANE_VARS_SEPARATOR: char = '\'';
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Pane {
#[cfg(feature = "tmux_1_6")]
pub active: Option<bool>,
#[cfg(feature = "tmux_2_6")]
pub at_bottom: Option<bool>,
#[cfg(feature = "tmux_2_6")]
pub at_left: Option<bool>,
#[cfg(feature = "tmux_2_6")]
pub at_right: Option<bool>,
#[cfg(feature = "tmux_2_6")]
pub at_top: Option<bool>,
#[cfg(feature = "tmux_2_0")]
pub bottom: Option<usize>,
#[cfg(feature = "tmux_1_8")]
pub current_command: Option<String>,
#[cfg(feature = "tmux_1_7")]
pub current_path: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub dead: Option<bool>,
#[cfg(feature = "tmux_2_0")]
pub dead_status: Option<usize>,
#[cfg(feature = "tmux_2_6")]
pub format: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub height: Option<usize>,
#[cfg(feature = "tmux_1_6")]
pub id: Option<usize>,
#[cfg(feature = "tmux_1_8")]
pub in_mode: Option<bool>,
#[cfg(feature = "tmux_1_7")]
pub index: Option<usize>,
#[cfg(feature = "tmux_2_0")]
pub input_off: Option<bool>,
#[cfg(feature = "tmux_2_0")]
pub left: Option<usize>,
#[cfg(feature = "tmux_3_0")]
pub marked: Option<bool>,
#[cfg(feature = "tmux_3_0")]
pub marked_set: Option<bool>,
#[cfg(feature = "tmux_2_5")]
pub mode: Option<usize>,
#[cfg(feature = "tmux_3_1")]
pub path: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub pid: Option<usize>,
#[cfg(feature = "tmux_2_6")]
pub pipe: Option<bool>,
#[cfg(feature = "tmux_2_0")]
pub right: Option<usize>,
#[cfg(feature = "tmux_2_5")]
pub search_string: Option<usize>,
#[cfg(feature = "tmux_1_6")]
pub start_command: Option<usize>,
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_2_0")))]
pub start_path: Option<usize>,
#[cfg(feature = "tmux_1_9")]
pub synchronized: Option<bool>,
#[cfg(feature = "tmux_1_8")]
pub tabs: Option<PaneTabs>,
#[cfg(feature = "tmux_1_6")]
pub title: Option<String>,
#[cfg(feature = "tmux_2_0")]
pub top: Option<usize>,
#[cfg(feature = "tmux_1_6")]
pub tty: Option<String>,
#[cfg(feature = "tmux_3_4")]
pub unseen_changes: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub width: Option<usize>,
}
impl FromStr for Pane {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
let mut pane = Pane::new();
let mut format = FormatsOutput::new();
format.separator(PANE_VARS_SEPARATOR);
#[cfg(feature = "tmux_1_6")]
format.pane_active(&mut pane.active);
#[cfg(feature = "tmux_2_6")]
format.pane_at_bottom(&mut pane.at_bottom);
#[cfg(feature = "tmux_2_6")]
format.pane_at_left(&mut pane.at_left);
#[cfg(feature = "tmux_2_6")]
format.pane_at_right(&mut pane.at_right);
#[cfg(feature = "tmux_2_6")]
format.pane_at_top(&mut pane.at_top);
#[cfg(feature = "tmux_2_0")]
format.pane_bottom(&mut pane.bottom);
#[cfg(feature = "tmux_1_8")]
format.pane_current_command(&mut pane.current_command);
#[cfg(feature = "tmux_1_7")]
format.pane_current_path(&mut pane.current_path);
#[cfg(feature = "tmux_1_6")]
format.pane_dead(&mut pane.dead);
#[cfg(feature = "tmux_2_0")]
format.pane_dead_status(&mut pane.dead_status);
#[cfg(feature = "tmux_2_6")]
format.pane_format(&mut pane.format);
#[cfg(feature = "tmux_1_6")]
format.pane_height(&mut pane.height);
#[cfg(feature = "tmux_1_6")]
format.pane_id(&mut pane.id);
#[cfg(feature = "tmux_1_8")]
format.pane_in_mode(&mut pane.in_mode);
#[cfg(feature = "tmux_1_7")]
format.pane_index(&mut pane.index);
#[cfg(feature = "tmux_2_0")]
format.pane_input_off(&mut pane.input_off);
#[cfg(feature = "tmux_2_0")]
format.pane_left(&mut pane.left);
#[cfg(feature = "tmux_3_0")]
format.pane_marked(&mut pane.marked);
#[cfg(feature = "tmux_3_0")]
format.pane_marked_set(&mut pane.marked_set);
#[cfg(feature = "tmux_2_5")]
format.pane_mode(&mut pane.mode);
#[cfg(feature = "tmux_3_1")]
format.pane_path(&mut pane.path);
#[cfg(feature = "tmux_1_6")]
format.pane_pid(&mut pane.pid);
#[cfg(feature = "tmux_2_6")]
format.pane_pipe(&mut pane.pipe);
#[cfg(feature = "tmux_2_0")]
format.pane_right(&mut pane.right);
#[cfg(feature = "tmux_2_5")]
format.pane_search_string(&mut pane.search_string);
#[cfg(feature = "tmux_1_6")]
format.pane_start_command(&mut pane.start_command);
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_2_0")))]
format.pane_start_path(&mut pane.start_path);
#[cfg(feature = "tmux_1_9")]
format.pane_synchronized(&mut pane.synchronized);
#[cfg(feature = "tmux_1_8")]
format.pane_tabs(&mut pane.tabs);
#[cfg(feature = "tmux_1_6")]
format.pane_title(&mut pane.title);
#[cfg(feature = "tmux_2_0")]
format.pane_top(&mut pane.top);
#[cfg(feature = "tmux_1_6")]
format.pane_tty(&mut pane.tty);
#[cfg(feature = "tmux_3_4")]
format.pane_unseen_changes(&mut pane.unseen_changes);
#[cfg(feature = "tmux_1_6")]
format.pane_width(&mut pane.width);
FormatsOutput::from_string_ext(s, &mut format);
Ok(pane)
}
}
impl Pane {
pub fn new() -> Self {
Default::default()
}
}