use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type ResizeP<'a> = ResizePane<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ResizePane<'a> {
#[cfg(feature = "tmux_1_5")]
pub down: bool,
#[cfg(feature = "tmux_1_5")]
pub left: bool,
#[cfg(feature = "tmux_2_1")]
pub mouse: bool,
#[cfg(feature = "tmux_1_5")]
pub right: bool,
#[cfg(feature = "tmux_3_2")]
pub trim: bool,
#[cfg(feature = "tmux_1_5")]
pub up: bool,
#[cfg(feature = "tmux_1_8")]
pub zoom: bool,
#[cfg(feature = "tmux_1_5")]
pub target_pane: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_8")]
pub width: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_8")]
pub height: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub adjustment: Option<Cow<'a, str>>,
}
impl<'a> ResizePane<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_1_5")]
pub fn down(mut self) -> Self {
self.down = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn left(mut self) -> Self {
self.left = true;
self
}
#[cfg(feature = "tmux_2_1")]
pub fn mouse(mut self) -> Self {
self.mouse = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn right(mut self) -> Self {
self.right = true;
self
}
#[cfg(feature = "tmux_3_2")]
pub fn trim(mut self) -> Self {
self.trim = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn up(mut self) -> Self {
self.up = true;
self
}
#[cfg(feature = "tmux_1_8")]
pub fn zoom(mut self) -> Self {
self.zoom = true;
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
}
#[cfg(feature = "tmux_1_8")]
pub fn width<S: Into<Cow<'a, str>>>(mut self, width: S) -> Self {
self.width = Some(width.into());
self
}
#[cfg(feature = "tmux_1_8")]
pub fn height<S: Into<Cow<'a, str>>>(mut self, height: S) -> Self {
self.height = Some(height.into());
self
}
#[cfg(feature = "tmux_1_5")]
pub fn adjustment<S: Into<Cow<'a, str>>>(mut self, adjustment: S) -> Self {
self.adjustment = Some(adjustment.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(RESIZE_PANE);
#[cfg(feature = "tmux_1_5")]
if self.down {
cmd.push_flag(D_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.left {
cmd.push_flag(L_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_2_1")]
if self.mouse {
cmd.push_flag(M_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.right {
cmd.push_flag(R_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_2")]
if self.trim {
cmd.push_flag(T_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if self.up {
cmd.push_flag(U_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_8")]
if self.zoom {
cmd.push_flag(Z_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
#[cfg(feature = "tmux_1_8")]
if let Some(width) = self.width {
cmd.push_option(X_LOWERCASE_KEY, width);
}
#[cfg(feature = "tmux_1_8")]
if let Some(height) = self.height {
cmd.push_option(Y_LOWERCASE_KEY, height);
}
#[cfg(feature = "tmux_1_5")]
if let Some(adjustment) = self.adjustment {
cmd.push_param(adjustment);
}
cmd
}
}