1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type BreakP<'a> = BreakPane<'a>;
/// Break `src-pane` off from its containing window to make it the only pane in `dst-window`
///
/// # Manual
///
/// tmux ^3.2:
/// ```text
/// break-pane [-abdP] [-F format] [-n window-name] [-s src-pane] [-t dst-window]
/// (alias: breakp)
/// ```
///
/// tmux ^2.4:
/// ```text
/// break-pane [-dP] [-F format] [-n window-name] [-s src-pane] [-t dst-window]
/// (alias: breakp)
/// ```
///
/// tmux ^2.2:
/// ```text
/// break-pane [-dP] [-F format] [-s src-pane] [-t dst-window]
/// (alias: breakp)
/// ```
///
/// tmux ^2.1:
/// ```text
/// break-pane [-dP] [-F format] [-s src-pane] [-t dst-pane]
/// (alias: breakp)
/// ```
///
/// tmux ^1.7:
/// ```text
/// break-pane [-dP] [-F format] [-t target-pane]
/// (alias: breakp)
/// ```
///
/// tmux ^1.0:
/// ```text
/// break-pane [-d] [-t target-window]
/// (alias: breakp)
/// ```
///
/// tmux ^0.8:
/// ```text
/// break-pane [-d] [-p pane-index] [-t target-window]
/// (alias: breakp)
/// ```
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct BreakPane<'a> {
/// `[-a]` - the window is moved to the next index after
#[cfg(feature = "tmux_3_2")]
pub after: bool,
/// `[-b]` - the window is moved to the next index before
#[cfg(feature = "tmux_3_2")]
pub before: bool,
/// `[-d]` - the new window does not become the current window
#[cfg(feature = "tmux_0_8")]
pub detached: bool,
/// `[-P]` - option prints information about the new window after it has been created
#[cfg(feature = "tmux_1_7")]
pub print: bool,
/// `[-F format]` - specify format
#[cfg(feature = "tmux_1_7")]
pub format: Option<Cow<'a, str>>,
/// `[-n window-name]` - window-name
#[cfg(feature = "tmux_2_4")]
pub window_name: Option<Cow<'a, str>>,
/// `[-s src-pane]` - src-pane
#[cfg(feature = "tmux_2_1")]
pub src_pane: Option<Cow<'a, str>>,
/// `[-t dst-pane]` - dst-pane
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_2")))]
pub dst_pane: Option<Cow<'a, str>>,
/// `[-t dst-window]` - dst-window
#[cfg(feature = "tmux_2_2")]
pub dst_window: Option<Cow<'a, str>>,
/// `[-t target-window]` - target-window
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_1")))]
pub target_window: Option<Cow<'a, str>>,
/// `[-t target-pane]` - target-pane
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_7")))]
pub target_pane: Option<Cow<'a, str>>,
// FIXME:
// `[-p pane-index]` - pane-index
}
impl<'a> BreakPane<'a> {
pub fn new() -> Self {
Default::default()
}
/// `[-a]` - the window is moved to the next index after
#[cfg(feature = "tmux_3_2")]
pub fn after(mut self) -> Self {
self.after = true;
self
}
/// `[-b]` - the window is moved to the next index before
#[cfg(feature = "tmux_3_2")]
pub fn before(mut self) -> Self {
self.before = true;
self
}
/// `[-d]` - the new window does not become the current window
#[cfg(feature = "tmux_0_8")]
pub fn detached(mut self) -> Self {
self.detached = true;
self
}
/// `[-P]` - option prints information about the new window after it has been created
#[cfg(feature = "tmux_1_7")]
pub fn print(mut self) -> Self {
self.print = true;
self
}
/// `[-F format]` - specify format
#[cfg(feature = "tmux_1_7")]
pub fn format<S: Into<Cow<'a, str>>>(mut self, format: S) -> Self {
self.format = Some(format.into());
self
}
/// `[-n window-name]` - window-name
#[cfg(feature = "tmux_2_4")]
pub fn window_name<S: Into<Cow<'a, str>>>(mut self, window_name: S) -> Self {
self.window_name = Some(window_name.into());
self
}
/// `[-s src-pane]` - src-pane
#[cfg(feature = "tmux_2_1")]
pub fn src_pane<S: Into<Cow<'a, str>>>(mut self, src_pane: S) -> Self {
self.src_pane = Some(src_pane.into());
self
}
/// `[-t dst-pane]` - dst-pane
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_2")))]
pub fn dst_pane<S: Into<Cow<'a, str>>>(mut self, dst_pane: S) -> Self {
self.dst_pane = Some(dst_pane.into());
self
}
/// `[-t dst-window]` - dst-window
#[cfg(feature = "tmux_2_2")]
pub fn dst_window<S: Into<Cow<'a, str>>>(mut self, dst_window: S) -> Self {
self.dst_window = Some(dst_window.into());
self
}
/// `[-t target-window]` - target-window
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_1")))]
pub fn target_window<S: Into<Cow<'a, str>>>(mut self, target_window: S) -> Self {
self.target_window = Some(target_window.into());
self
}
/// `[-t target-pane]` - target-pane
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_7")))]
pub fn target_pane<S: Into<Cow<'a, str>>>(mut self, target_pane: S) -> Self {
self.target_pane = Some(target_pane.into());
self
}
// FIXME:
// `[-p pane-index]` - pane-index
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(BREAK_PANE);
// `[-a]` - the window is moved to the next index after
#[cfg(feature = "tmux_3_2")]
if self.after {
cmd.push_flag(A_LOWERCASE_KEY);
}
// `[-b]` - the window is moved to the next index before
#[cfg(feature = "tmux_3_2")]
if self.before {
cmd.push_flag(B_LOWERCASE_KEY);
}
// `[-d]` - the new window does not become the current window
#[cfg(feature = "tmux_0_8")]
if self.detached {
cmd.push_flag(D_LOWERCASE_KEY);
}
// `[-P]` - option prints information about the new window after it has been created
#[cfg(feature = "tmux_1_7")]
if self.print {
cmd.push_flag(P_UPPERCASE_KEY);
}
// `[-F format]` - specify format
#[cfg(feature = "tmux_1_7")]
if let Some(format) = self.format {
cmd.push_option(F_UPPERCASE_KEY, format);
}
// `[-n]` - window-name
#[cfg(feature = "tmux_2_4")]
if let Some(window_name) = self.window_name {
cmd.push_option(N_LOWERCASE_KEY, window_name);
}
// `[-s src-pane]` - src-pane
#[cfg(feature = "tmux_2_1")]
if let Some(src_pane) = self.src_pane {
cmd.push_option(S_LOWERCASE_KEY, src_pane);
}
// `[-t dst-pane]` - dst-pane
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_2")))]
if let Some(dst_pane) = self.dst_pane {
cmd.push_option(T_LOWERCASE_KEY, dst_pane);
}
// `[-t dst-window]` - dst-window
#[cfg(feature = "tmux_2_2")]
if let Some(dst_window) = self.dst_window {
cmd.push_option(T_LOWERCASE_KEY, dst_window);
}
// `[-t target-window]` - target-window
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_1")))]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
// `[-t target-pane]` - target-pane
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_7")))]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
// FIXME:
// `[-p pane-index]` - pane-index
cmd
}
}