use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type SelectP<'a> = SelectPane<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct SelectPane<'a> {
#[cfg(feature = "tmux_1_5")]
pub down: bool,
#[cfg(feature = "tmux_2_0")]
pub disable: bool,
#[cfg(feature = "tmux_2_0")]
pub enable: bool,
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_1")))]
pub show_style: bool,
#[cfg(feature = "tmux_1_5")]
pub left: bool,
#[cfg(feature = "tmux_1_5")]
pub last: bool,
#[cfg(feature = "tmux_2_1")]
pub set_marked: bool,
#[cfg(feature = "tmux_2_1")]
pub clear_marked: bool,
#[cfg(feature = "tmux_1_5")]
pub right: bool,
#[cfg(feature = "tmux_1_5")]
pub up: bool,
#[cfg(feature = "tmux_3_1")]
pub keep_zoomed: bool,
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub pane_index: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_0a")))]
pub style: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_6")]
pub title: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub target_window: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub target_pane: Option<Cow<'a, str>>,
}
impl<'a> SelectPane<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_1_5")]
pub fn down(mut self) -> Self {
self.down = true;
self
}
#[cfg(feature = "tmux_2_0")]
pub fn disable(mut self) -> Self {
self.disable = true;
self
}
#[cfg(feature = "tmux_2_0")]
pub fn enable(mut self) -> Self {
self.enable = true;
self
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_1")))]
pub fn show_style(mut self) -> Self {
self.show_style = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn left(mut self) -> Self {
self.left = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn last(mut self) -> Self {
self.last = true;
self
}
#[cfg(feature = "tmux_2_1")]
pub fn set_marked(mut self) -> Self {
self.set_marked = true;
self
}
#[cfg(feature = "tmux_2_1")]
pub fn clear_marked(mut self) -> Self {
self.clear_marked = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn right(mut self) -> Self {
self.right = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn up(mut self) -> Self {
self.up = true;
self
}
#[cfg(feature = "tmux_3_1")]
pub fn keep_zoomed(mut self) -> Self {
self.keep_zoomed = true;
self
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub fn pane_index<S: Into<Cow<'a, str>>>(mut self, pane_index: S) -> Self {
self.pane_index = Some(pane_index.into());
self
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_0a")))]
pub fn style<S: Into<Cow<'a, str>>>(mut self, style: S) -> Self {
self.style = Some(style.into());
self
}
#[cfg(feature = "tmux_2_6")]
pub fn title<S: Into<Cow<'a, str>>>(mut self, title: S) -> Self {
self.title = Some(title.into());
self
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub fn target_window<S: Into<Cow<'a, str>>>(mut self, target_window: S) -> Self {
self.target_window = Some(target_window.into());
self
}
#[cfg(feature = "tmux_1_5")]
pub fn target_pane<S: Into<Cow<'a, str>>>(mut self, target_pane: S) -> Self {
self.target_pane = Some(target_pane.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(SELECT_PANE);
#[cfg(feature = "tmux_1_5")]
if self.down {
cmd.push_flag(D_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_2_0")]
if self.disable {
cmd.push_flag(D_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_2_0")]
if self.enable {
cmd.push_flag(E_LOWERCASE_KEY);
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_1")))]
if self.show_style {
cmd.push_flag(G_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.left {
cmd.push_flag(L_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.last {
cmd.push_flag(L_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_2_1")]
if self.set_marked {
cmd.push_flag(M_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_2_1")]
if self.clear_marked {
cmd.push_flag(M_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.right {
cmd.push_flag(R_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.up {
cmd.push_flag(U_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_1")]
if self.keep_zoomed {
cmd.push_flag(Z_UPPERCASE_KEY);
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
if let Some(pane_index) = self.pane_index {
cmd.push_option(P_LOWERCASE_KEY, pane_index);
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_0a")))]
if let Some(style) = self.style {
cmd.push_option(P_UPPERCASE_KEY, style);
}
#[cfg(feature = "tmux_2_6")]
if let Some(title) = self.title {
cmd.push_option(T_UPPERCASE_KEY, title);
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
#[cfg(feature = "tmux_1_5")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
cmd
}
}