use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct SendPrefix<'a> {
#[cfg(feature = "tmux_1_6")]
pub secondary: bool,
#[cfg(feature = "tmux_0_8")]
pub target_pane: Option<Cow<'a, str>>,
}
impl<'a> SendPrefix<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_1_6")]
pub fn secondary(mut self) -> Self {
self.secondary = true;
self
}
#[cfg(feature = "tmux_0_8")]
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(SEND_PREFIX);
#[cfg(feature = "tmux_1_6")]
if self.secondary {
cmd.push_flag(_2_KEY);
}
#[cfg(feature = "tmux_0_8")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
cmd
}
}