#[macro_export]
macro_rules! select_pane {
(@cmd ($cmd:expr) -D, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.down()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -d, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.disable()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -e, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.enable()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -g, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.show_style()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -L, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.left()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -l, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.last()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -M, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.set_marked()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -m, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.clear_marked()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -R, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.right()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -U, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.up()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -Z, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.keep_zoomed()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -p $pane_index:expr, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.pane_index($pane_index)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -P $style:expr, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.style($style)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -T $title:expr, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
$cmd.title($title)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target:expr, $($tail:tt)*) => {{
$crate::select_pane!(@cmd ({
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
{
$cmd.target_window($target)
}
#[cfg(feature = "tmux_1_5")]
{
$cmd.target_pane($target)
}
}) $($tail)*)
}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::SelectPane::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::select_pane!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::select_pane!(@cmd ({ $crate::SelectPane::new() }) $($tail)*,)
}};
}
#[test]
fn select_pane_macro() {
use std::borrow::Cow;
let select_pane = select_pane!();
#[cfg(feature = "tmux_1_5")]
let select_pane = select_pane!((select_pane), -D);
#[cfg(feature = "tmux_2_0")]
let select_pane = select_pane!((select_pane), -d);
#[cfg(feature = "tmux_2_0")]
let select_pane = select_pane!((select_pane), -e);
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_1")))]
let select_pane = select_pane!((select_pane), -g);
#[cfg(feature = "tmux_1_5")]
let select_pane = select_pane!((select_pane), -L);
#[cfg(feature = "tmux_1_5")]
let select_pane = select_pane!((select_pane), -l);
#[cfg(feature = "tmux_2_1")]
let select_pane = select_pane!((select_pane), -M);
#[cfg(feature = "tmux_2_1")]
let select_pane = select_pane!((select_pane), -m);
#[cfg(feature = "tmux_1_5")]
let select_pane = select_pane!((select_pane), -R);
#[cfg(feature = "tmux_1_5")]
let select_pane = select_pane!((select_pane), -U);
#[cfg(feature = "tmux_3_1")]
let select_pane = select_pane!((select_pane), -Z);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
let select_pane = select_pane!((select_pane), -p "1");
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_0a")))]
let select_pane = select_pane!((select_pane), -P "2");
#[cfg(feature = "tmux_2_6")]
let select_pane = select_pane!((select_pane), -T "3");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
let select_pane = select_pane!((select_pane), -t "4");
#[cfg(feature = "tmux_1_5")]
let select_pane = select_pane!((select_pane), -t "5");
#[cfg(not(feature = "cmd_alias"))]
let cmd = "select-pane";
#[cfg(feature = "cmd_alias")]
let cmd = "selectp";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_1_5")]
s.push("-D");
#[cfg(feature = "tmux_2_0")]
s.push("-d");
#[cfg(feature = "tmux_2_0")]
s.push("-e");
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_1")))]
s.push("-g");
#[cfg(feature = "tmux_1_5")]
s.push("-L");
#[cfg(feature = "tmux_1_5")]
s.push("-l");
#[cfg(feature = "tmux_2_1")]
s.push("-M");
#[cfg(feature = "tmux_2_1")]
s.push("-m");
#[cfg(feature = "tmux_1_5")]
s.push("-R");
#[cfg(feature = "tmux_1_5")]
s.push("-U");
#[cfg(feature = "tmux_3_1")]
s.push("-Z");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
s.extend_from_slice(&["-p", "1"]);
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_3_0a")))]
s.extend_from_slice(&["-P", "2"]);
#[cfg(feature = "tmux_2_6")]
s.extend_from_slice(&["-T", "3"]);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
s.extend_from_slice(&["-t", "4"]);
#[cfg(feature = "tmux_1_5")]
s.extend_from_slice(&["-t", "5"]);
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let select_pane = select_pane.build().to_vec();
assert_eq!(select_pane, s);
}