use crate::{Error, FormatsOutput, Layout, WindowFlags};
use std::str::FromStr;
pub const WINDOW_VARS_SEPARATOR: char = '\'';
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Window {
#[cfg(feature = "tmux_1_6")]
pub active: Option<bool>,
#[cfg(feature = "tmux_3_1")]
pub active_clients: Option<usize>,
#[cfg(feature = "tmux_3_1")]
pub active_clients_list: Option<String>,
#[cfg(feature = "tmux_3_1")]
pub active_sessions: Option<usize>,
#[cfg(feature = "tmux_3_1")]
pub active_sessions_list: Option<String>,
#[cfg(feature = "tmux_2_1")]
pub activity: Option<usize>,
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_2")))]
pub activity_string: Option<String>,
#[cfg(any(
all(feature = "tmux_1_9", not(feature = "tmux_2_2")),
feature = "tmux_2_3"
))]
pub activity_flag: Option<bool>,
#[cfg(feature = "tmux_1_9")]
pub bell_flag: Option<bool>,
#[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_0")))]
pub content_flag: Option<bool>,
#[cfg(feature = "tmux_2_9")]
pub bigger: Option<bool>,
#[cfg(feature = "tmux_3_1")]
pub cell_height: Option<usize>,
#[cfg(feature = "tmux_3_1")]
pub cell_width: Option<usize>,
#[cfg(feature = "tmux_2_9")]
pub end_flag: Option<bool>,
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub find_matches: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub flags: Option<WindowFlags>,
#[cfg(feature = "tmux_2_6")]
pub format: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub height: Option<usize>,
#[cfg(feature = "tmux_1_7")]
pub id: Option<usize>,
#[cfg(feature = "tmux_1_6")]
pub index: Option<usize>,
#[cfg(feature = "tmux_2_0")]
pub last_flag: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub layout: Option<Layout>,
#[cfg(feature = "tmux_2_1")]
pub linked: Option<bool>,
#[cfg(feature = "tmux_3_1")]
pub linked_sessions: Option<usize>,
#[cfg(feature = "tmux_3_1")]
pub linked_sessions_list: Option<String>,
#[cfg(feature = "tmux_3_1")]
pub marked_flag: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub name: Option<String>,
#[cfg(feature = "tmux_2_9")]
pub offset_x: Option<usize>,
#[cfg(feature = "tmux_2_9")]
pub offset_y: Option<usize>,
#[cfg(feature = "tmux_1_7")]
pub panes: Option<usize>,
#[cfg(feature = "tmux_1_9")]
pub silence_flag: Option<bool>,
#[cfg(feature = "tmux_2_5")]
pub stack_index: Option<usize>,
#[cfg(feature = "tmux_2_9")]
pub start_flag: Option<bool>,
#[cfg(feature = "tmux_2_2")]
pub visible_layout: Option<Layout>,
#[cfg(feature = "tmux_1_6")]
pub width: Option<usize>,
#[cfg(feature = "tmux_2_0")]
pub zoomed_flag: Option<bool>,
}
impl FromStr for Window {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
let mut window = Window::new();
let mut format = FormatsOutput::new();
format.separator(WINDOW_VARS_SEPARATOR);
#[cfg(feature = "tmux_1_6")]
format.window_active(&mut window.active);
#[cfg(feature = "tmux_3_1")]
format.window_active_clients(&mut window.active_clients);
#[cfg(feature = "tmux_3_1")]
format.window_active_clients_list(&mut window.active_clients_list);
#[cfg(feature = "tmux_3_1")]
format.window_active_sessions(&mut window.active_sessions);
#[cfg(feature = "tmux_3_1")]
format.window_active_sessions_list(&mut window.active_sessions_list);
#[cfg(feature = "tmux_2_1")]
format.window_activity(&mut window.activity);
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_2")))]
format.window_activity_string(&mut window.activity_string);
#[cfg(any(
all(feature = "tmux_1_9", not(feature = "tmux_2_2")),
feature = "tmux_2_3"
))]
format.window_activity_flag(&mut window.activity_flag);
#[cfg(feature = "tmux_1_9")]
format.window_bell_flag(&mut window.bell_flag);
#[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_0")))]
format.window_content_flag(&mut window.content_flag);
#[cfg(feature = "tmux_2_9")]
format.window_bigger(&mut window.bigger);
#[cfg(feature = "tmux_3_1")]
format.window_cell_height(&mut window.cell_height);
#[cfg(feature = "tmux_3_1")]
format.window_cell_width(&mut window.cell_width);
#[cfg(feature = "tmux_2_9")]
format.window_end_flag(&mut window.end_flag);
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
format.window_find_matches(&mut window.find_matches);
#[cfg(feature = "tmux_1_6")]
format.window_flags(&mut window.flags);
#[cfg(feature = "tmux_2_6")]
format.window_format(&mut window.format);
#[cfg(feature = "tmux_1_6")]
format.window_height(&mut window.height);
#[cfg(feature = "tmux_1_7")]
format.window_id(&mut window.id);
#[cfg(feature = "tmux_1_6")]
format.window_index(&mut window.index);
#[cfg(feature = "tmux_2_0")]
format.window_last_flag(&mut window.last_flag);
#[cfg(feature = "tmux_1_6")]
format.window_layout(&mut window.layout);
#[cfg(feature = "tmux_2_1")]
format.window_linked(&mut window.linked);
#[cfg(feature = "tmux_3_1")]
format.window_linked_sessions(&mut window.linked_sessions);
#[cfg(feature = "tmux_3_1")]
format.window_linked_sessions_list(&mut window.linked_sessions_list);
#[cfg(feature = "tmux_3_1")]
format.window_marked_flag(&mut window.marked_flag);
#[cfg(feature = "tmux_1_6")]
format.window_name(&mut window.name);
#[cfg(feature = "tmux_2_9")]
format.window_offset_x(&mut window.offset_x);
#[cfg(feature = "tmux_2_9")]
format.window_offset_y(&mut window.offset_y);
#[cfg(feature = "tmux_1_7")]
format.window_panes(&mut window.panes);
#[cfg(feature = "tmux_1_9")]
format.window_silence_flag(&mut window.silence_flag);
#[cfg(feature = "tmux_2_5")]
format.window_stack_index(&mut window.stack_index);
#[cfg(feature = "tmux_2_9")]
format.window_start_flag(&mut window.start_flag);
#[cfg(feature = "tmux_2_2")]
format.window_visible_layout(&mut window.visible_layout);
#[cfg(feature = "tmux_1_6")]
format.window_width(&mut window.width);
#[cfg(feature = "tmux_2_0")]
format.window_zoomed_flag(&mut window.zoomed_flag);
FormatsOutput::from_string_ext(s, &mut format);
Ok(window)
}
}
impl Window {
pub fn new() -> Self {
Default::default()
}
}