use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type Menu<'a> = DisplayMenu<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct DisplayMenu<'a> {
#[cfg(feature = "tmux_3_2")]
pub not_close: bool,
#[cfg(feature = "tmux_3_5")]
pub mouse_in_menu: bool,
#[cfg(feature = "tmux_3_0")]
pub target_client: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_0")]
pub target_pane: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_0")]
pub title: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_0")]
pub x: Option<usize>,
#[cfg(feature = "tmux_3_0")]
pub y: Option<usize>,
#[cfg(feature = "tmux_3_4")]
pub selected_style: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_4")]
pub style: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_4")]
pub border_style: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_0")]
pub name: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_0")]
pub key: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_0")]
pub command: Option<Cow<'a, str>>,
}
impl<'a> DisplayMenu<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_3_2")]
pub fn not_close(mut self) -> Self {
self.not_close = true;
self
}
#[cfg(feature = "tmux_3_5")]
pub fn mouse_in_menu(mut self) -> Self {
self.mouse_in_menu = true;
self
}
#[cfg(feature = "tmux_3_0")]
pub fn target_client<S: Into<Cow<'a, str>>>(mut self, target_client: S) -> Self {
self.target_client = Some(target_client.into());
self
}
#[cfg(feature = "tmux_3_0")]
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_3_0")]
pub fn title<S: Into<Cow<'a, str>>>(mut self, title: S) -> Self {
self.title = Some(title.into());
self
}
#[cfg(feature = "tmux_3_0")]
pub fn x(mut self, x: usize) -> Self {
self.x = Some(x);
self
}
#[cfg(feature = "tmux_3_0")]
pub fn y(mut self, y: usize) -> Self {
self.y = Some(y);
self
}
#[cfg(feature = "tmux_3_4")]
pub fn selected_style<S: Into<Cow<'a, str>>>(mut self, selected_style: S) -> Self {
self.selected_style = Some(selected_style.into());
self
}
#[cfg(feature = "tmux_3_4")]
pub fn style<S: Into<Cow<'a, str>>>(mut self, style: S) -> Self {
self.style = Some(style.into());
self
}
#[cfg(feature = "tmux_3_4")]
pub fn border_style<S: Into<Cow<'a, str>>>(mut self, border_style: S) -> Self {
self.border_style = Some(border_style.into());
self
}
#[cfg(feature = "tmux_3_0")]
pub fn name<S: Into<Cow<'a, str>>>(mut self, name: S) -> Self {
self.name = Some(name.into());
self
}
#[cfg(feature = "tmux_3_0")]
pub fn key<S: Into<Cow<'a, str>>>(mut self, key: S) -> Self {
self.key = Some(key.into());
self
}
#[cfg(feature = "tmux_3_0")]
pub fn command<S: Into<Cow<'a, str>>>(mut self, command: S) -> Self {
self.command = Some(command.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(DISPLAY_MENU);
#[cfg(feature = "tmux_3_2")]
if self.not_close {
cmd.push_flag(O_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_5")]
if self.mouse_in_menu {
cmd.push_flag(M_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_0")]
if let Some(target_client) = self.target_client {
cmd.push_option(C_LOWERCASE_KEY, target_client);
}
#[cfg(feature = "tmux_3_0")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
#[cfg(feature = "tmux_3_0")]
if let Some(title) = self.title {
cmd.push_option(T_UPPERCASE_KEY, title);
}
#[cfg(feature = "tmux_3_0")]
if let Some(x) = self.x {
cmd.push_option(X_LOWERCASE_KEY, x.to_string());
}
#[cfg(feature = "tmux_3_0")]
if let Some(y) = self.y {
cmd.push_option(Y_LOWERCASE_KEY, y.to_string());
}
#[cfg(feature = "tmux_3_4")]
if let Some(selected_style) = self.selected_style {
cmd.push_option(H_UPPERCASE_KEY, selected_style);
}
#[cfg(feature = "tmux_3_4")]
if let Some(style) = self.style {
cmd.push_option(S_LOWERCASE_KEY, style);
}
#[cfg(feature = "tmux_3_4")]
if let Some(border_style) = self.border_style {
cmd.push_option(S_UPPERCASE_KEY, border_style);
}
#[cfg(feature = "tmux_3_0")]
if let Some(name) = self.name {
cmd.push_param(name);
}
#[cfg(feature = "tmux_3_0")]
if let Some(key) = self.key {
cmd.push_param(key);
}
#[cfg(feature = "tmux_3_0")]
if let Some(command) = self.command {
cmd.push_param(command);
}
cmd
}
}