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