#[macro_export]
macro_rules! display_popup {
(@cmd ($cmd:expr) -B, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.no_border()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -C, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.close()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -E, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.close_on_exit()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -EE, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.close_on_success()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -k, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.any_key_dismiss()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -N, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.disable_previous()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -b $border_lines:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.border_lines($border_lines)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -c $target_client:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.target_client($target_client)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -d $start_directory:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.start_directory($start_directory)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -e $environment:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.environment($environment)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -h $height:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.height($height)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -s $style:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.style($style)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -S $border_style:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.border_style($border_style)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target_pane:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.target_pane($target_pane)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -T $title:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.title($title)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -w $width:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.width($width)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -x $x:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.x($x)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -y $y:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.y($y)
}) $($tail)*)
}};
(@cmd ($cmd:expr) $shell_command:expr, $($tail:tt)*) => {{
$crate::display_popup!(@cmd ({
$cmd.shell_command($shell_command)
}) $($tail)*)
}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::DisplayPopup::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::display_popup!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::display_popup!(@cmd ({ $crate::DisplayPopup::new() }) $($tail)*,)
}};
}
#[test]
fn display_popup_macro() {
use std::borrow::Cow;
let display_popup = display_popup!();
#[cfg(feature = "tmux_3_3")]
let display_popup = display_popup!((display_popup), -B);
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -C);
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -E);
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -EE);
#[cfg(feature = "tmux_3_6")]
let display_popup = display_popup!((display_popup), -k);
#[cfg(feature = "tmux_3_6")]
let display_popup = display_popup!((display_popup), -N);
#[cfg(feature = "tmux_3_3")]
let display_popup = display_popup!((display_popup), -b "1");
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -c "2");
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -d "3");
#[cfg(feature = "tmux_3_3")]
let display_popup = display_popup!((display_popup), -e "4");
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -h 5);
#[cfg(feature = "tmux_3_3")]
let display_popup = display_popup!((display_popup), -s "6");
#[cfg(feature = "tmux_3_3")]
let display_popup = display_popup!((display_popup), -S "7");
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -t "8");
#[cfg(feature = "tmux_3_3")]
let display_popup = display_popup!((display_popup), -T "9");
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -w 10);
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -x 11);
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), -y 12);
#[cfg(feature = "tmux_3_2")]
let display_popup = display_popup!((display_popup), "13");
#[cfg(not(feature = "cmd_alias"))]
let cmd = "display-popup";
#[cfg(feature = "cmd_alias")]
let cmd = "popup";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_3_3")]
s.push("-B");
#[cfg(feature = "tmux_3_2")]
s.push("-C");
#[cfg(feature = "tmux_3_2")]
s.push("-E");
#[cfg(feature = "tmux_3_2")]
s.push("-EE");
#[cfg(feature = "tmux_3_6")]
s.push("-k");
#[cfg(feature = "tmux_3_6")]
s.push("-N");
#[cfg(feature = "tmux_3_3")]
s.extend_from_slice(&["-b", "1"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-c", "2"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-d", "3"]);
#[cfg(feature = "tmux_3_3")]
s.extend_from_slice(&["-e", "4"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-h", "5"]);
#[cfg(feature = "tmux_3_3")]
s.extend_from_slice(&["-s", "6"]);
#[cfg(feature = "tmux_3_3")]
s.extend_from_slice(&["-S", "7"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-t", "8"]);
#[cfg(feature = "tmux_3_3")]
s.extend_from_slice(&["-T", "9"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-w", "10"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-x", "11"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-y", "12"]);
#[cfg(feature = "tmux_3_2")]
s.push("13");
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let display_popup = display_popup.build().to_vec();
assert_eq!(display_popup, s);
}