use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type LinkW<'a> = LinkWindow<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct LinkWindow<'a> {
#[cfg(feature = "tmux_2_1")]
pub after: bool,
#[cfg(feature = "tmux_3_2")]
pub before: bool,
#[cfg(feature = "tmux_0_8")]
pub detached: bool,
#[cfg(feature = "tmux_0_8")]
pub kill: bool,
#[cfg(feature = "tmux_0_8")]
pub src_window: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_0_8")]
pub dst_window: Option<Cow<'a, str>>,
}
impl<'a> LinkWindow<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_2_1")]
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_0_8")]
pub fn kill(mut self) -> Self {
self.kill = true;
self
}
#[cfg(feature = "tmux_0_8")]
pub fn src_window<S: Into<Cow<'a, str>>>(mut self, src_window: S) -> Self {
self.src_window = Some(src_window.into());
self
}
#[cfg(feature = "tmux_0_8")]
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(LINK_WINDOW);
#[cfg(feature = "tmux_2_1")]
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_0_8")]
if self.kill {
cmd.push_flag(K_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_0_8")]
if let Some(src_window) = self.src_window {
cmd.push_option(S_LOWERCASE_KEY, src_window);
}
#[cfg(feature = "tmux_0_8")]
if let Some(dst_window) = self.dst_window {
cmd.push_option(T_LOWERCASE_KEY, dst_window);
}
cmd
}
}