use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type CaptureP<'a> = CapturePane<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct CapturePane<'a> {
#[cfg(feature = "tmux_1_8")]
pub alternate_screen: bool,
#[cfg(feature = "tmux_3_4")]
pub a: bool,
#[cfg(feature = "tmux_1_8")]
pub escape_sequences: bool,
#[cfg(feature = "tmux_1_8")]
pub stdout: bool,
#[cfg(feature = "tmux_1_8")]
pub pane: bool,
#[cfg(feature = "tmux_1_8")]
pub quiet: bool,
#[cfg(feature = "tmux_2_4")]
pub escape_non_printable: bool,
#[cfg(feature = "tmux_2_4")]
pub join: bool,
#[cfg(feature = "tmux_3_6")]
pub screen_for_mode: bool,
#[cfg(feature = "tmux_3_1")]
pub trailing_spaces: bool,
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_0")))]
pub buffer_index: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_0")]
pub buffer_name: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub end_line: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub start_line: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub target_pane: Option<Cow<'a, str>>,
}
impl<'a> CapturePane<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_1_8")]
pub fn alternate_screen(mut self) -> Self {
self.alternate_screen = true;
self
}
#[cfg(feature = "tmux_3_4")]
pub fn a(mut self) -> Self {
self.a = true;
self
}
#[cfg(feature = "tmux_1_8")]
pub fn escape_sequences(mut self) -> Self {
self.escape_sequences = true;
self
}
#[cfg(feature = "tmux_1_8")]
pub fn stdout(mut self) -> Self {
self.stdout = true;
self
}
#[cfg(feature = "tmux_1_8")]
pub fn pane(mut self) -> Self {
self.pane = true;
self
}
#[cfg(feature = "tmux_1_8")]
pub fn quiet(mut self) -> Self {
self.quiet = true;
self
}
#[cfg(feature = "tmux_2_4")]
pub fn escape_non_printable(mut self) -> Self {
self.escape_non_printable = true;
self
}
#[cfg(feature = "tmux_2_4")]
pub fn join(mut self) -> Self {
self.join = true;
self
}
#[cfg(feature = "tmux_3_6")]
pub fn screen_for_mode(mut self) -> Self {
self.screen_for_mode = true;
self
}
#[cfg(feature = "tmux_3_1")]
pub fn trailing_spaces(mut self) -> Self {
self.trailing_spaces = true;
self
}
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_0")))]
pub fn buffer_index<S: Into<Cow<'a, str>>>(mut self, buffer_index: S) -> Self {
self.buffer_index = Some(buffer_index.into());
self
}
#[cfg(feature = "tmux_2_0")]
pub fn buffer_name<S: Into<Cow<'a, str>>>(mut self, buffer_name: S) -> Self {
self.buffer_name = Some(buffer_name.into());
self
}
#[cfg(feature = "tmux_1_5")]
pub fn end_line<S: Into<Cow<'a, str>>>(mut self, end_line: S) -> Self {
self.end_line = Some(end_line.into());
self
}
#[cfg(feature = "tmux_1_5")]
pub fn start_line<S: Into<Cow<'a, str>>>(mut self, start_line: S) -> Self {
self.start_line = Some(start_line.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(CAPTURE_PANE);
#[cfg(feature = "tmux_1_8")]
if self.alternate_screen {
cmd.push_flag(A_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_3_4")]
if self.a {
cmd.push_flag(A_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_8")]
if self.escape_sequences {
cmd.push_flag(E_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_8")]
if self.stdout {
cmd.push_flag(P_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_8")]
if self.pane {
cmd.push_flag(P_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_8")]
if self.quiet {
cmd.push_flag(Q_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_2_4")]
if self.escape_non_printable {
cmd.push_flag(C_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_2_4")]
if self.join {
cmd.push_flag(J_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_6")]
if self.screen_for_mode {
cmd.push_flag(M_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_1")]
if self.trailing_spaces {
cmd.push_flag(N_UPPERCASE_KEY);
}
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_0")))]
if let Some(buffer_index) = self.buffer_index {
cmd.push_option(B_LOWERCASE_KEY, buffer_index);
}
#[cfg(feature = "tmux_2_0")]
if let Some(buffer_name) = self.buffer_name {
cmd.push_option(B_LOWERCASE_KEY, buffer_name);
}
#[cfg(feature = "tmux_1_5")]
if let Some(end_line) = self.end_line {
cmd.push_option(E_UPPERCASE_KEY, end_line);
}
#[cfg(feature = "tmux_1_5")]
if let Some(start_line) = self.start_line {
cmd.push_option(S_UPPERCASE_KEY, start_line);
}
#[cfg(feature = "tmux_1_5")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
cmd
}
}