use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type BreakP<'a> = BreakPane<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct BreakPane<'a> {
#[cfg(feature = "tmux_3_2")]
pub after: bool,
#[cfg(feature = "tmux_3_2")]
pub before: bool,
#[cfg(feature = "tmux_0_8")]
pub detached: bool,
#[cfg(feature = "tmux_1_7")]
pub print: bool,
#[cfg(feature = "tmux_1_7")]
pub format: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_4")]
pub window_name: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub target_window: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_1")))]
pub target_pane: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_1")]
pub src_pane: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_1")))]
pub dst_pane: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_2")]
pub dst_window: Option<Cow<'a, str>>,
}
impl<'a> BreakPane<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_3_2")]
pub fn after(mut self) -> Self {
self.after = true;
self
}
#[cfg(feature = "tmux_3_2")]
pub fn before(mut self) -> Self {
self.before = true;
self
}
#[cfg(feature = "tmux_0_8")]
pub fn detached(mut self) -> Self {
self.detached = true;
self
}
#[cfg(feature = "tmux_1_7")]
pub fn print(mut self) -> Self {
self.print = true;
self
}
#[cfg(feature = "tmux_1_7")]
pub fn format<S: Into<Cow<'a, str>>>(mut self, format: S) -> Self {
self.format = Some(format.into());
self
}
#[cfg(feature = "tmux_2_4")]
pub fn window_name<S: Into<Cow<'a, str>>>(mut self, window_name: S) -> Self {
self.window_name = Some(window_name.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(all(feature = "tmux_1_5", not(feature = "tmux_2_1")))]
pub fn target_pane<S: Into<Cow<'a, str>>>(mut self, target_pane: S) -> Self {
self.target_pane = Some(target_pane.into());
self
}
#[cfg(feature = "tmux_2_1")]
pub fn src_pane<S: Into<Cow<'a, str>>>(mut self, src_pane: S) -> Self {
self.src_pane = Some(src_pane.into());
self
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_1")))]
pub fn dst_pane<S: Into<Cow<'a, str>>>(mut self, dst_pane: S) -> Self {
self.dst_pane = Some(dst_pane.into());
self
}
#[cfg(feature = "tmux_2_2")]
pub fn dst_window<S: Into<Cow<'a, str>>>(mut self, dst_window: S) -> Self {
self.dst_window = Some(dst_window.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(BREAK_PANE);
#[cfg(feature = "tmux_3_2")]
if self.after {
cmd.push_flag(A_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_3_2")]
if self.before {
cmd.push_flag(B_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_0_8")]
if self.detached {
cmd.push_flag(D_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_7")]
if self.print {
cmd.push_flag(P_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_7")]
if let Some(format) = self.format {
cmd.push_option(F_UPPERCASE_KEY, format);
}
#[cfg(feature = "tmux_2_4")]
if let Some(window_name) = self.window_name {
cmd.push_option(N_LOWERCASE_KEY, window_name);
}
#[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(all(feature = "tmux_1_5", not(feature = "tmux_2_1")))]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
#[cfg(feature = "tmux_2_1")]
if let Some(src_pane) = self.src_pane {
cmd.push_option(S_LOWERCASE_KEY, src_pane);
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_1")))]
if let Some(dst_pane) = self.dst_pane {
cmd.push_option(T_LOWERCASE_KEY, dst_pane);
}
#[cfg(feature = "tmux_2_2")]
if let Some(dst_window) = self.dst_window {
cmd.push_option(T_LOWERCASE_KEY, dst_window);
}
cmd
}
}