use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type LastP<'a> = LastPane<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct LastPane<'a> {
#[cfg(feature = "tmux_2_0")]
pub disable: bool,
#[cfg(feature = "tmux_2_0")]
pub enable: bool,
#[cfg(feature = "tmux_3_1")]
pub keep_zoomed: bool,
#[cfg(feature = "tmux_1_5")]
pub target_window: Option<Cow<'a, str>>,
}
impl<'a> LastPane<'a> {
pub fn new() -> Self {
Default::default()
}
#[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(feature = "tmux_3_1")]
pub fn keep_zoomed(mut self) -> Self {
self.keep_zoomed = true;
self
}
#[cfg(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
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(LAST_PANE);
#[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(feature = "tmux_3_1")]
if self.keep_zoomed {
cmd.push_flag(Z_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
cmd
}
}